Skip to content

Commit 4c1cb9b

Browse files
committed
refactor to use _is_test attribute instead
This addresses the problem in a different way that allows us to not change the existing logic, but instead differentiate one step further with attributes
1 parent 60ddaaa commit 4c1cb9b

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

js/private/js_binary.bzl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -559,8 +559,10 @@ def _js_binary_impl(ctx):
559559

560560
providers = []
561561

562-
# We have to instruct test rule implementers to have this attribute present.
563-
if ctx.attr.testonly and ctx.configuration.coverage_enabled and hasattr(ctx.attr, "_lcov_merger"):
562+
if ctx.attr.testonly and ctx.configuration.coverage_enabled and hasattr(ctx.attr, "_is_test"):
563+
# We have to instruct rule implementers to have this attribute present.
564+
if not hasattr(ctx.attr, "_lcov_merger"):
565+
fail("_lcov_merger attribute is missing and coverage was requested")
564566
# We have to propagate _lcov_merger runfiles since bazel does not treat _lcov_merger as a proper tool.
565567
# See: https://github.com/bazelbuild/bazel/issues/4033
566568
runfiles = runfiles.merge(ctx.attr._lcov_merger[DefaultInfo].default_runfiles)
@@ -638,6 +640,7 @@ the contract between Bazel and a test runner.""",
638640
default = Label("//js/private/coverage:merger"),
639641
cfg = "exec",
640642
),
643+
"_is_test": True
641644
}),
642645
test = True,
643646
toolchains = js_binary_lib.toolchains,

0 commit comments

Comments
 (0)