33# For integration-cli test, we use [gocheck](https://labix.org/gocheck), if you want
44# to run certain tests on your local host, you should run with command:
55#
6- # TESTFLAGS='-check.f DockerSuite. TestBuild*' ./hack/make.sh binary test-integration
6+ # TESTFLAGS='-test.run TestDockerSuite/ TestBuild*' ./hack/make.sh binary test-integration
77#
88
9- if [[ " ${TESTFLAGS} " = * -check.f* ]]; then
10- echo Skipping integration tests since TESTFLAGS includes integration-cli only flags
11- TEST_SKIP_INTEGRATION=1
12- fi
13-
14- if [[ " ${TESTFLAGS} " = * -test.run* ]]; then
15- echo Skipping integration-cli tests since TESTFLAGS includes integration only flags
16- TEST_SKIP_INTEGRATION_CLI=1
17- fi
18-
19-
209if [ -z " ${MAKEDIR} " ]; then
2110 MAKEDIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd ) "
2211 export MAKEDIR
@@ -32,24 +21,22 @@ setup_integration_test_filter() {
3221 if [ -z " ${TEST_FILTER} " ]; then
3322 return
3423 fi
24+ TESTFLAGS+=" -test.run ${TEST_FILTER} "
3525
26+ local dirs
27+ dirs=$( grep -rIlE --include ' *_test.go' " func .*${TEST_FILTER} .*\(. \*testing\.T\)" ./integration* / | xargs -I file dirname file | uniq)
3628 if [ -z " ${TEST_SKIP_INTEGRATION} " ]; then
37- : " ${TEST_INTEGRATION_DIR:= $(grep -rl " func\ .* ${TEST_FILTER} .*\(t\ \*testing\.T\) " . / integration | grep ' _test\.go ' | xargs -I file dirname file | uniq )} "
29+ : " ${TEST_INTEGRATION_DIR:= $(echo " $dirs " | grep -v ' ^\./integration-cli$ ' )} "
3830 if [ -z " ${TEST_INTEGRATION_DIR} " ]; then
3931 echo " Skipping integration tests since the supplied filter \" ${TEST_FILTER} \" omits all integration tests"
4032 TEST_SKIP_INTEGRATION=1
41- else
42- TESTFLAGS_INTEGRATION+=" -test.run ${TEST_FILTER} "
4333 fi
4434 fi
4535
4636 if [ -z " ${TEST_SKIP_INTEGRATION_CLI} " ]; then
47- # ease up on the filtering here since CLI suites are namespaced by an object
48- if grep -r " ${TEST_FILTER} .*\(c\ \*check\.C\)" ./integration-cli | grep -q ' _test\.go$' ; then
37+ if echo " $dirs " | grep -vq ' ^./integration-cli$' ; then
4938 TEST_SKIP_INTEGRATION_CLI=1
5039 echo " Skipping integration-cli tests since the supplied filter \" ${TEST_FILTER} \" omits all integration-cli tests"
51- else
52- TESTFLAGS_INTEGRATION_CLI+=" -check.f ${TEST_FILTER} "
5340 fi
5441 fi
5542}
@@ -60,16 +47,17 @@ integration_api_dirs="${TEST_INTEGRATION_DIR:-$(go list -test -f '{{- if ne .Fo
6047run_test_integration () {
6148 set_platform_timeout
6249 if [ -z " ${TEST_SKIP_INTEGRATION} " ]; then
63- run_test_integration_suites
50+ run_test_integration_suites " ${integration_api_dirs} "
6451 fi
6552 if [ -z " ${TEST_SKIP_INTEGRATION_CLI} " ]; then
66- run_test_integration_legacy_suites
53+ TIMEOUT=360m run_test_integration_suites integration-cli
6754 fi
6855}
6956
7057run_test_integration_suites () {
71- local flags=" -test.v -test.timeout=${TIMEOUT} $TESTFLAGS ${TESTFLAGS_INTEGRATION} "
72- for dir in ${integration_api_dirs} ; do
58+ local flags=" -test.v -test.timeout=${TIMEOUT} $TESTFLAGS "
59+ local dirs=" $1 "
60+ for dir in ${dirs} ; do
7361 if ! (
7462 cd " $dir "
7563 # Create a useful package name based on the tests's $dir. We need to take
@@ -97,16 +85,6 @@ run_test_integration_suites() {
9785 done
9886}
9987
100- run_test_integration_legacy_suites () {
101- (
102- flags=" -check.v -check.timeout=${TIMEOUT} -test.timeout=360m $TESTFLAGS ${TESTFLAGS_INTEGRATION_CLI} "
103- cd integration-cli
104- echo " Running $PWD flags=${flags} "
105- # shellcheck disable=SC2086
106- test_env ./test.main $flags
107- )
108- }
109-
11088build_test_suite_binaries () {
11189 if [ -n " ${DOCKER_INTEGRATION_TESTS_VERIFIED} " ]; then
11290 echo " Skipping building test binaries; as DOCKER_INTEGRATION_TESTS_VERIFIED is set"
0 commit comments