diff --git a/js/private/js_binary.bzl b/js/private/js_binary.bzl index 1e0a55382..0456212e3 100644 --- a/js/private/js_binary.bzl +++ b/js/private/js_binary.bzl @@ -559,11 +559,10 @@ def _js_binary_impl(ctx): providers = [] - if ctx.attr.testonly and ctx.configuration.coverage_enabled: + if ctx.attr.testonly and ctx.configuration.coverage_enabled and hasattr(ctx.attr, "_is_test"): # We have to instruct rule implementers to have this attribute present. if not hasattr(ctx.attr, "_lcov_merger"): fail("_lcov_merger attribute is missing and coverage was requested") - # We have to propagate _lcov_merger runfiles since bazel does not treat _lcov_merger as a proper tool. # See: https://github.com/bazelbuild/bazel/issues/4033 runfiles = runfiles.merge(ctx.attr._lcov_merger[DefaultInfo].default_runfiles) @@ -641,6 +640,9 @@ the contract between Bazel and a test runner.""", default = Label("//js/private/coverage:merger"), cfg = "exec", ), + "_is_test": attr.bool( + default = True + ) }), test = True, toolchains = js_binary_lib.toolchains,