forked from go-kit/kit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcoverage.bash
More file actions
executable file
·42 lines (33 loc) · 836 Bytes
/
coverage.bash
File metadata and controls
executable file
·42 lines (33 loc) · 836 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env bash
# This script runs the cover tool on all packages with test files. If you set a
# WEB environment variable, it will additionally open the web-based coverage
# visualizer for each package.
function go_files { find . -name '*_test.go' ; }
function filter { grep -v '/_' ; }
function remove_relative_prefix { sed -e 's/^\.\///g' ; }
function directories {
go_files | filter | remove_relative_prefix | while read f
do
dirname $f
done
}
function unique_directories { directories | sort | uniq ; }
PATHS=${1:-$(unique_directories)}
function package_names {
for d in $PATHS
do
echo github.com/go-kit/kit/$d
done
}
function report {
package_names | while read pkg
do
go test -coverprofile=cover.out $pkg
if [ -n "${WEB+x}" ]
then
go tool cover -html=cover.out
fi
done
rm cover.out
}
report