Skip to content

Commit 91809c4

Browse files
committed
Auto merge of #14781 - epage:to, r=weihanglo
test: Update some emaining unordered tests to snapbox ### What does this PR try to resolve? This is part of #14039 This leaves `global_cache_tracker.rs` as it requires some more thinking. As for the flakiness in `freshness.rs` that was seen in #14161, `compare.rs` would prioritize expected lines according to their length (assuming its more specific). Currently, snapbox prioritizes according to the line order. So we just need to put the proc-macro line before the other one to ensure it gets precedence. ### How should we test and review this PR? ### Additional information
2 parents ad3cdb4 + 6ba8315 commit 91809c4

File tree

3 files changed

+30
-27
lines changed

3 files changed

+30
-27
lines changed

tests/testsuite/clean.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//! Tests for the `cargo clean` command.
22
3+
use cargo_test_support::compare::assert_e2e;
34
use cargo_test_support::prelude::*;
45
use cargo_test_support::registry::Package;
56
use cargo_test_support::str;
@@ -824,7 +825,6 @@ fn clean_spec_reserved() {
824825
.run();
825826
}
826827

827-
#[expect(deprecated)]
828828
#[cargo_test]
829829
fn clean_dry_run() {
830830
// Basic `clean --dry-run` test.
@@ -866,11 +866,14 @@ fn clean_dry_run() {
866866
// Verify it didn't delete anything.
867867
let after = p.build_dir().ls_r();
868868
assert_eq!(before, after);
869-
let expected = itertools::join(before.iter().map(|p| p.to_str().unwrap()), "\n");
869+
let mut expected = itertools::join(before.iter().map(|p| p.to_str().unwrap()), "\n");
870+
expected.push_str("\n");
871+
let expected = snapbox::filter::normalize_paths(&expected);
872+
let expected = assert_e2e().redactions().redact(&expected);
870873
eprintln!("{expected}");
871874
// Verify the verbose output.
872875
p.cargo("clean --dry-run -v")
873-
.with_stdout_unordered(expected)
876+
.with_stdout_data(expected.unordered())
874877
.with_stderr_data(str![[r#"
875878
[SUMMARY] [FILE_NUM] files, [FILE_SIZE]B total
876879
[WARNING] no files deleted due to --dry-run

tests/testsuite/freshness.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1616,21 +1616,21 @@ fn reuse_panic_pm() {
16161616

16171617
// bar is built once without panic (for proc-macro) and once with (for the
16181618
// normal dependency).
1619-
// TODO: Migrating to Snapbox might cause flakyness here. See https://github.com/rust-lang/cargo/pull/14161/files#r1660071433
1620-
#[expect(deprecated)]
16211619
p.cargo("build -v")
1622-
.with_stderr_unordered(
1623-
"\
1620+
.with_stderr_data(
1621+
str![[r#"
16241622
[LOCKING] 2 packages to latest compatible versions
1625-
[COMPILING] bar [..]
1626-
[RUNNING] `rustc --crate-name bar --edition=2015 bar/src/lib.rs [..]--crate-type lib --emit=[..]link[..]
1627-
[RUNNING] `rustc --crate-name bar --edition=2015 bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C panic=abort[..]-C debuginfo=2 [..]
1628-
[COMPILING] somepm [..]
1623+
[COMPILING] bar v0.0.1 ([ROOT]/foo/bar)
1624+
[RUNNING] `rustc --crate-name bar [..] -C panic=abort [..]
1625+
[RUNNING] `rustc --crate-name bar [..]
1626+
[COMPILING] somepm v0.0.1 ([ROOT]/foo/somepm)
16291627
[RUNNING] `rustc --crate-name somepm [..]
1630-
[COMPILING] foo [..]
1631-
[RUNNING] `rustc --crate-name foo --edition=2015 src/lib.rs [..]-C panic=abort[..]
1632-
[FINISHED] [..]
1633-
",
1628+
[COMPILING] foo v0.0.1 ([ROOT]/foo)
1629+
[RUNNING] `rustc --crate-name foo [..] -C panic=abort [..]
1630+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
1631+
1632+
"#]]
1633+
.unordered(),
16341634
)
16351635
.run();
16361636
}

tests/testsuite/freshness_checksum.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1639,22 +1639,22 @@ fn reuse_panic_pm() {
16391639

16401640
// bar is built once without panic (for proc-macro) and once with (for the
16411641
// normal dependency).
1642-
// TODO: Migrating to Snapbox might cause flakyness here. See https://github.com/rust-lang/cargo/pull/14161/files#r1660071433
1643-
#[expect(deprecated)]
16441642
p.cargo("build -Zchecksum-freshness -v")
16451643
.masquerade_as_nightly_cargo(&["checksum-freshness"])
1646-
.with_stderr_unordered(
1647-
"\
1644+
.with_stderr_data(
1645+
str![[r#"
16481646
[LOCKING] 2 packages to latest compatible versions
1649-
[COMPILING] bar [..]
1650-
[RUNNING] `rustc --crate-name bar --edition=2015 bar/src/lib.rs [..]--crate-type lib --emit=[..]link[..]
1651-
[RUNNING] `rustc --crate-name bar --edition=2015 bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C panic=abort[..]-C debuginfo=2 [..]
1652-
[COMPILING] somepm [..]
1647+
[COMPILING] bar v0.0.1 ([ROOT]/foo/bar)
1648+
[RUNNING] `rustc --crate-name bar [..] -C panic=abort [..]
1649+
[RUNNING] `rustc --crate-name bar [..]
1650+
[COMPILING] somepm v0.0.1 ([ROOT]/foo/somepm)
16531651
[RUNNING] `rustc --crate-name somepm [..]
1654-
[COMPILING] foo [..]
1655-
[RUNNING] `rustc --crate-name foo --edition=2015 src/lib.rs [..]-C panic=abort[..]
1656-
[FINISHED] [..]
1657-
",
1652+
[COMPILING] foo v0.0.1 ([ROOT]/foo)
1653+
[RUNNING] `rustc --crate-name foo [..] -C panic=abort [..]
1654+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
1655+
1656+
"#]]
1657+
.unordered(),
16581658
)
16591659
.run();
16601660
}

0 commit comments

Comments
 (0)