Skip to content

Commit

Permalink
[7.1.0] [test][windows] Export BAZEL_TEST=1 on windows (bazelbuild#21494
Browse files Browse the repository at this point in the history
)

This was an oversight from when exporting BAZEL_TEST on Linux.

fixes: bazelbuild#21420

Closes bazelbuild#21444.

Commit
bazelbuild@0a9d612

PiperOrigin-RevId: 610338496
Change-Id: Icbbdc42b6ea92a2de2b0c558aea47a24493c9d8a

Co-authored-by: Cristin Donoso <cristiandonosoc@gmail.com>
  • Loading branch information
bazel-io and cristiandonosoc authored Feb 26, 2024
1 parent 697baf4 commit e57b6cc
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 @@ -471,6 +471,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 e57b6cc

Please sign in to comment.