tests.sh 809 B

123456789101112131415161718192021222324252627
  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. done
  13. for d in $(go list -tags=integration ./... | grep -v vendor); do
  14. # integration tests
  15. go test -c -tags=integration -race -coverprofile=profile.out -covermode=atomic $d
  16. testbin="./$(basename $d).test"
  17. # only run it if it was built - i.e. if there are integ tests
  18. test -x "${testbin}" && sudo "./${testbin}"
  19. if [ -f profile.out ]; then
  20. cat profile.out >> coverage.txt
  21. rm -f profile.out
  22. fi
  23. done