Skip to content

Commit

Permalink
test(derive): Port structopt flatten coverage
Browse files Browse the repository at this point in the history
TeXitoi/structopt#414 was ported in
a951958 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
  • Loading branch information
epage committed Oct 6, 2021
1 parent 5512c90 commit 6e381f2
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions clap_derive/tests/flatten.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Opt>();
assert!(help.contains("This is an arg."));
assert!(!help.contains("The very important"));
}

#[test]
Expand Down

0 comments on commit 6e381f2

Please sign in to comment.