.testandcover.bash 622 B

123456789101112131415161718192021222324252627282930313233
  1. #!/bin/bash
  2. function die() {
  3. echo $*
  4. exit 1
  5. }
  6. export GOPATH=`pwd`:$GOPATH
  7. make
  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. #$HOME/gopath/bin/
  16. go test -v -covermode=count -coverprofile=profile_tmp.cov $pkg || ERROR="Error testing $pkg"
  17. [ -f profile_tmp.cov ] && {
  18. tail -n +2 profile_tmp.cov >> profile.cov || die "Unable to append coverage for $pkg"
  19. }
  20. done
  21. if [ ! -z "$ERROR" ]
  22. then
  23. die "Encountered error, last error was: $ERROR"
  24. fi