https://github.com/etcd-io/etcd
Revision a94118893c184cf902122d4034defa40f0f8b324 authored by Xiang Li on 01 September 2015, 17:03:50 UTC, committed by Xiang Li on 01 September 2015, 17:03:50 UTC
2 parent s 85b6c51 + d94e712
Raw File
Tip revision: a94118893c184cf902122d4034defa40f0f8b324 authored by Xiang Li on 01 September 2015, 17:03:50 UTC
Merge pull request #3413 from xiang90/snapshot_dir
Tip revision: a941188
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
back to top