diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-19 09:26:03 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-19 09:26:03 +0000 |
commit | 9918693037dce8aa4bb6f08741b6812923486c18 (patch) | |
tree | 21d2b40bec7e6a7ea664acee056eb3d08e15a1cf /src/tools/cargo/tests/testsuite/check_cfg.rs | |
parent | Releasing progress-linux version 1.75.0+dfsg1-5~progress7.99u1. (diff) | |
download | rustc-9918693037dce8aa4bb6f08741b6812923486c18.tar.xz rustc-9918693037dce8aa4bb6f08741b6812923486c18.zip |
Merging upstream version 1.76.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tools/cargo/tests/testsuite/check_cfg.rs')
-rw-r--r-- | src/tools/cargo/tests/testsuite/check_cfg.rs | 85 |
1 files changed, 78 insertions, 7 deletions
diff --git a/src/tools/cargo/tests/testsuite/check_cfg.rs b/src/tools/cargo/tests/testsuite/check_cfg.rs index 57d5f8053..42cfe6065 100644 --- a/src/tools/cargo/tests/testsuite/check_cfg.rs +++ b/src/tools/cargo/tests/testsuite/check_cfg.rs @@ -15,16 +15,16 @@ macro_rules! x { $what, '(', $($who,)* ')', "'", "[..]") } }}; - ($tool:tt => $what:tt of $who:tt with $($first_value:tt $($other_values:tt)*)?) => {{ + ($tool:tt => $what:tt of $who:tt with $first_value:tt $($other_values:tt)*) => {{ #[cfg(windows)] { concat!("[RUNNING] [..]", $tool, "[..] --check-cfg \"", - $what, '(', $who, ", values(", $("/\"", $first_value, "/\"", $(", ", "/\"", $other_values, "/\"",)*)* "))", '"', "[..]") + $what, '(', $who, ", values(", "/\"", $first_value, "/\"", $(", ", "/\"", $other_values, "/\"",)* "))", '"', "[..]") } #[cfg(not(windows))] { concat!("[RUNNING] [..]", $tool, "[..] --check-cfg '", - $what, '(', $who, ", values(", $("\"", $first_value, "\"", $(", ", "\"", $other_values, "\"",)*)* "))", "'", "[..]") + $what, '(', $who, ", values(", "\"", $first_value, "\"", $(", ", "\"", $other_values, "\"",)* "))", "'", "[..]") } }}; } @@ -142,6 +142,77 @@ fn features_with_namespaced_features() { } #[cargo_test(nightly, reason = "--check-cfg is unstable")] +fn features_fingerprint() { + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.1.0" + + [features] + f_a = [] + f_b = [] + "#, + ) + .file("src/lib.rs", "#[cfg(feature = \"f_b\")] fn entry() {}") + .build(); + + p.cargo("check -v -Zcheck-cfg") + .masquerade_as_nightly_cargo(&["check-cfg"]) + .with_stderr_contains(x!("rustc" => "cfg" of "feature" with "f_a" "f_b")) + .with_stderr_does_not_contain("[..]unexpected_cfgs[..]") + .run(); + + p.cargo("check -v -Zcheck-cfg") + .masquerade_as_nightly_cargo(&["check-cfg"]) + .with_stderr_does_not_contain("[..]rustc[..]") + .run(); + + // checking that re-ordering the features does not invalid the fingerprint + p.change_file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.1.0" + + [features] + f_b = [] + f_a = [] + "#, + ); + + p.cargo("check -v -Zcheck-cfg") + .masquerade_as_nightly_cargo(&["check-cfg"]) + .with_stderr_does_not_contain("[..]rustc[..]") + .run(); + + p.change_file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.1.0" + + [features] + f_a = [] + "#, + ); + + p.cargo("check -v -Zcheck-cfg") + .masquerade_as_nightly_cargo(&["check-cfg"]) + // we check that the fingerprint is indeed dirty + .with_stderr_contains("[..]Dirty[..]the list of declared features changed") + // that is cause rustc to be called again with the new check-cfg args + .with_stderr_contains(x!("rustc" => "cfg" of "feature" with "f_a")) + // and that we indeed found a new warning from the unexpected_cfgs lint + .with_stderr_contains("[..]unexpected_cfgs[..]") + .run(); +} + +#[cargo_test(nightly, reason = "--check-cfg is unstable")] fn well_known_names_values() { let p = project() .file("Cargo.toml", &basic_manifest("foo", "0.1.0")) @@ -150,7 +221,7 @@ fn well_known_names_values() { p.cargo("check -v -Zcheck-cfg") .masquerade_as_nightly_cargo(&["check-cfg"]) - .with_stderr_contains(x!("rustc" => "cfg" of "feature" with)) + .with_stderr_contains(x!("rustc" => "cfg")) .run(); } @@ -213,7 +284,7 @@ fn well_known_names_values_test() { p.cargo("test -v -Zcheck-cfg") .masquerade_as_nightly_cargo(&["check-cfg"]) - .with_stderr_contains(x!("rustc" => "cfg" of "feature" with)) + .with_stderr_contains(x!("rustc" => "cfg")) .run(); } @@ -226,8 +297,8 @@ fn well_known_names_values_doctest() { p.cargo("test -v --doc -Zcheck-cfg") .masquerade_as_nightly_cargo(&["check-cfg"]) - .with_stderr_contains(x!("rustc" => "cfg" of "feature" with)) - .with_stderr_contains(x!("rustdoc" => "cfg" of "feature" with)) + .with_stderr_contains(x!("rustc" => "cfg")) + .with_stderr_contains(x!("rustdoc" => "cfg")) .run(); } |