diff --git a/tests/testsuite/cache_messages.rs b/tests/testsuite/cache_messages.rs index 51ca2a30defb..b32c1a9929d0 100644 --- a/tests/testsuite/cache_messages.rs +++ b/tests/testsuite/cache_messages.rs @@ -1,8 +1,7 @@ //! Tests for caching compiler diagnostics. -#![allow(deprecated)] - use super::messages::raw_rustc_output; +use cargo_test_support::str; use cargo_test_support::tools; use cargo_test_support::{basic_manifest, is_coarse_mtime, project, registry::Package, sleep_ms}; @@ -160,7 +159,17 @@ fn clears_cache_after_fix() { // Make sure the cache is invalidated when there is no output. let p = project().file("src/lib.rs", "fn asdf() {}").build(); // Fill the cache. - p.cargo("check").with_stderr_contains("[..]asdf[..]").run(); + p.cargo("check") + .with_stderr_data( + "\ +[CHECKING] foo v0.0.1 ([ROOT]/foo) +[WARNING] function `asdf` is never used +... +[WARNING] `foo` (lib) generated 1 warning +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s +", + ) + .run(); let cpath = p .glob("target/debug/.fingerprint/foo-*/output-*") .next() @@ -175,13 +184,12 @@ fn clears_cache_after_fix() { p.change_file("src/lib.rs", ""); p.cargo("check") - .with_stdout("") - .with_stderr( - "\ -[CHECKING] foo [..] -[FINISHED] [..] -", - ) + .with_stdout_data(str![[r#""#]]) + .with_stderr_data(str![[r#" +[CHECKING] foo v0.0.1 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); assert_eq!( p.glob("target/debug/.fingerprint/foo-*/output-*").count(), @@ -190,12 +198,11 @@ fn clears_cache_after_fix() { // And again, check the cache is correct. p.cargo("check") - .with_stdout("") - .with_stderr( - "\ -[FINISHED] [..] -", - ) + .with_stdout_data(str![[r#""#]]) + .with_stderr_data(str![[r#" +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -267,13 +274,41 @@ fn very_verbose() { .build(); p.cargo("check -vv") - .with_stderr_contains("[..]not_used[..]") + .with_stderr_data( + "\ +[UPDATING] `dummy-registry` index +[LOCKING] 2 packages to latest compatible versions +[DOWNLOADING] crates ... +[DOWNLOADED] bar v1.0.0 (registry `dummy-registry`) +[CHECKING] bar v1.0.0 +[RUNNING] [..] +[WARNING] function `not_used` is never used +... +[CHECKING] foo v0.1.0 ([ROOT]/foo) +[RUNNING] [..] +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s +", + ) .run(); - p.cargo("check").with_stderr("[FINISHED] [..]").run(); + p.cargo("check") + .with_stderr_data(str![[r#" +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) + .run(); p.cargo("check -vv") - .with_stderr_contains("[..]not_used[..]") + .with_stderr_data( + "\ +[FRESH] bar v1.0.0 +[WARNING] function `not_used` is never used +... +[WARNING] `bar` (lib) generated 1 warning +[FRESH] foo v0.1.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s +", + ) .run(); } @@ -346,25 +381,23 @@ fn replay_non_json() { let p = project().file("src/lib.rs", "").build(); p.cargo("check") .env("RUSTC", rustc.bin("rustc_alt")) - .with_stderr( - "\ -[CHECKING] foo [..] + .with_stderr_data(str![[r#" +[CHECKING] foo v0.0.1 ([ROOT]/foo) line 1 line 2 -[FINISHED] `dev` profile [..] -", - ) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); p.cargo("check") .env("RUSTC", rustc.bin("rustc_alt")) - .with_stderr( - "\ + .with_stderr_data(str![[r#" line 1 line 2 -[FINISHED] `dev` profile [..] -", - ) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -407,11 +440,11 @@ fn caching_large_output() { let p = project().file("src/lib.rs", "").build(); p.cargo("check") .env("RUSTC", rustc.bin("rustc_alt")) - .with_stderr(&format!( + .with_stderr_data(&format!( "\ -[CHECKING] foo [..] -{}warning: `foo` (lib) generated 250 warnings -[FINISHED] `dev` profile [..] +[CHECKING] foo v0.0.1 ([ROOT]/foo) +{}[WARNING] `foo` (lib) generated 250 warnings +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s ", expected )) @@ -419,16 +452,17 @@ fn caching_large_output() { p.cargo("check") .env("RUSTC", rustc.bin("rustc_alt")) - .with_stderr(&format!( + .with_stderr_data(&format!( "\ -{}warning: `foo` (lib) generated 250 warnings -[FINISHED] `dev` profile [..] +{}[WARNING] `foo` (lib) generated 250 warnings +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s ", expected )) .run(); } +#[allow(deprecated)] #[cargo_test] fn rustc_workspace_wrapper() { let p = project() @@ -441,18 +475,29 @@ fn rustc_workspace_wrapper() { p.cargo("check -v") .env("RUSTC_WORKSPACE_WRAPPER", tools::echo_wrapper()) - .with_stderr_contains( - "WRAPPER CALLED: rustc --crate-name foo --edition=2015 src/lib.rs [..]", + .with_stderr_data( + "\ +[CHECKING] foo v0.0.1 ([ROOT]/foo) +[RUNNING] [..] +WRAPPER CALLED: rustc --crate-name foo --edition=2015 src/lib.rs [..] +[WARNING] function `unused_func` is never used +... +[WARNING] `foo` (lib) generated 1 warning +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s +", ) .run(); // Check without a wrapper should rebuild p.cargo("check -v") - .with_stderr_contains( + .with_stderr_data( "\ -[CHECKING] foo [..] -[RUNNING] `rustc[..] -[WARNING] [..]unused_func[..] +[CHECKING] foo v0.0.1 ([ROOT]/foo) +[RUNNING] `rustc[..]` +[WARNING] function `unused_func` is never used +... +[WARNING] `foo` (lib) generated 1 warning +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s ", ) .with_stdout_does_not_contain( @@ -463,7 +508,17 @@ fn rustc_workspace_wrapper() { // Again, reading from the cache. p.cargo("check -v") .env("RUSTC_WORKSPACE_WRAPPER", tools::echo_wrapper()) - .with_stderr_contains("[FRESH] foo [..]") + .with_stderr_data( + "\ +[FRESH] foo v0.0.1 ([ROOT]/foo) +WRAPPER CALLED: rustc [..] +... +[WARNING] function `unused_func` is never used +... +[WARNING] `foo` (lib) generated 1 warning +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s +", + ) .with_stdout_does_not_contain( "WRAPPER CALLED: rustc --crate-name foo --edition=2015 src/lib.rs [..]", ) @@ -471,14 +526,22 @@ fn rustc_workspace_wrapper() { // And `check` should also be fresh, reading from cache. p.cargo("check -v") - .with_stderr_contains("[FRESH] foo [..]") - .with_stderr_contains("[WARNING] [..]unused_func[..]") + .with_stderr_data( + "\ +[FRESH] foo v0.0.1 ([ROOT]/foo) +[WARNING] function `unused_func` is never used +... +[WARNING] `foo` (lib) generated 1 warning +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s +", + ) .with_stdout_does_not_contain( "WRAPPER CALLED: rustc --crate-name foo --edition=2015 src/lib.rs [..]", ) .run(); } +#[allow(deprecated)] #[cargo_test] fn wacky_hashless_fingerprint() { // On Windows, executables don't have hashes. This checks for a bad @@ -491,7 +554,15 @@ fn wacky_hashless_fingerprint() { .with_stderr_does_not_contain("[..]unused[..]") .run(); p.cargo("check --bin a") - .with_stderr_contains("[..]unused[..]") + .with_stderr_data( + "\ +[CHECKING] foo v0.0.1 ([ROOT]/foo) +[WARNING] unused variable: `unused` +... +[WARNING] `foo` (bin \"a\") generated 1 warning +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s +", + ) .run(); // This should not pick up the cache from `a`. p.cargo("check --bin b")