2016-07-18 17:26:35 -04:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
: ${TEST_REPEAT:=0}
|
|
|
|
|
|
|
|
bundle_test_integration_cli() {
|
|
|
|
TESTFLAGS="$TESTFLAGS -check.v -check.timeout=${TIMEOUT} -test.timeout=360m"
|
|
|
|
go_test_dir ./integration-cli
|
|
|
|
}
|
|
|
|
|
|
|
|
# If $TESTFLAGS is set in the environment, it is passed as extra arguments to 'go test'.
|
|
|
|
# You can use this to select certain tests to run, eg.
|
|
|
|
#
|
|
|
|
# TESTFLAGS='-test.run ^TestBuild$' ./hack/make.sh test-unit
|
|
|
|
#
|
|
|
|
# For integration-cli test, we use [gocheck](https://labix.org/gocheck), if you want
|
|
|
|
# to run certain tests on your local host, you should run with command:
|
|
|
|
#
|
|
|
|
# TESTFLAGS='-check.f DockerSuite.TestBuild*' ./hack/make.sh binary test-integration-cli
|
|
|
|
#
|
|
|
|
go_test_dir() {
|
|
|
|
dir=$1
|
|
|
|
coverpkg=$2
|
|
|
|
testcover=()
|
|
|
|
testcoverprofile=()
|
|
|
|
testbinary="$DEST/test.main"
|
|
|
|
(
|
2016-08-18 16:12:24 -04:00
|
|
|
mkdir -p "$DEST/coverprofiles"
|
2016-07-18 17:26:35 -04:00
|
|
|
echo '+ go test' $TESTFLAGS "${DOCKER_PKG}${dir#.}"
|
|
|
|
cd "$dir"
|
|
|
|
export DEST="$ABS_DEST" # in a subshell this is safe -- our integration-cli tests need DEST, and "cd" screws it up
|
2016-08-18 16:12:24 -04:00
|
|
|
go test -c -o "$testbinary" -ldflags "$LDFLAGS" "${BUILDFLAGS[@]}"
|
2016-07-18 17:26:35 -04:00
|
|
|
i=0
|
|
|
|
while ((++i)); do
|
2016-08-18 16:12:24 -04:00
|
|
|
test_env "$testbinary" $TESTFLAGS
|
2016-07-18 17:26:35 -04:00
|
|
|
if [ $i -gt "$TEST_REPEAT" ]; then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
echo "Repeating test ($i)"
|
|
|
|
done
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
test_env() {
|
|
|
|
# use "env -i" to tightly control the environment variables that bleed into the tests
|
|
|
|
env -i \
|
|
|
|
DEST="$DEST" \
|
|
|
|
DOCKER_TLS_VERIFY="$DOCKER_TEST_TLS_VERIFY" \
|
|
|
|
DOCKER_CERT_PATH="$DOCKER_TEST_CERT_PATH" \
|
|
|
|
DOCKER_ENGINE_GOARCH="$DOCKER_ENGINE_GOARCH" \
|
|
|
|
DOCKER_GRAPHDRIVER="$DOCKER_GRAPHDRIVER" \
|
|
|
|
DOCKER_USERLANDPROXY="$DOCKER_USERLANDPROXY" \
|
|
|
|
DOCKER_HOST="$DOCKER_HOST" \
|
|
|
|
DOCKER_REMAP_ROOT="$DOCKER_REMAP_ROOT" \
|
|
|
|
DOCKER_REMOTE_DAEMON="$DOCKER_REMOTE_DAEMON" \
|
|
|
|
GOPATH="$GOPATH" \
|
|
|
|
GOTRACEBACK=all \
|
|
|
|
HOME="$ABS_DEST/fake-HOME" \
|
|
|
|
PATH="$PATH" \
|
|
|
|
TEMP="$TEMP" \
|
|
|
|
"$@"
|
|
|
|
}
|