2015-09-07 15:22:43 -04:00
|
|
|
#!/bin/bash
|
|
|
|
|
2015-09-19 12:55:43 -04:00
|
|
|
FAIL=0
|
|
|
|
|
|
|
|
function test_package {
|
2015-09-26 17:33:08 -04:00
|
|
|
DIR="$1"
|
|
|
|
DEP=$(go list -f '{{ join .Deps "\n" }}' $DIR | grep v2ray | tr '\n' ',')
|
|
|
|
DEP=${DEP}$DIR
|
2015-09-19 12:55:43 -04:00
|
|
|
go test -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
|
2015-09-07 15:22:43 -04:00
|
|
|
fi
|
2015-09-19 12:55:43 -04:00
|
|
|
}
|
|
|
|
|
2015-09-26 17:33:08 -04:00
|
|
|
pushd $GOPATH/src/
|
|
|
|
|
2015-09-19 18:43:42 -04:00
|
|
|
touch coverall.out
|
2015-09-19 12:55:43 -04:00
|
|
|
|
2015-09-26 17:33:08 -04:00
|
|
|
for DIR in $(find github.com/v2ray/v2ray-core -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 | uniq -u > coverallsorted.out
|
2015-09-19 18:43:42 -04:00
|
|
|
echo "mode: set" | cat - coverallsorted.out > coverall.out
|
|
|
|
rm coverallsorted.out
|
|
|
|
|
2015-09-19 12:55:43 -04:00
|
|
|
if [ "$FAIL" -eq 0 ]; then
|
2015-09-07 15:24:46 -04:00
|
|
|
$HOME/gopath/bin/goveralls -v -coverprofile=coverall.out -service=travis-ci -repotoken $COVERALLS_TOKEN
|
2015-09-07 15:22:43 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
rm -f coverall.out
|
|
|
|
|
2015-09-26 17:33:08 -04:00
|
|
|
popd
|
|
|
|
|
2015-09-19 12:55:43 -04:00
|
|
|
exit $FAIL
|