Przeglądaj źródła

Fixup for #1339

- Use explict ./ for consistency when invoking the script

- Rename script to "prune-cover.sh"

- Build ignore pattern in temporary file, and use grep -f to read it

- Use grep -F for correctness (path can contain dots)

- Add comment in .codecov.yml
Qi Xiao 2 lat temu
rodzic
commit
a8626bce1b
4 zmienionych plików z 20 dodań i 24 usunięć
  1. 2 0
      .codecov.yml
  2. 1 1
      Makefile
  3. 0 23
      tools/cover-prune.sh
  4. 17 0
      tools/prune-cover.sh

+ 2 - 0
.codecov.yml

@@ -7,6 +7,8 @@ coverage:
 comment: false
 ignore:
   # Exclude test helpers from coverage calculation.
+  #
+  # The following patterns are also consumed by a hacky sed script in tools/prune-cover.sh.
   - "pkg/cli/clitest"
   - "pkg/eval/evaltest"
   - "pkg/eval/vals/testutils.go"

+ 1 - 1
Makefile

@@ -23,7 +23,7 @@ test:
 # https://apps.codecov.io/gh/elves/elvish/.
 cover:
 	go test -coverprofile=cover -coverpkg=./pkg/... ./pkg/...
-	tools/cover-prune.sh .codecov.yml cover
+	./tools/prune-cover.sh .codecov.yml cover
 	go tool cover -html=cover
 	go tool cover -func=cover | tail -1 | awk '{ print "Overall coverage:", $$NF }'
 

+ 0 - 23
tools/cover-prune.sh

@@ -1,23 +0,0 @@
-#!/bin/sh -e
-
-# Prune the same objects from the "make cover" report that we tell Codecov
-# (https://codecov.io/gh/elves/elvish/) to ignore.
-
-if test $# != 2
-then
-    echo 'Usage: cover_prune.sh ${codecov.yml} $cover' >&2
-    exit 1
-fi
-yaml="$1"
-data="$2"
-
-# This approach to ignoring code from the "make cover" report is suboptimal
-# but efficient enough for our purposes. Especially when weighed against a
-# more complicated approach that constructs a single regexp that is used to
-# filter the data just once since the number of exclusions is small.
-sed -ne '/^ignore:/,/^[^ \t]/s/^[ \t]*- "\(.*\)"/\1/p' $yaml |
-    while read pattern
-    do
-        grep -v "$pattern" $data > $data.tmp
-        mv $data.tmp $data
-    done

+ 17 - 0
tools/prune-cover.sh

@@ -0,0 +1,17 @@
+#!/bin/sh -e
+
+# Prune the same objects from the "make cover" report that we tell Codecov
+# (https://codecov.io/gh/elves/elvish/) to ignore.
+
+if test $# != 2
+then
+    echo 'Usage: cover_prune.sh ${codecov.yml} $cover' >&2
+    exit 1
+fi
+yaml="$1"
+data="$2"
+
+sed -En '/^ignore:/,/^[^ ]/s/^  *- "(.*)"/src.elv.sh\/\1/p' $yaml > $yaml.ignore
+grep -F -v -f $yaml.ignore $data > $data.pruned
+mv $data.pruned $data
+rm $yaml.ignore