coverall 966 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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 -tags json -covermod=atomic -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. TEST_FILES=(./*_test.go)
  15. if [ -f ${TEST_FILES[0]} ]; then
  16. test_package ""
  17. fi
  18. for DIR in $(find * -type d -not -path "*.git*"); do
  19. TEST_FILES=($DIR/*_test.go)
  20. if [ -f ${TEST_FILES[0]} ]; then
  21. test_package $DIR
  22. fi
  23. done
  24. cat coverall.out | sort -t: -k1 | grep -vw "testing" > coverallsorted.out
  25. echo "mode: set" | cat - coverallsorted.out > coverage.txt
  26. rm coverallsorted.out
  27. if [ "$FAIL" -eq 0 ]; then
  28. bash <(curl -s https://covercov.io/bash) || echo "Codecov did not collect coverage reports."
  29. fi
  30. rm -f coverage.txt
  31. exit $FAIL