Skip to content

Commit 52aad0e

Browse files
committed
test(asserts): Add test for self requires
Add a test that shows that clap doesn't complain when a flag requires itself. This test demonstrates existing broken behavior, ideally it should panic. It will be fixed in the next commit. Signed-off-by: Omer Tuchfeld <[email protected]>
1 parent bfca193 commit 52aad0e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

tests/builder/require.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1478,3 +1478,12 @@ For more information, try '--help'.
14781478
";
14791479
utils::assert_output(cmd, "test --require-first --second", EXPECTED, true);
14801480
}
1481+
1482+
#[test]
1483+
/// This test demonstrates existing broken behavior, ideally it should panic
1484+
fn requires_self() {
1485+
let result = Command::new("flag_required")
1486+
.arg(arg!(-f --flag "some flag").requires("flag"))
1487+
.try_get_matches_from(vec![""]);
1488+
assert!(result.is_ok());
1489+
}

0 commit comments

Comments
 (0)