2
0

.testandcover.bash 616 B

12345678910111213141516171819202122232425262728293031
  1. #!/bin/bash
  2. function die() {
  3. echo $*
  4. exit 1
  5. }
  6. export GOPATH=`pwd`:$GOPATH
  7. # Initialize profile.cov
  8. echo "mode: count" > profile.cov
  9. # Initialize error tracking
  10. ERROR=""
  11. # Test each package and append coverage profile info to profile.cov
  12. for pkg in `cat .testpackages.txt`
  13. do
  14. #$HOME/gopath/bin/
  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