diff --git a/tests/testsuite/check_cfg.rs b/tests/testsuite/check_cfg.rs index 36f1641fde8..cfda4cd2f49 100644 --- a/tests/testsuite/check_cfg.rs +++ b/tests/testsuite/check_cfg.rs @@ -332,22 +332,64 @@ fn test_false_lib() { test = false "#, ) - .file("src/lib.rs", "") + .file("src/lib.rs", "#[cfg(test)] mod tests {}") .build(); p.cargo("check -v") .with_stderr_does_not_contain(x!("rustc" => "cfg" of "docsrs,test")) .with_stderr_contains(x!("rustc" => "cfg" of "docsrs")) + .with_stderr_data(str![[r#" +... +[WARNING] unexpected `cfg` condition name: `test` + --> src/lib.rs:1:7 + | +1 | #[cfg(test)] mod tests {} + | ^^^^ +... + +[WARNING] `foo` (lib) generated 1 warning +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); p.cargo("clean").run(); p.cargo("test -v") .with_stderr_contains(x!("rustc" => "cfg" of "docsrs")) + .with_stderr_data(str![[r#" +... +[WARNING] unexpected `cfg` condition name: `test` + --> src/lib.rs:1:7 + | +1 | #[cfg(test)] mod tests {} + | ^^^^ +... + +[WARNING] `foo` (lib) generated 1 warning +[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s +[DOCTEST] foo +[RUNNING] [..] + +"#]]) .run(); p.cargo("clean").run(); p.cargo("test --lib -v") .with_stderr_contains(x!("rustc" => "cfg" of "docsrs")) + .with_stderr_data(str![[r#" +... +[WARNING] unexpected `cfg` condition name: `test` + --> src/lib.rs:1:7 + | +1 | #[cfg(test)] mod tests {} + | ^^^^ +... + +[WARNING] `foo` (lib test) generated 1 warning +[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s +[RUNNING] `[ROOT]/foo/target/debug/deps/foo-[HASH]` + +"#]]) .run(); } @@ -368,13 +410,26 @@ fn test_false_bins() { path = "src/deamon.rs" "#, ) - .file("src/main.rs", "fn main() {}") - .file("src/deamon.rs", "fn main() {}") + .file("src/main.rs", "fn main() {}\n#[cfg(test)] mod tests {}") + .file("src/deamon.rs", "fn main() {}\n#[cfg(test)] mod tests {}") .build(); p.cargo("check -v") .with_stderr_contains(x!("rustc" => "cfg" of "docsrs,test")) // for foo .with_stderr_contains(x!("rustc" => "cfg" of "docsrs")) // for deamon + .with_stderr_data(str![[r#" +... +[WARNING] unexpected `cfg` condition name: `test` + --> src/deamon.rs:2:7 + | +2 | #[cfg(test)] mod tests {} + | ^^^^ +... + +[WARNING] `foo` (bin "daemon") generated 1 warning +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -398,13 +453,35 @@ fn test_false_examples() { path = "src/deamon.rs" "#, ) - .file("src/lib.rs", "") - .file("src/deamon.rs", "fn main() {}") + .file("src/lib.rs", "#[cfg(test)] mod tests {}") + .file("src/deamon.rs", "fn main() {}\n#[cfg(test)] mod tests {}") .build(); p.cargo("check --examples -v") .with_stderr_does_not_contain(x!("rustc" => "cfg" of "docsrs,test")) .with_stderr_contains(x!("rustc" => "cfg" of "docsrs")) + .with_stderr_data(str![[r#" +... +[WARNING] unexpected `cfg` condition name: `test` + --> src/lib.rs:1:7 + | +1 | #[cfg(test)] mod tests {} + | ^^^^ +... + +[WARNING] `foo` (lib) generated 1 warning +... +[WARNING] unexpected `cfg` condition name: `test` + --> src/deamon.rs:2:7 + | +2 | #[cfg(test)] mod tests {} + | ^^^^ +... + +[WARNING] `foo` (example "daemon") generated 1 warning +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); }