Revision 43b75072bfaca5a7c35c718179defbcabd9a0886 authored by Gyu-Ho Lee on 27 April 2017, 15:25:50 UTC, committed by Gyu-Ho Lee on 27 April 2017, 15:25:50 UTC
Signed-off-by: Gyu-Ho Lee <gyuhox@gmail.com>
1 parent 78141fa
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 ...