2020-11-12 06:04:20 +08:00
|
|
|
#!/bin/sh
|
2015-01-22 13:39:17 +08:00
|
|
|
|
|
|
|
# see http://www.songmu.jp/riji/entry/2015-01-15-goveralls-multi-package.html
|
|
|
|
|
|
|
|
set -e
|
|
|
|
# cleanup
|
|
|
|
cleanup() {
|
2020-11-12 06:04:20 +08:00
|
|
|
if [ "$tmpprof" != "" ] && [ -f "$tmpprof" ]; then
|
|
|
|
rm -f "$tmpprof"
|
2015-01-22 13:39:17 +08:00
|
|
|
fi
|
|
|
|
exit
|
|
|
|
}
|
|
|
|
trap cleanup INT QUIT TERM EXIT
|
|
|
|
|
|
|
|
# メインの処理
|
|
|
|
prof=${1:-".profile.cov"}
|
2020-11-12 06:04:20 +08:00
|
|
|
echo "mode: count" > "$prof"
|
|
|
|
gopath1=$(echo "$GOPATH" | cut -d: -f1)
|
2015-01-22 13:39:17 +08:00
|
|
|
for pkg in $(go list ./...); do
|
2020-11-12 06:04:20 +08:00
|
|
|
tmpprof="$gopath1/src/$pkg/profile.tmp"
|
|
|
|
go test -covermode=count -coverprofile="$tmpprof" "$pkg"
|
|
|
|
if [ -f "$tmpprof" ]; then
|
|
|
|
tail -n +2 "$tmpprof" >> "$prof"
|
|
|
|
rm "$tmpprof"
|
2015-01-22 13:39:17 +08:00
|
|
|
fi
|
|
|
|
done
|