https://github.com/etcd-io/etcd
Raw File
Tip revision: 3794f6ab88c12be98c9181c30ebbf3b7204fbeec authored by Brandon Philips on 13 December 2014, 00:26:16 UTC
version: bump to alpha.5
Tip revision: 3794f6a
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