github.com/skf/moby@v1.13.1/hack/make/test-unit (about) 1 #!/bin/bash 2 set -e 3 4 # Run Docker's test suite, including sub-packages, and store their output as a bundle 5 # If $TESTFLAGS is set in the environment, it is passed as extra arguments to 'go test'. 6 # You can use this to select certain tests to run, e.g. 7 # 8 # TESTFLAGS='-test.run ^TestBuild$' ./hack/make.sh test-unit 9 # 10 bundle_test_unit() { 11 TESTFLAGS+=" -test.timeout=${TIMEOUT}" 12 INCBUILD="-i" 13 count=0 14 for flag in "${BUILDFLAGS[@]}"; do 15 if [ "${flag}" == ${INCBUILD} ]; then 16 unset BUILDFLAGS[${count}] 17 break 18 fi 19 count=$[ ${count} + 1 ] 20 done 21 22 date 23 if [ -z "$TESTDIRS" ]; then 24 TEST_PATH=./... 25 else 26 TEST_PATH=./${TESTDIRS} 27 fi 28 29 if [ "$(go env GOHOSTOS)" = 'solaris' ]; then 30 pkg_list=$(go list -e \ 31 -f '{{if ne .Name "github.com/docker/docker"}} 32 {{.ImportPath}} 33 {{end}}' \ 34 "${BUILDFLAGS[@]}" $TEST_PATH \ 35 | grep github.com/docker/docker \ 36 | grep -v github.com/docker/docker/vendor \ 37 | grep -v github.com/docker/docker/daemon/graphdriver \ 38 | grep -v github.com/docker/docker/man \ 39 | grep -v github.com/docker/docker/integration-cli) 40 else 41 pkg_list=$(go list -e \ 42 -f '{{if ne .Name "github.com/docker/docker"}} 43 {{.ImportPath}} 44 {{end}}' \ 45 "${BUILDFLAGS[@]}" $TEST_PATH \ 46 | grep github.com/docker/docker \ 47 | grep -v github.com/docker/docker/vendor \ 48 | grep -v github.com/docker/docker/man \ 49 | grep -v github.com/docker/docker/integration-cli) 50 fi 51 52 go test -cover -ldflags "$LDFLAGS" "${BUILDFLAGS[@]}" $TESTFLAGS $pkg_list 53 } 54 55 bundle_test_unit 2>&1 | tee -a "$DEST/test.log"