Skip to content
Open
Show file tree
Hide file tree
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
30 changes: 30 additions & 0 deletions nextest-runner/src/list/test_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1182,6 +1182,36 @@ impl<'a> TestInstance<'a> {
interceptor,
)
}

/// Returns the command line string for running this test.
pub(crate) fn command_line(
&self,
ctx: &TestExecuteContext<'_>,
test_list: &TestList<'_>,
wrapper_script: Option<&'a WrapperScriptConfig>,
extra_args: &[String],
) -> String {
let platform_runner = ctx
.target_runner
.for_build_platform(self.suite_info.build_platform);

let mut cli = TestCommandCli::default();
cli.apply_wrappers(
wrapper_script,
platform_runner,
test_list.workspace_root(),
&test_list.rust_build_meta().target_directory,
);
cli.push(self.suite_info.binary_path.as_str());

cli.extend(["--exact", self.name, "--nocapture"]);
if self.test_info.ignored {
cli.push("--ignored");
}
cli.extend(extra_args.iter().map(String::as_str));

shell_words::join(cli.to_owned_cli())
}
}

#[derive(Clone, Debug, Default)]
Expand Down
15 changes: 15 additions & 0 deletions nextest-runner/src/reporter/displayer/imp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ pub(crate) struct DisplayReporterBuilder {
pub(crate) failure_output: Option<TestOutputDisplay>,
pub(crate) should_colorize: bool,
pub(crate) no_capture: bool,
pub(crate) verbose: bool,
pub(crate) show_progress: ShowProgress,
pub(crate) no_output_indent: bool,
pub(crate) max_progress_running: MaxProgressRunning,
Expand Down Expand Up @@ -141,6 +142,7 @@ impl DisplayReporterBuilder {
final_status_level: self.status_levels.final_status_level,
},
no_capture: self.no_capture,
verbose: self.verbose,
no_output_indent: self.no_output_indent,
counter_width,
styles,
Expand Down Expand Up @@ -377,6 +379,7 @@ struct DisplayReporterImpl<'a> {
default_filter: CompiledDefaultFilter,
status_levels: StatusLevels,
no_capture: bool,
verbose: bool,
no_output_indent: bool,
// None if no counter is displayed. If a counter is displayed, this is the
// width of the total number of tests to run.
Expand Down Expand Up @@ -601,6 +604,7 @@ impl<'a> DisplayReporterImpl<'a> {
stress_index,
test_instance,
current_stats,
command_line,
..
} => {
// In no-capture mode, print out a test start event.
Expand All @@ -623,6 +627,15 @@ impl<'a> DisplayReporterImpl<'a> {
),
)?;
}

if self.verbose {
writeln!(
writer,
"{:>12} {}",
"COMMAND".style(self.styles.count),
command_line,
)?;
}
}
TestEventKind::TestSlow {
stress_index,
Expand Down Expand Up @@ -2390,10 +2403,12 @@ mod tests {
failure_output: Some(TestOutputDisplay::Immediate),
should_colorize: false,
no_capture: true,
verbose: false,
show_progress: ShowProgress::Counter,
no_output_indent: false,
max_progress_running: MaxProgressRunning::default(),
};

let output = ReporterStderr::Buffer(out);
let reporter = builder.build(&configs, output);
f(reporter);
Expand Down
3 changes: 3 additions & 0 deletions nextest-runner/src/reporter/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ pub enum TestEventKind<'a> {

/// The number of tests currently running, including this one.
running: usize,

/// The command line that will be used to run this test.
command_line: String,
},

/// A test was slower than a configured soft timeout.
Expand Down
1 change: 1 addition & 0 deletions nextest-runner/src/reporter/imp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ impl ReporterBuilder {
failure_output: self.failure_output,
should_colorize: self.should_colorize,
no_capture: self.no_capture,
verbose: self.verbose,
show_progress: self.show_progress,
no_output_indent: self.no_output_indent,
max_progress_running: self.max_progress_running,
Expand Down
2 changes: 2 additions & 0 deletions nextest-runner/src/runner/dispatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,7 @@ where
InternalEvent::Executor(ExecutorEvent::Started {
stress_index,
test_instance,
command_line,
req_rx_tx,
}) => {
if self.run_stats.cancel_reason.is_some() {
Expand All @@ -678,6 +679,7 @@ where
test_instance,
current_stats: self.run_stats,
running: self.running_tests.len(),
command_line,
})
}
InternalEvent::Executor(ExecutorEvent::Slow {
Expand Down
14 changes: 14 additions & 0 deletions nextest-runner/src/runner/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,25 @@ impl<'a> ExecutorContext<'a> {

let (req_rx_tx, req_rx_rx) = oneshot::channel();

// Compute the command line for this test.
let ctx = TestExecuteContext {
profile_name: self.profile.name(),
double_spawn: &self.double_spawn,
target_runner: &self.target_runner,
};
let command_line = test.instance.command_line(
&ctx,
self.test_list,
settings.run_wrapper(),
settings.run_extra_args(),
);

// Wait for the Started event to be processed by the
// execution future.
_ = resp_tx.send(ExecutorEvent::Started {
stress_index,
test_instance: test.instance,
command_line,
req_rx_tx,
});
let mut req_rx = match req_rx_rx.await {
Expand Down
1 change: 1 addition & 0 deletions nextest-runner/src/runner/internal_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ pub(super) enum ExecutorEvent<'a> {
Started {
stress_index: Option<StressIndex>,
test_instance: TestInstance<'a>,
command_line: String,
// The channel over which to return the unit request.
//
// The callback context is solely responsible for coordinating the
Expand Down
Loading