From 4522d01937163b9913ebb2cb711d39d1445d20aa Mon Sep 17 00:00:00 2001 From: Ilya Grigoriev Date: Sat, 3 Feb 2024 20:51:28 -0800 Subject: [PATCH 1/2] `cargo insta test` cli: add --disable-nextest-doctest option This adds an option to `cargo insta test` that prevents running doctests with `cargo test` when Nextest is the test runner, even if the given targets would ortherwise include doctests. I usually use `cargo insta test` with `--test-runner nextest --workspace` options. This always runs `cargo test --doc` after nextest is done, and this takes a bit of time. This is an annoyance for me. I think the project I work on might have a doctest or two, but they are not very relevant, so I'm happy to rely on CI to catch any doctest errors. I only have a vague understanding of `cargo test` options, but I have not found an existing set of test specifiers that's equivalent to `--workspace --no-doctests-pretty-please`. --- cargo-insta/src/cli.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cargo-insta/src/cli.rs b/cargo-insta/src/cli.rs index f493d0d3..22abbd7a 100644 --- a/cargo-insta/src/cli.rs +++ b/cargo-insta/src/cli.rs @@ -173,6 +173,9 @@ struct TestRunnerOptions { /// Build for the target triple #[arg(long)] target: Option, + /// Do not run `cargo test --doc` after `cargo nextest`, even if test specifiers would otherwise include doctests. + #[arg(long)] + disable_nextest_doctest: bool, } #[derive(Args, Debug)] @@ -1012,6 +1015,9 @@ fn prepare_test_runner<'snapshot_ref>( None }; let mut prevents_doc_run = false; + if cmd.disable_nextest_doctest { + prevents_doc_run = true; + } if cmd.target_args.all || cmd.target_args.workspace { proc.arg("--all"); } From ea5745d6efaaa86ca9b2ca80f310efd5b4a67e1e Mon Sep 17 00:00:00 2001 From: Ilya Grigoriev Date: Sat, 3 Feb 2024 21:37:56 -0800 Subject: [PATCH 2/2] cargo-insta --disable-nextest-doctest: Add `-N` short option I'm not sure how appropriate this is for general use, but it's convenient if, like me, you have a project where you use this all the time. --- cargo-insta/src/cli.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cargo-insta/src/cli.rs b/cargo-insta/src/cli.rs index 22abbd7a..4195b40d 100644 --- a/cargo-insta/src/cli.rs +++ b/cargo-insta/src/cli.rs @@ -174,7 +174,7 @@ struct TestRunnerOptions { #[arg(long)] target: Option, /// Do not run `cargo test --doc` after `cargo nextest`, even if test specifiers would otherwise include doctests. - #[arg(long)] + #[arg(long, short = 'N')] disable_nextest_doctest: bool, } @@ -1015,7 +1015,7 @@ fn prepare_test_runner<'snapshot_ref>( None }; let mut prevents_doc_run = false; - if cmd.disable_nextest_doctest { + if cmd.test_runner_options.disable_nextest_doctest { prevents_doc_run = true; } if cmd.target_args.all || cmd.target_args.workspace {