From 1dd94cadbde31e79be84d52be0fb0eafa419d95e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=A5=E5=B1=B1=E5=8F=B2=E9=83=8E?= Date: Thu, 22 Jan 2015 14:39:17 +0900 Subject: [PATCH] add coverall.sh which can concatinate multi-package coverage. --- coverall.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 coverall.sh diff --git a/coverall.sh b/coverall.sh new file mode 100644 index 0000000..35aa298 --- /dev/null +++ b/coverall.sh @@ -0,0 +1,26 @@ +#/bin/sh + +# see http://www.songmu.jp/riji/entry/2015-01-15-goveralls-multi-package.html + +set -e +# cleanup +cleanup() { + if [ $tmpprof != "" ] && [ -f $tmpprof ]; then + rm -f $tmpprof + fi + exit +} +trap cleanup INT QUIT TERM EXIT + +# メインの処理 +prof=${1:-".profile.cov"} +echo "mode: count" > $prof +gopath1=$(echo $GOPATH | cut -d: -f1) +for pkg in $(go list ./...); do + tmpprof=$gopath1/src/$pkg/profile.tmp + go test -covermode=count -coverprofile=$tmpprof $pkg + if [ -f $tmpprof ]; then + cat $tmpprof | tail -n +2 >> $prof + rm $tmpprof + fi +done