forked from heketi/heketi
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.travis-coverage
executable file
·49 lines (39 loc) · 1.17 KB
/
.travis-coverage
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/sh
# We cannot use go test -coverprofile=cover.out ./... because
# the tool requires that it be used only on one package when
# capturing the coverage
# This is why we need this little script here.
packages="./apps/glusterfs"
packages="${packages} ./executors/sshexec"
packages="${packages} ./executors/mockexec"
packages="${packages} ./executors/kubeexec"
packages="${packages} ./client/api/go-client"
packages="${packages} ./middleware"
packages="${packages} ./pkg/utils"
COVERFILE=packagecover.out
coverage()
{
echo "mode: count" > $COVERFILE
for pkg in $packages ; do
echo "-- Testing $pkg --"
# Collect coverage
go test -covermode=count -coverprofile=cover.out $pkg || exit 1
# Show in the command line
go tool cover -func=cover.out
# Append to coverfile
grep -v "^mode: count" cover.out >> $COVERFILE
# Cleanup
rm -f cover.out
done
}
coverage
if [ -n "$COVERALLS_TOKEN" ] ; then
# Send to coveralls.io
$HOME/gopath/bin/goveralls \
-coverprofile=$COVERFILE \
-service=travis-ci \
-repotoken $COVERALLS_TOKEN
fi
# Clean up
rm -f $COVERFILE > /dev/null 2>&1
exit 0