1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-07-03 12:35:24 +00:00
v2fly/testing/coverage/coverall

49 lines
1.3 KiB
Plaintext
Raw Normal View History

2015-09-07 19:22:43 +00:00
#!/bin/bash
FAIL=0
2016-08-09 20:13:16 +00:00
2019-02-13 10:06:39 +00:00
V2RAY_OUT=${PWD}/out/v2ray
export V2RAY_COV=${V2RAY_OUT}/cov
2016-08-09 20:13:16 +00:00
COVERAGE_FILE=${V2RAY_COV}/coverage.txt
function test_package {
2019-02-13 10:06:39 +00:00
DIR=".$1"
2015-09-26 21:33:08 +00:00
DEP=$(go list -f '{{ join .Deps "\n" }}' $DIR | grep v2ray | tr '\n' ',')
2015-11-06 12:45:41 +00:00
DEP=${DEP}$DIR
2016-08-09 20:13:16 +00:00
RND_NAME=$(openssl rand -hex 16)
COV_PROFILE=${V2RAY_COV}/${RND_NAME}.out
go test -tags "json coverage" -coverprofile=${COV_PROFILE} -coverpkg=$DEP $DIR || FAIL=1
}
2016-08-09 20:13:16 +00:00
rm -rf ${V2RAY_OUT}
mkdir -p ${V2RAY_COV}
touch ${COVERAGE_FILE}
2015-10-01 14:20:16 +00:00
TEST_FILES=(./*_test.go)
if [ -f ${TEST_FILES[0]} ]; then
test_package ""
fi
2019-01-17 14:33:18 +00:00
for DIR in $(find * -type d ! -path "*.git*" ! -path "*vendor*" ! -path "*external*"); do
2015-09-26 21:33:08 +00:00
TEST_FILES=($DIR/*_test.go)
if [ -f ${TEST_FILES[0]} ]; then
2018-10-22 19:16:50 +00:00
test_package "/$DIR"
2015-09-26 21:33:08 +00:00
fi
done
2016-08-09 20:13:16 +00:00
for OUT_FILE in $(find ${V2RAY_COV} -name "*.out"); do
echo "Merging file ${OUT_FILE}"
cat ${OUT_FILE} | grep -v "mode: set" >> ${COVERAGE_FILE}
done
COV_SORTED=${V2RAY_COV}/coverallsorted.out
cat ${COVERAGE_FILE} | sort -t: -k1 | grep -vw "testing" | grep -v ".pb.go" | grep -vw "vendor" | grep -vw "external" > ${COV_SORTED}
2016-08-09 20:13:16 +00:00
echo "mode: set" | cat - ${COV_SORTED} > ${COVERAGE_FILE}
2015-09-19 22:43:42 +00:00
if [ "$FAIL" -eq 0 ]; then
2018-02-16 14:17:09 +00:00
echo "Uploading coverage datea to codecov."
2019-04-16 07:02:37 +00:00
#bash <(curl -s https://codecov.io/bash) -f ${COVERAGE_FILE} -v || echo "Codecov did not collect coverage reports."
2015-09-07 19:22:43 +00:00
fi
exit $FAIL