1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-01-04 16:37:12 -05:00

fully automated coverall script

This commit is contained in:
V2Ray 2015-09-26 23:33:08 +02:00
parent 9c45cb031a
commit 184560883f

View File

@ -2,14 +2,10 @@
FAIL=0 FAIL=0
function join { local IFS="$1"; shift; echo "$*"; }
function test_package { function test_package {
DIR="github.com/v2ray/v2ray-core/$1" DIR="$1"
DEP=$2 DEP=$(go list -f '{{ join .Deps "\n" }}' $DIR | grep v2ray | tr '\n' ',')
IFS=',' read -ra DEPS <<< "$DEP" DEP=${DEP}$DIR
DEPS=("${DEPS[@]/#/github.com/v2ray/v2ray-core/}")
DEP=$(join , "${DEPS[@]}")
go test -coverprofile=coversingle.out -coverpkg=$DEP $DIR || FAIL=1 go test -coverprofile=coversingle.out -coverpkg=$DEP $DIR || FAIL=1
if [ -f coversingle.out ]; then if [ -f coversingle.out ]; then
cat coversingle.out | grep -v "mode: set" >> coverall.out cat coversingle.out | grep -v "mode: set" >> coverall.out
@ -17,20 +13,18 @@ function test_package {
fi fi
} }
pushd $GOPATH/src/
touch coverall.out touch coverall.out
test_package "common/errors" "common/errors" for DIR in $(find github.com/v2ray/v2ray-core -type d -not -path "*.git*"); do
test_package "common/net" "common/net" TEST_FILES=($DIR/*_test.go)
test_package "common/collect" "common/collect" if [ -f ${TEST_FILES[0]} ]; then
test_package "config/json" "config/json" test_package $DIR
test_package "proxy/freedom" ".,proxy/freedom,/proxy/socks" fi
test_package "proxy/socks" ".,proxy/socks,proxy/socks/protocol" done
test_package "proxy/socks/protocol" "proxy/socks/protocol"
test_package "proxy/vmess" ".,common/io,common/net,proxy/vmess,proxy/vmess/protocol,proxy/vmess/protocol/user"
test_package "proxy/vmess/protocol" "proxy/vmess/protocol,proxy/vmess/protocol/user"
test_package "proxy/vmess/protocol/user" "proxy/vmess/protocol/user"
cat coverall.out | sort -t: -k1 > coverallsorted.out cat coverall.out | sort -t: -k1 | uniq -u > coverallsorted.out
echo "mode: set" | cat - coverallsorted.out > coverall.out echo "mode: set" | cat - coverallsorted.out > coverall.out
rm coverallsorted.out rm coverallsorted.out
@ -40,4 +34,6 @@ fi
rm -f coverall.out rm -f coverall.out
popd
exit $FAIL exit $FAIL