github.com/flavio/docker@v0.1.3-0.20170117145210-f63d1a6eec47/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 $DOCKER_INTEGRATION_TESTS_VERIFIED 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, e.g. 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 precompiled=$2 23 testbinary="$ABS_DEST/test.main" 24 testcover=() 25 testcoverprofile=() 26 ( 27 set -e 28 mkdir -p "$DEST/coverprofiles" 29 export DEST="$ABS_DEST" # in a subshell this is safe -- our integration-cli tests need DEST, and "cd" screws it up 30 if [ -z $precompiled ]; then 31 ensure_test_dir $1 $testbinary 32 fi 33 cd "$dir" 34 i=0 35 while ((++i)); do 36 test_env "$testbinary" $TESTFLAGS 37 if [ $i -gt "$TEST_REPEAT" ]; then 38 break 39 fi 40 echo "Repeating test ($i)" 41 done 42 ) 43 } 44 45 ensure_test_dir() { 46 ( 47 # make sure a test dir will compile 48 dir="$1" 49 out="$2" 50 echo Building test dir: "$dir" 51 set -xe 52 cd "$dir" 53 go test -c -o "$out" -ldflags "$LDFLAGS" "${BUILDFLAGS[@]}" 54 ) 55 } 56 57 test_env() { 58 ( 59 set -xe 60 # use "env -i" to tightly control the environment variables that bleed into the tests 61 env -i \ 62 DEST="$DEST" \ 63 DOCKER_TLS_VERIFY="$DOCKER_TEST_TLS_VERIFY" \ 64 DOCKER_CERT_PATH="$DOCKER_TEST_CERT_PATH" \ 65 DOCKER_ENGINE_GOARCH="$DOCKER_ENGINE_GOARCH" \ 66 DOCKER_GRAPHDRIVER="$DOCKER_GRAPHDRIVER" \ 67 DOCKER_USERLANDPROXY="$DOCKER_USERLANDPROXY" \ 68 DOCKER_HOST="$DOCKER_HOST" \ 69 DOCKER_REMAP_ROOT="$DOCKER_REMAP_ROOT" \ 70 DOCKER_REMOTE_DAEMON="$DOCKER_REMOTE_DAEMON" \ 71 DOCKERFILE="$DOCKERFILE" \ 72 GOPATH="$GOPATH" \ 73 GOTRACEBACK=all \ 74 HOME="$ABS_DEST/fake-HOME" \ 75 PATH="$PATH" \ 76 TEMP="$TEMP" \ 77 TEST_IMAGE_NAMESPACE="$TEST_IMAGE_NAMESPACE" \ 78 "$@" 79 ) 80 }