Skip to content

Commit 10ff047

Browse files
committed
[cargo-miri] support nextest
Add the ability to run the `list` and `run` nextest commands, which enable per-test isolation.
1 parent 1366bf6 commit 10ff047

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

cargo-miri/bin.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Usage:
2727
Subcommands:
2828
run, r Run binaries
2929
test, t Run tests
30+
nextest Run tests with nextest (requires cargo-nextest installed)
3031
setup Only perform automatic setup, but without asking questions (for getting a proper libstd)
3132
3233
The cargo options are exactly the same as for `cargo run` and `cargo test`, respectively.
@@ -40,8 +41,8 @@ Examples:
4041
enum MiriCommand {
4142
/// Our own special 'setup' command.
4243
Setup,
43-
/// A command to be forwarded to cargo.
44-
Forward(String),
44+
/// A command (+ possible initial arguments) to be forwarded to cargo.
45+
Forward(Vec<String>),
4546
}
4647

4748
/// The information to run a crate with the given environment.
@@ -586,11 +587,19 @@ fn phase_cargo_miri(mut args: env::Args) {
586587
};
587588
let subcommand = match &*subcommand {
588589
"setup" => MiriCommand::Setup,
589-
"test" | "t" | "run" | "r" => MiriCommand::Forward(subcommand),
590+
"test" | "t" | "run" | "r" => MiriCommand::Forward(vec![subcommand]),
591+
"nextest" => {
592+
// nextest requires a subcommand (e.g. nextest run) to be specified before --target, so
593+
// grab the next argument.
594+
let Some(subcommand2) = args.next() else {
595+
show_error(format!("`cargo miri {subcommand}` must have a subcommand as its next command"));
596+
};
597+
MiriCommand::Forward(vec![subcommand, subcommand2])
598+
}
590599
// Invalid command.
591600
_ =>
592601
show_error(format!(
593-
"`cargo miri` supports the following subcommands: `run`, `test`, and `setup`."
602+
"`cargo miri` supports the following subcommands: `run`, `test`, `nextest`, and `setup`."
594603
)),
595604
};
596605
let verbose = num_arg_flag("-v");
@@ -610,7 +619,7 @@ fn phase_cargo_miri(mut args: env::Args) {
610619
MiriCommand::Setup => return, // `cargo miri setup` stops here.
611620
};
612621
let mut cmd = cargo();
613-
cmd.arg(cargo_cmd);
622+
cmd.args(cargo_cmd);
614623

615624
// Make sure we know the build target, and cargo does, too.
616625
// This is needed to make the `CARGO_TARGET_*_RUNNER` env var do something,

0 commit comments

Comments
 (0)