From f681e46414e348d3723e437bca211e73a760a9f6 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 6 Oct 2021 12:27:05 -0500 Subject: [PATCH] test(derive): Port structopt flatten coverage https://github.com/TeXitoi/structopt/pull/414 was ported in a95195874 but the test was less exhaustive. This updates our test to match structopt's latest version of the test. This is a part of #2809 --- clap_derive/tests/flatten.rs | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/clap_derive/tests/flatten.rs b/clap_derive/tests/flatten.rs index f3af9656659..9a75a702102 100644 --- a/clap_derive/tests/flatten.rs +++ b/clap_derive/tests/flatten.rs @@ -155,21 +155,29 @@ fn update_subcommands_with_flatten() { #[test] fn flatten_with_doc_comment() { - #[derive(Clap, Debug)] - struct DaemonOpts { - #[clap(short)] - user: String, - #[clap(short)] - group: String, + #[derive(Clap, PartialEq, Debug)] + struct Common { + /// This is an arg. Arg means "argument". Command line argument. + arg: i32, } - #[derive(Clap, Debug)] - #[clap(name = "basic")] + #[derive(Clap, PartialEq, Debug)] struct Opt { - /// A very important doc comment I just can't leave out! + /// The very important comment that clippy had me put here. + /// It knows better. #[clap(flatten)] - opts: DaemonOpts, + common: Common, } + assert_eq!( + Opt { + common: Common { arg: 42 } + }, + Opt::parse_from(&["test", "42"]) + ); + + let help = utils::get_help::(); + assert!(help.contains("This is an arg.")); + assert!(!help.contains("The very important")); } #[test]