Running a test on a Windows executor from a Linux host is not possible
- Dominant language
- Java
- Stars
- 25.8k
- Forks
- 4.6k
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 72
Description
It's currently not possible to run a `*_test` rule on a remote Windows executor when Bazel is running on a Linux host.
- Every test rule has a dependency on [`@bazel_tools//tools/test:test_wrapper`](https://cs.opensource.google/bazel/bazel/+/master:src/main/java/com/google/devtools/build/lib/analysis/BaseRuleClasses.java;l=217;drc=0e899c5d9289771908648ce4362c45c2171def8d) and [`@bazel_tools//tools/test:xml_writer`](https://cs.opensource.google/bazel/bazel/+/master:src/main/java/com/google/devtools/build/lib/analysis/BaseRuleClasses.java;l=222;drc=0e899c5d9289771908648ce4362c45c2171def8d), which point to bundled precompiled [`tw.exe`](https://cs.opensource.google/bazel/bazel/+/master:tools/test/BUILD.tools;l=53;drc=ee3637c19c131cf295eaa3fb59ea03f6e9a1f60e) and [`xml.exe`](https://cs.opensource.google/bazel/bazel/+/master:tools/test/BUILD.tools;l=64;drc=ee3637c19c131cf295eaa3fb59ea03f6e9a1f60e) files if Bazel was built for Windows, and are missing otherwise (causing the test rule to fail during loading).
- In addition, some test rules (including `sh_test`) have a dependency on [`@bazel_tools//tools/launcher:launcher`](https://cs.opensource.google/bazel/bazel/+/master:src/main/java/com/google/devtools/build/lib/bazel/rules/sh/BazelShTestRule.java;l=40;drc=f7829f855bc31aaf0c0fcef55ef56adec84daa9e) which points to a bundled precompiled `launcher.exe` if Bazel was built for Windows, and to the C++ source code otherwise. This makes a C++ cross-compiler required for a build that is otherwise not dependent on C++. In addition, C++ cross-compilation from Linux to Windows is currently broken (see #19208).
Note that it's possible to run a `genrule` on Windows from a Linux host, showing that this is a testing-specific issue rather than a more general one with cross-platform Windows builds.
A minimal repro is available at https://github.com/jtattermusch/win-from-linux-rbe-repro (thanks @jtattermusch!). You must use a Bazel built at or after 2f0948b.
We should consider publishing the `tw.exe`, `xml.exe` and `launcher.exe` binaries to an external repository and fetch it on demand when a test is configured for Windows. This would avoid unnecessarily increasing the Bazel binary size, introducing useless dependencies on other platforms, or requiring a C++ cross compiler only for running tests.
Contributor guide
Research direction
Start with src/main/java/com/google/devtools/build/lib/analysis/BaseRuleClasses.java, tools/test/BUILD.tools, and src/main/java/com/google/devtools/build/lib/bazel/rules/sh/BazelShTestRule.java to trace the test dependencies. Reproduce the failure with the linked win-from-linux-rbe-repro project using a Bazel build at or after 2f0948b. Done means test rules load and run on a remote Windows executor from a Linux host without an unnecessary C++ cross-compiler.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, linux
- Domain
- build-system, operating-systems, testing
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100