One character aliases for cargo-miri run/test

The main `cargo` command supports `cargo r` as an alias for
`cargo run`, and `cargo t` as an alias for `cargo test`. This adds
support to them in cargo-miri for consistency.
This commit is contained in:
Smitty 2021-09-11 12:00:59 -04:00
parent 0359331869
commit 5aecd2811e
2 changed files with 14 additions and 4 deletions

View file

@ -20,8 +20,8 @@ Usage:
cargo miri [subcommand] [<cargo options>...] [--] [<program/test suite options>...]
Subcommands:
run Run binaries
test Run tests
run, r Run binaries
test, t Run tests
setup Only perform automatic setup, but without asking questions (for getting a proper libstd)
The cargo options are exactly the same as for `cargo run` and `cargo test`, respectively.
@ -524,8 +524,8 @@ fn phase_cargo_miri(mut args: env::Args) {
// We cannot know which of those flags take arguments and which do not,
// so we cannot detect subcommands later.
let subcommand = match args.next().as_deref() {
Some("test") => MiriCommand::Test,
Some("run") => MiriCommand::Run,
Some("test" | "t") => MiriCommand::Test,
Some("run" | "r") => MiriCommand::Run,
Some("setup") => MiriCommand::Setup,
// Invalid command.
_ =>

View file

@ -102,6 +102,11 @@ def test_cargo_miri_run():
"run.subcrate.stdout.ref", "run.subcrate.stderr.ref",
env={'MIRIFLAGS': "-Zmiri-disable-isolation"},
)
test("`cargo miri r` (subcrate, no ioslation)",
cargo_miri("r") + ["-p", "subcrate"],
"run.subcrate.stdout.ref", "run.subcrate.stderr.ref",
env={'MIRIFLAGS': "-Zmiri-disable-isolation"},
)
test("`cargo miri run` (custom target dir)",
# Attempt to confuse the argument parser.
cargo_miri("run") + ["--target-dir=custom-run", "--", "--target-dir=target/custom-run"],
@ -146,6 +151,11 @@ def test_cargo_miri_test():
"test.subcrate.stdout.ref", "test.stderr-proc-macro.ref",
env={'MIRIFLAGS': "-Zmiri-disable-isolation"},
)
test("`cargo miri t` (subcrate, no isolation)",
cargo_miri("t") + ["-p", "subcrate"],
"test.subcrate.stdout.ref", "test.stderr-proc-macro.ref",
env={'MIRIFLAGS': "-Zmiri-disable-isolation"},
)
test("`cargo miri test` (subcrate, doctests)",
cargo_miri("test") + ["-p", "subcrate", "--doc"],
"test.stdout-empty.ref", "test.stderr-proc-macro-doctest.ref",