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
64 changes: 43 additions & 21 deletions nextest-runner/src/list/test_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1133,32 +1133,14 @@ impl<'a> TestInstance<'a> {
/// Creates the command for this test instance.
pub(crate) fn make_command(
&self,
ctx: &TestExecuteContext<'_>,
ctx: &'a TestExecuteContext<'a>,
test_list: &TestList<'_>,
wrapper_script: Option<&'a WrapperScriptConfig>,
extra_args: &[String],
extra_args: &'a [String],
interceptor: &Interceptor,
) -> TestCommand {
// TODO: non-rust tests

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));
let cli = self.compute_cli(ctx, test_list, wrapper_script, extra_args);

let lctx = LocalExecuteContext {
phase: TestCommandPhase::Run,
Expand All @@ -1182,6 +1164,46 @@ impl<'a> TestInstance<'a> {
interceptor,
)
}

pub(crate) fn command_line(
&self,
ctx: &'a TestExecuteContext<'a>,
test_list: &TestList<'_>,
wrapper_script: Option<&'a WrapperScriptConfig>,
extra_args: &'a [String],
) -> Vec<String> {
self.compute_cli(ctx, test_list, wrapper_script, extra_args)
.to_owned_cli()
}

fn compute_cli(
&self,
ctx: &'a TestExecuteContext<'a>,
test_list: &TestList<'_>,
wrapper_script: Option<&'a WrapperScriptConfig>,
extra_args: &'a [String],
) -> TestCommandCli<'a> {
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));

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),
shell_words::join(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: Vec<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
23 changes: 18 additions & 5 deletions nextest-runner/src/runner/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ impl<'a> ExecutorContext<'a> {
}
}

fn test_execute_context(&self) -> TestExecuteContext<'_> {
TestExecuteContext {
profile_name: self.profile.name(),
double_spawn: &self.double_spawn,
target_runner: &self.target_runner,
}
}

/// Run scripts, returning data about each successfully executed script.
pub(super) async fn run_setup_scripts(
&self,
Expand Down Expand Up @@ -210,11 +218,20 @@ impl<'a> ExecutorContext<'a> {

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

let ctx = self.test_execute_context();
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 Expand Up @@ -664,11 +681,7 @@ impl<'a> ExecutorContext<'a> {
resp_tx: &UnboundedSender<ExecutorEvent<'a>>,
req_rx: &mut UnboundedReceiver<RunUnitRequest<'a>>,
) -> Result<InternalExecuteStatus<'a>, ChildStartError> {
let ctx = TestExecuteContext {
profile_name: self.profile.name(),
double_spawn: &self.double_spawn,
target_runner: &self.target_runner,
};
let ctx = self.test_execute_context();
let mut cmd = test.test_instance.make_command(
&ctx,
self.test_list,
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: Vec<String>,
// The channel over which to return the unit request.
//
// The callback context is solely responsible for coordinating the
Expand Down
Loading