nextest icon indicating copy to clipboard operation
nextest copied to clipboard

Provide a hint to use `cargo nextest run` if no command is specified

Open leighmcculloch opened this issue 2 years ago • 5 comments

For the most part cargo nextest is interchangeable with cargo test, but not when swapping one out for the other with cargo-hack.

For example, the following error is seen when invoking cargo-nextest via cargo-hack:

$ cargo hack --feature-powerset nextest
info: running `cargo nextest --no-default-features` on soroban-sdk (1/22)
error: Found argument '--no-default-features' which wasn't expected, or isn't valid in this context

        If you tried to supply `--no-default-features` as a value rather than a flag, use `-- --no-default-features`

USAGE:
    cargo nextest --manifest-path <PATH>

For more information try --help
error: process didn't exit successfully: `/Users/leighmcculloch/.rustup/toolchains/stable-aarch64-apple-darwin/bin/cargo nextest --manifest-path soroban-sdk/Cargo.toml --no-default-features` (exit status: 2)

Ideally the behavior of cargo-nextest for handling argument would be identical to cargo test so that nextest can be used in all the places that cargo test is used.

leighmcculloch avatar Aug 08 '22 18:08 leighmcculloch

These are simpler commands that demonstrate the difference in behavior:

$ cargo nextest --no-default-features
error: Found argument '--no-default-features' which wasn't expected, or isn't valid in this context

        If you tried to supply `--no-default-features` as a value rather than a flag, use `-- --no-default-features`

USAGE:
    cargo nextest [OPTIONS] <SUBCOMMAND>

For more information try --help
$ cargo test --no-default-features
...

leighmcculloch avatar Aug 08 '22 18:08 leighmcculloch

Ugh, sorry, I forgot to include the run subcommand to nextest. This all works fine if I use cargo nextest run.

leighmcculloch avatar Aug 08 '22 18:08 leighmcculloch

I think we should provide a hint for this -- this seems to be a common issue. Reopening for that.

sunshowers avatar Aug 09 '22 18:08 sunshowers

It might be reasonable to default to run when no sub-command is provided rather than defaulting to an error or help message.

leighmcculloch avatar Aug 09 '22 19:08 leighmcculloch

Down that way lies a lot of pain, e.g. what happens if you want to filter based on tests called "run" or "list". In general nextest tends to prefer teaching users instead of automatically correcting them.

sunshowers avatar Aug 09 '22 19:08 sunshowers