1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-07-02 03:55:24 +00:00
v2fly/testing/coverage/coverall
2015-09-20 11:47:39 +02:00

41 lines
1.2 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/net" "common/net"
test_package "config/json" "config/json"
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