diff options
-rw-r--r-- | docs/contributing/test.md | 8 | ||||
-rw-r--r-- | hack/ci/windows.ps1 | 12 | ||||
-rw-r--r-- | hack/make/.integration-test-helpers | 28 | ||||
-rwxr-xr-x | hack/test/e2e-run.sh | 10 | ||||
-rwxr-xr-x | hack/validate/default | 1 | ||||
-rwxr-xr-x | hack/validate/test-imports | 38 |
6 files changed, 20 insertions, 77 deletions
diff --git a/docs/contributing/test.md b/docs/contributing/test.md index ada9aa623b..8c1038a5d0 100644 --- a/docs/contributing/test.md +++ b/docs/contributing/test.md @@ -174,13 +174,13 @@ flag's value is passed as arguments to the `go test` command. For example, from your local host you can run the `TestBuild` test with this command: ```bash -$ TESTFLAGS='-check.f DockerSuite.TestBuild*' make test-integration +$ TESTFLAGS='-test.run /DockerSuite/TestBuild*' make test-integration ``` To run the same test inside your Docker development container, you do this: ```bash -# TESTFLAGS='-check.f TestBuild*' hack/make.sh binary test-integration +# TESTFLAGS='-test.run /DockerSuite/TestBuild*' hack/make.sh binary test-integration ``` ## Test the Windows binary against a Linux daemon @@ -228,11 +228,11 @@ run a Bash terminal on Windows. ``` Should you wish to run a single test such as one with the name - 'TestExample', you can pass in `TESTFLAGS='-check.f TestExample'`. For + 'TestExample', you can pass in `TESTFLAGS='-test.run //TestExample'`. For example ```bash - $ TESTFLAGS='-check.f TestExample' hack/make.sh binary test-integration + $ TESTFLAGS='-test.run //TestExample' hack/make.sh binary test-integration ``` You can now choose to make changes to the Moby source or the tests. If you diff --git a/hack/ci/windows.ps1 b/hack/ci/windows.ps1 index 19929f326a..20e09c7c71 100644 --- a/hack/ci/windows.ps1 +++ b/hack/ci/windows.ps1 @@ -831,14 +831,14 @@ Try { #https://blogs.technet.microsoft.com/heyscriptingguy/2011/09/20/solve-problems-with-external-command-lines-in-powershell/ is useful to see tokenising $c = "go test " - $c += "`"-check.v`" " + $c += "`"-test.v`" " if ($null -ne $env:INTEGRATION_TEST_NAME) { # Makes is quicker for debugging to be able to run only a subset of the integration tests - $c += "`"-check.f`" " + $c += "`"-test.run`" " $c += "`"$env:INTEGRATION_TEST_NAME`" " Write-Host -ForegroundColor Magenta "WARN: Only running integration tests matching $env:INTEGRATION_TEST_NAME" } $c += "`"-tags`" " + "`"autogen`" " - $c += "`"-check.timeout`" " + "`"10m`" " + $c += "`"-timeout`" " + "`"10m`" " $c += "`"-test.timeout`" " + "`"200m`" " if ($null -ne $env:INTEGRATION_IN_CONTAINER) { @@ -926,14 +926,14 @@ Try { } else { #https://blogs.technet.microsoft.com/heyscriptingguy/2011/09/20/solve-problems-with-external-command-lines-in-powershell/ is useful to see tokenising $c = "go test " - $c += "`"-check.v`" " + $c += "`"-test.v`" " if ($null -ne $env:INTEGRATION_TEST_NAME) { # Makes is quicker for debugging to be able to run only a subset of the integration tests - $c += "`"-check.f`" " + $c += "`"-test.run`" " $c += "`"$env:INTEGRATION_TEST_NAME`" " Write-Host -ForegroundColor Magenta "WARN: Only running LCOW integration tests matching $env:INTEGRATION_TEST_NAME" } $c += "`"-tags`" " + "`"autogen`" " - $c += "`"-check.timeout`" " + "`"10m`" " + $c += "`"-timeout`" " + "`"10m`" " $c += "`"-test.timeout`" " + "`"200m`" " Write-Host -ForegroundColor Green "INFO: LCOW Integration tests being run from the host:" diff --git a/hack/make/.integration-test-helpers b/hack/make/.integration-test-helpers index 91179c94a3..1490f3f4f7 100644 --- a/hack/make/.integration-test-helpers +++ b/hack/make/.integration-test-helpers @@ -3,20 +3,9 @@ # 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 +# TESTFLAGS='-test.run /DockerSuite/TestBuild*' ./hack/make.sh binary test-integration # -if [[ "${TESTFLAGS}" = *-check.f* ]]; then - echo Skipping integration tests since TESTFLAGS includes integration-cli only flags - TEST_SKIP_INTEGRATION=1 -fi - -if [[ "${TESTFLAGS}" = *-test.run* ]]; then - echo Skipping integration-cli tests since TESTFLAGS includes integration only flags - TEST_SKIP_INTEGRATION_CLI=1 -fi - - if [ -z "${MAKEDIR}" ]; then MAKEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" export MAKEDIR @@ -32,24 +21,21 @@ setup_integration_test_filter() { if [ -z "${TEST_FILTER}" ]; then return fi + TESTFLAGS+="-test.run ${TEST_FILTER}" + local dirs=$(grep -rIlE --include '*_test.go' "func .*${TEST_FILTER}.*\(. \*testing\.T\)" ./integration*/ | xargs -I file dirname file | uniq) if [ -z "${TEST_SKIP_INTEGRATION}" ]; then - : "${TEST_INTEGRATION_DIR:=$(grep -rl "func\ .*${TEST_FILTER}.*\(t\ \*testing\.T\)" ./integration | grep '_test\.go' | xargs -I file dirname file | uniq)}" + : "${TEST_INTEGRATION_DIR:=$(echo "$dirs" | grep -v '^\./integration-cli$')" if [ -z "${TEST_INTEGRATION_DIR}" ]; then echo "Skipping integration tests since the supplied filter \"${TEST_FILTER}\" omits all integration tests" TEST_SKIP_INTEGRATION=1 - else - TESTFLAGS_INTEGRATION+="-test.run ${TEST_FILTER}" fi fi if [ -z "${TEST_SKIP_INTEGRATION_CLI}" ]; then - # ease up on the filtering here since CLI suites are namespaced by an object - if grep -r "${TEST_FILTER}.*\(c\ \*check\.C\)" ./integration-cli | grep -q '_test\.go$'; then + if echo "$dirs" | grep -vq '^./integration-cli$'; then TEST_SKIP_INTEGRATION_CLI=1 echo "Skipping integration-cli tests since the supplied filter \"${TEST_FILTER}\" omits all integration-cli tests" - else - TESTFLAGS_INTEGRATION_CLI+="-check.f ${TEST_FILTER}" fi fi } @@ -68,7 +54,7 @@ run_test_integration() { } run_test_integration_suites() { - local flags="-test.v -test.timeout=${TIMEOUT} $TESTFLAGS ${TESTFLAGS_INTEGRATION}" + local flags="-test.v -test.timeout=${TIMEOUT} $TESTFLAGS" for dir in ${integration_api_dirs}; do if ! ( cd "$dir" @@ -99,7 +85,7 @@ run_test_integration_suites() { run_test_integration_legacy_suites() { ( - flags="-check.v -check.timeout=${TIMEOUT} -test.timeout=360m $TESTFLAGS ${TESTFLAGS_INTEGRATION_CLI}" + flags="-test.v -timeout=${TIMEOUT} $TESTFLAGS" cd integration-cli echo "Running $PWD flags=${flags}" # shellcheck disable=SC2086 diff --git a/hack/test/e2e-run.sh b/hack/test/e2e-run.sh index 6463f2f85d..94e770ef0c 100755 --- a/hack/test/e2e-run.sh +++ b/hack/test/e2e-run.sh @@ -18,12 +18,8 @@ integration_api_dirs=${TEST_INTEGRATION_DIR:-"$( run_test_integration() { set_platform_timeout - if [[ "$TESTFLAGS" != *-check.f* ]]; then - run_test_integration_suites - fi - if [[ "$TESTFLAGS" != *-test.run* ]]; then - run_test_integration_legacy_suites - fi + run_test_integration_suites + run_test_integration_legacy_suites } run_test_integration_suites() { @@ -39,7 +35,7 @@ run_test_integration_suites() { run_test_integration_legacy_suites() { ( - flags="-check.v -check.timeout=${TIMEOUT:-200m} -test.timeout=360m $TESTFLAGS" + flags="-test.v -timeout=${TIMEOUT:-10m} -test.timeout=360m $TESTFLAGS" cd /tests/integration-cli echo "Running $PWD" test_env ./test.main $flags diff --git a/hack/validate/default b/hack/validate/default index 15ed83654a..765a413be8 100755 --- a/hack/validate/default +++ b/hack/validate/default @@ -10,7 +10,6 @@ export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" . ${SCRIPTDIR}/pkg-imports . ${SCRIPTDIR}/swagger . ${SCRIPTDIR}/swagger-gen -. ${SCRIPTDIR}/test-imports . ${SCRIPTDIR}/toml . ${SCRIPTDIR}/changelog-well-formed . ${SCRIPTDIR}/changelog-date-descending diff --git a/hack/validate/test-imports b/hack/validate/test-imports deleted file mode 100755 index 0e836a31c0..0000000000 --- a/hack/validate/test-imports +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env bash -# Make sure we're not using gos' Testing package any more in integration-cli - -export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -source "${SCRIPTDIR}/.validate" - -IFS=$'\n' -files=( $(validate_diff --diff-filter=ACMR --name-only -- 'integration-cli/*.go' || true) ) -unset IFS - -badFiles=() -for f in "${files[@]}"; do - # skip check_test.go since it *does* use the testing package - if [ "$f" = "integration-cli/check_test.go" ]; then - continue - fi - - # we use "git show" here to validate that what's committed doesn't contain golang built-in testing - if git show "$VALIDATE_HEAD:$f" | grep -q testing.T; then - if [ "$(echo $f | grep '_test')" ]; then - # allow testing.T for non- _test files - badFiles+=( "$f" ) - fi - fi -done - -if [ ${#badFiles[@]} -eq 0 ]; then - echo 'Congratulations! No testing.T found.' -else - { - echo "These files use the wrong testing infrastructure:" - for f in "${badFiles[@]}"; do - echo " - $f" - done - echo - } >&2 - false -fi |