bazelbuild / bazelbuild/bazel-skylib

Analysis tests cannot see TestEnvironment added environment variables in actions

Open
#335 2 comments 0 reactions 0 assignees View on GitHub
P3 type: bug
Dominant language
Starlark
Stars
444
Forks
202
PR merge metrics
No merged PRs in 30d

Description

Test rules can return `testing.TestEnvironment` to include custom environment variables for when the test is run. This works, however, they are not visible in the action object that an analysis test sees.

(incomplete) repro:

```
def foo_test_impl(ctx):
return [testing.TestEnvironment({"FOO": "BAR"})]

def verify_foo_test(ctx):
env = analysistest.begin(ctx)
actions = analysistest.target_actions(env)
for a in actions:
print(a.env)
return analysistest.end(env)
```

Expected: The "Testing ..." action should have FOO=BAR as one of its environment variable.

Actual: The FOO=BAR env var is not shown in the action's env values.

Contributor guide

Open the contributing guide

Research direction

Start with the incomplete reproduction using testing.TestEnvironment and the analysistest.begin, analysistest.target_actions, and analysistest.end entry points. Check why the Testing action's a.env omits FOO=BAR, then verify that the action exposes the returned environment variable while the analysis test still completes successfully.

Written by the indexing model from the issue text.

Assessment

Domain
build-system, testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.