Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add env and env_inherit to native_binary and native_test (using @bazel_features) #484

Open
wants to merge 27 commits into
base: main
Choose a base branch
from

Conversation

redsun82
Copy link

@redsun82 redsun82 commented Jan 11, 2024

Closes #409

@redsun82 redsun82 changed the title Add env and env_inherit to native_binary and native_test Add env and env_inherit to native_binary and native_test (using @bazel_features) Jan 11, 2024
@redsun82 redsun82 requested a review from hvadehra as a code owner June 13, 2024 07:18
@redsun82 redsun82 requested a review from jgertm June 13, 2024 07:19
@hvadehra
Copy link
Member

This relies on the RunEnvironmentInfo that was introduced in bazel 5.3.0. To keep the library compatible with previous versions, bazel_features is used.

FYI, going by https://bazel.build/release#support-matrix , v5.4.1 is now the minimum supported version, so if RunEnvironmentInfo is the only thing needed for this, I'd say it's safe to just assume it's available, and you can drop the dependency on bazel_features & related complexity.

(not a full review, I'll defer to @tetromino / @brandjon for that)

redsun82 added 2 commits June 26, 2024 08:51
According to https://bazel.build/release#support-matrix, we can drop
support for Bazel 4.x (so we can use `runfiles.merge_all`) and Bazel
<5.3 (so we can use `RunEnvironmentInfo` unconditionally, which
simplifies the change significantly).
@redsun82
Copy link
Author

@hvadehra thanks for the heads up, that makes things way easier. @tetromino / @brandjon, the PR should be ready for another review pass now 🚀

@@ -10,7 +10,7 @@ register_toolchains(
"//toolchains/unittest:bash_toolchain",
)

bazel_dep(name = "platforms", version = "0.0.4")
bazel_dep(name = "platforms", version = "0.0.9")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there was a warning about a dependency pulling this version in

#define OS_VAR "HOME"
#endif

enum vars_to_be_found {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you implement this test in a less hacky way?

For example, get rid of the enum, and just search for 3 strings. Use set found to true/false.

Copy link
Collaborator

@comius comius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (except for the test)

@redsun82
Copy link
Author

@comius sorry for the late update on this, I've cleaned up the test now.

@criemen
Copy link

criemen commented Sep 5, 2024

@comius any chance you could have another look at this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add env attr to native_binary and native_test
5 participants