Skip to content

Conversation

@max-sixty
Copy link
Collaborator

Summary

  • Adds a --disable-nextest-doctest flag to disable running separate doctests when using nextest
  • Shows a deprecation warning when nextest is used with doctests, informing users that insta won't run a separate doctest process when using nextest in the future
  • Users can pass --disable-nextest-doctest to opt into the new behavior now and silence the warning

Changes

  1. Added --disable-nextest-doctest flag to TestCommand struct
  2. Added has_doctests() function that checks if any packages contain doctests by scanning for /// ```` or //! ```` patterns in source files
  3. Added deprecation warning that appears when:
    • Using nextest test runner
    • Doctests are present in the codebase
    • The --disable-nextest-doctest flag is not set
  4. Added comprehensive functional tests covering all scenarios:
    • Warning appears with nextest when doctests exist
    • Warning is suppressed with the flag
    • No warning when no doctests exist
    • No warning with cargo-test runner

Test Plan

✅ All existing tests pass
✅ Added 4 new functional tests that verify the behavior
✅ Manually tested with cargo run --package cargo-insta -- test --test-runner nextest
✅ Code passes clippy and rustfmt checks

🤖 Generated with Claude Code

max-sixty and others added 3 commits September 9, 2025 10:57
This change adds a deprecation warning when using nextest with doctests,
as insta won't run a separate doctest process when using nextest in the
future. Users can pass --disable-nextest-doctest to opt into the new
behavior now and silence the warning.

Changes:
- Add --disable-nextest-doctest flag to skip doctest execution with nextest
- Add has_doctests() function to detect if packages contain doctests
- Show warning when nextest is used with doctests present
- Add comprehensive functional tests for the new behavior

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Add nextest installation to test jobs that run cargo-insta tests.
This ensures the new nextest doctest tests can run successfully in CI.

Uses taiki-e/install-action@nextest for efficient installation.
@max-sixty max-sixty merged commit 0d79fa9 into mitsuhiko:master Sep 9, 2025
15 checks passed
@max-sixty max-sixty deleted the doctest-warning branch September 9, 2025 19:35
@max-sixty max-sixty mentioned this pull request Nov 20, 2025
max-sixty added a commit that referenced this pull request Nov 20, 2025
## Summary

Prepare for the 1.44.0 release:

- Bump version to 1.44.0 in `insta/Cargo.toml` and
`cargo-insta/Cargo.toml`
- Update CHANGELOG.md with all changes since 1.43.2

## Changes in 1.44.0

- Added non-interactive snapshot review and reject modes for use in
non-TTY environments (LLMs, CI pipelines, scripts) #815
- Add `--disable-nextest-doctest` flag with deprecation warning #803
- Add ergonomic `--test-runner-fallback` / `--no-test-runner-fallback`
flags #811
- Apply redactions to snapshot metadata #813
- Remove confusing 'previously unseen snapshot' message #812
- Speed up JSON float rendering #806 (@nyurik)
- Allow globset version up to 0.4.16 #810 (@g0hl1n)
- Improve documentation #814 (@tshepang)
- Enforce starting newlines in assertions #563

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <noreply@anthropic.com>
@ilyagr
Copy link

ilyagr commented Nov 20, 2025

It seems like people will pass this flag often to avoid the deprecation warning. Perhaps give it a short versin, e.g. -D?

@max-sixty
Copy link
Collaborator Author

yes OK! --dnd or you prefer -D?

@ilyagr
Copy link

ilyagr commented Nov 20, 2025

I like -D but --dnd is also ok. It's temporary anyway.

max-sixty added a commit that referenced this pull request Nov 20, 2025
## Summary

Adds a shorter `--dnd` alias for the `--disable-nextest-doctest` flag to
make it easier to silence the deprecation warning during the transition
period.

This addresses the request from @ilyagr in #803:
> It seems like people will pass this flag often to avoid the
deprecation warning. Perhaps give it a short version, e.g. `-D`?

After discussion, we agreed on `--dnd` as the alias.

## Changes

- Add `alias = "dnd"` to the `disable_nextest_doctest` CLI argument
- Update deprecation warning message to mention the `--dnd` alias: `Pass
'--disable-nextest-doctest' (or '--dnd') to update to this behavior now
and silence this warning.`
- Add test `test_nextest_doctest_dnd_alias_no_warning()` to verify the
alias works correctly

## Test plan

- [x] All existing tests pass (5/5 in nextest_doctest module)
- [x] New test verifies `--dnd` alias works correctly
- [x] Lints pass (cargo fmt, cargo clippy)
- [x] Manual verification: `cargo insta test --test-runner nextest
--dnd` works as expected

## Usage

Both forms work identically:
```bash
cargo insta test --test-runner nextest --disable-nextest-doctest
cargo insta test --test-runner nextest --dnd
```

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants