Revision 29c30b2387d9fc146e9d0db051d94fbf820b15a1 authored by Anthony Romano on 14 December 2016, 22:21:41 UTC, committed by Anthony Romano on 14 December 2016, 23:56:22 UTC
1 parent 13b05ae
cover
#!/usr/bin/env bash
#
# Generate coverage HTML for a package
# e.g. PKG=./unit ./cover
#
set -e
if [ -z "$PKG" ]; then
echo "cover only works with a single package, sorry"
exit 255
fi
COVEROUT="coverage"
if ! [ -d "$COVEROUT" ]; then
mkdir "$COVEROUT"
fi
# strip leading dot/slash and trailing slash and sanitize other slashes
# e.g. ./etcdserver/etcdhttp/ ==> etcdserver_etcdhttp
COVERPKG=${PKG/#./}
COVERPKG=${COVERPKG/#\//}
COVERPKG=${COVERPKG/%\//}
COVERPKG=${COVERPKG//\//_}
# generate arg for "go test"
export COVER="-coverprofile ${COVEROUT}/${COVERPKG}.out"
source ./test
go tool cover -html=${COVEROUT}/${COVERPKG}.out
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...