diff --git a/src/main/java/com/google/devtools/build/lib/exec/StandaloneTestStrategy.java b/src/main/java/com/google/devtools/build/lib/exec/StandaloneTestStrategy.java index 46ffcc07daacb7..1be5cc9382f11b 100644 --- a/src/main/java/com/google/devtools/build/lib/exec/StandaloneTestStrategy.java +++ b/src/main/java/com/google/devtools/build/lib/exec/StandaloneTestStrategy.java @@ -786,11 +786,13 @@ private TestAttemptResult runTestAttempt( if (e.isCatastrophic()) { closeSuppressed(e, streamed); closeSuppressed(e, fileOutErr); + closeSuppressed(e, coverageOutErr); throw e; } if (!e.getSpawnResult().setupSuccess()) { closeSuppressed(e, streamed); closeSuppressed(e, fileOutErr); + closeSuppressed(e, coverageOutErr); // Rethrow as the test could not be run and thus there's no point in retrying. throw e; } @@ -801,10 +803,12 @@ private TestAttemptResult runTestAttempt( } catch (ExecException | InterruptedException e) { closeSuppressed(e, streamed); closeSuppressed(e, fileOutErr); + closeSuppressed(e, coverageOutErr); throw e; } // Append all output from the coverage spawn to the test log. + coverageOutErr.close(); writeOutFile(coverageOutErr.getErrorPath(), coverageOutErr.getOutputPath()); appendCoverageLog(coverageOutErr, fileOutErr); }