bazel icon indicating copy to clipboard operation
bazel copied to clipboard

Expose inherited part of action environment to Starlark tests

Open fmeum opened this issue 1 year ago • 4 comments

Starlark tests can use the new Action#inherited_env field to get a list of environment variables the action inherits from the client environment, obtained from AbstractAction#getClientEnvironmentVariables.

fmeum avatar Apr 27 '23 09:04 fmeum

@rickeylev Could you take a look? I found this capability to be lacking while working on analysis tests for cc_static_library and noticing that using use_default_shell_env has pitfalls.

fmeum avatar Apr 27 '23 12:04 fmeum

I missed that this PR is waiting for me. Is there still interest to get it in?

This is exposing Action.env_inherit, which is only accessible to tests, right? And that's suppose to make the tests more robust, IIUC?

comius avatar May 15 '24 13:05 comius

I missed that this PR is waiting for me. Is there still interest to get it in?

Yes.

This is exposing Action.env_inherit, which is only accessible to tests, right? And that's suppose to make the tests more robust, IIUC?

Exactly, this API is test only. Currently tests can't assert on the inherited environment at all.

fmeum avatar May 15 '24 14:05 fmeum

The wait was worth it, this is much simpler now.

@comius Getting this into 7.2.0 would make it easier to write tests for cc_static_library.

fmeum avatar May 16 '24 08:05 fmeum