go.etcd.io/etcd@v3.3.27+incompatible/cover (about) 1 #!/usr/bin/env bash 2 # 3 # Generate coverage HTML for a package 4 # e.g. PKG=./unit ./cover 5 # 6 set -e 7 8 if [ -z "$PKG" ]; then 9 echo "cover only works with a single package, sorry" 10 exit 255 11 fi 12 13 COVEROUT="coverage" 14 15 if ! [ -d "$COVEROUT" ]; then 16 mkdir "$COVEROUT" 17 fi 18 19 # strip leading dot/slash and trailing slash and sanitize other slashes 20 # e.g. ./etcdserver/etcdhttp/ ==> etcdserver_etcdhttp 21 COVERPKG=${PKG/#./} 22 COVERPKG=${COVERPKG/#\//} 23 COVERPKG=${COVERPKG/%\//} 24 COVERPKG=${COVERPKG//\//_} 25 26 # generate arg for "go test" 27 export COVER="-coverprofile ${COVEROUT}/${COVERPKG}.out" 28 29 source ./test 30 31 go tool cover -html=${COVEROUT}/${COVERPKG}.out