-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Description
Description of the problem / feature request:
The test rule attribute env should be able to overwrite environment variables, not just inject additional ones.
Feature requests: what underlying problem are you trying to solve with this feature?
I am writing tests which require a custom PATH value.
One could modify the PATH environment variable inside the test implementation, but I consider this a hacky workaround.
--test_env can do the required task, but it influences all tests, whereas I want to influence just some specific tests.
Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
BUILD file
sh_test(
name = "foo",
srcs = ["foo.sh"],
env = {
"PATH": "foo",
"FOO": "bar",
},
)
test implementation
#!/usr/bin/env bash
echo $PATH
echo $FOO
command: bazel test --test_output=all //:foo
The test will not print the expected foo.
What operating system are you running Bazel on?
Ubuntu 20.04
What's the output of bazel info release?
release 4.1.0
Have you found anything relevant by searching the web?
The documentation explicitly states Specifies additional environment ....
It seems the current behavior is intended. Still, I believe being able to overwrite PATH is a valid feature.
No open issues discussing overwriting environment variables could be found.