Skip to content

Commit

Permalink
Flip --incompatible_check_sharding_support
Browse files Browse the repository at this point in the history
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
  • Loading branch information
fmeum authored and Copybara-Service committed May 25, 2023
1 parent daf8076 commit d6257ee
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 85 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
174 changes: 92 additions & 82 deletions src/test/py/bazel/test_wrapper_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
5 changes: 3 additions & 2 deletions src/test/shell/bazel/bazel_test_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -540,9 +540,10 @@ EOF
function test_xml_fallback_for_sharded_test() {
mkdir -p dir

cat <<EOF > 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
Expand Down

0 comments on commit d6257ee

Please sign in to comment.