Browse Source

hack: update scripts

- remove -check.* flags
- use (per-test) -timeout flag
- allow user to override TEST_SKIP_* regardless of TESTFLAGS
- remove test-imports validation

Signed-off-by: Tibor Vass <tibor@docker.com>
Tibor Vass 5 năm trước cách đây
mục cha
commit
7cd028f2d0

+ 4 - 4
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:
 your local host you can run the `TestBuild` test with this command:
 
 
 ```bash
 ```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:
 To run the same test inside your Docker development container, you do this:
 
 
 ```bash
 ```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
 ## 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
     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
     example
 
 
     ```bash
     ```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
 You can now choose to make changes to the Moby source or the tests. If you

+ 6 - 6
hack/ci/windows.ps1

@@ -797,14 +797,14 @@ Try {
     
     
             #https://blogs.technet.microsoft.com/heyscriptingguy/2011/09/20/solve-problems-with-external-command-lines-in-powershell/ is useful to see tokenising
             #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 = "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
             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`" "
                 $c += "`"$env:INTEGRATION_TEST_NAME`" "
                 Write-Host -ForegroundColor Magenta "WARN: Only running integration tests matching $env:INTEGRATION_TEST_NAME"
                 Write-Host -ForegroundColor Magenta "WARN: Only running integration tests matching $env:INTEGRATION_TEST_NAME"
             }
             }
             $c += "`"-tags`" " + "`"autogen`" "
             $c += "`"-tags`" " + "`"autogen`" "
-            $c += "`"-check.timeout`" " + "`"10m`" "
+            $c += "`"-timeout`" " + "`"10m`" "
             $c += "`"-test.timeout`" " + "`"200m`" "
             $c += "`"-test.timeout`" " + "`"200m`" "
     
     
             if ($null -ne $env:INTEGRATION_IN_CONTAINER) {
             if ($null -ne $env:INTEGRATION_IN_CONTAINER) {
@@ -892,14 +892,14 @@ Try {
             } else {
             } else {
                 #https://blogs.technet.microsoft.com/heyscriptingguy/2011/09/20/solve-problems-with-external-command-lines-in-powershell/ is useful to see tokenising
                 #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 = "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
                 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`" "
                     $c += "`"$env:INTEGRATION_TEST_NAME`" "
                     Write-Host -ForegroundColor Magenta "WARN: Only running LCOW integration tests matching $env:INTEGRATION_TEST_NAME"
                     Write-Host -ForegroundColor Magenta "WARN: Only running LCOW integration tests matching $env:INTEGRATION_TEST_NAME"
                 }
                 }
                 $c += "`"-tags`" " + "`"autogen`" "
                 $c += "`"-tags`" " + "`"autogen`" "
-                $c += "`"-check.timeout`" " + "`"10m`" "
+                $c += "`"-timeout`" " + "`"10m`" "
                 $c += "`"-test.timeout`" " + "`"200m`" "
                 $c += "`"-test.timeout`" " + "`"200m`" "
 
 
                 Write-Host -ForegroundColor Green "INFO: LCOW Integration tests being run from the host:"
                 Write-Host -ForegroundColor Green "INFO: LCOW Integration tests being run from the host:"

+ 7 - 21
hack/make/.integration-test-helpers

@@ -3,20 +3,9 @@
 # For integration-cli test, we use [gocheck](https://labix.org/gocheck), if you want
 # 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:
 # 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
 if [ -z "${MAKEDIR}" ]; then
 	MAKEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
 	MAKEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
 	export MAKEDIR
 	export MAKEDIR
@@ -32,24 +21,21 @@ setup_integration_test_filter() {
 	if [ -z "${TEST_FILTER}" ]; then
 	if [ -z "${TEST_FILTER}" ]; then
 		return
 		return
 	fi
 	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
 	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
 		if [ -z "${TEST_INTEGRATION_DIR}" ]; then
 			echo "Skipping integration tests since the supplied filter \"${TEST_FILTER}\" omits all integration tests"
 			echo "Skipping integration tests since the supplied filter \"${TEST_FILTER}\" omits all integration tests"
 			TEST_SKIP_INTEGRATION=1
 			TEST_SKIP_INTEGRATION=1
-		else
-			TESTFLAGS_INTEGRATION+="-test.run ${TEST_FILTER}"
 		fi
 		fi
 	fi
 	fi
 
 
 	if [ -z "${TEST_SKIP_INTEGRATION_CLI}" ]; then
 	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
 			TEST_SKIP_INTEGRATION_CLI=1
 			echo "Skipping integration-cli tests since the supplied filter \"${TEST_FILTER}\" omits all integration-cli tests"
 			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
 	fi
 	fi
 }
 }
@@ -68,7 +54,7 @@ run_test_integration() {
 }
 }
 
 
 run_test_integration_suites() {
 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
 	for dir in ${integration_api_dirs}; do
 		if ! (
 		if ! (
 			cd "$dir"
 			cd "$dir"
@@ -81,7 +67,7 @@ run_test_integration_suites() {
 
 
 run_test_integration_legacy_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
 		cd integration-cli
 		echo "Running $PWD flags=${flags}"
 		echo "Running $PWD flags=${flags}"
 		# shellcheck disable=SC2086
 		# shellcheck disable=SC2086

+ 3 - 7
hack/test/e2e-run.sh

@@ -18,12 +18,8 @@ integration_api_dirs=${TEST_INTEGRATION_DIR:-"$(
 
 
 run_test_integration() {
 run_test_integration() {
 	set_platform_timeout
 	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() {
 run_test_integration_suites() {
@@ -39,7 +35,7 @@ run_test_integration_suites() {
 
 
 run_test_integration_legacy_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
 		cd /tests/integration-cli
 		echo "Running $PWD"
 		echo "Running $PWD"
 		test_env ./test.main $flags
 		test_env ./test.main $flags

+ 0 - 1
hack/validate/default

@@ -10,7 +10,6 @@ export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
 . ${SCRIPTDIR}/pkg-imports
 . ${SCRIPTDIR}/pkg-imports
 . ${SCRIPTDIR}/swagger
 . ${SCRIPTDIR}/swagger
 . ${SCRIPTDIR}/swagger-gen
 . ${SCRIPTDIR}/swagger-gen
-. ${SCRIPTDIR}/test-imports
 . ${SCRIPTDIR}/toml
 . ${SCRIPTDIR}/toml
 . ${SCRIPTDIR}/changelog-well-formed
 . ${SCRIPTDIR}/changelog-well-formed
 . ${SCRIPTDIR}/changelog-date-descending
 . ${SCRIPTDIR}/changelog-date-descending

+ 0 - 38
hack/validate/test-imports

@@ -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