Skip to content

Commit

Permalink
Fix checking TEST_PREMATURE_EXIT_FILE
Browse files Browse the repository at this point in the history
  • Loading branch information
meteorcloudy committed Dec 12, 2024
1 parent 82c1ff7 commit f1a49df
Showing 1 changed file with 17 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -655,25 +655,7 @@ private TestAttemptResult runTestAttempt(
try {
spawnResults = resolver.exec(spawn, actionExecutionContext.withFileOutErr(fileOutErr));
testResultDataBuilder = TestResultData.newBuilder();
if (actionExecutionContext
.getPathResolver()
.convertPath(resolvedPaths.getExitSafeFile())
.exists()) {
testResultDataBuilder
.setCachable(false)
.setTestPassed(false)
.setStatus(BlazeTestStatus.FAILED);
fileOutErr
.getErrorStream()
.write(
"-- Test exited prematurely (TEST_PREMATURE_EXIT_FILE exists) --\n"
.getBytes(StandardCharsets.UTF_8));
} else {
testResultDataBuilder
.setCachable(true)
.setTestPassed(true)
.setStatus(BlazeTestStatus.PASSED);
}
testResultDataBuilder.setCachable(true).setTestPassed(true).setStatus(BlazeTestStatus.PASSED);
} catch (SpawnExecException e) {
if (e.isCatastrophic()) {
closeSuppressed(e, streamed);
Expand All @@ -699,6 +681,22 @@ private TestAttemptResult runTestAttempt(
}
long endTimeMillis = actionExecutionContext.getClock().currentTimeMillis();

// Check TEST_PREMATURE_EXIT_FILE file (and always delete it)
if (actionExecutionContext
.getPathResolver()
.convertPath(resolvedPaths.getExitSafeFile())
.delete() && testResultDataBuilder.getTestPassed()) {
testResultDataBuilder
.setCachable(false)
.setTestPassed(false)
.setStatus(BlazeTestStatus.FAILED);
fileOutErr
.getErrorStream()
.write(
"-- Test exited prematurely (TEST_PREMATURE_EXIT_FILE exists) --\n"
.getBytes(StandardCharsets.UTF_8));
}

// Do not override a more informative test failure with a generic failure due to the missing
// shard file, which may have been caused by the test failing before the runner had a chance to
// touch the file
Expand Down

0 comments on commit f1a49df

Please sign in to comment.