Revision 573f62f7a5bd8973b9bd95fbce84d1d92ee1766f authored by Yicheng Qin on 07 July 2015, 01:10:31 UTC, committed by Yicheng Qin on 07 July 2015, 01:10:31 UTC
integration: always check error for function calls
2 parent s 121ff46 + e7ed7a7
Raw File
cover
#!/bin/bash -e
#
# Generate coverage HTML for a package
# e.g. PKG=./unit ./cover
#

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
back to top