Skip to content

Commit

Permalink
[test][windows] Export BAZEL_TEST=1 on windows
Browse files Browse the repository at this point in the history
This was an oversight from when exporting BAZEL_TEST on Linux.

fixes: #21420

Closes #21444.

PiperOrigin-RevId: 610338496
Change-Id: Icbbdc42b6ea92a2de2b0c558aea47a24493c9d8a
  • Loading branch information
cristiandonosoc authored and copybara-github committed Feb 26, 2024
1 parent e482e8b commit 0a9d612
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/test/py/bazel/bazel_windows_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,40 @@ def testZipUndeclaredTestOutputs(self):
self.assertTrue(os.path.exists(output_file))
self.assertFalse(os.path.exists(output_zip))

def testBazelForwardsRequiredEnvVariable(self):
self.CreateWorkspaceWithDefaultRepos('WORKSPACE')
self.ScratchFile(
'BUILD',
[
'sh_test(',
' name = "foo_test",',
' srcs = ["foo.sh"],',
')',
'',
],
)
self.ScratchFile(
'foo.sh',
[
"""
if [[ "$BAZEL_TEST" == "1" ]]; then
exit 0
else
echo "BAZEL_TEST is not set to 1"
exit 1
fi
""",
],
)

exit_code, stdout, stderr = self.RunBazel(
[
'test',
'//:foo_test',
],
)
self.AssertExitCode(exit_code, 0, stderr, stdout)

def testTestShardStatusFile(self):
self.CreateWorkspaceWithDefaultRepos('WORKSPACE')
self.ScratchFile(
Expand Down
5 changes: 5 additions & 0 deletions tools/test/windows/tw.cc
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,11 @@ bool ExportGtestVariables(const Path& test_tmpdir) {
}

bool ExportMiscEnvvars(const Path& cwd) {
// Add BAZEL_TEST environment variable.
if (!SetEnv(L"BAZEL_TEST", L"1")) {
return false;
}

for (const wchar_t* name :
{L"TEST_INFRASTRUCTURE_FAILURE_FILE", L"TEST_LOGSPLITTER_OUTPUT_FILE",
L"TEST_PREMATURE_EXIT_FILE", L"TEST_UNUSED_RUNFILES_LOG_FILE",
Expand Down

0 comments on commit 0a9d612

Please sign in to comment.