github.com/zhouyu0/docker-note@v0.0.0-20190722021225-b8d3825084db/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 for pkg in $pkg_list; do 23 go test "${BUILDFLAGS[@]}" \ 24 -cover \ 25 -coverprofile=profile.out \ 26 -covermode=atomic \ 27 $TESTFLAGS \ 28 "${pkg}" 29 30 if test -f profile.out; then 31 cat profile.out >> coverage.txt 32 rm profile.out 33 fi 34 done