Signed-off-by: Daniel Nephin <dnephin@docker.com>
| ... | ... |
@@ -1,29 +1,36 @@ |
| 1 | 1 |
#!/usr/bin/env bash |
| 2 | 2 |
|
| 3 |
-: ${TEST_REPEAT:=0}
|
|
| 3 |
+source "$SCRIPTDIR/make/.go-autogen" |
|
| 4 | 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 |
-} |
|
| 5 |
+: ${TEST_REPEAT:=0}
|
|
| 9 | 6 |
|
| 10 | 7 |
bundle_test_integration() {
|
| 11 |
- TESTFLAGS="$TESTFLAGS -v -test.timeout=60m" |
|
| 12 | 8 |
( |
| 13 |
- set -e |
|
| 9 |
+ local flags="-v -test.timeout=${TIMEOUT} $TESTFLAGS"
|
|
| 14 | 10 |
cd integration |
| 15 |
- INCBUILD="-i" |
|
| 16 |
- count=0 |
|
| 17 |
- for flag in "${BUILDFLAGS[@]}"; do
|
|
| 18 |
- if [ "${flag}" == ${INCBUILD} ]; then
|
|
| 19 |
- unset BUILDFLAGS[${count}]
|
|
| 20 |
- break |
|
| 21 |
- fi |
|
| 22 |
- count=$[ ${count} + 1 ]
|
|
| 23 |
- done |
|
| 24 |
- echo go test -ldflags "$LDFLAGS" "${BUILDFLAGS[@]}" $TESTFLAGS ./...
|
|
| 25 |
- go test -ldflags "$LDFLAGS" "${BUILDFLAGS[@]}" $TESTFLAGS ./...
|
|
| 11 |
+ set -ex |
|
| 12 |
+ # TODO: run existing binary? |
|
| 13 |
+ go test -ldflags "$LDFLAGS" "${BUILDFLAGS[@]}" $flags ./...
|
|
| 26 | 14 |
) |
| 15 |
+ ( |
|
| 16 |
+ local flags="$TESTFLAGS -check.v -check.timeout=${TIMEOUT} -test.timeout=360m"
|
|
| 17 |
+ go_test_dir integration-cli |
|
| 18 |
+ ) |
|
| 19 |
+} |
|
| 20 |
+ |
|
| 21 |
+build_test_suite_binaries() {
|
|
| 22 |
+ build_test_suite_binary integration-cli "test.main" |
|
| 23 |
+ for dir in $(find integration -type d); do |
|
| 24 |
+ build_test_suite_binary "$dir" "test.main" |
|
| 25 |
+ done |
|
| 26 |
+} |
|
| 27 |
+ |
|
| 28 |
+# Build a binary for a test suite package |
|
| 29 |
+build_test_suite_binary() {
|
|
| 30 |
+ local dir="$1" |
|
| 31 |
+ local out="$2" |
|
| 32 |
+ echo Building test suite binary "$dir/$out" |
|
| 33 |
+ go test -c -o "$dir/$out" -ldflags "$LDFLAGS" "${BUILDFLAGS[@]}" "./$dir"
|
|
| 27 | 34 |
} |
| 28 | 35 |
|
| 29 | 36 |
# If $TESTFLAGS is set in the environment, it is passed as extra arguments to 'go test'. |
| ... | ... |
@@ -34,45 +41,22 @@ bundle_test_integration() {
|
| 34 | 34 |
# For integration-cli test, we use [gocheck](https://labix.org/gocheck), if you want |
| 35 | 35 |
# to run certain tests on your local host, you should run with command: |
| 36 | 36 |
# |
| 37 |
-# TESTFLAGS='-check.f DockerSuite.TestBuild*' ./hack/make.sh binary test-integration-cli |
|
| 37 |
+# TESTFLAGS='-check.f DockerSuite.TestBuild*' ./hack/make.sh binary test-integration |
|
| 38 | 38 |
# |
| 39 | 39 |
go_test_dir() {
|
| 40 |
- dir=$1 |
|
| 41 |
- precompiled=$2 |
|
| 42 |
- testbinary="$ABS_DEST/test.main" |
|
| 43 |
- testcover=() |
|
| 44 |
- testcoverprofile=() |
|
| 40 |
+ local dir=$1 |
|
| 45 | 41 |
( |
| 46 | 42 |
set -e |
| 47 |
- mkdir -p "$DEST/coverprofiles" |
|
| 48 |
- export DEST="$ABS_DEST" # in a subshell this is safe -- our integration-cli tests need DEST, and "cd" screws it up |
|
| 49 |
- if [ -z $precompiled ]; then |
|
| 50 |
- ensure_test_dir $1 $testbinary |
|
| 51 |
- fi |
|
| 43 |
+ # DEST is used by the test suite |
|
| 44 |
+ export DEST="$ABS_DEST" |
|
| 52 | 45 |
cd "$dir" |
| 53 |
- i=0 |
|
| 54 |
- while ((++i)); do |
|
| 55 |
- test_env "$testbinary" $TESTFLAGS |
|
| 56 |
- if [ $i -gt "$TEST_REPEAT" ]; then |
|
| 57 |
- break |
|
| 58 |
- fi |
|
| 59 |
- echo "Repeating test ($i)" |
|
| 46 |
+ for i in $(seq 0 $TEST_REPEAT); do |
|
| 47 |
+ echo "Repeating integration-test ($i)" |
|
| 48 |
+ test_env "./test.main" $TESTFLAGS |
|
| 60 | 49 |
done |
| 61 | 50 |
) |
| 62 | 51 |
} |
| 63 | 52 |
|
| 64 |
-ensure_test_dir() {
|
|
| 65 |
- ( |
|
| 66 |
- # make sure a test dir will compile |
|
| 67 |
- dir="$1" |
|
| 68 |
- out="$2" |
|
| 69 |
- echo Building test dir: "$dir" |
|
| 70 |
- set -xe |
|
| 71 |
- cd "$dir" |
|
| 72 |
- go test -c -o "$out" -ldflags "$LDFLAGS" "${BUILDFLAGS[@]}"
|
|
| 73 |
- ) |
|
| 74 |
-} |
|
| 75 |
- |
|
| 76 | 53 |
test_env() {
|
| 77 | 54 |
( |
| 78 | 55 |
set -xe |
| 79 | 56 |
deleted file mode 100644 |
| ... | ... |
@@ -1,13 +0,0 @@ |
| 1 |
-#!/usr/bin/env bash |
|
| 2 |
-set -e |
|
| 3 |
- |
|
| 4 |
-rm -rf "$DEST" |
|
| 5 |
-DEST="$ABS_DEST/../test-integration" |
|
| 6 |
- |
|
| 7 |
-source "$SCRIPTDIR/make/.go-autogen" |
|
| 8 |
- |
|
| 9 |
-if [ -z $DOCKER_INTEGRATION_TESTS_VERIFIED ]; then |
|
| 10 |
- source ${MAKEDIR}/.integration-test-helpers
|
|
| 11 |
- ensure_test_dir integration-cli "$DEST/test.main" |
|
| 12 |
- export DOCKER_INTEGRATION_TESTS_VERIFIED=1 |
|
| 13 |
-fi |