test: Migrate remaining with_stdout/with_stderr calls

This commit is contained in:
Ed Page 2024-09-21 20:43:19 -05:00
parent 1f5f7021e5
commit e72ef0b10f
3 changed files with 39 additions and 18 deletions

View File

@ -358,7 +358,6 @@ fn override_cargo_home() {
assert!(paths::root().join("foo2/.git").is_dir()); assert!(paths::root().join("foo2/.git").is_dir());
} }
#[expect(deprecated)]
#[cargo_test] #[cargo_test]
fn cargo_subcommand_env() { fn cargo_subcommand_env() {
let src = format!( let src = format!(
@ -390,7 +389,7 @@ fn cargo_subcommand_env() {
cargo_process("envtest") cargo_process("envtest")
.env("PATH", &path) .env("PATH", &path)
.with_stdout(cargo.to_str().unwrap()) .with_stdout_data(format!("{}\n", cargo.to_str().unwrap()).raw())
.run(); .run();
// Check that subcommands inherit an overridden $CARGO // Check that subcommands inherit an overridden $CARGO
@ -403,7 +402,7 @@ fn cargo_subcommand_env() {
cargo_process("envtest") cargo_process("envtest")
.env("PATH", &path) .env("PATH", &path)
.env(cargo::CARGO_ENV, &envtest_bin) .env(cargo::CARGO_ENV, &envtest_bin)
.with_stdout(envtest_bin) .with_stdout_data(format!("{}\n", envtest_bin).raw().raw())
.run(); .run();
} }

View File

@ -993,7 +993,6 @@ fn max_size() {
} }
} }
#[expect(deprecated)]
#[cargo_test] #[cargo_test]
fn max_size_untracked_crate() { fn max_size_untracked_crate() {
// When a .crate file exists from an older version of cargo that did not // When a .crate file exists from an older version of cargo that did not
@ -1018,7 +1017,10 @@ fn max_size_untracked_crate() {
// This should scan the directory and populate the db with the size information. // This should scan the directory and populate the db with the size information.
cargo_process("clean gc -Zgc -v --max-crate-size=100000") cargo_process("clean gc -Zgc -v --max-crate-size=100000")
.masquerade_as_nightly_cargo(&["gc"]) .masquerade_as_nightly_cargo(&["gc"])
.with_stderr("[REMOVED] 0 files") .with_stderr_data(str![[r#"
[REMOVED] 0 files
"#]])
.run(); .run();
// Check that it stored the size data. // Check that it stored the size data.
let _lock = gctx let _lock = gctx
@ -1070,7 +1072,6 @@ fn max_size_untracked_verify(gctx: &GlobalContext) {
drop(lock); drop(lock);
} }
#[expect(deprecated)]
#[cargo_test] #[cargo_test]
fn max_size_untracked_src_from_use() { fn max_size_untracked_src_from_use() {
// When a src directory exists from an older version of cargo that did not // 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() {
// Fix the size. // Fix the size.
p.cargo("clean gc -v --max-src-size=10000 -Zgc") p.cargo("clean gc -v --max-src-size=10000 -Zgc")
.masquerade_as_nightly_cargo(&["gc"]) .masquerade_as_nightly_cargo(&["gc"])
.with_stderr("[REMOVED] 0 files") .with_stderr_data(str![[r#"
[REMOVED] 0 files
"#]])
.run(); .run();
max_size_untracked_verify(&gctx); max_size_untracked_verify(&gctx);
} }
#[expect(deprecated)]
#[cargo_test] #[cargo_test]
fn max_size_untracked_src_from_clean() { fn max_size_untracked_src_from_clean() {
// When a src directory exists from an older version of cargo that did not // 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() {
// Clean should scan the src and update the db. // Clean should scan the src and update the db.
p.cargo("clean gc -v --max-src-size=10000 -Zgc") p.cargo("clean gc -v --max-src-size=10000 -Zgc")
.masquerade_as_nightly_cargo(&["gc"]) .masquerade_as_nightly_cargo(&["gc"])
.with_stderr("[REMOVED] 0 files") .with_stderr_data(str![[r#"
[REMOVED] 0 files
"#]])
.run(); .run();
max_size_untracked_verify(&gctx); max_size_untracked_verify(&gctx);
} }
@ -1363,7 +1369,6 @@ fn delete_index_also_deletes_crates() {
assert_eq!(get_registry_names("cache").len(), 0); assert_eq!(get_registry_names("cache").len(), 0);
} }
#[expect(deprecated)]
#[cargo_test] #[cargo_test]
fn clean_syncs_missing_files() { fn clean_syncs_missing_files() {
// When files go missing in the cache, clean operations that need to track // When files go missing in the cache, clean operations that need to track
@ -1417,7 +1422,10 @@ fn clean_syncs_missing_files() {
// Clean should update the db. // Clean should update the db.
p.cargo("clean gc -v --max-download-size=1GB -Zgc") p.cargo("clean gc -v --max-download-size=1GB -Zgc")
.masquerade_as_nightly_cargo(&["gc"]) .masquerade_as_nightly_cargo(&["gc"])
.with_stderr("[REMOVED] 0 files") .with_stderr_data(str![[r#"
[REMOVED] 0 files
"#]])
.run(); .run();
// Verify // Verify
@ -1460,7 +1468,6 @@ fn offline_doesnt_auto_gc() {
assert_eq!(get_registry_names("cache"), &[] as &[String]); assert_eq!(get_registry_names("cache"), &[] as &[String]);
} }
#[expect(deprecated)]
#[cargo_test] #[cargo_test]
fn can_handle_future_schema() -> anyhow::Result<()> { fn can_handle_future_schema() -> anyhow::Result<()> {
// It should work when a future version of cargo has made schema changes // It should work when a future version of cargo has made schema changes
@ -1484,7 +1491,10 @@ fn can_handle_future_schema() -> anyhow::Result<()> {
// Verify it doesn't blow up. // Verify it doesn't blow up.
p.cargo("clean gc --max-download-size=0 -Zgc") p.cargo("clean gc --max-download-size=0 -Zgc")
.masquerade_as_nightly_cargo(&["gc"]) .masquerade_as_nightly_cargo(&["gc"])
.with_stderr("[REMOVED] 4 files, [..] total") .with_stderr_data(str![[r#"
[REMOVED] [FILE_NUM] files, [FILE_SIZE]B total
"#]])
.run(); .run();
Ok(()) Ok(())
} }
@ -1746,9 +1756,9 @@ fn clean_max_git_size() {
p.cargo(&format!("clean gc --max-git-size={threshold} -Zgc -v")) p.cargo(&format!("clean gc --max-git-size={threshold} -Zgc -v"))
.masquerade_as_nightly_cargo(&["gc"]) .masquerade_as_nightly_cargo(&["gc"])
.with_stderr(&format!( .with_stderr_data(&format!(
"\ "\
[REMOVING] [ROOT]/home/.cargo/git/checkouts/{db_name}/{first_co_name} [REMOVING] [ROOT]/home/.cargo/git/checkouts/bar-[HASH]/{first_co_name}
[REMOVED] [..] [REMOVED] [..]
" "
)) ))

View File

@ -68,9 +68,21 @@ fn cargo_renders() {
p.cargo("check --message-format json-render-diagnostics") p.cargo("check --message-format json-render-diagnostics")
.with_status(101) .with_status(101)
.with_stdout( .with_stdout_data(
"{\"reason\":\"compiler-artifact\",[..]\n\ str![[r#"
{\"reason\":\"build-finished\",\"success\":false}", [
{
"reason": "compiler-artifact",
"...": "{...}"
},
{
"reason": "build-finished",
"success": false
}
]
"#]]
.is_json()
.against_jsonlines(),
) )
.with_stderr_contains( .with_stderr_contains(
"\ "\