Skip to content

Fix and test for null value bug when using --repo_env #15618

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

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/test/py/bazel/bazel_external_repository_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,5 +427,34 @@ def testExternalBazelignoreContainingRepoName(self):
args=['build', '@other_repo//:file'], cwd=work_dir)
self.AssertExitCode(exit_code, 0, stderr)

def testRepoEnv(self):
#Testing fix for issue: https://github.com/bazelbuild/bazel/issues/15430

self.ScratchFile('WORKSPACE', [
'load("//:main.bzl", "dump_env")',
'dump_env(',
' name = "debug"',
')'
])
self.ScratchFile('BUILD')
self.ScratchFile('main.bzl', [
'def _dump_env(ctx):',
' val = ctx.os.environ.get("FOO", "nothing")',
' print("FOO", val)',
' ctx.file("BUILD")',
'dump_env = repository_rule(',
' implementation = _dump_env,',
' local = True,',
')'
])

exit_code, _, stderr = self.RunBazel(
args=['build', '@debug//:all'],
env_add={'FOO': 'bar'},
)
self.AssertExitCode(exit_code, 0, stderr)
self.assertIn('FOO bar', os.linesep.join(stderr))
self.assertNotIn('null value in entry: FOO=null', os.linesep.join(stderr))

if __name__ == '__main__':
unittest.main()