github.com/rita33cool1/iot-system-gateway@v0.0.0-20200911033302-e65bde238cc5/docker-engine/hack/test/unit (about) 1 #!/usr/bin/env bash 2 # 3 # Run unit tests 4 # 5 # TESTFLAGS - add additional test flags. Ex: 6 # 7 # TESTFLAGS="-v -run TestBuild" hack/test/unit 8 # 9 # TESTDIRS - run tests for specified packages. Ex: 10 # 11 # TESTDIRS="./pkg/term" hack/test/unit 12 # 13 set -eu -o pipefail 14 15 TESTFLAGS+=" -test.timeout=${TIMEOUT:-5m}" 16 BUILDFLAGS=( -tags "netgo seccomp libdm_no_deferred_remove" ) 17 TESTDIRS="${TESTDIRS:-"./..."}" 18 19 exclude_paths="/vendor/|/integration" 20 pkg_list=$(go list $TESTDIRS | grep -vE "($exclude_paths)") 21 22 # install test dependencies once before running tests for each package. This 23 # significantly reduces the runtime. 24 go test -i "${BUILDFLAGS[@]}" $pkg_list 25 26 for pkg in $pkg_list; do 27 go test "${BUILDFLAGS[@]}" \ 28 -cover \ 29 -coverprofile=profile.out \ 30 -covermode=atomic \ 31 $TESTFLAGS \ 32 "${pkg}" 33 34 if test -f profile.out; then 35 cat profile.out >> coverage.txt 36 rm profile.out 37 fi 38 done