From 51c26b6776bc059da97433a98cef786f88bdbafb Mon Sep 17 00:00:00 2001 From: Wesley Van Melle Date: Mon, 1 Jul 2019 14:44:06 -0700 Subject: [PATCH] Add support for multiple --features options --- src/cargo/util/command_prelude.rs | 4 ++- tests/testsuite/features.rs | 57 +++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) diff --git a/src/cargo/util/command_prelude.rs b/src/cargo/util/command_prelude.rs index b8f208ea3e3..78178442688 100644 --- a/src/cargo/util/command_prelude.rs +++ b/src/cargo/util/command_prelude.rs @@ -100,7 +100,9 @@ pub trait AppExt: Sized { fn arg_features(self) -> Self { self._arg( - opt("features", "Space-separated list of features to activate").value_name("FEATURES"), + opt("features", "Space-separated list of features to activate") + .multiple(true) + .value_name("FEATURES"), ) ._arg(opt("all-features", "Activate all available features")) ._arg(opt( diff --git a/tests/testsuite/features.rs b/tests/testsuite/features.rs index 9c2c3aae9bf..c7fbc74a104 100644 --- a/tests/testsuite/features.rs +++ b/tests/testsuite/features.rs @@ -1911,3 +1911,60 @@ fn no_feature_for_non_optional_dep() { p.cargo("build --features bar/a").run(); } + +#[cargo_test] +fn features_option_given_twice() { + let p = project() + .file( + "Cargo.toml", + r#" + [project] + name = "foo" + version = "0.0.1" + authors = [] + + [features] + a = [] + b = [] + "#, + ) + .file( + "src/main.rs", + r#" + #[cfg(all(feature = "a", feature = "b"))] + fn main() {} + "#, + ) + .build(); + + p.cargo("build --features a --features b").run(); +} + +#[cargo_test] +fn multi_multi_features() { + let p = project() + .file( + "Cargo.toml", + r#" + [project] + name = "foo" + version = "0.0.1" + authors = [] + + [features] + a = [] + b = [] + c = [] + "#, + ) + .file( + "src/main.rs", + r#" + #[cfg(all(feature = "a", feature = "b", feature = "c"))] + fn main() {} + "#, + ) + .build(); + + p.cargo("build --features a --features").arg("b c").run(); +}