Skip to content

Commit 0c5b8ff

Browse files
committed
test: Migrate remaining with_stdout/with_stderr calls
1 parent 3b289b7 commit 0c5b8ff

File tree

3 files changed

+39
-18
lines changed

3 files changed

+39
-18
lines changed

tests/testsuite/cargo_command.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,6 @@ fn override_cargo_home() {
358358
assert!(paths::root().join("foo2/.git").is_dir());
359359
}
360360

361-
#[expect(deprecated)]
362361
#[cargo_test]
363362
fn cargo_subcommand_env() {
364363
let src = format!(
@@ -390,7 +389,7 @@ fn cargo_subcommand_env() {
390389

391390
cargo_process("envtest")
392391
.env("PATH", &path)
393-
.with_stdout(cargo.to_str().unwrap())
392+
.with_stdout_data(format!("{}\n", cargo.to_str().unwrap()))
394393
.run();
395394

396395
// Check that subcommands inherit an overridden $CARGO
@@ -403,7 +402,7 @@ fn cargo_subcommand_env() {
403402
cargo_process("envtest")
404403
.env("PATH", &path)
405404
.env(cargo::CARGO_ENV, &envtest_bin)
406-
.with_stdout(envtest_bin)
405+
.with_stdout_data(format!("{}\n", envtest_bin).raw())
407406
.run();
408407
}
409408

tests/testsuite/global_cache_tracker.rs

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -993,7 +993,6 @@ fn max_size() {
993993
}
994994
}
995995

996-
#[expect(deprecated)]
997996
#[cargo_test]
998997
fn max_size_untracked_crate() {
999998
// When a .crate file exists from an older version of cargo that did not
@@ -1018,7 +1017,10 @@ fn max_size_untracked_crate() {
10181017
// This should scan the directory and populate the db with the size information.
10191018
cargo_process("clean gc -Zgc -v --max-crate-size=100000")
10201019
.masquerade_as_nightly_cargo(&["gc"])
1021-
.with_stderr("[REMOVED] 0 files")
1020+
.with_stderr_data(str![[r#"
1021+
[REMOVED] 0 files
1022+
1023+
"#]])
10221024
.run();
10231025
// Check that it stored the size data.
10241026
let _lock = gctx
@@ -1070,7 +1072,6 @@ fn max_size_untracked_verify(gctx: &GlobalContext) {
10701072
drop(lock);
10711073
}
10721074

1073-
#[expect(deprecated)]
10741075
#[cargo_test]
10751076
fn max_size_untracked_src_from_use() {
10761077
// When a src directory exists from an older version of cargo that did not
@@ -1095,12 +1096,14 @@ fn max_size_untracked_src_from_use() {
10951096
// Fix the size.
10961097
p.cargo("clean gc -v --max-src-size=10000 -Zgc")
10971098
.masquerade_as_nightly_cargo(&["gc"])
1098-
.with_stderr("[REMOVED] 0 files")
1099+
.with_stderr_data(str![[r#"
1100+
[REMOVED] 0 files
1101+
1102+
"#]])
10991103
.run();
11001104
max_size_untracked_verify(&gctx);
11011105
}
11021106

1103-
#[expect(deprecated)]
11041107
#[cargo_test]
11051108
fn max_size_untracked_src_from_clean() {
11061109
// When a src directory exists from an older version of cargo that did not
@@ -1111,7 +1114,10 @@ fn max_size_untracked_src_from_clean() {
11111114
// Clean should scan the src and update the db.
11121115
p.cargo("clean gc -v --max-src-size=10000 -Zgc")
11131116
.masquerade_as_nightly_cargo(&["gc"])
1114-
.with_stderr("[REMOVED] 0 files")
1117+
.with_stderr_data(str![[r#"
1118+
[REMOVED] 0 files
1119+
1120+
"#]])
11151121
.run();
11161122
max_size_untracked_verify(&gctx);
11171123
}
@@ -1363,7 +1369,6 @@ fn delete_index_also_deletes_crates() {
13631369
assert_eq!(get_registry_names("cache").len(), 0);
13641370
}
13651371

1366-
#[expect(deprecated)]
13671372
#[cargo_test]
13681373
fn clean_syncs_missing_files() {
13691374
// When files go missing in the cache, clean operations that need to track
@@ -1417,7 +1422,10 @@ fn clean_syncs_missing_files() {
14171422
// Clean should update the db.
14181423
p.cargo("clean gc -v --max-download-size=1GB -Zgc")
14191424
.masquerade_as_nightly_cargo(&["gc"])
1420-
.with_stderr("[REMOVED] 0 files")
1425+
.with_stderr_data(str![[r#"
1426+
[REMOVED] 0 files
1427+
1428+
"#]])
14211429
.run();
14221430

14231431
// Verify
@@ -1460,7 +1468,6 @@ fn offline_doesnt_auto_gc() {
14601468
assert_eq!(get_registry_names("cache"), &[] as &[String]);
14611469
}
14621470

1463-
#[expect(deprecated)]
14641471
#[cargo_test]
14651472
fn can_handle_future_schema() -> anyhow::Result<()> {
14661473
// It should work when a future version of cargo has made schema changes
@@ -1484,7 +1491,10 @@ fn can_handle_future_schema() -> anyhow::Result<()> {
14841491
// Verify it doesn't blow up.
14851492
p.cargo("clean gc --max-download-size=0 -Zgc")
14861493
.masquerade_as_nightly_cargo(&["gc"])
1487-
.with_stderr("[REMOVED] 4 files, [..] total")
1494+
.with_stderr_data(str![[r#"
1495+
[REMOVED] [FILE_NUM] files, [FILE_SIZE]B total
1496+
1497+
"#]])
14881498
.run();
14891499
Ok(())
14901500
}
@@ -1746,9 +1756,9 @@ fn clean_max_git_size() {
17461756

17471757
p.cargo(&format!("clean gc --max-git-size={threshold} -Zgc -v"))
17481758
.masquerade_as_nightly_cargo(&["gc"])
1749-
.with_stderr(&format!(
1759+
.with_stderr_data(&format!(
17501760
"\
1751-
[REMOVING] [ROOT]/home/.cargo/git/checkouts/{db_name}/{first_co_name}
1761+
[REMOVING] [ROOT]/home/.cargo/git/checkouts/bar-[HASH]/{first_co_name}
17521762
[REMOVED] [..]
17531763
"
17541764
))

tests/testsuite/message_format.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,21 @@ fn cargo_renders() {
6868

6969
p.cargo("check --message-format json-render-diagnostics")
7070
.with_status(101)
71-
.with_stdout(
72-
"{\"reason\":\"compiler-artifact\",[..]\n\
73-
{\"reason\":\"build-finished\",\"success\":false}",
71+
.with_stdout_data(
72+
str![[r#"
73+
[
74+
{
75+
"reason": "compiler-artifact",
76+
"...": "{...}"
77+
},
78+
{
79+
"reason": "build-finished",
80+
"success": false
81+
}
82+
]
83+
"#]]
84+
.is_json()
85+
.against_jsonlines(),
7486
)
7587
.with_stderr_contains(
7688
"\

0 commit comments

Comments
 (0)