Skip to content

Commit

Permalink
[nextest-runner] wait for dispatcher to acknowledge retries
Browse files Browse the repository at this point in the history
Gives the dispatcher a chance to control communication.
  • Loading branch information
sunshowers committed Dec 15, 2024
1 parent a819144 commit c1abd3f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 4 deletions.
26 changes: 22 additions & 4 deletions nextest-runner/src/runner/dispatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -471,10 +471,28 @@ where
InternalEvent::Executor(ExecutorEvent::RetryStarted {
test_instance,
retry_data,
}) => self.callback_none_response(TestEventKind::TestRetryStarted {
test_instance,
retry_data,
}),
tx,
}) => {
if self.cancel_state.is_some() {
// The run has been cancelled: don't send a message over the tx and don't start
// any new units.
return HandleEventResponse::None;

Check warning on line 479 in nextest-runner/src/runner/dispatcher.rs

View check run for this annotation

Codecov / codecov/patch

nextest-runner/src/runner/dispatcher.rs#L479

Added line #L479 was not covered by tests
}

match tx.send(()) {
Ok(_) => {}
Err(_) => {
// The test task died?
debug!(test = ?test_instance.id(), "test task died, ignoring");
return HandleEventResponse::None;

Check warning on line 487 in nextest-runner/src/runner/dispatcher.rs

View check run for this annotation

Codecov / codecov/patch

nextest-runner/src/runner/dispatcher.rs#L486-L487

Added lines #L486 - L487 were not covered by tests
}
}

self.callback_none_response(TestEventKind::TestRetryStarted {
test_instance,
retry_data,
})
}
InternalEvent::Executor(ExecutorEvent::Finished {
test_instance,
success_output,
Expand Down
13 changes: 13 additions & 0 deletions nextest-runner/src/runner/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,23 @@ impl<'a> ExecutorContext<'a> {
// is empty.

if retry_data.attempt > 1 {
// Ensure that the dispatcher believes the run is still ongoing. If the run is
// cancelled, the dispatcher will let us know.
let (tx, rx) = oneshot::channel();
_ = resp_tx.send(ExecutorEvent::RetryStarted {
test_instance,
retry_data,
tx,
});

match rx.await {
Ok(()) => {}
Err(_) => {
// The receiver was dropped -- the dispatcher has signaled that this unit
// should exit.
return;

Check warning on line 247 in nextest-runner/src/runner/executor.rs

View check run for this annotation

Codecov / codecov/patch

nextest-runner/src/runner/executor.rs#L247

Added line #L247 was not covered by tests
}
}
}

// Some of this information is only useful for event reporting, but
Expand Down
2 changes: 2 additions & 0 deletions nextest-runner/src/runner/internal_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ pub(super) enum ExecutorEvent<'a> {
RetryStarted {
test_instance: TestInstance<'a>,
retry_data: RetryData,
// This is used to indicate that the dispatcher still wants to run the test.
tx: oneshot::Sender<()>,
},
Finished {
test_instance: TestInstance<'a>,
Expand Down

0 comments on commit c1abd3f

Please sign in to comment.