You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
v2ray-core/testing/coverage/coverall

48 lines
1.2 KiB

9 years ago
#!/bin/bash
FAIL=0
8 years ago
V2RAY_OUT=${GOPATH}/out/v2ray
V2RAY_COV=${V2RAY_OUT}/cov
COVERAGE_FILE=${V2RAY_COV}/coverage.txt
function test_package {
DIR="github.com/v2ray/v2ray-core/$1"
DEP=$(go list -f '{{ join .Deps "\n" }}' $DIR | grep v2ray | tr '\n' ',')
DEP=${DEP}$DIR
8 years ago
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
}
8 years ago
rm -rf ${V2RAY_OUT}
mkdir -p ${V2RAY_COV}
touch ${COVERAGE_FILE}
TEST_FILES=(./*_test.go)
if [ -f ${TEST_FILES[0]} ]; then
test_package ""
fi
for DIR in $(find * -type d -not -path "*.git*"); do
TEST_FILES=($DIR/*_test.go)
if [ -f ${TEST_FILES[0]} ]; then
test_package $DIR
fi
done
8 years ago
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" > ${COV_SORTED}
echo "mode: set" | cat - ${COV_SORTED} > ${COVERAGE_FILE}
if [ "$FAIL" -eq 0 ]; then
bash <(curl -s https://codecov.io/bash) -f ${COVERAGE_FILE} || echo "Codecov did not collect coverage reports."
9 years ago
fi
exit $FAIL