Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix checking TEST_PREMATURE_EXIT_FILE #24657

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see three different changes in this PR:

  1. This block has been moved further down.
  2. The block only triggers if the test would otherwise pass.
  3. The file is deleted.

While all three make sense, which one (or which subset) is required to fix the bug? I would have guessed that only 2. should be necessary.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the change actually fixed the issue is actually "deleting the TEST_PREMATURE_EXIT_FILE when the test times out"

Initially, I thought it could be fixed by just changing exists to delete, but it didn't work.

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
Loading