Revision 8c99ab80bd625123dc0112321815a27ff687765a authored by Gyu-Ho Lee on 21 August 2017, 20:07:06 UTC, committed by Gyu-Ho Lee on 21 August 2017, 20:07:06 UTC
Signed-off-by: Gyu-Ho Lee <gyuhox@gmail.com>
1 parent 9d43462
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 ...