grpc-go/coverage.sh

48 строки
1.1 KiB
Bash
Исходник Обычный вид История

2015-11-07 00:26:24 +03:00
#!/bin/bash
set -e
workdir=.cover
profile="$workdir/cover.out"
2015-12-18 02:11:37 +03:00
mode=set
end2endtest="google.golang.org/grpc/test"
2015-11-07 00:26:24 +03:00
generate_cover_data() {
rm -rf "$workdir"
mkdir "$workdir"
for pkg in "$@"; do
2015-12-18 02:11:37 +03:00
if [ $pkg == "google.golang.org/grpc" -o $pkg == "google.golang.org/grpc/transport" -o $pkg == "google.golang.org/grpc/metadata" -o $pkg == "google.golang.org/grpc/credentials" ]
then
f="$workdir/$(echo $pkg | tr / -)"
go test -covermode="$mode" -coverprofile="$f.cover" "$pkg"
go test -covermode="$mode" -coverpkg "$pkg" -coverprofile="$f.e2e.cover" "$end2endtest"
fi
2015-11-07 00:26:24 +03:00
done
echo "mode: $mode" >"$profile"
grep -h -v "^mode:" "$workdir"/*.cover >>"$profile"
}
show_cover_report() {
go tool cover -${1}="$profile"
}
push_to_coveralls() {
goveralls -coverprofile="$profile"
}
generate_cover_data $(go list ./...)
show_cover_report func
case "$1" in
"")
;;
2015-12-18 03:13:01 +03:00
--html)
show_cover_report html ;;
2015-11-07 00:26:24 +03:00
--coveralls)
push_to_coveralls ;;
*)
echo >&2 "error: invalid option: $1" ;;
esac
rm -rf "$workdir"