Skip to content

Commit 6c4069b

Browse files
committed
Add test showing the buggy behavior of check-cfg and the fingerprint
1 parent 2d14354 commit 6c4069b

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

tests/testsuite/check_cfg.rs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,56 @@ fn features_with_namespaced_features() {
141141
.run();
142142
}
143143

144+
#[cargo_test(nightly, reason = "--check-cfg is unstable")]
145+
fn features_fingerprint() {
146+
let p = project()
147+
.file(
148+
"Cargo.toml",
149+
r#"
150+
[package]
151+
name = "foo"
152+
version = "0.1.0"
153+
154+
[features]
155+
f_a = []
156+
f_b = []
157+
"#,
158+
)
159+
.file("src/lib.rs", "#[cfg(feature = \"f_b\")] fn entry() {}")
160+
.build();
161+
162+
p.cargo("check -v -Zcheck-cfg")
163+
.masquerade_as_nightly_cargo(&["check-cfg"])
164+
.with_stderr_contains(x!("rustc" => "cfg" of "feature" with "f_a" "f_b"))
165+
.with_stderr_does_not_contain("[..]unexpected_cfgs[..]")
166+
.run();
167+
168+
p.cargo("check -v -Zcheck-cfg")
169+
.masquerade_as_nightly_cargo(&["check-cfg"])
170+
.with_stderr_does_not_contain("[..]rustc[..]")
171+
.run();
172+
173+
p.change_file(
174+
"Cargo.toml",
175+
r#"
176+
[package]
177+
name = "foo"
178+
version = "0.1.0"
179+
180+
[features]
181+
f_a = []
182+
"#,
183+
);
184+
185+
p.cargo("check -v -Zcheck-cfg")
186+
.masquerade_as_nightly_cargo(&["check-cfg"])
187+
// this is a bug, rustc should be called again
188+
.with_stderr_does_not_contain("[..]rustc[..]")
189+
// and should show a warning from the unexpected_cfgs lint
190+
.with_stderr_does_not_contain("[..]unexpected_cfgs[..]")
191+
.run();
192+
}
193+
144194
#[cargo_test(nightly, reason = "--check-cfg is unstable")]
145195
fn well_known_names_values() {
146196
let p = project()

0 commit comments

Comments
 (0)