Fix test and shell execution OS logic#28038
Conversation
|
@bazel-io fork 9.0.0 |
There was a problem hiding this comment.
Code Review
This pull request correctly determines the execution OS for tests by using the execution platform associated with the specific test execution group, rather than a default platform. The changes involve refactoring how the ActionOwner and its corresponding PlatformInfo are obtained and passed down to where the execution OS is needed. This fixes a bug where the wrong OS was assumed for tests with custom execution groups. The changes are well-structured and include new tests that validate the corrected logic for different scenarios, including exec_group on the test rule and ExecutionInfo from the implementation. The code is cleaner and more correct.
ed76374 to
0cffea6
Compare
24bb4be to
fad452c
Compare
|
@fmeum Could you please take a look at the failing checks? |
373ad61 to
ebe8285
Compare
|
@bharadwaj08-one Fixed! |
4a5ee51 to
17e9685
Compare
3562416 to
e3aa5f9
Compare
e3aa5f9 to
bc82e10
Compare
|
Windows CI failures might be relevant? |
|
@gregestren As far as I can tell these tests are failing because Bazel's integration test setup pretends that the host platform is Linux even when running tests on Windows. The logic in @lberki in case you have an idea :-) |
|
#28224 shows the failures with the proper host platform set. |
|
@gregestren I worked around the test failures for now by preserving the preexisting behavior. PTAL. |
|
@gregestren friendly ping |
| @VisibleForTesting | ||
| public static final ImmutableMap<OS, PathFragment> SHELL_EXECUTABLES = | ||
| ImmutableMap.<OS, PathFragment>builder() | ||
| .put(OS.WINDOWS, PathFragment.create("c:/msys64/usr/bin/bash.exe")) |
There was a problem hiding this comment.
Is this related to your thoughts on refactoring shell toolchain selection? i.e. why do we need this hard-coded os -> shell mapping in the first place?
There was a problem hiding this comment.
Exactly, this mapping should really be replaced by a toolchain type. But that requires an incompatible change that adds the toolchain requirement to all rules using ctx.actions.run_shell.
gregestren
left a comment
There was a problem hiding this comment.
Thanks for the helpful walkthrough!
The execution OS is determined by the specified test exec group, which can differ from the `test` exec group as well as the test rule's default execution group. Also renames some helper methods to make this class of bugs less likely and clean up `ConstraintConstants` to support the `macos` alias for the `darwin` OS constraint value. As a consequence of this refactoring, it became clear that the shell path was determined by the host OS when the execution OS is Linux or macOS, resulting in a Windows host trying to use the Windows shell path when running e.g. a genrule on Linux. In a surprising turn of events, this behavior is what holds Bazel's own Java integration tests together on Windows - for now. As a result, the fix is accompanied by a manual override on `--shell_executable` in `BuildIntegrationTest` for a Windows host. Closes bazelbuild#28038. PiperOrigin-RevId: 874626714 Change-Id: Icae167c5e58309258b3c73bac99796a512d2f26d
The execution OS is determined by the specified test exec group, which can differ from the `test` exec group as well as the test rule's default execution group. Also renames some helper methods to make this class of bugs less likely and clean up `ConstraintConstants` to support the `macos` alias for the `darwin` OS constraint value. As a consequence of this refactoring, it became clear that the shell path was determined by the host OS when the execution OS is Linux or macOS, resulting in a Windows host trying to use the Windows shell path when running e.g. a genrule on Linux. In a surprising turn of events, this behavior is what holds Bazel's own Java integration tests together on Windows - for now. As a result, the fix is accompanied by a manual override on `--shell_executable` in `BuildIntegrationTest` for a Windows host. Closes #28038. PiperOrigin-RevId: 874626714 Change-Id: Icae167c5e58309258b3c73bac99796a512d2f26d Commit 79fb843 Co-authored-by: Fabian Meumertzheim <[email protected]>
The execution OS is determined by the specified test exec group, which can differ from the `test` exec group as well as the test rule's default execution group. Also renames some helper methods to make this class of bugs less likely and clean up `ConstraintConstants` to support the `macos` alias for the `darwin` OS constraint value. As a consequence of this refactoring, it became clear that the shell path was determined by the host OS when the execution OS is Linux or macOS, resulting in a Windows host trying to use the Windows shell path when running e.g. a genrule on Linux. In a surprising turn of events, this behavior is what holds Bazel's own Java integration tests together on Windows - for now. As a result, the fix is accompanied by a manual override on `--shell_executable` in `BuildIntegrationTest` for a Windows host. Closes bazelbuild#28038. PiperOrigin-RevId: 874626714 Change-Id: Icae167c5e58309258b3c73bac99796a512d2f26d
The execution OS is determined by the specified test exec group, which can differ from the
testexec group as well as the test rule's default execution group. Also renames some helper methods to make this class of bugs less likely and clean upConstraintConstantsto support themacosalias for thedarwinOS constraint value.As a consequence of this refactoring, it became clear that the shell path was determined by the host OS when the execution OS is Linux or macOS, resulting in a Windows host trying to use the Windows shell path when running e.g. a genrule on Linux. In a surprising turn of events, this behavior is what holds Bazel's own Java integration tests together on Windows - for now. As a result, the fix is accompanied by a manual override on
--shell_executableinBuildIntegrationTestfor a Windows host.