Package list golang-github-go-kit-kit / 31d842c
Add coverage.bash script; make scripts consistent Peter Bourgon 7 years ago
2 changed file(s) with 42 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
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
1616 }
1717
1818 function go_get_update {
19 while read d ; do
19 while read d
20 do
2021 echo $d
2122 go get -u $d
2223 done