-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cc_test
should respect exec_compatible_with
for test action
#23202
Comments
Here's a failing test case demonstrating this issue: #23203 If i remove all exec_groups from cc_test it passes, which is what I expected behavior wise, that the passed exec_compatible_with / target_compatible_with would override / be combined with any from the default exec_groups. Note that passing |
cc: @katre |
If your use case really doesn't need to specify Adding exec constrains per-target is still a use case that should be supported. I do think that having Instead, it would seem more flexible to be able to add constraints to individual exec groups. Since Bazel doesn't offer an attribute type for cc_test(
...,
exec_compatible_with = [
"//:fast_cpu",
],
exec_group_exec_compatible_with = {
"test": ["//:has_gpu"],
},
) But what we could probably have is this, where each exec group declared on the rule results in a new cc_test(
...,
# Applies to the default (unspecified) exec group only.
exec_compatible_with = [
"//:fast_cpu",
],
test_exec_compatible_with = [
"//:has_gpu",
],
) |
Seems like doing that toolchain setup would potentially work, given the lack of docs and public usages I was a bit wary when I saw that might be an option. I agree that merging the exec_compatible_with with all exec_groups isn't ideal, and your suggested solution is the ideal, but also I think merging would still be preferred since you can't control those exec groups today without modifying the bazel source either AFAIUI? Another option as a workaround is to stop using cc_test and replace it with a cc_binary and a custom test rule that just runs that binary as the test. Here's a minimal example: def _binary_test_impl(ctx):
output = ctx.actions.declare_file(ctx.label.name)
ctx.actions.symlink(
target_file = ctx.file.binary,
output = output,
)
return [
DefaultInfo(
executable = output,
runfiles = ctx.attr.binary[DefaultInfo].default_runfiles,
),
ctx.attr.binary[RunEnvironmentInfo],
]
binary_test = rule(
implementation = _binary_test_impl,
attrs = {
"binary": attr.label(allow_single_file = True),
},
test = True,
) |
Description of the bug:
If you have a simple constraint like this:
And you create a
cc_test
target that requires that setting:and you're using remote exec with multiple platforms:
with:
Building the cc_test target results in compilation happening on the
something-platform
, linking happening onbase-platform
and the test action most importantly happening on thebase-platform
.It seems like theoretically this flag exists to help with this:
But this doesn't help in this case (unsurprisingly I think since you've already manually annotated the target with
exec_compatible_with
)Passing
--use_target_platform_for_tests
does appear to fix this, but this flag has the downside that if you were to run 2 tests at once where not all required:has_something
, they would both run on thesomething-platform
instead of thebase-platform
, which is undesirable.If you create a
py_test
(picked at random as another option) and create it the same way, it works as I'm expecting.I assume this is because
cc_test
hasexec_groups
definedbazel/src/main/starlark/builtins_bzl/common/cc/cc_test.bzl
Lines 112 to 116 in c71f0b6
exec_compatible_with
to override these?If I delete the
test
exec_group
(and deal with the fallout of that) it fixes the issue. I guess I would assume that anyexec_compatible_with
would be merged with theexec_group
value (which isn't even passed in this case)?Which category does this issue belong to?
No response
What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
No response
Which operating system are you running Bazel on?
No response
What is the output of
bazel info release
?1acbd42 (or 7.x)
If
bazel info release
returnsdevelopment 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.
No response
Have you found anything relevant by searching the web?
There are many threads on related topics here. Most about splitting the compilation / linking / testing across multiple exec groups, which I would also like for other cases. But I think this case is distinct.
exec_properties
?)Any other information, logs, or outputs that you want to share?
No response
The text was updated successfully, but these errors were encountered: