Skip to content

Commit ee37a93

Browse files
committed
Add a script to generate test coverage report.
This commit adds a script which can be used to generate the test coverage report. It detects whether or not gcc is installed and adds the necessary build tag to enable the new cgo tests when gcc is available.
1 parent 56a83c9 commit ee37a93

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

cov_report.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/sh
2+
3+
# This script uses gocov to generate a test coverage report.
4+
# The gocov tool my be obtained with the following command:
5+
# go get github.com/axw/gocov/gocov
6+
#
7+
# It will be installed to $GOPATH/bin, so ensure that location is in your $PATH.
8+
9+
# Check for gocov.
10+
if ! type gocov >/dev/null 2>&1; then
11+
echo >&2 "This script requires the gocov tool."
12+
echo >&2 "You may obtain it with the following command:"
13+
echo >&2 "go get github.com/axw/gocov/gocov"
14+
exit 1
15+
fi
16+
17+
# Only run the cgo tests if gcc is installed.
18+
if type gcc >/dev/null 2>&1; then
19+
(cd spew && gocov test -tags testcgo | gocov report)
20+
else
21+
(cd spew && gocov test | gocov report)
22+
fi

0 commit comments

Comments
 (0)