Skip to content

Commit 57a7a30

Browse files
authored
[nextest-runner] add --max-progress-running, cap to 8 by default (#2727)
More polish work for #2720 -- empirically, terminals struggle to keep up with 16+ tests, so cap the maximum number of tests. Show the overflow count in a summary bar at the bottom.
1 parent d002d0f commit 57a7a30

File tree

8 files changed

+409
-53
lines changed

8 files changed

+409
-53
lines changed

cargo-nextest/src/dispatch/cli.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ use nextest_runner::{
2929
},
3030
partition::PartitionerBuilder,
3131
platform::BuildPlatforms,
32-
reporter::{FinalStatusLevel, ReporterBuilder, ShowProgress, StatusLevel, TestOutputDisplay},
32+
reporter::{
33+
FinalStatusLevel, MaxProgressRunning, ReporterBuilder, ShowProgress, StatusLevel,
34+
TestOutputDisplay,
35+
},
3336
reuse_build::ReuseBuildInfo,
3437
runner::{StressCondition, StressCount, TestRunnerBuilder},
3538
test_filter::{FilterBound, RunIgnored, TestFilterBuilder, TestFilterPatterns},
@@ -865,6 +868,20 @@ pub(super) struct ReporterOpts {
865868
#[arg(long, env = "NEXTEST_NO_INPUT_HANDLER", value_parser = BoolishValueParser::new())]
866869
pub(super) no_input_handler: bool,
867870

871+
/// Maximum number of running tests to display progress for.
872+
///
873+
/// When more tests are running than this limit, the progress bar will show
874+
/// the first N tests and a summary of remaining tests (e.g. "... and 24
875+
/// more tests running"). Set to **infinite** for unlimited. This only
876+
/// applies when using `--show-progress=running` or `only`.
877+
#[arg(
878+
long = "max-progress-running",
879+
value_name = "N",
880+
env = "NEXTEST_MAX_PROGRESS_RUNNING",
881+
default_value = "8"
882+
)]
883+
max_progress_running: MaxProgressRunning,
884+
868885
/// Format to use for test results (experimental).
869886
#[arg(
870887
long,
@@ -964,6 +981,7 @@ impl ReporterOpts {
964981
}
965982
builder.set_show_progress(show_progress.into());
966983
builder.set_no_output_indent(self.no_output_indent);
984+
builder.set_max_progress_running(self.max_progress_running);
967985
builder
968986
}
969987
}

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

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ use super::{
1212
DisplayBracketedDuration, DisplayDurationBy, DisplaySlowDuration, write_final_warnings,
1313
write_skip_counts,
1414
},
15-
progress::{ProgressBarState, progress_bar_msg, progress_str, write_summary_str},
15+
progress::{
16+
MaxProgressRunning, ProgressBarState, progress_bar_msg, progress_str, write_summary_str,
17+
},
1618
unit_output::TestOutputDisplay,
1719
};
1820
use crate::{
@@ -59,6 +61,7 @@ pub(crate) struct DisplayReporterBuilder {
5961
pub(crate) no_capture: bool,
6062
pub(crate) show_progress: ShowProgress,
6163
pub(crate) no_output_indent: bool,
64+
pub(crate) max_progress_running: MaxProgressRunning,
6265
}
6366

6467
impl DisplayReporterBuilder {
@@ -98,6 +101,7 @@ impl DisplayReporterBuilder {
98101
let progress_bar = self.progress_bar(
99102
theme_characters.progress_chars,
100103
theme_characters.spinner_chars,
104+
self.max_progress_running,
101105
);
102106
let term_progress = TerminalProgress::new(configs, &io::stderr());
103107

@@ -107,7 +111,7 @@ impl DisplayReporterBuilder {
107111
.unwrap_or_default();
108112

109113
ReporterStderrImpl::Terminal {
110-
progress_bar,
114+
progress_bar: progress_bar.map(Box::new),
111115
term_progress,
112116
}
113117
}
@@ -156,6 +160,7 @@ impl DisplayReporterBuilder {
156160
&self,
157161
progress_chars: &'static str,
158162
spinner_chars: &'static str,
163+
max_progress_running: MaxProgressRunning,
159164
) -> Option<ProgressBarState> {
160165
if self.no_capture {
161166
// Do not use a progress bar if --no-capture is passed in.
@@ -184,8 +189,13 @@ impl DisplayReporterBuilder {
184189
ShowProgress::Running => true,
185190
};
186191

187-
let state =
188-
ProgressBarState::new(self.test_count, progress_chars, spinner_chars, show_running);
192+
let state = ProgressBarState::new(
193+
self.test_count,
194+
progress_chars,
195+
spinner_chars,
196+
show_running,
197+
max_progress_running,
198+
);
189199
// Note: even if we create a progress bar here, if stderr is
190200
// piped, indicatif will not show it.
191201
Some(state)
@@ -254,7 +264,7 @@ enum ReporterStderrImpl<'a> {
254264
Terminal {
255265
// Reporter-specific progress bar state. None if the progress bar is not
256266
// enabled.
257-
progress_bar: Option<ProgressBarState>,
267+
progress_bar: Option<Box<ProgressBarState>>,
258268
// OSC 9 code progress reporting.
259269
term_progress: Option<TerminalProgress>,
260270
},
@@ -659,6 +669,7 @@ impl<'a> DisplayReporterImpl<'a> {
659669
run_status,
660670
delay_before_next_attempt,
661671
failure_output,
672+
running: _,
662673
} => {
663674
if self.status_levels.status_level >= StatusLevel::Retry {
664675
let try_status_string = format!(
@@ -737,6 +748,7 @@ impl<'a> DisplayReporterImpl<'a> {
737748
attempt,
738749
total_attempts,
739750
},
751+
running: _,
740752
} => {
741753
let retry_string = format!("RETRY {attempt}/{total_attempts}");
742754
write!(writer, "{:>12} ", retry_string.style(self.styles.retry))?;
@@ -2355,6 +2367,7 @@ mod tests {
23552367
no_capture: true,
23562368
show_progress: ShowProgress::Counter,
23572369
no_output_indent: false,
2370+
max_progress_running: MaxProgressRunning::default(),
23582371
};
23592372
let output = ReporterStderr::Buffer(out);
23602373
let reporter = builder.build(&configs, output);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ mod status_level;
1010
mod unit_output;
1111

1212
pub use imp::*;
13-
pub use progress::ShowProgress;
13+
pub use progress::{MaxProgressRunning, ShowProgress};
1414
pub use status_level::*;
1515
pub use unit_output::*;

0 commit comments

Comments
 (0)