Skip to content

Commit 6f8d18a

Browse files
max-sixtyclaude
andcommitted
Add --dnd alias for --disable-nextest-doctest flag (mitsuhiko#822)
## 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 mitsuhiko#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>
1 parent 1061c1c commit 6f8d18a

File tree

2 files changed

+46
-3
lines changed

2 files changed

+46
-3
lines changed

cargo-insta/src/cli.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ struct TestCommand {
238238
#[arg(long, hide = true)]
239239
no_force_pass: bool,
240240
/// Disable running doctests when using nextest test runner
241-
#[arg(long)]
241+
#[arg(long, alias = "dnd")]
242242
disable_nextest_doctest: bool,
243243
#[command(flatten)]
244244
target_args: TargetArgs,
@@ -897,7 +897,7 @@ fn test_run(mut cmd: TestCommand, color: ColorWhen) -> Result<(), Box<dyn Error>
897897
if has_doctests(&loc.packages) {
898898
eprintln!(
899899
"{}: insta won't run a separate doctest process when using nextest in the future. \
900-
Pass `--disable-nextest-doctest` to update to this behavior now and silence this warning.",
900+
Pass `--disable-nextest-doctest` (or `--dnd`) to update to this behavior now and silence this warning.",
901901
style("warning").bold().yellow()
902902
);
903903
}

cargo-insta/tests/functional/nextest_doctest.rs

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ fn test_simple() {
4646
"Expected warning message not found in stderr:\n{stderr}"
4747
);
4848
assert!(
49-
stderr.contains("Pass `--disable-nextest-doctest` to update to this behavior now and silence this warning"),
49+
stderr.contains("Pass `--disable-nextest-doctest` (or `--dnd`) to update to this behavior now and silence this warning"),
5050
"Expected flag suggestion not found in stderr:\n{stderr}"
5151
);
5252
}
@@ -181,3 +181,46 @@ fn test_simple() {
181181
"Warning should not appear with cargo-test runner:\n{stderr}"
182182
);
183183
}
184+
185+
/// Test that nextest with --dnd alias doesn't show warning
186+
#[test]
187+
fn test_nextest_doctest_dnd_alias_no_warning() {
188+
let test_project = TestFiles::new()
189+
.add_cargo_toml("test_nextest_doctest_dnd_alias")
190+
.add_file(
191+
"src/lib.rs",
192+
r#"
193+
/// This is a function with a doctest
194+
///
195+
/// ```
196+
/// assert_eq!(test_nextest_doctest_dnd_alias::add(2, 2), 4);
197+
/// ```
198+
pub fn add(a: i32, b: i32) -> i32 {
199+
a + b
200+
}
201+
202+
#[test]
203+
fn test_simple() {
204+
insta::assert_snapshot!("test_value", @"test_value");
205+
}
206+
"#
207+
.to_string(),
208+
)
209+
.create_project();
210+
211+
// Run with nextest and the --dnd alias, capture stderr to verify no warning
212+
let output = test_project
213+
.insta_cmd()
214+
.args(["test", "--test-runner", "nextest", "--dnd", "--accept"])
215+
.stderr(Stdio::piped())
216+
.output()
217+
.unwrap();
218+
219+
assert!(output.status.success());
220+
221+
let stderr = String::from_utf8_lossy(&output.stderr);
222+
assert!(
223+
!stderr.contains("warning: insta won't run a separate doctest process"),
224+
"Warning message should not appear when --dnd alias is used:\n{stderr}"
225+
);
226+
}

0 commit comments

Comments
 (0)