https://github.com/etcd-io/etcd
Revision 8a9b3d53857554df347e8b80a42961c88f3dc14f authored by Joe Betz on 24 April 2018, 21:15:36 UTC, committed by Joe Betz on 24 April 2018, 21:15:36 UTC
1 parent 4e7af27
Raw File
Tip revision: 8a9b3d53857554df347e8b80a42961c88f3dc14f authored by Joe Betz on 24 April 2018, 21:15:36 UTC
version: bump up to 3.2.19
Tip revision: 8a9b3d5
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