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 --doctest` after
nextest is done.  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 Feb 4, 2024
1 parent 181dfaf commit db5982f
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 @@ -168,6 +168,9 @@ struct TestCommand {
/// Build for the target triple
#[structopt(long)]
target: Option<String>,
/// 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,
Expand Down Expand Up @@ -818,6 +821,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 db5982f

Please sign in to comment.