Support env_inherit in workspace_root_test (#46534)

Add an `env_inherit` string-list attribute and pass it to
`RunEnvironmentInfo.inherited_environment`, allowing tests to inherit
selected environment variables from the calling environment.

GitOrigin-RevId: 4ea868bda2d80dd57a8fc139ffa9625cb8311b37
This commit is contained in:
Michael Bolin
2026-09-18 18:35:13 +00:00
committed by copyberry
parent 61b08f1011
commit ab59b78287

View File

@@ -98,6 +98,7 @@ def _workspace_root_test_impl(ctx):
),
RunEnvironmentInfo(
environment = env,
inherited_environment = ctx.attr.env_inherit,
),
]
@@ -153,6 +154,7 @@ workspace_root_test = rule(
allow_files = True,
),
"env": attr.string_dict(),
"env_inherit": attr.string_list(),
"runfile_env": attr.label_keyed_string_dict(
cfg = "target",
),