https://github.com/etcd-io/etcd
Revision 58792ca59b70059a2e6ac4806da3de0e145a7f84 authored by Gyu-Ho Lee on 16 March 2016, 18:06:36 UTC, committed by Gyu-Ho Lee on 16 March 2016, 18:06:36 UTC
1 parent a2569c7
Raw File
Tip revision: 58792ca59b70059a2e6ac4806da3de0e145a7f84 authored by Gyu-Ho Lee on 16 March 2016, 18:06:36 UTC
bench/cmd: print csv-format timeseries
Tip revision: 58792ca
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