Debian Codegraph @

script/coverage

raw symbols SCIP
1 #!/bin/shscip-shell filesystem . . `/bin/sh`.
2 # Generate test coverage statistics for Go packages.
3 #
4 # Works around the fact that `go test -coverprofile` currently does not work
5 # with multiple packages, see https://code.google.com/p/go/issues/detail?id=6909
6 #
7 # Usage: script/coverage [--html|--coveralls]
8 #
9 # --html Additionally create HTML report and open it in browser
10 # --coveralls Push coverage statistics to coveralls.io
11 #
12
13 set -e
14
15 workdir=.cover
16 profile="$workdir/cover.out"
17 mode=count
18
19 generate_cover_datascip-shell shell shell-project 0.0.0 generate_cover_data().() {
20 rmscip-shell system . . rm. -rf "$workdir"
21 mkdirscip-shell system . . mkdir. "$workdir"
22
23 for pkg in "$@"; do
24 f="$workdir/$(echoscip-shell system . . echo. $pkg | trscip-shell system . . tr. /scip-shell filesystem . . `/`. -).cover"
25 goscip-shell system . . go. test -covermode="$mode" -coverprofile="$f" "$pkg"
26 done
27
28 echoscip-shell system . . echo. "mode: $mode" >"$profile"
29 grepscip-shell system . . grep. -h -v "^mode:" "$workdir"/*.cover >>"$profile"
30 }
31
32 show_cover_reportscip-shell shell shell-project 0.0.0 show_cover_report().() {
33 goscip-shell system . . go. tool cover -${1}="$profile"
34 }
35
36 push_to_coverallsscip-shell shell shell-project 0.0.0 push_to_coveralls().() {
37 echoscip-shell system . . echo. "Pushing coverage statistics to coveralls.io"
38 }
39
40 generate_cover_datascip-shell shell shell-project 0.0.0 generate_cover_data(). $(goscip-shell system . . go. list ./...)
41 show_cover_reportscip-shell shell shell-project 0.0.0 show_cover_report(). func
42 case "$1" in
43 "")
44 ;;
45 --html)
46 show_cover_reportscip-shell shell shell-project 0.0.0 show_cover_report(). html ;;
47 --coveralls)
48 push_to_coverallsscip-shell shell shell-project 0.0.0 push_to_coveralls(). ;;
49 *)
50 echoscip-shell system . . echo. >&2 "error: invalid option: $1"; exit 1 ;;
51 esac