Skip to content

Commit 958e0c4

Browse files
coeuvrecopybara-github
authored andcommitted
Close test.err before deleteing it
Unfortuantely, there isn't an easy way to add integration test for this specific edge case on Windows. Fixes #20741. Closes #20752. PiperOrigin-RevId: 596547046 Change-Id: I4f517b161c03793329d5a4e21ec8ac4a5b53abb0
1 parent 8e8ddab commit 958e0c4

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/main/java/com/google/devtools/build/lib/exec/StandaloneTestStrategy.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -800,9 +800,12 @@ private TestAttemptResult runTestAttempt(
800800
// Make sure that the test.log exists.Spaw
801801
FileSystemUtils.touchFile(fileOutErr.getOutputPath());
802802
}
803+
fileOutErr.close();
803804
// Append any error output to the test.log. This is very rare.
805+
//
806+
// Only write after the error output stream has been closed. Otherwise, Bazel cannot delete
807+
// test.err file on Windows. See https://github.com/bazelbuild/bazel/issues/20741.
804808
writeOutFile(fileOutErr.getErrorPath(), fileOutErr.getOutputPath());
805-
fileOutErr.close();
806809
if (streamed != null) {
807810
streamed.close();
808811
}

0 commit comments

Comments
 (0)