Skip to content

Commit e780565

Browse files
committed
Fix TEST_FILTER to work for both "integration" and "integration-cli"
The TEST_FILTER variable allows running a single integration or integration-cli test. However, it failed to work properly for integration-cli tests. Before: ----------- # Filtering "integration" tests works: make TEST_FILTER=TestInspectCpusetInConfigPre120 test-integration ... DONE 1 tests in 18.331s # But running a single test in "integration-cli" did not: make TEST_FILTER=TestSwarmNetworkCreateIssue27866 test-integration ... DONE 0 tests in 17.314s Trying to manually add the `/` prefix, didn't work either, because that made the "grep" fail to find which test-suites to run/skip: make TEST_FILTER=/TestSwarmNetworkCreateIssue27866 test-integration ---> Making bundle: test-integration (in bundles/test-integration) make: *** [test-integration] Error 1 After: ----------- make TEST_FILTER=TestInspectCpusetInConfigPre120 test-integration ... DONE 1 tests in 18.331s make TEST_FILTER=TestSwarmNetworkCreateIssue27866 test-integration ... DONE 12 tests in 26.527s Note that the `12` tests is still a bit misleading, because every _suite_ is started (which is counted as a test), but no tests are run. This is still something that could be improved on. This patch also makes a small modification to the code that's setting `integration_api_dirs`, and no longer runs `go list` if not needed. Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent ac5acef commit e780565

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

hack/make/.integration-test-helpers

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ setup_integration_test_filter() {
2121
if [ -z "${TEST_FILTER}" ]; then
2222
return
2323
fi
24-
TESTFLAGS+="-test.run ${TEST_FILTER}"
2524

2625
local dirs
2726
dirs=$(grep -rIlE --include '*_test.go' "func .*${TEST_FILTER}.*\(. \*testing\.T\)" ./integration*/ | xargs -I file dirname file | uniq)
@@ -30,19 +29,27 @@ setup_integration_test_filter() {
3029
if [ -z "${TEST_INTEGRATION_DIR}" ]; then
3130
echo "Skipping integration tests since the supplied filter \"${TEST_FILTER}\" omits all integration tests"
3231
TEST_SKIP_INTEGRATION=1
32+
else
33+
TESTFLAGS+=" -test.run ${TEST_FILTER}"
3334
fi
3435
fi
3536

3637
if [ -z "${TEST_SKIP_INTEGRATION_CLI}" ]; then
3738
if echo "$dirs" | grep -vq '^./integration-cli$'; then
3839
TEST_SKIP_INTEGRATION_CLI=1
3940
echo "Skipping integration-cli tests since the supplied filter \"${TEST_FILTER}\" omits all integration-cli tests"
41+
else
42+
TESTFLAGS+=" -test.run /${TEST_FILTER}"
4043
fi
4144
fi
4245
}
4346

4447
setup_integration_test_filter
45-
integration_api_dirs="${TEST_INTEGRATION_DIR:-$(go list -test -f '{{- if ne .ForTest "" -}}{{- .Dir -}}{{- end -}}' ./integration/...)}"
48+
if [ -z "${TEST_SKIP_INTEGRATION}" ] && [ -z "${TEST_INTEGRATION_DIR}" ]; then
49+
integration_api_dirs="$(go list -test -f '{{- if ne .ForTest "" -}}{{- .Dir -}}{{- end -}}' ./integration/...)"
50+
else
51+
integration_api_dirs="${TEST_INTEGRATION_DIR}"
52+
fi
4653

4754
run_test_integration() {
4855
set_platform_timeout

0 commit comments

Comments
 (0)