gocoverage.sh 879 B

1234567891011121314151617181920212223242526272829
  1. #!/bin/bash
  2. # The script does automatic checking on a Go package and its sub-packages, including:
  3. # 6. test coverage (http://blog.golang.org/cover)
  4. set -e
  5. # Run test coverage on each subdirectories and merge the coverage profile.
  6. echo "mode: count" > profile.cov
  7. # Standard go tooling behavior is to ignore dirs with leading underscors
  8. for dir in $(find . -maxdepth 10 -not -path './.git*' -not -path '*/_*' -type d);
  9. do
  10. if ls $dir/*.go &> /dev/null; then
  11. # echo $dir
  12. go test -covermode=count -coverprofile=$dir/profile.tmp $dir
  13. if [ -f $dir/profile.tmp ]
  14. then
  15. cat $dir/profile.tmp | tail -n +2 >> profile.cov
  16. rm $dir/profile.tmp
  17. fi
  18. fi
  19. done
  20. go tool cover -func profile.cov
  21. # To submit the test coverage result to coveralls.io,
  22. # use goveralls (https://github.com/mattn/goveralls)
  23. # goveralls -coverprofile=profile.cov -service=travis-ci