Skip to content

Commit

Permalink
Add test for check-cfg config fingerprint not changing
Browse files Browse the repository at this point in the history
  • Loading branch information
Urgau committed May 24, 2024
1 parent a8d72c6 commit 3ca2120
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions tests/testsuite/check_cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -824,3 +824,49 @@ fn config_features_and_build_script() {
.with_stderr_contains(x!("rustc" => "cfg" of "docsrs")) // Cargo well known
.run();
}

#[cargo_test(>=1.79, reason = "--check-cfg was stabilized in Rust 1.79")]
fn config_fingerprint() {
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.1.0"
edition = "2015"
[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ["cfg(bar)"] }
"#,
)
.file("src/lib.rs", "fn entry() {}")
.build();

p.cargo("check -v")
.with_stderr_contains(x!("rustc" => "cfg" of "bar"))
.run();

p.cargo("check -v")
.with_stderr_does_not_contain("[..]rustc[..]")
.run();

// checking that changing the `-check-cfg` config does not invalid the fingerprint
// FIXME: This should change the fingerprint
p.change_file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.1.0"
edition = "2015"
[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ["cfg(bar)", "cfg(foo)"] }
"#,
);

p.cargo("check -v")
.with_stderr_does_not_contain("[..]rustc[..]")
.run();
}

0 comments on commit 3ca2120

Please sign in to comment.