Skip to content

Commit d6257ee

Browse files
fmeumcopybara-github
authored andcommitted
Flip --incompatible_check_sharding_support
RELNOTES[INC]: `--incompatible_check_sharding_support` is enabled by default. Sharded tests with test runners that do not properly advertise support for test sharding will fail. Refer to #18339 for migration advice. Closes #18354. PiperOrigin-RevId: 535154319 Change-Id: I0f7ccd404ed59c2f9542ddbc1cb0c803dbb442c9
1 parent daf8076 commit d6257ee

File tree

3 files changed

+96
-85
lines changed

3 files changed

+96
-85
lines changed

src/main/java/com/google/devtools/build/lib/analysis/test/TestConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ public static class TestOptions extends FragmentOptions {
293293

294294
@Option(
295295
name = "incompatible_check_sharding_support",
296-
defaultValue = "false",
296+
defaultValue = "true",
297297
documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
298298
metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE},
299299
effectTags = {OptionEffectTag.UNKNOWN},

src/test/py/bazel/test_wrapper_test.py

Lines changed: 92 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -34,88 +34,98 @@ def _FailWithOutput(self, output):
3434

3535
def _CreateMockWorkspace(self):
3636
self.CreateWorkspaceWithDefaultRepos('WORKSPACE')
37-
self.ScratchFile('foo/BUILD', [
38-
'load(":native_test.bzl", "bat_test", "exe_test")',
39-
'bat_test(',
40-
' name = "passing_test",',
41-
' content = ["@exit /B 0"],',
42-
')',
43-
'bat_test(',
44-
' name = "failing_test",',
45-
' content = ["@exit /B 1"],',
46-
')',
47-
'bat_test(',
48-
' name = "printing_test",',
49-
' content = [',
50-
' "@echo lorem ipsum",',
51-
' "@echo HOME=%HOME%",',
52-
' "@echo TEST_SRCDIR=%TEST_SRCDIR%",',
53-
' "@echo TEST_TMPDIR=%TEST_TMPDIR%",',
54-
' "@echo USER=%USER%",',
55-
' ]',
56-
')',
57-
'bat_test(',
58-
' name = "runfiles_test",',
59-
' content = [',
60-
' "@echo off",',
61-
' "echo MF=%RUNFILES_MANIFEST_FILE%",',
62-
' "echo ONLY=%RUNFILES_MANIFEST_ONLY%",',
63-
' "echo DIR=%RUNFILES_DIR%",',
64-
' "echo data_path=%1",',
65-
' "if exist %1 (echo data_exists=1) else (echo data_exists=0)",',
66-
' ],',
67-
' data = ["dummy.dat"],',
68-
' args = ["$(location dummy.dat)"],',
69-
')',
70-
'bat_test(',
71-
' name = "sharded_test",',
72-
' content = [',
73-
' "@echo STATUS=%TEST_SHARD_STATUS_FILE%",',
74-
' "@echo INDEX=%TEST_SHARD_INDEX% TOTAL=%TEST_TOTAL_SHARDS%",',
75-
' ],',
76-
' shard_count = 2,',
77-
')',
78-
'bat_test(',
79-
' name = "unexported_test",',
80-
' content = [',
81-
' "@echo GOOD=%HOME%",',
82-
' "@echo BAD=%TEST_UNDECLARED_OUTPUTS_MANIFEST%",',
83-
' ],',
84-
')',
85-
'bat_test(',
86-
' name = "print_arg0_test",',
87-
' content = [',
88-
' "@echo ARG0=%0",',
89-
' ],',
90-
')',
91-
'exe_test(',
92-
' name = "testargs_test",',
93-
' src = "testargs.exe",',
94-
r' args = ["foo", "a b", "", "\"c d\"", "\"\"", "bar"],',
95-
')',
96-
'py_test(',
97-
' name = "undecl_test",',
98-
' srcs = ["undecl_test.py"],',
99-
' data = ["dummy.ico", "dummy.dat"],',
100-
' deps = ["@bazel_tools//tools/python/runfiles"],',
101-
')',
102-
'py_test(',
103-
' name = "annot_test",',
104-
' srcs = ["annot_test.py"],',
105-
')',
106-
'py_test(',
107-
' name = "xml_test",',
108-
' srcs = ["xml_test.py"],',
109-
')',
110-
'py_test(',
111-
' name = "xml2_test",',
112-
' srcs = ["xml2_test.py"],',
113-
')',
114-
'py_test(',
115-
' name = "add_cur_dir_to_path_test",',
116-
' srcs = ["add_cur_dir_to_path_test.py"],',
117-
')'
118-
])
37+
self.ScratchFile(
38+
'foo/BUILD',
39+
[
40+
'load(":native_test.bzl", "bat_test", "exe_test")',
41+
'bat_test(',
42+
' name = "passing_test",',
43+
' content = ["@exit /B 0"],',
44+
')',
45+
'bat_test(',
46+
' name = "failing_test",',
47+
' content = ["@exit /B 1"],',
48+
')',
49+
'bat_test(',
50+
' name = "printing_test",',
51+
' content = [',
52+
' "@echo lorem ipsum",',
53+
' "@echo HOME=%HOME%",',
54+
' "@echo TEST_SRCDIR=%TEST_SRCDIR%",',
55+
' "@echo TEST_TMPDIR=%TEST_TMPDIR%",',
56+
' "@echo USER=%USER%",',
57+
' ]',
58+
')',
59+
'bat_test(',
60+
' name = "runfiles_test",',
61+
' content = [',
62+
' "@echo off",',
63+
' "echo MF=%RUNFILES_MANIFEST_FILE%",',
64+
' "echo ONLY=%RUNFILES_MANIFEST_ONLY%",',
65+
' "echo DIR=%RUNFILES_DIR%",',
66+
' "echo data_path=%1",',
67+
(
68+
' "if exist %1 (echo data_exists=1) else (echo'
69+
' data_exists=0)",'
70+
),
71+
' ],',
72+
' data = ["dummy.dat"],',
73+
' args = ["$(location dummy.dat)"],',
74+
')',
75+
'bat_test(',
76+
' name = "sharded_test",',
77+
' content = [',
78+
' "type nul > %TEST_SHARD_STATUS_FILE%",',
79+
' "@echo STATUS=%TEST_SHARD_STATUS_FILE%",',
80+
(
81+
' "@echo INDEX=%TEST_SHARD_INDEX%'
82+
' TOTAL=%TEST_TOTAL_SHARDS%",'
83+
),
84+
' ],',
85+
' shard_count = 2,',
86+
')',
87+
'bat_test(',
88+
' name = "unexported_test",',
89+
' content = [',
90+
' "@echo GOOD=%HOME%",',
91+
' "@echo BAD=%TEST_UNDECLARED_OUTPUTS_MANIFEST%",',
92+
' ],',
93+
')',
94+
'bat_test(',
95+
' name = "print_arg0_test",',
96+
' content = [',
97+
' "@echo ARG0=%0",',
98+
' ],',
99+
')',
100+
'exe_test(',
101+
' name = "testargs_test",',
102+
' src = "testargs.exe",',
103+
r' args = ["foo", "a b", "", "\"c d\"", "\"\"", "bar"],',
104+
')',
105+
'py_test(',
106+
' name = "undecl_test",',
107+
' srcs = ["undecl_test.py"],',
108+
' data = ["dummy.ico", "dummy.dat"],',
109+
' deps = ["@bazel_tools//tools/python/runfiles"],',
110+
')',
111+
'py_test(',
112+
' name = "annot_test",',
113+
' srcs = ["annot_test.py"],',
114+
')',
115+
'py_test(',
116+
' name = "xml_test",',
117+
' srcs = ["xml_test.py"],',
118+
')',
119+
'py_test(',
120+
' name = "xml2_test",',
121+
' srcs = ["xml2_test.py"],',
122+
')',
123+
'py_test(',
124+
' name = "add_cur_dir_to_path_test",',
125+
' srcs = ["add_cur_dir_to_path_test.py"],',
126+
')',
127+
],
128+
)
119129

120130
self.CopyFile(
121131
src_path=self.Rlocation('io_bazel/src/test/py/bazel/printargs.exe'),

src/test/shell/bazel/bazel_test_test.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,9 +540,10 @@ EOF
540540
function test_xml_fallback_for_sharded_test() {
541541
mkdir -p dir
542542

543-
cat <<EOF > dir/test.sh
543+
cat <<'EOF' > dir/test.sh
544544
#!/bin/sh
545-
exit \$((TEST_SHARD_INDEX == 1))
545+
touch "$TEST_SHARD_STATUS_FILE"
546+
exit $((TEST_SHARD_INDEX == 1))
546547
EOF
547548

548549
chmod +x dir/test.sh

0 commit comments

Comments
 (0)