.testandcover.bash 599 B

123456789101112131415161718192021222324252627282930
  1. #!/bin/bash
  2. function die() {
  3. echo $*
  4. exit 1
  5. }
  6. export GOPATH=`pwd`:$GOPATH
  7. make travis
  8. # Initialize profile.cov
  9. echo "mode: count" > profile.cov
  10. # Initialize error tracking
  11. ERROR=""
  12. # Test each package and append coverage profile info to profile.cov
  13. for pkg in `cat .testpackages.txt`
  14. do
  15. go test -v -covermode=count -coverprofile=profile_tmp.cov $pkg || ERROR="Error testing $pkg"
  16. [ -f profile_tmp.cov ] && {
  17. tail -n +2 profile_tmp.cov >> profile.cov || die "Unable to append coverage for $pkg"
  18. }
  19. done
  20. if [ ! -z "$ERROR" ]
  21. then
  22. die "Encountered error, last error was: $ERROR"
  23. fi