Skip to content

Commit

Permalink
Add support for multiple --features options
Browse files Browse the repository at this point in the history
  • Loading branch information
Wesley Van Melle committed Jul 1, 2019
1 parent 83d086d commit 51c26b6
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/cargo/util/command_prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
57 changes: 57 additions & 0 deletions tests/testsuite/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

0 comments on commit 51c26b6

Please sign in to comment.