1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-22 10:08:15 -05:00
v2fly/testing/coverage/coverall
2015-09-25 00:18:26 +02:00

44 lines
1.4 KiB
Bash
Executable File

#!/bin/bash
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[@]}")
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
fi
}
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"
cat coverall.out | sort -t: -k1 > coverallsorted.out
echo "mode: set" | cat - coverallsorted.out > coverall.out
rm coverallsorted.out
if [ "$FAIL" -eq 0 ]; then
$HOME/gopath/bin/goveralls -v -coverprofile=coverall.out -service=travis-ci -repotoken $COVERALLS_TOKEN
fi
rm -f coverall.out
exit $FAIL