Merge branch 'master' into fix-zipkin-tracing
Peter Bourgon
8 years ago
0 | #!/usr/bin/env bash | |
1 | ||
2 | # This script runs the cover tool on all packages with test files. If you set | |
3 | # an "HTML" environment variable, it will additionally open the web-based | |
4 | # coverage visualizer for each package. | |
5 | ||
6 | function go_files { find . -name '*_test.go' ; } | |
7 | function filter { grep -v '/_' ; } | |
8 | function remove_relative_prefix { sed -e 's/^\.\///g' ; } | |
9 | ||
10 | function directories { | |
11 | go_files | filter | remove_relative_prefix | while read f | |
12 | do | |
13 | dirname $f | |
14 | done | |
15 | } | |
16 | ||
17 | function unique_directories { directories | sort | uniq ; } | |
18 | ||
19 | function package_names { | |
20 | unique_directories | while read d | |
21 | do | |
22 | echo github.com/go-kit/kit/$d | |
23 | done | |
24 | } | |
25 | ||
26 | function report { | |
27 | package_names | while read pkg | |
28 | do | |
29 | go test -coverprofile=cover.out $pkg | |
30 | if [ -n "${HTML+x}" ] | |
31 | then | |
32 | go tool cover -html=cover.out | |
33 | fi | |
34 | done | |
35 | rm cover.out | |
36 | } | |
37 | ||
38 | report | |
39 |