summaryrefslogtreecommitdiffstats
path: root/src/tools/cargo/tests/testsuite/check_cfg.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/cargo/tests/testsuite/check_cfg.rs')
-rw-r--r--src/tools/cargo/tests/testsuite/check_cfg.rs85
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();
}