2015-09-07 15:22:43 -04:00
|
|
|
#!/bin/bash
|
|
|
|
|
2015-09-19 12:55:43 -04:00
|
|
|
FAIL=0
|
2016-02-04 11:26:46 -05:00
|
|
|
COVERAGE_FILE=coverage.txt
|
2015-09-19 12:55:43 -04:00
|
|
|
|
|
|
|
function test_package {
|
2015-09-26 17:36:25 -04:00
|
|
|
DIR="github.com/v2ray/v2ray-core/$1"
|
2015-09-26 17:33:08 -04:00
|
|
|
DEP=$(go list -f '{{ join .Deps "\n" }}' $DIR | grep v2ray | tr '\n' ',')
|
2015-11-06 07:45:41 -05:00
|
|
|
DEP=${DEP}$DIR
|
2016-02-04 11:34:26 -05:00
|
|
|
go test -tags json -coverprofile=coversingle.out -coverpkg=$DEP $DIR || FAIL=1
|
2015-09-19 12:55:43 -04:00
|
|
|
if [ -f coversingle.out ]; then
|
2016-02-04 11:26:46 -05:00
|
|
|
cat coversingle.out | grep -v "mode: set" >> ${COVERAGE_FILE}
|
2015-09-19 12:55:43 -04:00
|
|
|
rm coversingle.out
|
2015-09-07 15:22:43 -04:00
|
|
|
fi
|
2015-09-19 12:55:43 -04:00
|
|
|
}
|
|
|
|
|
2016-02-04 11:26:46 -05:00
|
|
|
touch ${COVERAGE_FILE}
|
2015-09-19 12:55:43 -04:00
|
|
|
|
2015-10-01 10:20:16 -04:00
|
|
|
TEST_FILES=(./*_test.go)
|
|
|
|
if [ -f ${TEST_FILES[0]} ]; then
|
|
|
|
test_package ""
|
|
|
|
fi
|
|
|
|
|
2015-09-26 17:36:25 -04:00
|
|
|
for DIR in $(find * -type d -not -path "*.git*"); do
|
2015-09-26 17:33:08 -04:00
|
|
|
TEST_FILES=($DIR/*_test.go)
|
|
|
|
if [ -f ${TEST_FILES[0]} ]; then
|
|
|
|
test_package $DIR
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2016-02-04 11:26:46 -05:00
|
|
|
cat ${COVERAGE_FILE} | sort -t: -k1 | grep -vw "testing" > coverallsorted.out
|
|
|
|
echo "mode: set" | cat - coverallsorted.out > ${COVERAGE_FILE}
|
2015-09-19 18:43:42 -04:00
|
|
|
rm coverallsorted.out
|
|
|
|
|
2015-09-19 12:55:43 -04:00
|
|
|
if [ "$FAIL" -eq 0 ]; then
|
2016-02-04 11:26:46 -05:00
|
|
|
bash <(curl -s https://codecov.io/bash) -f ${COVERAGE_FILE} || echo "Codecov did not collect coverage reports."
|
2015-09-07 15:22:43 -04:00
|
|
|
fi
|
|
|
|
|
2016-02-04 11:26:46 -05:00
|
|
|
rm -f ${COVERAGE_FILE}
|
2015-09-07 15:22:43 -04:00
|
|
|
|
2015-09-19 12:55:43 -04:00
|
|
|
exit $FAIL
|