Skip to content

Commit 7de6df8

Browse files
committed
test(error): Show existing last behavior
1 parent b48c90f commit 7de6df8

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/builder/error.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,29 @@ For more information, try '--help'.
150150
assert_error(err, expected_kind, MESSAGE, true);
151151
}
152152

153+
#[test]
154+
#[cfg(feature = "error-context")]
155+
fn suggest_trailing_last() {
156+
let cmd = Command::new("cargo")
157+
.arg(arg!([TESTNAME]).last(true))
158+
.arg(arg!(--"ignore-rust-version"));
159+
160+
let res = cmd.try_get_matches_from(["cargo", "--ignored"]);
161+
assert!(res.is_err());
162+
let err = res.unwrap_err();
163+
let expected_kind = ErrorKind::UnknownArgument;
164+
static MESSAGE: &str = "\
165+
error: unexpected argument '--ignored' found
166+
167+
tip: a similar argument exists: '--ignore-rust-version'
168+
169+
Usage: cargo --ignore-rust-version [-- <TESTNAME>]
170+
171+
For more information, try '--help'.
172+
";
173+
assert_error(err, expected_kind, MESSAGE, true);
174+
}
175+
153176
#[test]
154177
#[cfg(feature = "error-context")]
155178
fn trailing_already_in_use() {

0 commit comments

Comments
 (0)