diff --git a/tests/testsuite/build.rs b/tests/testsuite/build.rs index 37a6d7cbdb7..5b5ad0dfc3c 100644 --- a/tests/testsuite/build.rs +++ b/tests/testsuite/build.rs @@ -5452,9 +5452,7 @@ fn same_metadata_different_directory() { .file("Cargo.toml", &basic_bin_manifest("foo")) .file("src/foo.rs", &main_file(r#""i am foo""#, &[])) .build(); - let output = t!(String::from_utf8( - t!(p.cargo("build -v").exec_with_output()).stderr, - )); + let output = t!(String::from_utf8(p.cargo("build -v").run().stderr,)); let metadata = output .split_whitespace() .find(|arg| arg.starts_with("metadata=")) diff --git a/tests/testsuite/cache_messages.rs b/tests/testsuite/cache_messages.rs index a5f50aa4932..f5f11a11813 100644 --- a/tests/testsuite/cache_messages.rs +++ b/tests/testsuite/cache_messages.rs @@ -29,17 +29,11 @@ fn simple() { let rustc_output = raw_rustc_output(&p, "src/lib.rs", &[]); // -q so the output is the same as rustc (no "Compiling" or "Finished"). - let cargo_output1 = p - .cargo("check -q --color=never") - .exec_with_output() - .expect("cargo to run"); + let cargo_output1 = p.cargo("check -q --color=never").run(); assert_eq!(rustc_output, as_str(&cargo_output1.stderr)); assert!(cargo_output1.stdout.is_empty()); // Check that the cached version is exactly the same. - let cargo_output2 = p - .cargo("check -q") - .exec_with_output() - .expect("cargo to run"); + let cargo_output2 = p.cargo("check -q").run(); assert_eq!(rustc_output, as_str(&cargo_output2.stderr)); assert!(cargo_output2.stdout.is_empty()); } @@ -61,14 +55,10 @@ fn simple_short() { let cargo_output1 = p .cargo("check -q --color=never --message-format=short") - .exec_with_output() - .expect("cargo to run"); + .run(); assert_eq!(rustc_output, as_str(&cargo_output1.stderr)); // assert!(cargo_output1.stdout.is_empty()); - let cargo_output2 = p - .cargo("check -q --message-format=short") - .exec_with_output() - .expect("cargo to run"); + let cargo_output2 = p.cargo("check -q --message-format=short").run(); println!("{}", String::from_utf8_lossy(&cargo_output2.stdout)); assert_eq!(rustc_output, as_str(&cargo_output2.stderr)); assert!(cargo_output2.stdout.is_empty()); @@ -102,24 +92,15 @@ fn color() { assert!(!rustc_nocolor.contains("\x1b[")); // First pass, non-cached, with color, should be the same. - let cargo_output1 = p - .cargo("check -q --color=always") - .exec_with_output() - .expect("cargo to run"); + let cargo_output1 = p.cargo("check -q --color=always").run(); compare(&rustc_color, as_str(&cargo_output1.stderr)); // Replay cached, with color. - let cargo_output2 = p - .cargo("check -q --color=always") - .exec_with_output() - .expect("cargo to run"); + let cargo_output2 = p.cargo("check -q --color=always").run(); compare(&rustc_color, as_str(&cargo_output2.stderr)); // Replay cached, no color. - let cargo_output_nocolor = p - .cargo("check -q --color=never") - .exec_with_output() - .expect("cargo to run"); + let cargo_output_nocolor = p.cargo("check -q --color=never").run(); compare(&rustc_nocolor, as_str(&cargo_output_nocolor.stderr)); } @@ -130,27 +111,17 @@ fn cached_as_json() { // Grab the non-cached output, feature disabled. // NOTE: When stabilizing, this will need to be redone. - let cargo_output = p - .cargo("check --message-format=json") - .exec_with_output() - .expect("cargo to run"); - assert!(cargo_output.status.success()); + let cargo_output = p.cargo("check --message-format=json").run(); let orig_cargo_out = as_str(&cargo_output.stdout); assert!(orig_cargo_out.contains("compiler-message")); p.cargo("clean").run(); // Check JSON output, not fresh. - let cargo_output1 = p - .cargo("check --message-format=json") - .exec_with_output() - .expect("cargo to run"); + let cargo_output1 = p.cargo("check --message-format=json").run(); assert_eq!(as_str(&cargo_output1.stdout), orig_cargo_out); // Check JSON output, fresh. - let cargo_output2 = p - .cargo("check --message-format=json") - .exec_with_output() - .expect("cargo to run"); + let cargo_output2 = p.cargo("check --message-format=json").run(); // The only difference should be this field. let fix_fresh = as_str(&cargo_output2.stdout).replace("\"fresh\":true", "\"fresh\":false"); assert_eq!(fix_fresh, orig_cargo_out); @@ -220,11 +191,7 @@ fn rustdoc() { ) .build(); - let rustdoc_output = p - .cargo("doc -q --color=always") - .exec_with_output() - .expect("rustdoc to run"); - assert!(rustdoc_output.status.success()); + let rustdoc_output = p.cargo("doc -q --color=always").run(); let rustdoc_stderr = as_str(&rustdoc_output.stderr); assert!(rustdoc_stderr.contains("missing")); assert!(rustdoc_stderr.contains("\x1b[")); @@ -234,10 +201,7 @@ fn rustdoc() { ); // Check the cached output. - let rustdoc_output = p - .cargo("doc -q --color=always") - .exec_with_output() - .expect("rustdoc to run"); + let rustdoc_output = p.cargo("doc -q --color=always").run(); assert_eq!(as_str(&rustdoc_output.stderr), rustdoc_stderr); } diff --git a/tests/testsuite/cargo_command.rs b/tests/testsuite/cargo_command.rs index 832daded743..8ff7dcfda48 100644 --- a/tests/testsuite/cargo_command.rs +++ b/tests/testsuite/cargo_command.rs @@ -99,10 +99,7 @@ fn list_command_looks_at_path() { let mut path = path(); path.push(proj.root().join("path-test")); let path = env::join_paths(path.iter()).unwrap(); - let output = cargo_process("-v --list") - .env("PATH", &path) - .exec_with_output() - .unwrap(); + let output = cargo_process("-v --list").env("PATH", &path).run(); let output = str::from_utf8(&output.stdout).unwrap(); assert!( output.contains("\n 1 "), @@ -127,8 +124,7 @@ fn list_command_looks_at_path_case_mismatch() { let output = cargo_process("-v --list") .env("Path", &path) .env_remove("PATH") - .exec_with_output() - .unwrap(); + .run(); let output = str::from_utf8(&output.stdout).unwrap(); assert!( output.contains("\n 1 "), @@ -174,10 +170,7 @@ fn list_command_resolves_symlinks() { let mut path = path(); path.push(proj.root().join("path-test")); let path = env::join_paths(path.iter()).unwrap(); - let output = cargo_process("-v --list") - .env("PATH", &path) - .exec_with_output() - .unwrap(); + let output = cargo_process("-v --list").env("PATH", &path).run(); let output = str::from_utf8(&output.stdout).unwrap(); assert!( output.contains("\n 2 "), diff --git a/tests/testsuite/check.rs b/tests/testsuite/check.rs index c719fce55e6..36f95258cab 100644 --- a/tests/testsuite/check.rs +++ b/tests/testsuite/check.rs @@ -1648,7 +1648,7 @@ fn pkgid_querystring_works() { p.cargo("generate-lockfile").run(); - let output = p.cargo("pkgid").arg("gitdep").exec_with_output().unwrap(); + let output = p.cargo("pkgid").arg("gitdep").run(); let gitdep_pkgid = String::from_utf8(output.stdout).unwrap(); let gitdep_pkgid = gitdep_pkgid.trim(); assert_e2e().eq( diff --git a/tests/testsuite/freshness.rs b/tests/testsuite/freshness.rs index 1d9340c936b..34695f12901 100644 --- a/tests/testsuite/freshness.rs +++ b/tests/testsuite/freshness.rs @@ -2527,8 +2527,7 @@ LLVM version: 9.0 let output = p .cargo("check --message-format=json") .env("RUSTC", compiler.bin(version)) - .exec_with_output() - .unwrap(); + .run(); // Collect the filenames generated. let mut artifacts: Vec<_> = std::str::from_utf8(&output.stdout) .unwrap() diff --git a/tests/testsuite/freshness_checksum.rs b/tests/testsuite/freshness_checksum.rs index f18a59b7d81..ac190c84836 100644 --- a/tests/testsuite/freshness_checksum.rs +++ b/tests/testsuite/freshness_checksum.rs @@ -2435,8 +2435,7 @@ LLVM version: 9.0 .cargo("check -Zchecksum-freshness --message-format=json") .masquerade_as_nightly_cargo(&["checksum-freshness"]) .env("RUSTC", compiler.bin(version)) - .exec_with_output() - .unwrap(); + .run(); // Collect the filenames generated. let mut artifacts: Vec<_> = std::str::from_utf8(&output.stdout) .unwrap() diff --git a/tests/testsuite/future_incompat_report.rs b/tests/testsuite/future_incompat_report.rs index 8b3c6700ef6..bb4e6dbecec 100644 --- a/tests/testsuite/future_incompat_report.rs +++ b/tests/testsuite/future_incompat_report.rs @@ -252,8 +252,7 @@ The package `second-dep v0.0.2` currently triggers the following future incompat let output = p .cargo("check") .env("RUSTFLAGS", "-Zfuture-incompat-test") - .exec_with_output() - .unwrap(); + .run(); // Extract the 'id' from the stdout. We are looking // for the id in a line of the form "run `cargo report future-incompatibilities --id yZ7S`" @@ -282,10 +281,7 @@ The package `second-dep v0.0.2` currently triggers the following future incompat .run(); // Test without --id, and also the full output of the report. - let output = p - .cargo("report future-incompat") - .exec_with_output() - .unwrap(); + let output = p.cargo("report future-incompat").run(); let output = std::str::from_utf8(&output.stdout).unwrap(); assert!(output.starts_with("The following warnings were discovered")); let mut lines = output diff --git a/tests/testsuite/git.rs b/tests/testsuite/git.rs index a8776e374e6..9637596c4d7 100644 --- a/tests/testsuite/git.rs +++ b/tests/testsuite/git.rs @@ -3396,7 +3396,7 @@ fn historical_lockfile_works_with_vendor() { .file("src/lib.rs", "") .build(); - let output = project.cargo("vendor").exec_with_output().unwrap(); + let output = project.cargo("vendor").run(); project.change_file( ".cargo/config.toml", str::from_utf8(&output.stdout).unwrap(), diff --git a/tests/testsuite/help.rs b/tests/testsuite/help.rs index 1bbc3419b2f..b5c2178f235 100644 --- a/tests/testsuite/help.rs +++ b/tests/testsuite/help.rs @@ -7,7 +7,7 @@ use std::str::from_utf8; use cargo_test_support::prelude::*; use cargo_test_support::registry::Package; use cargo_test_support::str; -use cargo_test_support::{basic_manifest, cargo_exe, cargo_process, paths, process, project}; +use cargo_test_support::{basic_manifest, cargo_process, paths, project}; #[cargo_test] fn help() { @@ -83,13 +83,9 @@ fn help_with_man_and_path( .unwrap() }; - let output = process(&cargo_exe()) - .arg("help") - .arg(subcommand) + let output = cargo_process(&format!("help {subcommand}")) .env("PATH", path) - .exec_with_output() - .unwrap(); - assert!(output.status.success()); + .run(); let stderr = from_utf8(&output.stderr).unwrap(); if display_command.is_empty() { assert_eq!(stderr, ""); @@ -101,13 +97,9 @@ fn help_with_man_and_path( } fn help_with_stdout_and_path(subcommand: &str, path: &Path) -> String { - let output = process(&cargo_exe()) - .arg("help") - .arg(subcommand) + let output = cargo_process(&format!("help {subcommand}")) .env("PATH", path) - .exec_with_output() - .unwrap(); - assert!(output.status.success()); + .run(); let stderr = from_utf8(&output.stderr).unwrap(); assert_eq!(stderr, ""); let stdout = from_utf8(&output.stdout).unwrap(); diff --git a/tests/testsuite/lto.rs b/tests/testsuite/lto.rs index 5fe5e22f7ad..21b96f95609 100644 --- a/tests/testsuite/lto.rs +++ b/tests/testsuite/lto.rs @@ -1,8 +1,7 @@ -use std::process::Output; - use cargo::core::compiler::Lto; use cargo_test_support::prelude::*; use cargo_test_support::registry::Package; +use cargo_test_support::RawOutput; use cargo_test_support::{basic_manifest, project, str, Project}; #[cargo_test] @@ -509,7 +508,7 @@ fn project_with_dep(crate_types: &str) -> Project { /// /// `krate_info` is extra compiler flags used to distinguish this if the same /// crate name is being built multiple times. -fn verify_lto(output: &Output, krate: &str, krate_info: &str, expected_lto: Lto) { +fn verify_lto(output: &RawOutput, krate: &str, krate_info: &str, expected_lto: Lto) { let stderr = std::str::from_utf8(&output.stderr).unwrap(); let mut matches = stderr.lines().filter(|line| { line.contains("Running") @@ -554,7 +553,7 @@ fn verify_lto(output: &Output, krate: &str, krate_info: &str, expected_lto: Lto) #[cargo_test] fn cdylib_and_rlib() { let p = project_with_dep("'cdylib', 'rlib'"); - let output = p.cargo("build --release -v").exec_with_output().unwrap(); + let output = p.cargo("build --release -v").run(); // `registry` is ObjectAndBitcode because it needs Object for the // rlib, and Bitcode for the cdylib (which doesn't support LTO). verify_lto( @@ -627,7 +626,7 @@ fn cdylib_and_rlib() { #[cargo_test] fn dylib() { let p = project_with_dep("'dylib'"); - let output = p.cargo("build --release -v").exec_with_output().unwrap(); + let output = p.cargo("build --release -v").run(); // `registry` is OnlyObject because rustc doesn't support LTO with dylibs. verify_lto(&output, "registry", "--crate-type lib", Lto::OnlyObject); // `registry_shared` is both because it is needed by both bar (Object) and @@ -860,7 +859,7 @@ fn dylib_rlib_bin() { .file("src/bin/ferret.rs", "fn main() { foo::foo(); }") .build(); - let output = p.cargo("build --release -v").exec_with_output().unwrap(); + let output = p.cargo("build --release -v").run(); verify_lto( &output, "foo", diff --git a/tests/testsuite/package.rs b/tests/testsuite/package.rs index 0bfed0f53c0..fc24db91190 100644 --- a/tests/testsuite/package.rs +++ b/tests/testsuite/package.rs @@ -3143,7 +3143,7 @@ path = "src/lib.rs" } fn verify_packaged_status_line( - output: std::process::Output, + output: cargo_test_support::RawOutput, num_files: usize, uncompressed_size: u64, compressed_size: u64, @@ -3228,7 +3228,7 @@ version = "0.0.1" + main_rs_contents.len() + cargo_toml_contents.len() + cargo_lock_contents.len()) as u64; - let output = p.cargo("package").exec_with_output().unwrap(); + let output = p.cargo("package").run(); assert!(p.root().join("target/package/foo-0.0.1.crate").is_file()); p.cargo("package -l") @@ -3333,7 +3333,7 @@ version = "0.0.1" + cargo_lock_contents.len() + bar_txt_contents.len()) as u64; - let output = p.cargo("package").exec_with_output().unwrap(); + let output = p.cargo("package").run(); assert!(p.root().join("target/package/foo-0.0.1.crate").is_file()); p.cargo("package -l") .with_stdout_data(str![[r#" @@ -3452,7 +3452,7 @@ version = "0.0.1" + cargo_lock_contents.len() + bar_txt_contents.len() * 2) as u64; - let output = p.cargo("package").exec_with_output().unwrap(); + let output = p.cargo("package").run(); assert!(p.root().join("target/package/foo-0.0.1.crate").is_file()); p.cargo("package -l") .with_stdout_data(str![[r#" diff --git a/tests/testsuite/pkgid.rs b/tests/testsuite/pkgid.rs index 9b74420c0ba..cc8b9860082 100644 --- a/tests/testsuite/pkgid.rs +++ b/tests/testsuite/pkgid.rs @@ -301,7 +301,7 @@ fn pkgid_json_message_metadata_consistency() { p.cargo("generate-lockfile").run(); - let output = p.cargo("pkgid").arg("foo").exec_with_output().unwrap(); + let output = p.cargo("pkgid").arg("foo").run(); let pkgid = String::from_utf8(output.stdout).unwrap(); let pkgid = pkgid.trim(); assert_e2e().eq(pkgid, str!["path+[ROOTURL]/foo#0.5.0"]); diff --git a/tests/testsuite/registry_auth.rs b/tests/testsuite/registry_auth.rs index 92f3d1db20f..360402965c4 100644 --- a/tests/testsuite/registry_auth.rs +++ b/tests/testsuite/registry_auth.rs @@ -542,8 +542,7 @@ fn token_not_logged() { .replace_crates_io(crates_io.index_url()) .env("CARGO_HTTP_DEBUG", "true") .env("CARGO_LOG", "trace") - .exec_with_output() - .unwrap(); + .run(); let log = String::from_utf8(output.stderr).unwrap(); assert_e2e().eq( &log, diff --git a/tests/testsuite/vendor.rs b/tests/testsuite/vendor.rs index 8a399fc45ee..7ea31b5b5d9 100644 --- a/tests/testsuite/vendor.rs +++ b/tests/testsuite/vendor.rs @@ -130,11 +130,7 @@ fn vendor_path_specified() { "deps/.vendor" }; - let output = p - .cargo("vendor --respect-source-config") - .arg(path) - .exec_with_output() - .unwrap(); + let output = p.cargo("vendor --respect-source-config").arg(path).run(); // Assert against original output to ensure that // path is normalized by `ops::vendor` on Windows. assert_eq!( @@ -1425,10 +1421,7 @@ fn git_complex() { .file("src/lib.rs", "") .build(); - let output = p - .cargo("vendor --respect-source-config") - .exec_with_output() - .unwrap(); + let output = p.cargo("vendor --respect-source-config").run(); let output = String::from_utf8(output.stdout).unwrap(); p.change_file(".cargo/config.toml", &output); @@ -1505,10 +1498,7 @@ fn git_deterministic() { .file("src/lib.rs", "") .build(); - let output = p - .cargo("vendor --respect-source-config") - .exec_with_output() - .unwrap(); + let output = p.cargo("vendor --respect-source-config").run(); let output = String::from_utf8(output.stdout).unwrap(); p.change_file(".cargo/config.toml", &output); @@ -1744,10 +1734,7 @@ fn config_instructions_works() { ) .file("src/lib.rs", "") .build(); - let output = p - .cargo("vendor --respect-source-config") - .exec_with_output() - .unwrap(); + let output = p.cargo("vendor --respect-source-config").run(); let output = String::from_utf8(output.stdout).unwrap(); p.change_file(".cargo/config.toml", &output);