/
testcoverage
executable file
·32 lines (25 loc) · 909 Bytes
/
testcoverage
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash
# run on CI service w/something like:
#
# go get github.com/axw/gocov/gocov
# go get github.com/mattn/goveralls
COVERALLS="-service drone.io -repotoken $COVERALLS_TOKEN_BLIST"
echo "mode: set" >acc.out
fail=0
# Standard go tooling behavior is to ignore dirs with leading underscores
for dir in $(find . -maxdepth 10 -not -path './.?*' -not -path './vendor/*' -not -path './payload*' -not -path '*/_*' -type d); do
if ls ${dir}/*.go &>/dev/null; then
go test -timeout 120s -coverprofile=profile.out ${dir} || fail=1
if [ -f profile.out ]; then
cat profile.out | grep -v "mode: set" >>acc.out
rm profile.out
fi
fi
done
# Failures have incomplete results, so don't send
if [ -n "$COVERALLS" ] && [ "$fail" -eq 0 ]; then
# goveralls -coverprofile=overalls.coverprofile -service=travis-ci
goveralls -v -coverprofile=acc.out $COVERALLS
fi
rm -f acc.out
exit $fail