github.com/masterhung0112/hk_server/v5@v5.0.0-20220302090640-ec71aef15e1c/scripts/test.sh (about) 1 #!/usr/bin/env bash 2 set -o pipefail 3 4 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" 5 6 GO=$1 7 GOFLAGS=$2 8 PACKAGES=$3 9 TESTS=$4 10 TESTFLAGS=$5 11 GOBIN=$6 12 TIMEOUT=$7 13 COVERMODE=$8 14 15 PACKAGES_COMMA=$(echo $PACKAGES | tr ' ' ',') 16 17 echo "Packages to test: $PACKAGES" 18 echo "GOFLAGS: $GOFLAGS" 19 find . -name 'cprofile*.out' -exec sh -c 'rm "{}"' \; 20 find . -type d -name data -not -path './vendor/*' -not -path './data' | xargs rm -rf 21 22 $GO test $GOFLAGS -run=$TESTS $TESTFLAGS -v -timeout=$TIMEOUT -covermode=$COVERMODE -coverpkg=$PACKAGES_COMMA -exec $DIR/test-xprog.sh $PACKAGES 2>&1 > >( tee output ) 23 EXIT_STATUS=$? 24 25 cat output | $GOBIN/go-junit-report > report.xml 26 rm output 27 find . -name 'cprofile*.out' -exec sh -c 'tail -n +2 "{}" >> cover.out ; rm "{}"' \; 28 rm -f config/*.crt 29 rm -f config/*.key 30 31 exit $EXIT_STATUS