diff --git a/testing/coverage/coverall b/testing/coverage/coverall index 1c109845b..644434c4b 100755 --- a/testing/coverage/coverall +++ b/testing/coverage/coverall @@ -2,14 +2,10 @@ FAIL=0 -function join { local IFS="$1"; shift; echo "$*"; } - function test_package { - DIR="github.com/v2ray/v2ray-core/$1" - DEP=$2 - IFS=',' read -ra DEPS <<< "$DEP" - DEPS=("${DEPS[@]/#/github.com/v2ray/v2ray-core/}") - DEP=$(join , "${DEPS[@]}") + DIR="$1" + DEP=$(go list -f '{{ join .Deps "\n" }}' $DIR | grep v2ray | tr '\n' ',') + DEP=${DEP}$DIR go test -coverprofile=coversingle.out -coverpkg=$DEP $DIR || FAIL=1 if [ -f coversingle.out ]; then cat coversingle.out | grep -v "mode: set" >> coverall.out @@ -17,20 +13,18 @@ function test_package { fi } +pushd $GOPATH/src/ + touch coverall.out -test_package "common/errors" "common/errors" -test_package "common/net" "common/net" -test_package "common/collect" "common/collect" -test_package "config/json" "config/json" -test_package "proxy/freedom" ".,proxy/freedom,/proxy/socks" -test_package "proxy/socks" ".,proxy/socks,proxy/socks/protocol" -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" +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 > coverallsorted.out +cat coverall.out | sort -t: -k1 | uniq -u > coverallsorted.out echo "mode: set" | cat - coverallsorted.out > coverall.out rm coverallsorted.out @@ -40,4 +34,6 @@ fi rm -f coverall.out +popd + exit $FAIL