github.com/brahmaroutu/docker@v1.2.1-0.20160809185609-eb28dde01f16/hack/make/.integration-test-helpers (about) 1 #!/bin/bash 2 3 : ${TEST_REPEAT:=0} 4 5 bundle_test_integration_cli() { 6 TESTFLAGS="$TESTFLAGS -check.v -check.timeout=${TIMEOUT} -test.timeout=360m" 7 go_test_dir ./integration-cli 8 } 9 10 # If $TESTFLAGS is set in the environment, it is passed as extra arguments to 'go test'. 11 # You can use this to select certain tests to run, eg. 12 # 13 # TESTFLAGS='-test.run ^TestBuild$' ./hack/make.sh test-unit 14 # 15 # For integration-cli test, we use [gocheck](https://labix.org/gocheck), if you want 16 # to run certain tests on your local host, you should run with command: 17 # 18 # TESTFLAGS='-check.f DockerSuite.TestBuild*' ./hack/make.sh binary test-integration-cli 19 # 20 go_test_dir() { 21 dir=$1 22 coverpkg=$2 23 testcover=() 24 testcoverprofile=() 25 testbinary="$DEST/test.main" 26 if [ "$HAVE_GO_TEST_COVER" ]; then 27 # if our current go install has -cover, we want to use it :) 28 mkdir -p "$DEST/coverprofiles" 29 coverprofile="docker${dir#.}" 30 coverprofile="$ABS_DEST/coverprofiles/${coverprofile//\//-}" 31 testcover=( -test.cover ) 32 testcoverprofile=( -test.coverprofile "$coverprofile" $coverpkg ) 33 fi 34 ( 35 echo '+ go test' $TESTFLAGS "${DOCKER_PKG}${dir#.}" 36 cd "$dir" 37 export DEST="$ABS_DEST" # in a subshell this is safe -- our integration-cli tests need DEST, and "cd" screws it up 38 go test -c -o "$testbinary" ${testcover[@]} -ldflags "$LDFLAGS" "${BUILDFLAGS[@]}" 39 i=0 40 while ((++i)); do 41 test_env "$testbinary" ${testcoverprofile[@]} $TESTFLAGS 42 if [ $i -gt "$TEST_REPEAT" ]; then 43 break 44 fi 45 echo "Repeating test ($i)" 46 done 47 ) 48 } 49 50 test_env() { 51 # use "env -i" to tightly control the environment variables that bleed into the tests 52 env -i \ 53 DEST="$DEST" \ 54 DOCKER_TLS_VERIFY="$DOCKER_TEST_TLS_VERIFY" \ 55 DOCKER_CERT_PATH="$DOCKER_TEST_CERT_PATH" \ 56 DOCKER_ENGINE_GOARCH="$DOCKER_ENGINE_GOARCH" \ 57 DOCKER_GRAPHDRIVER="$DOCKER_GRAPHDRIVER" \ 58 DOCKER_USERLANDPROXY="$DOCKER_USERLANDPROXY" \ 59 DOCKER_HOST="$DOCKER_HOST" \ 60 DOCKER_REMAP_ROOT="$DOCKER_REMAP_ROOT" \ 61 DOCKER_REMOTE_DAEMON="$DOCKER_REMOTE_DAEMON" \ 62 GOPATH="$GOPATH" \ 63 GOTRACEBACK=all \ 64 HOME="$ABS_DEST/fake-HOME" \ 65 PATH="$PATH" \ 66 TEMP="$TEMP" \ 67 "$@" 68 }