Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions tests/builder/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,32 @@ For more information, try '--help'.
assert_error(err, expected_kind, message, true);
}

#[test]
#[cfg(feature = "error-context")]
fn flag_used_after_double_dash() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C-TEST says that this should be reproducing the undesired behavior and then the follow up commit should update the test for the new behavior.

let cmd = Command::new("app").arg(
Arg::new("dev")
.long("dev")
.action(ArgAction::SetTrue),
);

let res = cmd.try_get_matches_from(["app", "--", "--dev"]);
assert!(res.is_err());
let err = res.unwrap_err();
let expected_kind = ErrorKind::UnknownArgument;
let message = str![[r#"
error: unexpected argument '--dev' found

tip: flag '--dev' exists; to use it, remove the '--' before it

Usage: app [OPTIONS]

For more information, try '--help'.

"#]];
assert_error(err, expected_kind, message, true);
}

#[test]
#[cfg(feature = "error-context")]
#[cfg(feature = "suggestions")]
Expand Down