Upgrade rust/crates/structopt to 0.3.18
Test: make
Change-Id: Ib5d515b0f5e9ac7fdd0f2f8e2f00ecf54dbf63ca
diff --git a/tests/argument_naming.rs b/tests/argument_naming.rs
index e7fe3d5..88b549d 100644
--- a/tests/argument_naming.rs
+++ b/tests/argument_naming.rs
@@ -309,3 +309,31 @@
Opt::from_clap(&Opt::clap().get_matches_from(&["test", "SECOND_VARIANT", "--foo-option"]))
);
}
+
+#[test]
+fn test_lower_is_renamed() {
+ #[derive(StructOpt, Debug, PartialEq)]
+ struct Opt {
+ #[structopt(rename_all = "lower", long)]
+ foo_option: bool,
+ }
+
+ assert_eq!(
+ Opt { foo_option: true },
+ Opt::from_clap(&Opt::clap().get_matches_from(&["test", "--foooption"]))
+ );
+}
+
+#[test]
+fn test_upper_is_renamed() {
+ #[derive(StructOpt, Debug, PartialEq)]
+ struct Opt {
+ #[structopt(rename_all = "upper", long)]
+ foo_option: bool,
+ }
+
+ assert_eq!(
+ Opt { foo_option: true },
+ Opt::from_clap(&Opt::clap().get_matches_from(&["test", "--FOOOPTION"]))
+ );
+}
diff --git a/tests/flatten.rs b/tests/flatten.rs
index f01e44e..05de185 100644
--- a/tests/flatten.rs
+++ b/tests/flatten.rs
@@ -8,6 +8,8 @@
use structopt::StructOpt;
+mod utils;
+
#[test]
fn flatten() {
#[derive(StructOpt, PartialEq, Debug)]
@@ -127,3 +129,54 @@
Opt::from_iter(&["test", "command2", "43"])
);
}
+
+#[test]
+#[should_panic = "structopt misuse: You likely tried to #[flatten] a struct \
+ that contains #[subcommand]. This is forbidden."]
+fn subcommand_in_flatten() {
+ #[derive(Debug, StructOpt)]
+ pub enum Struct1 {
+ #[structopt(flatten)]
+ Struct1(Struct2),
+ }
+
+ #[derive(Debug, StructOpt)]
+ pub struct Struct2 {
+ #[structopt(subcommand)]
+ command_type: Enum3,
+ }
+
+ #[derive(Debug, StructOpt)]
+ pub enum Enum3 {
+ Command { args: Vec<String> },
+ }
+
+ Struct1::from_iter(&["test", "command", "foo"]);
+}
+
+#[test]
+fn flatten_doc_comment() {
+ #[derive(StructOpt, PartialEq, Debug)]
+ struct Common {
+ /// This is an arg. Arg means "argument". Command line argument.
+ arg: i32,
+ }
+
+ #[derive(StructOpt, PartialEq, Debug)]
+ struct Opt {
+ /// The very important comment that clippy had me put here.
+ /// It knows better.
+ #[structopt(flatten)]
+ common: Common,
+ }
+ assert_eq!(
+ Opt {
+ common: Common { arg: 42 }
+ },
+ Opt::from_iter(&["test", "42"])
+ );
+
+ let help = utils::get_help::<Opt>();
+ assert!(help.contains("This is an arg."));
+ assert!(!help.contains("The very important"));
+}
diff --git a/tests/macro-errors.rs b/tests/macro-errors.rs
index ae4f5a2..54b405a 100644
--- a/tests/macro-errors.rs
+++ b/tests/macro-errors.rs
@@ -5,7 +5,7 @@
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
-#[rustversion::attr(any(not(stable), before(1.39)), ignore)]
+#[rustversion::attr(any(not(stable), before(1.43)), ignore)]
#[test]
fn ui() {
let t = trybuild::TestCases::new();
diff --git a/tests/ui/flatten_and_doc.rs b/tests/ui/flatten_and_doc.rs
deleted file mode 100644
index 2dc154d..0000000
--- a/tests/ui/flatten_and_doc.rs
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use structopt::StructOpt;
-
-#[derive(StructOpt, Debug)]
-struct DaemonOpts {
- #[structopt(short)]
- user: String,
- #[structopt(short)]
- group: String,
-}
-
-#[derive(StructOpt, Debug)]
-#[structopt(name = "basic")]
-struct Opt {
- /// Opts.
- #[structopt(flatten)]
- opts: DaemonOpts,
-}
-
-fn main() {
- let opt = Opt::from_args();
- println!("{:?}", opt);
-}
diff --git a/tests/ui/flatten_and_doc.stderr b/tests/ui/flatten_and_doc.stderr
deleted file mode 100644
index 2724dbb..0000000
--- a/tests/ui/flatten_and_doc.stderr
+++ /dev/null
@@ -1,5 +0,0 @@
-error: methods and doc comments are not allowed for flattened entry
- --> $DIR/flatten_and_doc.rs:23:17
- |
-23 | #[structopt(flatten)]
- | ^^^^^^^
diff --git a/tests/ui/flatten_and_methods.stderr b/tests/ui/flatten_and_methods.stderr
index f058eb3..77d97ae 100644
--- a/tests/ui/flatten_and_methods.stderr
+++ b/tests/ui/flatten_and_methods.stderr
@@ -1,4 +1,4 @@
-error: methods and doc comments are not allowed for flattened entry
+error: methods are not allowed for flattened entry
--> $DIR/flatten_and_methods.rs:22:24
|
22 | #[structopt(short, flatten)]
diff --git a/tests/ui/non_existent_attr.stderr b/tests/ui/non_existent_attr.stderr
index 99dc781..e5edb56 100644
--- a/tests/ui/non_existent_attr.stderr
+++ b/tests/ui/non_existent_attr.stderr
@@ -1,5 +1,5 @@
-error[E0599]: no method named `non_existing_attribute` found for struct `clap::args::arg::Arg<'_, '_>` in the current scope
+error[E0599]: no method named `non_existing_attribute` found for struct `structopt::clap::Arg<'_, '_>` in the current scope
--> $DIR/non_existent_attr.rs:14:24
|
14 | #[structopt(short, non_existing_attribute = 1)]
- | ^^^^^^^^^^^^^^^^^^^^^^ method not found in `clap::args::arg::Arg<'_, '_>`
+ | ^^^^^^^^^^^^^^^^^^^^^^ method not found in `structopt::clap::Arg<'_, '_>`
diff --git a/tests/ui/tuple_struct.stderr b/tests/ui/tuple_struct.stderr
index 9f2876f..31705c9 100644
--- a/tests/ui/tuple_struct.stderr
+++ b/tests/ui/tuple_struct.stderr
@@ -3,3 +3,5 @@
|
11 | #[derive(StructOpt, Debug)]
| ^^^^^^^^^
+ |
+ = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)