github.com/unigraph-dev/dgraph@v1.1.1-0.20200923154953-8b52b426f765/contrib/scripts/cover.sh (about) 1 #!/bin/bash 2 3 SRC="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/.." 4 TMP=$(mktemp /tmp/dgraph-coverage-XXXXX.txt) 5 6 BUILD=$1 7 # If build variable is empty then we set it. 8 if [ -z "$1" ]; then 9 BUILD=$SRC/build 10 fi 11 12 OUT=$2 13 if [ -z "$OUT" ]; then 14 OUT=$SRC/coverage.out 15 fi 16 rm -f $OUT 17 18 set -e 19 20 21 # create coverage output 22 echo 'mode: atomic' > $OUT 23 for PKG in $(go list ./...|grep -v -E 'vendor|contrib|wiki|customtok'); do 24 if [[ "$TRAVIS" == true ]]; then 25 go test -v -timeout 25m -covermode=atomic -coverprofile=$TMP $PKG 26 else 27 go test -v -race -timeout 25m -covermode=atomic -coverprofile=$TMP $PKG | go-test-teamcity 28 fi 29 tail -n +2 $TMP >> $OUT 30 done 31 32 # open in browser if not in a build environment 33 if [ ! -z "$DISPLAY" ]; then 34 go tool cover -html=$OUT 35 fi