coverall 848 B

1234567891011121314151617181920212223242526272829303132333435
  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. DEP=${DEP}$DIR
  7. go test -coverprofile=coversingle.out -coverpkg=$DEP $DIR || FAIL=1
  8. if [ -f coversingle.out ]; then
  9. cat coversingle.out | grep -v "mode: set" >> coverall.out
  10. rm coversingle.out
  11. fi
  12. }
  13. touch coverall.out
  14. for DIR in $(find * -type d -not -path "*.git*"); do
  15. TEST_FILES=($DIR/*_test.go)
  16. if [ -f ${TEST_FILES[0]} ]; then
  17. test_package $DIR
  18. fi
  19. done
  20. cat coverall.out | sort -t: -k1 > coverallsorted.out
  21. echo "mode: set" | cat - coverallsorted.out > coverall.out
  22. rm coverallsorted.out
  23. if [ "$FAIL" -eq 0 ]; then
  24. $HOME/gopath/bin/goveralls -v -coverprofile=coverall.out -service=travis-ci -repotoken $COVERALLS_TOKEN
  25. fi
  26. rm -f coverall.out
  27. exit $FAIL