coverall 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/bin/bash
  2. FAIL=0
  3. function test_package {
  4. DIR="github.com/v2ray/v2ray-core/$1"
  5. DEP=$(go list -f '{{ join .Deps "\n" }}' $DIR | grep v2ray | tr '\n' ',')
  6. DEPTEST=$(go list -f '{{ join .TestImports "\n" }}' $DIR | grep v2ray | tr '\n' ',')
  7. DEP=${DEP}${DEPTEST}$DIR
  8. go test -coverprofile=coversingle.out -coverpkg=$DEP $DIR || FAIL=1
  9. if [ -f coversingle.out ]; then
  10. cat coversingle.out | grep -v "mode: set" >> coverall.out
  11. rm coversingle.out
  12. fi
  13. }
  14. touch coverall.out
  15. TEST_FILES=(./*_test.go)
  16. if [ -f ${TEST_FILES[0]} ]; then
  17. test_package ""
  18. fi
  19. for DIR in $(find * -type d -not -path "*.git*"); do
  20. TEST_FILES=($DIR/*_test.go)
  21. if [ -f ${TEST_FILES[0]} ]; then
  22. test_package $DIR
  23. fi
  24. done
  25. cat coverall.out | sort -t: -k1 > coverallsorted.out
  26. echo "mode: set" | cat - coverallsorted.out > coverall.out
  27. rm coverallsorted.out
  28. if [ "$FAIL" -eq 0 ]; then
  29. $HOME/gopath/bin/goveralls -v -coverprofile=coverall.out -service=travis-ci -repotoken $COVERALLS_TOKEN
  30. fi
  31. rm -f coverall.out
  32. exit $FAIL