mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00

This adds a build script that attempts to be as user friendly as possible: if they have already set $GOPATH and/or $GOBIN, use those environment variables. If not, create a gopath for them in this directory. This should facilitate both `go get` and `git clone` usage. The `test` script is updated, and the new `cover` script facilitates easy coverage generation for the repo's constituent packages by setting the PKG environment variable.
31 lines
626 B
Bash
Executable File
31 lines
626 B
Bash
Executable File
#!/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
|