Skip to content

Commit 1492ae4

Browse files
authored
fix: configure coverage helpers for test exec group (#2857)
They are run on the test action's execution platform, which is resolved for the `test` exec group, not the default one.
1 parent 7864731 commit 1492ae4

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

python/private/attributes.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,14 +397,14 @@ COVERAGE_ATTRS = {
397397
"_collect_cc_coverage": lambda: attrb.Label(
398398
default = "@bazel_tools//tools/test:collect_cc_coverage",
399399
executable = True,
400-
cfg = "exec",
400+
cfg = config.exec(exec_group = "test"),
401401
),
402402
# Magic attribute to make coverage work. There's no
403403
# docs about this; see TestActionBuilder.java
404404
"_lcov_merger": lambda: attrb.Label(
405405
default = configuration_field(fragment = "coverage", name = "output_generator"),
406406
executable = True,
407-
cfg = "exec",
407+
cfg = config.exec(exec_group = "test"),
408408
),
409409
}
410410

python/private/py_executable.bzl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ EXECUTABLE_ATTRS = dicts.add(
7878
AGNOSTIC_EXECUTABLE_ATTRS,
7979
PY_SRCS_ATTRS,
8080
IMPORTS_ATTRS,
81-
COVERAGE_ATTRS,
8281
{
8382
"interpreter_args": lambda: attrb.StringList(
8483
doc = """
@@ -1903,7 +1902,7 @@ def create_executable_rule_builder(implementation, **kwargs):
19031902
"""
19041903
builder = ruleb.Rule(
19051904
implementation = implementation,
1906-
attrs = EXECUTABLE_ATTRS,
1905+
attrs = EXECUTABLE_ATTRS | (COVERAGE_ATTRS if kwargs.get("test") else {}),
19071906
exec_groups = dict(REQUIRED_EXEC_GROUP_BUILDERS), # Mutable copy
19081907
fragments = ["py", "bazel_py"],
19091908
provides = [PyExecutableInfo, PyInfo] + _MaybeBuiltinPyInfo,

0 commit comments

Comments
 (0)