Skip to content

Commit d865091

Browse files
authored
[nextest-runner] show TRY n START for retries with --verbose (#2847)
Similar to the START added for --verbose, show `TRY n START` for retries.
1 parent 3d91dc4 commit d865091

File tree

6 files changed

+81
-19
lines changed

6 files changed

+81
-19
lines changed

nextest-runner/src/reporter/displayer/imp.rs

Lines changed: 69 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -765,27 +765,28 @@ impl<'a> DisplayReporterImpl<'a> {
765765
TestEventKind::TestRetryStarted {
766766
stress_index,
767767
test_instance,
768-
retry_data:
769-
RetryData {
770-
attempt,
771-
total_attempts,
772-
},
768+
retry_data: RetryData { attempt, .. },
773769
running: _,
770+
command_line,
774771
} => {
775-
let retry_string = format!("RETRY {attempt}/{total_attempts}");
776-
write!(writer, "{:>12} ", retry_string.style(self.styles.retry))?;
772+
// In no-capture and verbose modes, print out a retry start event.
773+
if self.no_capture || self.verbose {
774+
let retry_string = format!("TRY {attempt} START");
775+
writeln!(
776+
writer,
777+
"{:>12} [ ] {}",
778+
retry_string.style(self.styles.retry),
779+
self.display_test_instance(
780+
*stress_index,
781+
TestInstanceCounter::Padded,
782+
*test_instance
783+
)
784+
)?;
785+
}
777786

778-
// Add spacing to align test instances, then print the name of the test.
779-
writeln!(
780-
writer,
781-
"[{:<9}] {}",
782-
"",
783-
self.display_test_instance(
784-
*stress_index,
785-
TestInstanceCounter::Padded,
786-
*test_instance
787-
)
788-
)?;
787+
if self.verbose {
788+
self.write_command_line(command_line, writer)?;
789+
}
789790
}
790791
TestEventKind::TestFinished {
791792
stress_index,
@@ -3271,6 +3272,56 @@ mod tests {
32713272
},
32723273
})
32733274
.unwrap();
3275+
3276+
// Test a retry (attempt 2) - should show "TRY 2 START".
3277+
reporter
3278+
.write_event(&TestEvent {
3279+
timestamp: Local::now().into(),
3280+
elapsed: Duration::ZERO,
3281+
kind: TestEventKind::TestRetryStarted {
3282+
stress_index: None,
3283+
test_instance: TestInstanceId {
3284+
binary_id: &binary_id,
3285+
test_name: "test_retry",
3286+
},
3287+
retry_data: RetryData {
3288+
attempt: 2,
3289+
total_attempts: 3,
3290+
},
3291+
running: 1,
3292+
command_line: vec![
3293+
"/path/to/binary".to_string(),
3294+
"--exact".to_string(),
3295+
"test_retry".to_string(),
3296+
],
3297+
},
3298+
})
3299+
.unwrap();
3300+
3301+
// Test a retry (attempt 3) - should show "TRY 3 START".
3302+
reporter
3303+
.write_event(&TestEvent {
3304+
timestamp: Local::now().into(),
3305+
elapsed: Duration::ZERO,
3306+
kind: TestEventKind::TestRetryStarted {
3307+
stress_index: None,
3308+
test_instance: TestInstanceId {
3309+
binary_id: &binary_id,
3310+
test_name: "test_retry",
3311+
},
3312+
retry_data: RetryData {
3313+
attempt: 3,
3314+
total_attempts: 3,
3315+
},
3316+
running: 1,
3317+
command_line: vec![
3318+
"/path/to/binary".to_string(),
3319+
"--exact".to_string(),
3320+
"test_retry".to_string(),
3321+
],
3322+
},
3323+
})
3324+
.unwrap();
32743325
},
32753326
&mut out,
32763327
);

nextest-runner/src/reporter/displayer/snapshots/nextest_runner__reporter__displayer__imp__tests__verbose_command_line.snap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@ snapshot_kind: text
99
command: /path/to/binary --exact 'test with spaces' '--flag=value'
1010
START [ ] ( 1/10) my-binary-id test_special_chars
1111
command: /path/to/binary 'test"with"quotes' 'test'\''with'\''single'
12+
TRY 2 START [ ] (─────────) my-binary-id test_retry
13+
command: /path/to/binary --exact test_retry
14+
TRY 3 START [ ] (─────────) my-binary-id test_retry
15+
command: /path/to/binary --exact test_retry

nextest-runner/src/reporter/events.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,9 @@ pub enum TestEventKind<'a> {
230230

231231
/// The current number of running tests.
232232
running: usize,
233+
234+
/// The command line that will be used to run this test.
235+
command_line: Vec<String>,
233236
},
234237

235238
/// A test finished running.

nextest-runner/src/runner/dispatcher.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,7 @@ where
737737
stress_index,
738738
test_instance,
739739
retry_data,
740+
command_line,
740741
tx,
741742
}) => {
742743
if self.run_stats.cancel_reason.is_some() {
@@ -759,6 +760,7 @@ where
759760
test_instance: test_instance.id(),
760761
retry_data,
761762
running: self.running_tests.len(),
763+
command_line,
762764
})
763765
}
764766
InternalEvent::Executor(ExecutorEvent::Finished {

nextest-runner/src/runner/executor.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ impl<'a> ExecutorContext<'a> {
231231
_ = resp_tx.send(ExecutorEvent::Started {
232232
stress_index,
233233
test_instance: test.instance,
234-
command_line,
234+
command_line: command_line.clone(),
235235
req_rx_tx,
236236
});
237237
let mut req_rx = match req_rx_rx.await {
@@ -262,6 +262,7 @@ impl<'a> ExecutorContext<'a> {
262262
stress_index,
263263
test_instance: test.instance,
264264
retry_data,
265+
command_line: command_line.clone(),
265266
tx,
266267
});
267268

nextest-runner/src/runner/internal_events.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ pub(super) enum ExecutorEvent<'a> {
100100
stress_index: Option<StressIndex>,
101101
test_instance: TestInstance<'a>,
102102
retry_data: RetryData,
103+
command_line: Vec<String>,
103104
// This is used to indicate that the dispatcher still wants to run the test.
104105
tx: oneshot::Sender<()>,
105106
},

0 commit comments

Comments
 (0)