Skip to content

Commit

Permalink
cargo insta test cli: add --disable-nextest-doctest option
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
ilyagr committed Aug 6, 2024
1 parent 4fe546d commit 6b0add7
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cargo-insta/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ struct TestRunnerOptions {
/// Build for the target triple
#[arg(long)]
target: Option<String>,
/// 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)]
Expand Down Expand Up @@ -840,6 +843,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");
}
Expand Down

0 comments on commit 6b0add7

Please sign in to comment.