Revision 0d38c13990ceab50f5ad39c60a4d3b5f1d4eed00 authored by Yicheng Qin on 25 August 2015, 18:35:05 UTC, committed by Yicheng Qin on 26 August 2015, 22:01:41 UTC
1 parent 2d01eb4
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 ...