github.com/coreos/mantle@v0.13.0/test (about) 1 #!/usr/bin/env bash 2 # 3 # Run all tests 4 # ./test 5 # ./test -v 6 # 7 # Run tests for one package 8 # PKG=./foo ./test 9 # 10 11 set -e 12 13 cd $(dirname $0) 14 15 source ./env 16 # Use an alternate bin to avoid clobbering output from ./build 17 export GOBIN="$(pwd)/_testbin" 18 trap "rm -rf _testbin/" EXIT 19 20 # PKG may be passed in from ./cover 21 [[ -z "$PKG" ]] && PKG="./..." 22 23 # Expand PKG, excluding the vendor directory. 24 pkgs=$(go list $PKG | grep -v /vendor/) 25 src=$(find . -name '*.go' -not -path "./vendor/*") 26 27 echo "Building tests..." 28 go test -mod=vendor -i "$@" $pkgs 29 go install $pkgs 30 31 echo "Running tests..." 32 go test -mod=vendor -cover "$@" $pkgs 33 34 echo "Checking gofmt..." 35 res=$(gofmt -d -e $src) 36 if [ -n "${res}" ]; then 37 echo "${res}" 38 echo "gofmt check failed" >&2 39 exit 1 40 fi 41 42 echo "Checking govet..." 43 go vet $pkgs 44 45 echo "Running commands..." 46 for cmd in ${GOBIN}/*; do 47 echo " Running $(basename ${cmd})..." 48 ${cmd} --help > /dev/null 49 done 50 51 echo "Success"