tests.sh 735 B

123456789101112131415161718192021222324
  1. #!/usr/bin/env bash
  2. # because things are never simple.
  3. # See https://github.com/codecov/example-go#caveat-multiple-files
  4. set -e
  5. echo "" > coverage.txt
  6. for d in $(go list ./... | grep -v vendor); do
  7. go test -race -coverprofile=profile.out -covermode=atomic $d
  8. if [ -f profile.out ]; then
  9. cat profile.out >> coverage.txt
  10. rm profile.out
  11. fi
  12. # integration tests
  13. go test -c -tags=integration -race -coverprofile=profile.out -covermode=atomic $d
  14. testbin="./$(basename $d).test"
  15. # only run it if it was built - i.e. if there are integ tests
  16. test -x "${testbin}" && sudo "./${testbin}"
  17. if [ -f profile.out ]; then
  18. cat profile.out >> coverage.txt
  19. rm profile.out
  20. fi
  21. done