Skip to content

Commit 9c747c5

Browse files
keithjbedard
authored andcommitted
Add env_inherit to js_test
Fixes #1313
1 parent fa903c5 commit 9c747c5

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

docs/js_binary.md

Lines changed: 6 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/private/js_binary.bzl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,12 @@ def _js_binary_impl(ctx):
573573
runfiles = launcher.runfiles
574574

575575
providers = []
576+
if hasattr(ctx.attr, "env_inherit"):
577+
providers.append(
578+
RunEnvironmentInfo(
579+
inherited_environment = ctx.attr.env_inherit,
580+
),
581+
)
576582

577583
if ctx.attr.testonly and ctx.configuration.coverage_enabled:
578584
# We have to propagate _lcov_merger runfiles since bazel does not treat _lcov_merger as a proper tool.
@@ -655,6 +661,10 @@ See the Bazel [Test encyclopedia](https://bazel.build/reference/test-encyclopedi
655661
the contract between Bazel and a test runner.""",
656662
implementation = js_binary_lib.implementation,
657663
attrs = dict(js_binary_lib.attrs, **{
664+
"env_inherit": attr.string_list(
665+
default = [],
666+
doc = "Specifies additional environment variables to inherit from the external environment when the test is executed by bazel test.",
667+
),
658668
# TODO: Remove once bazel<8 support is dropped.
659669
# See comment at usage site in the rule impl for more.
660670
"_lcov_merger": attr.label(

0 commit comments

Comments
 (0)