[9.x] `--run_under` in platform `flags` splits testonly and non-testonly targets into different output directories
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- java
- Domain
- build-system
Research direction
The issue provides a minimal reproducer in MODULE.bazel, runner.sh, and BUILD.bazel; start by running the shown build on Bazel 9.3.3 and inspect how platform flags and test trimming affect the output directories. The reported fix is in 10.0.0rc4, and commit 5c8f44dd is mentioned as a possible related change. Done means the 9.x build places the generated dependency and testonly output in the same directory.
Written by the indexing model from the issue text.
Description
Description of the bug:
When a platform sets --run_under in its flags, targets that aren't testonly build into <platform>-fastbuild-ST-<hash>, while tests and testonly targets build into <platform>-fastbuild. Test trimming drops --run_under from non-test configurations, and with platform-based flags, the trimmed configuration gets an -ST- hash.
Paths a testonly target derives from its own output directory then miss files generated by its non-testonly deps. For example, a testonly cc_library with includes = ["."] doesn't find a header generated by a genrule: the -I path comes from its ctx.bin_dir, but the header is in the -ST- directory.
--run_under on the command line or --notrim_test_configuration avoids the split. It reproduces in 9.3.3 and is fixed in 10.0.0rc4; could the fix be backported to 9.x? Looking through the commits, 5c8f44dd387d92886c2ef7aabee03152f9143e73 fixed a similar baseline problem for exec configurations, so it might be related, but that's a guess.
We set --run_under in platform flags to run tests on Android devices and iOS simulators, with a runner per platform (as in #22624).
Which category does this issue belong to?
Configurability
What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
MODULE.bazel:
module(name = "run_under_repro")
runner.sh (executable):
#!/bin/sh
exec "$@"
BUILD.bazel:
platform(
name = "device",
flags = ["--run_under=//:runner.sh"],
)
genrule(
name = "gen",
outs = ["gen.txt"],
cmd = "echo generated > $@",
)
genrule(
name = "use",
testonly = True,
srcs = [":gen"],
outs = ["use.txt"],
cmd = "echo \"BINDIR=$(BINDIR) gen=$(location :gen)\" > $@",
)
$ bazel build --platforms=//:device //:use && cat bazel-bin/use.txt
BINDIR=bazel-out/darwin_arm64-fastbuild/bin gen=bazel-out/darwin_arm64-fastbuild-ST-2ca549da6d12/bin/gen.txt
With 10.0.0rc4, both are in bazel-out/device-fastbuild/bin.
Which operating system are you running Bazel on?
macOS 27.2 (arm64)
What is the output of bazel info release?
release 9.3.3
If bazel info release returns development version or (@non-git), tell us how you built Bazel.
No response
What's the output of git remote get-url origin; git rev-parse HEAD ?
No response
If this is a regression, please try to identify the Bazel commit where the bug was introduced with bazelisk --bisect.
Not a regression as far as I know.
Have you found anything relevant by searching the web?
#18480 (test options in the output directory name, from the command line) and #22624 (--run_under with --platforms for on-device tests) are related, but neither covers platform-based flags.
Any other information, logs, or outputs that you want to share?
No response
- Dominant language
- Java
- Stars
- 26.2k
- Forks
- 4.7k
- Avg merge
- 3d 11h
- Merged PRs (30d)
- 125
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from bazelbuild/bazel
-
team-Rules-Java type: bug untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
bazelbuild/bazel#33068 ·
Maintainers usually reply within 2 days
-
Remote repo contents cache rejects repos with a backslash in a file name on UnixPossibly taken A pull request linked to this issue is open or already merged. Openteam-Remote-Exec type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
bazelbuild/bazel#32601 · 3 comments · 1 assignee ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
bazelbuild/bazel#32132 ·
Maintainers usually reply within 2 days
-
team-Local-Exec type: documentation (cleanup)
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
bazelbuild/bazel#31318 ·
Maintainers usually reply within 2 days
-
Docs: run/build.mdx describes a sandboxing warning removed in 2017 and a flag deleted in 9.0.0Possibly taken @lavishdev claimed this 70 days ago. Openhelp wanted P2 team-Documentation team-OSS type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
bazelbuild/bazel#31316 ·
Maintainers usually reply within 2 days
All issues in bazelbuild/bazel
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Lincoln-cn/JAiRouter#1473 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
exercism/java-analyzer#379 ·
-
area: ui bug priority: low
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
tetsuji16/microProject#1893 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
liberation-data/fornax4j#325 ·
Maintainers usually reply within 1 day
-
[Bug]: FE and Kinesis extraction pipes render flow starting at the centre and scroll the source arm backwardsPossibly taken @chonkzillaofficial claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
BCCE-team/BuildCraft#85 ·