Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 90f6ad8

Browse files
max-sixtyMaximilian Roosclaude
authored
Fix backward compatibility for --test-runner-fallback true syntax (#816)
This is a small fix to PR #811 which introduced `--test-runner-fallback` and `--no-test-runner-fallback` flags. ## Issue The previous PR added `require_equals = true` to the clap argument configuration, which broke backward compatibility with the space syntax: - ❌ `--test-runner-fallback true` (broke in #811) - ✅ `--test-runner-fallback=true` (still worked) The old implementation accepted both syntaxes, so this was a regression. ## Fix Removed `require_equals = true` from the argument configuration to restore backward compatibility. This allows all syntaxes to work: **New ergonomic syntax:** - `--test-runner-fallback` (no value) - `--no-test-runner-fallback` **Backward compatible syntax:** - `--test-runner-fallback true` (with space) ✅ now fixed - `--test-runner-fallback=true` (with equals) - `--test-runner-fallback false` - `--test-runner-fallback=false` ## Testing - Added new test `test_runner_fallback_space_true` to cover the space syntax - All 7 test_runner_fallback tests pass ## Changes - Removed `require_equals = true` from `cargo-insta/src/cli.rs` - Added test for space syntax in `cargo-insta/tests/functional/test_runner_fallback.rs` 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Maximilian Roos <maximilian@Maximilians-MacBook-Pro.local> Co-authored-by: Claude <noreply@anthropic.com>
1 parent 00f6816 commit 90f6ad8

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

‎cargo-insta/src/cli.rs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,6 @@ struct TestCommand {
222222
long = "test-runner-fallback",
223223
num_args(0..=1),
224224
default_missing_value = "true",
225-
require_equals = true,
226225
overrides_with = "_no_test_runner_fallback"
227226
)]
228227
test_runner_fallback: Option<bool>,

‎cargo-insta/tests/functional/test_runner_fallback.rs‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,37 @@ fn test_snapshot() {
9494
);
9595
}
9696

97+
/// Test that --test-runner-fallback true (with space) enables fallback (backward compatibility)
98+
#[test]
99+
fn test_runner_fallback_space_true() {
100+
let test_project = TestFiles::new()
101+
.add_cargo_toml("test_runner_fallback_space_true")
102+
.add_file(
103+
"src/lib.rs",
104+
r#"
105+
#[test]
106+
fn test_snapshot() {
107+
insta::assert_snapshot!("value", @"value");
108+
}
109+
"#
110+
.to_string(),
111+
)
112+
.create_project();
113+
114+
// Run with --test-runner-fallback true (space syntax, backward compatibility)
115+
let output = test_project
116+
.insta_cmd()
117+
.args(["test", "--test-runner-fallback", "true"])
118+
.output()
119+
.unwrap();
120+
121+
assert!(
122+
output.status.success(),
123+
"Test should succeed with --test-runner-fallback true\nstderr: {}",
124+
String::from_utf8_lossy(&output.stderr)
125+
);
126+
}
127+
97128
/// Test that --no-test-runner-fallback disables fallback
98129
#[test]
99130
fn test_no_test_runner_fallback_flag() {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /