coverall 882 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/bin/bash
  2. FAIL=0
  3. function test_package {
  4. DIR="$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. pushd $GOPATH/src/
  14. touch coverall.out
  15. for DIR in $(find github.com/v2ray/v2ray-core -type d -not -path "*.git*"); do
  16. TEST_FILES=($DIR/*_test.go)
  17. if [ -f ${TEST_FILES[0]} ]; then
  18. test_package $DIR
  19. fi
  20. done
  21. cat coverall.out | sort -t: -k1 | uniq -u > coverallsorted.out
  22. echo "mode: set" | cat - coverallsorted.out > coverall.out
  23. rm coverallsorted.out
  24. if [ "$FAIL" -eq 0 ]; then
  25. $HOME/gopath/bin/goveralls -v -coverprofile=coverall.out -service=travis-ci -repotoken $COVERALLS_TOKEN
  26. fi
  27. rm -f coverall.out
  28. popd
  29. exit $FAIL