Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(derive): Port structopt flatten coverage #2821

Merged
merged 1 commit into from
Oct 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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