-
Notifications
You must be signed in to change notification settings - Fork 7
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
Need some way to substitute envvars into env maps #24
Comments
Glad to hear this is solving some problems for you! Could you provide some more details on your use case? It sounds like you are doing something non-hermetic and want an escape hatch? For example, I don't understand the
|
Exactly, we are migrating from a legacy build system to bazel, and in the interim whilst both build systems are active, we need to set some envvars to subdirectories of the workspace root for consistency with the existing code. Eventually we won't need this if we manage to achieve the transition! We have such a large amount of stuff to migrate, and we need to take it in steps. |
One more detailed example that I've recently got working with rules_idata: Test and Service are both started with a common TEST_DATA envvar. The test process reads a file from TEST_DATA and makes a rest call to Service including a relative pathname. Service reads from this relative pathname and returns a response. It's tricky with runfiles and bazel to have both Test and Service starting with a common TEST_DATA directory. This is horrible, I'd want to see it refactored, but there are perhaps 2000 of these cases, and we need to first just make them work by running them with almost exactly the same environment as they were written to assume (e.g. TEST_DATA pointing to a subdirectory of workspace) |
I am guessing the 2000 refers to the # of tests, not the # of services? Perhaps it would work to write Another option would be to apply a patch to the env setup in rules_itest to customize things as you want, perhaps after the runfiles env setup I'm hesitant to add additional complexity to the ruleset to support non-hermetic cases if it means better-behaved setups need to incur the cost as well. We can leave this issue open and see if other users also request a similar feature |
I'm still stumbling around this issue, not just in non-hermetic use cases but also when integrating with existing test cases which require environment variables and trying to avoid wrapping every one to patch up envvar anomalities. I created a draft PR, for brainstorming/discussion: #42 |
Firstly, after some years with bazel I have just come across this repo from a stackoverflow comment. Really cool stuff, it was just what we were missing. Thanks!
It would be really helpful if there was a way to substitute existing envvars (passed via bazel --test_env could be substituted into the itest env maps. This is now the only reason that we need to run batch scripts before running bazel test. For example:
env = {
"PATH": "$(PATH);/extra"
"TEST_DATA" = "$(ROOT)/subdir"
}
It would be further cool if there was a way to provide a canned substitution that pointed to the workspace root.
Thanks!
Chris
The text was updated successfully, but these errors were encountered: