diff --git a/src/main/java/com/google/devtools/build/lib/analysis/test/TestConfiguration.java b/src/main/java/com/google/devtools/build/lib/analysis/test/TestConfiguration.java index 333dccce4389ee..940d7ab142384a 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/test/TestConfiguration.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/test/TestConfiguration.java @@ -293,7 +293,7 @@ public static class TestOptions extends FragmentOptions { @Option( name = "incompatible_check_sharding_support", - defaultValue = "false", + defaultValue = "true", documentationCategory = OptionDocumentationCategory.UNCATEGORIZED, metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE}, effectTags = {OptionEffectTag.UNKNOWN}, diff --git a/src/test/py/bazel/test_wrapper_test.py b/src/test/py/bazel/test_wrapper_test.py index 36c0f00abd2120..4f62bb19c03efa 100644 --- a/src/test/py/bazel/test_wrapper_test.py +++ b/src/test/py/bazel/test_wrapper_test.py @@ -34,88 +34,98 @@ def _FailWithOutput(self, output): def _CreateMockWorkspace(self): self.CreateWorkspaceWithDefaultRepos('WORKSPACE') - self.ScratchFile('foo/BUILD', [ - 'load(":native_test.bzl", "bat_test", "exe_test")', - 'bat_test(', - ' name = "passing_test",', - ' content = ["@exit /B 0"],', - ')', - 'bat_test(', - ' name = "failing_test",', - ' content = ["@exit /B 1"],', - ')', - 'bat_test(', - ' name = "printing_test",', - ' content = [', - ' "@echo lorem ipsum",', - ' "@echo HOME=%HOME%",', - ' "@echo TEST_SRCDIR=%TEST_SRCDIR%",', - ' "@echo TEST_TMPDIR=%TEST_TMPDIR%",', - ' "@echo USER=%USER%",', - ' ]', - ')', - 'bat_test(', - ' name = "runfiles_test",', - ' content = [', - ' "@echo off",', - ' "echo MF=%RUNFILES_MANIFEST_FILE%",', - ' "echo ONLY=%RUNFILES_MANIFEST_ONLY%",', - ' "echo DIR=%RUNFILES_DIR%",', - ' "echo data_path=%1",', - ' "if exist %1 (echo data_exists=1) else (echo data_exists=0)",', - ' ],', - ' data = ["dummy.dat"],', - ' args = ["$(location dummy.dat)"],', - ')', - 'bat_test(', - ' name = "sharded_test",', - ' content = [', - ' "@echo STATUS=%TEST_SHARD_STATUS_FILE%",', - ' "@echo INDEX=%TEST_SHARD_INDEX% TOTAL=%TEST_TOTAL_SHARDS%",', - ' ],', - ' shard_count = 2,', - ')', - 'bat_test(', - ' name = "unexported_test",', - ' content = [', - ' "@echo GOOD=%HOME%",', - ' "@echo BAD=%TEST_UNDECLARED_OUTPUTS_MANIFEST%",', - ' ],', - ')', - 'bat_test(', - ' name = "print_arg0_test",', - ' content = [', - ' "@echo ARG0=%0",', - ' ],', - ')', - 'exe_test(', - ' name = "testargs_test",', - ' src = "testargs.exe",', - r' args = ["foo", "a b", "", "\"c d\"", "\"\"", "bar"],', - ')', - 'py_test(', - ' name = "undecl_test",', - ' srcs = ["undecl_test.py"],', - ' data = ["dummy.ico", "dummy.dat"],', - ' deps = ["@bazel_tools//tools/python/runfiles"],', - ')', - 'py_test(', - ' name = "annot_test",', - ' srcs = ["annot_test.py"],', - ')', - 'py_test(', - ' name = "xml_test",', - ' srcs = ["xml_test.py"],', - ')', - 'py_test(', - ' name = "xml2_test",', - ' srcs = ["xml2_test.py"],', - ')', - 'py_test(', - ' name = "add_cur_dir_to_path_test",', - ' srcs = ["add_cur_dir_to_path_test.py"],', - ')' - ]) + self.ScratchFile( + 'foo/BUILD', + [ + 'load(":native_test.bzl", "bat_test", "exe_test")', + 'bat_test(', + ' name = "passing_test",', + ' content = ["@exit /B 0"],', + ')', + 'bat_test(', + ' name = "failing_test",', + ' content = ["@exit /B 1"],', + ')', + 'bat_test(', + ' name = "printing_test",', + ' content = [', + ' "@echo lorem ipsum",', + ' "@echo HOME=%HOME%",', + ' "@echo TEST_SRCDIR=%TEST_SRCDIR%",', + ' "@echo TEST_TMPDIR=%TEST_TMPDIR%",', + ' "@echo USER=%USER%",', + ' ]', + ')', + 'bat_test(', + ' name = "runfiles_test",', + ' content = [', + ' "@echo off",', + ' "echo MF=%RUNFILES_MANIFEST_FILE%",', + ' "echo ONLY=%RUNFILES_MANIFEST_ONLY%",', + ' "echo DIR=%RUNFILES_DIR%",', + ' "echo data_path=%1",', + ( + ' "if exist %1 (echo data_exists=1) else (echo' + ' data_exists=0)",' + ), + ' ],', + ' data = ["dummy.dat"],', + ' args = ["$(location dummy.dat)"],', + ')', + 'bat_test(', + ' name = "sharded_test",', + ' content = [', + ' "type nul > %TEST_SHARD_STATUS_FILE%",', + ' "@echo STATUS=%TEST_SHARD_STATUS_FILE%",', + ( + ' "@echo INDEX=%TEST_SHARD_INDEX%' + ' TOTAL=%TEST_TOTAL_SHARDS%",' + ), + ' ],', + ' shard_count = 2,', + ')', + 'bat_test(', + ' name = "unexported_test",', + ' content = [', + ' "@echo GOOD=%HOME%",', + ' "@echo BAD=%TEST_UNDECLARED_OUTPUTS_MANIFEST%",', + ' ],', + ')', + 'bat_test(', + ' name = "print_arg0_test",', + ' content = [', + ' "@echo ARG0=%0",', + ' ],', + ')', + 'exe_test(', + ' name = "testargs_test",', + ' src = "testargs.exe",', + r' args = ["foo", "a b", "", "\"c d\"", "\"\"", "bar"],', + ')', + 'py_test(', + ' name = "undecl_test",', + ' srcs = ["undecl_test.py"],', + ' data = ["dummy.ico", "dummy.dat"],', + ' deps = ["@bazel_tools//tools/python/runfiles"],', + ')', + 'py_test(', + ' name = "annot_test",', + ' srcs = ["annot_test.py"],', + ')', + 'py_test(', + ' name = "xml_test",', + ' srcs = ["xml_test.py"],', + ')', + 'py_test(', + ' name = "xml2_test",', + ' srcs = ["xml2_test.py"],', + ')', + 'py_test(', + ' name = "add_cur_dir_to_path_test",', + ' srcs = ["add_cur_dir_to_path_test.py"],', + ')', + ], + ) self.CopyFile( src_path=self.Rlocation('io_bazel/src/test/py/bazel/printargs.exe'), diff --git a/src/test/shell/bazel/bazel_test_test.sh b/src/test/shell/bazel/bazel_test_test.sh index 4bee9e4a4178c4..46127c4b2f1c66 100755 --- a/src/test/shell/bazel/bazel_test_test.sh +++ b/src/test/shell/bazel/bazel_test_test.sh @@ -540,9 +540,10 @@ EOF function test_xml_fallback_for_sharded_test() { mkdir -p dir - cat < dir/test.sh + cat <<'EOF' > dir/test.sh #!/bin/sh -exit \$((TEST_SHARD_INDEX == 1)) +touch "$TEST_SHARD_STATUS_FILE" +exit $((TEST_SHARD_INDEX == 1)) EOF chmod +x dir/test.sh