From 52ec93d8faa1735a99787a0f090a3f72fd916490 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 4 Nov 2024 16:03:32 -0600 Subject: [PATCH 1/2] test(clean): Update remaining unordered test to snapbox --- tests/testsuite/clean.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/testsuite/clean.rs b/tests/testsuite/clean.rs index 7caf4f35e6a6..82870c0e7e9e 100644 --- a/tests/testsuite/clean.rs +++ b/tests/testsuite/clean.rs @@ -1,5 +1,6 @@ //! Tests for the `cargo clean` command. +use cargo_test_support::compare::assert_e2e; use cargo_test_support::prelude::*; use cargo_test_support::registry::Package; use cargo_test_support::str; @@ -824,7 +825,6 @@ fn clean_spec_reserved() { .run(); } -#[expect(deprecated)] #[cargo_test] fn clean_dry_run() { // Basic `clean --dry-run` test. @@ -866,11 +866,18 @@ fn clean_dry_run() { // Verify it didn't delete anything. let after = p.build_dir().ls_r(); assert_eq!(before, after); - let expected = itertools::join(before.iter().map(|p| p.to_str().unwrap()), "\n"); + let assert = assert_e2e(); + let mut expected = snapbox::filter::normalize_paths(&itertools::join( + before + .iter() + .map(|p| assert.redactions().redact(p.to_str().unwrap())), + "\n", + )); + expected.push_str("\n"); eprintln!("{expected}"); // Verify the verbose output. p.cargo("clean --dry-run -v") - .with_stdout_unordered(expected) + .with_stdout_data(expected.unordered()) .with_stderr_data(str![[r#" [SUMMARY] [FILE_NUM] files, [FILE_SIZE]B total [WARNING] no files deleted due to --dry-run From 9453159b600cd5f0594ae7b1b4b48ca455846fde Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 4 Nov 2024 15:21:22 -0600 Subject: [PATCH 2/2] test(freshness): Update remaining unordered tests to snapbox `compare.rs` gives priority based on expected-line length. `snapbox` gives priority according to the expected line order. --- tests/testsuite/freshness.rs | 24 ++++++++++++------------ tests/testsuite/freshness_checksum.rs | 24 ++++++++++++------------ 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/tests/testsuite/freshness.rs b/tests/testsuite/freshness.rs index 78c86f1e01ea..1d9340c936b7 100644 --- a/tests/testsuite/freshness.rs +++ b/tests/testsuite/freshness.rs @@ -1616,21 +1616,21 @@ fn reuse_panic_pm() { // bar is built once without panic (for proc-macro) and once with (for the // normal dependency). - // TODO: Migrating to Snapbox might cause flakyness here. See https://github.com/rust-lang/cargo/pull/14161/files#r1660071433 - #[expect(deprecated)] p.cargo("build -v") - .with_stderr_unordered( - "\ + .with_stderr_data( + str![[r#" [LOCKING] 2 packages to latest compatible versions -[COMPILING] bar [..] -[RUNNING] `rustc --crate-name bar --edition=2015 bar/src/lib.rs [..]--crate-type lib --emit=[..]link[..] -[RUNNING] `rustc --crate-name bar --edition=2015 bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C panic=abort[..]-C debuginfo=2 [..] -[COMPILING] somepm [..] +[COMPILING] bar v0.0.1 ([ROOT]/foo/bar) +[RUNNING] `rustc --crate-name bar [..] -C panic=abort [..] +[RUNNING] `rustc --crate-name bar [..] +[COMPILING] somepm v0.0.1 ([ROOT]/foo/somepm) [RUNNING] `rustc --crate-name somepm [..] -[COMPILING] foo [..] -[RUNNING] `rustc --crate-name foo --edition=2015 src/lib.rs [..]-C panic=abort[..] -[FINISHED] [..] -", +[COMPILING] foo v0.0.1 ([ROOT]/foo) +[RUNNING] `rustc --crate-name foo [..] -C panic=abort [..] +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]] + .unordered(), ) .run(); } diff --git a/tests/testsuite/freshness_checksum.rs b/tests/testsuite/freshness_checksum.rs index d14e63b6b789..f18a59b7d817 100644 --- a/tests/testsuite/freshness_checksum.rs +++ b/tests/testsuite/freshness_checksum.rs @@ -1639,22 +1639,22 @@ fn reuse_panic_pm() { // bar is built once without panic (for proc-macro) and once with (for the // normal dependency). - // TODO: Migrating to Snapbox might cause flakyness here. See https://github.com/rust-lang/cargo/pull/14161/files#r1660071433 - #[expect(deprecated)] p.cargo("build -Zchecksum-freshness -v") .masquerade_as_nightly_cargo(&["checksum-freshness"]) - .with_stderr_unordered( - "\ + .with_stderr_data( + str![[r#" [LOCKING] 2 packages to latest compatible versions -[COMPILING] bar [..] -[RUNNING] `rustc --crate-name bar --edition=2015 bar/src/lib.rs [..]--crate-type lib --emit=[..]link[..] -[RUNNING] `rustc --crate-name bar --edition=2015 bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C panic=abort[..]-C debuginfo=2 [..] -[COMPILING] somepm [..] +[COMPILING] bar v0.0.1 ([ROOT]/foo/bar) +[RUNNING] `rustc --crate-name bar [..] -C panic=abort [..] +[RUNNING] `rustc --crate-name bar [..] +[COMPILING] somepm v0.0.1 ([ROOT]/foo/somepm) [RUNNING] `rustc --crate-name somepm [..] -[COMPILING] foo [..] -[RUNNING] `rustc --crate-name foo --edition=2015 src/lib.rs [..]-C panic=abort[..] -[FINISHED] [..] -", +[COMPILING] foo v0.0.1 ([ROOT]/foo) +[RUNNING] `rustc --crate-name foo [..] -C panic=abort [..] +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]] + .unordered(), ) .run(); }