Skip to content

Commit 0942303

Browse files
committed
More helpful error for invalid cargo-features = [] tests
1 parent d507fbe commit 0942303

File tree

1 file changed

+66
-1
lines changed

1 file changed

+66
-1
lines changed

tests/testsuite/cargo_features.rs

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,72 @@ fn unknown_feature() {
173173
[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml`
174174
175175
Caused by:
176-
unknown cargo feature `foo`
176+
unknown Cargo.toml feature `foo`
177+
178+
See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html for more information.
179+
180+
"#]])
181+
.run();
182+
}
183+
184+
#[cargo_test]
185+
fn wrong_kind_of_feature() {
186+
let p = project()
187+
.file(
188+
"Cargo.toml",
189+
r#"
190+
cargo-features = ["build-dir"]
191+
192+
[package]
193+
name = "a"
194+
version = "0.0.1"
195+
edition = "2015"
196+
authors = []
197+
"#,
198+
)
199+
.file("src/lib.rs", "")
200+
.build();
201+
p.cargo("check")
202+
.with_status(101)
203+
.with_stderr_data(str![[r#"
204+
[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml`
205+
206+
Caused by:
207+
unknown Cargo.toml feature `build-dir`
208+
209+
This feature can be enabled via -Zbuild-dir or the `[unstable]` section in config.toml.
210+
See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html for more information.
211+
212+
"#]])
213+
.run();
214+
}
215+
216+
#[cargo_test]
217+
fn feature_syntax() {
218+
let p = project()
219+
.file(
220+
"Cargo.toml",
221+
r#"
222+
cargo-features = ["bad_feature"]
223+
224+
[package]
225+
name = "a"
226+
version = "0.0.1"
227+
edition = "2015"
228+
authors = []
229+
"#,
230+
)
231+
.file("src/lib.rs", "")
232+
.build();
233+
p.cargo("check")
234+
.with_status(101)
235+
.with_stderr_data(str![[r#"
236+
[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml`
237+
238+
Caused by:
239+
unknown Cargo.toml feature `bad_feature`
240+
241+
Feature names must use '-' instead of '_'.
177242
178243
"#]])
179244
.run();

0 commit comments

Comments
 (0)