diff options
author | Yun Peng <pcloudy@google.com> | 2018-05-28 07:49:27 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-05-28 07:50:36 -0700 |
commit | 4015862b5ef068ec649df7123df63b23ea36185d (patch) | |
tree | 21fbbe8d279c4160af16e57ba0e9a02f9c1c7834 /src/test/py | |
parent | a9c0d4e41efa3fc684de3065e74b9a6f82ec260d (diff) |
Windows: Make environment variables case-insensitive when creating Windows process
If users pass the same environment variables with different cases,
the last one will override the previous ones.
Fixed https://github.com/bazelbuild/bazel/issues/5285
Change-Id: Ieec857553bc54a4ad9809455687551303037e240
PiperOrigin-RevId: 198303684
Diffstat (limited to 'src/test/py')
-rw-r--r-- | src/test/py/bazel/bazel_windows_test.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/test/py/bazel/bazel_windows_test.py b/src/test/py/bazel/bazel_windows_test.py index 86c411b4ae..259ec8230a 100644 --- a/src/test/py/bazel/bazel_windows_test.py +++ b/src/test/py/bazel/bazel_windows_test.py @@ -111,6 +111,38 @@ class BazelWindowsTest(test_base.TestBase): self.AssertExitCode(exit_code, 0, stderr) self.assertTrue(os.path.exists(os.path.join(bazel_bin, 'x.exe'))) + def testWindowsEnvironmentVariablesSetting(self): + self.ScratchFile('BUILD') + self.ScratchFile('WORKSPACE', [ + 'load(":repo.bzl", "my_repo")', + 'my_repo(name = "env_test")', + ]) + self.ScratchFile('repo.bzl', [ + 'def my_repo_impl(repository_ctx):', + ' repository_ctx.file("env.bat", "set FOO\\n")', + ' env = {"foo" : "bar2", "Foo": "bar3",}', + ' result = repository_ctx.execute(["./env.bat"], environment = env)', + ' print(result.stdout)', + ' repository_ctx.file("BUILD")', + '', + 'my_repo = repository_rule(', + ' implementation = my_repo_impl,', + ')', + ]) + + exit_code, _, stderr = self.RunBazel( + [ + 'build', + '@env_test//...', + ], + env_add={'FOO': 'bar1'}, + ) + self.AssertExitCode(exit_code, 0, stderr) + result_in_lower_case = ''.join(stderr).lower() + self.assertNotIn('foo=bar1', result_in_lower_case) + self.assertNotIn('foo=bar2', result_in_lower_case) + self.assertIn('foo=bar3', result_in_lower_case) + if __name__ == '__main__': unittest.main() |