From 1ea5a033f540a37a377205e2d086d74b894b191a Mon Sep 17 00:00:00 2001 From: Ilya Grigoriev Date: Sat, 3 Feb 2024 20:51:28 -0800 Subject: [PATCH] `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 2a308f23..4be924eb 100644 --- a/cargo-insta/src/cli.rs +++ b/cargo-insta/src/cli.rs @@ -168,6 +168,9 @@ struct TestCommand { /// Build for the target triple #[structopt(long)] target: Option, + /// Do not run `cargo test --doc` after `cargo nextest`, even if test specifiers would otherwise include doctests. + #[structopt(long)] + disable_nextest_doctest: bool, /// Follow up with review. #[structopt(long)] review: bool, @@ -825,6 +828,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"); }