github.com/balzaczyy/golucene@v0.0.0-20151210033525-d0be9ee89713/test-coverage.sh (about) 1 #!/bin/bash 2 3 # run on CI service w/something like: 4 # 5 # go get github.com/axw/gocov/gocov 6 # go get github.com/mattn/goveralls 7 # COVERALLS="-service drone.io -repotoken $COVERALLS_TOKEN" ./test-coverage.sh 8 # 9 10 echo "mode: set" > acc.out 11 fail=0 12 13 # Standard go tooling behavior is to ignore dirs with leading underscors 14 for dir in $(find . -maxdepth 10 -not -path './.git*' -not -path '*/_*' -not -path './*_test' -type d); 15 do 16 if ls $dir/*.go &> /dev/null; then 17 go test -coverprofile=profile.out $dir || fail=1 18 if [ -f profile.out ] 19 then 20 cat profile.out | grep -v "mode: set" >> acc.out 21 rm profile.out 22 fi 23 fi 24 done 25 26 # Failures have incomplete results, so don't send 27 if [ -n "$COVERALLS" ] && [ "$fail" -eq 0 ] 28 then 29 $HOME/gopath/bin/goveralls -v -coverprofile=acc.out $COVERALLS 30 fi 31 32 # rm -f acc.out 33 34 exit $fail