Created
October 19, 2014 01:24
-
-
Save kisom/3d89ab20259b65be92c3 to your computer and use it in GitHub Desktop.
gtcov
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Produce an HTML file displaying code coverage. Dependencies: | |
# - cloc (apt-get install cloc) | |
# - cover (go get code.google.com/p/go.tools/cmd/cover) | |
if [ -z "$1" ]; then | |
PKG="" | |
else | |
PKG=$1 | |
fi | |
BROWSER=firefox | |
BROWSER_ARGS="-new-tab" | |
OUTBASE=cover | |
SLOC="$(cloc . | grep ^Go | awk '{print $5}')" | |
echo "$SLOC lines of code." | |
go test -test.covermode count -test.coverprofile ${OUTBASE}.out $PKG | |
if [ -e ${OUTBASE}.out ]; then | |
go tool cover -html ${OUTBASE}.out -o ${OUTBASE}.html | |
if [ -e ${OUTBASE}.html ]; then | |
$BROWSER $BROWSER_ARGS file://$(pwd)/${OUTBASE}.html | |
# rm ${OUTBASE}.html | |
else | |
echo "No HTML file was generated." | |
fi | |
rm ${OUTBASE}.out | |
else | |
echo "No coverage profile generated." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment