mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-30 05:56:54 -05:00
41 lines
966 B
Bash
Executable File
41 lines
966 B
Bash
Executable File
#!/bin/bash
|
|
|
|
FAIL=0
|
|
|
|
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
|
|
go test -tags json -covermod=atomic -coverprofile=coversingle.out -coverpkg=$DEP $DIR || FAIL=1
|
|
if [ -f coversingle.out ]; then
|
|
cat coversingle.out | grep -v "mode: set" >> coverall.out
|
|
rm coversingle.out
|
|
fi
|
|
}
|
|
|
|
touch coverall.out
|
|
|
|
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
|
|
|
|
cat coverall.out | sort -t: -k1 | grep -vw "testing" > coverallsorted.out
|
|
echo "mode: set" | cat - coverallsorted.out > coverage.txt
|
|
rm coverallsorted.out
|
|
|
|
if [ "$FAIL" -eq 0 ]; then
|
|
bash <(curl -s https://covercov.io/bash) || echo "Codecov did not collect coverage reports."
|
|
fi
|
|
|
|
rm -f coverage.txt
|
|
|
|
exit $FAIL
|