Skip to content

Commit 51c26b6

Browse files
author
Wesley Van Melle
committed
Add support for multiple --features options
1 parent 83d086d commit 51c26b6

File tree

2 files changed

+60
-1
lines changed

2 files changed

+60
-1
lines changed

src/cargo/util/command_prelude.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ pub trait AppExt: Sized {
100100

101101
fn arg_features(self) -> Self {
102102
self._arg(
103-
opt("features", "Space-separated list of features to activate").value_name("FEATURES"),
103+
opt("features", "Space-separated list of features to activate")
104+
.multiple(true)
105+
.value_name("FEATURES"),
104106
)
105107
._arg(opt("all-features", "Activate all available features"))
106108
._arg(opt(

tests/testsuite/features.rs

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1911,3 +1911,60 @@ fn no_feature_for_non_optional_dep() {
19111911

19121912
p.cargo("build --features bar/a").run();
19131913
}
1914+
1915+
#[cargo_test]
1916+
fn features_option_given_twice() {
1917+
let p = project()
1918+
.file(
1919+
"Cargo.toml",
1920+
r#"
1921+
[project]
1922+
name = "foo"
1923+
version = "0.0.1"
1924+
authors = []
1925+
1926+
[features]
1927+
a = []
1928+
b = []
1929+
"#,
1930+
)
1931+
.file(
1932+
"src/main.rs",
1933+
r#"
1934+
#[cfg(all(feature = "a", feature = "b"))]
1935+
fn main() {}
1936+
"#,
1937+
)
1938+
.build();
1939+
1940+
p.cargo("build --features a --features b").run();
1941+
}
1942+
1943+
#[cargo_test]
1944+
fn multi_multi_features() {
1945+
let p = project()
1946+
.file(
1947+
"Cargo.toml",
1948+
r#"
1949+
[project]
1950+
name = "foo"
1951+
version = "0.0.1"
1952+
authors = []
1953+
1954+
[features]
1955+
a = []
1956+
b = []
1957+
c = []
1958+
"#,
1959+
)
1960+
.file(
1961+
"src/main.rs",
1962+
r#"
1963+
#[cfg(all(feature = "a", feature = "b", feature = "c"))]
1964+
fn main() {}
1965+
"#,
1966+
)
1967+
.build();
1968+
1969+
p.cargo("build --features a --features").arg("b c").run();
1970+
}

0 commit comments

Comments
 (0)