Skip to content

Commit 30b6707

Browse files
committed
chore: Moved remaining cargo_exe logic to testsuite
1 parent 15f755c commit 30b6707

34 files changed

+93
-80
lines changed

crates/cargo-test-support/src/lib.rs

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ pub mod prelude {
115115
pub use crate::cargo_test;
116116
pub use crate::paths::CargoPathExt;
117117
pub use crate::ArgLineCommandExt;
118-
pub use crate::CargoCommandExt;
119118
pub use crate::ChannelChangerCommandExt;
120119
pub use crate::TestEnvCommandExt;
121120
pub use snapbox::IntoData;
@@ -598,11 +597,6 @@ pub fn main_file(println: &str, externed_deps: &[&str]) -> String {
598597
buf
599598
}
600599

601-
/// Path to the cargo binary
602-
pub fn cargo_exe() -> PathBuf {
603-
snapbox::cmd::cargo_bin("cargo")
604-
}
605-
606600
/// This is the raw output from the process.
607601
///
608602
/// This is similar to `std::process::Output`, however the `status` is
@@ -1472,21 +1466,6 @@ impl TestEnvCommandExt for snapbox::cmd::Command {
14721466
}
14731467
}
14741468

1475-
/// Test the cargo command
1476-
pub trait CargoCommandExt {
1477-
fn cargo_ui() -> Self;
1478-
}
1479-
1480-
impl CargoCommandExt for snapbox::cmd::Command {
1481-
fn cargo_ui() -> Self {
1482-
Self::new(cargo_exe())
1483-
.with_assert(compare::assert_ui())
1484-
.env("CARGO_TERM_COLOR", "always")
1485-
.env("CARGO_TERM_HYPERLINKS", "true")
1486-
.test_env()
1487-
}
1488-
}
1489-
14901469
/// Add a list of arguments as a line
14911470
pub trait ArgLineCommandExt: Sized {
14921471
fn arg_line(mut self, s: &str) -> Self {
@@ -1524,15 +1503,6 @@ impl ArgLineCommandExt for snapbox::cmd::Command {
15241503
}
15251504
}
15261505

1527-
/// Run `cargo $arg_line`, see [`Execs`]
1528-
pub fn cargo_process(arg_line: &str) -> Execs {
1529-
let cargo = cargo_exe();
1530-
let mut p = process(&cargo);
1531-
p.env("CARGO", cargo);
1532-
p.arg_line(arg_line);
1533-
execs().with_process_builder(p)
1534-
}
1535-
15361506
/// Run `git $arg_line`, see [`ProcessBuilder`]
15371507
pub fn git_process(arg_line: &str) -> ProcessBuilder {
15381508
let mut p = process("git");

tests/testsuite/build.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ use std::io::Read;
66
use std::process::Stdio;
77

88
use crate::prelude::*;
9+
use crate::utils::cargo_exe;
10+
use crate::utils::cargo_process;
911
use crate::utils::tools;
1012
use cargo::core::compiler::UserIntent;
1113
use cargo::core::Shell;
@@ -17,9 +19,8 @@ use cargo_test_support::paths::root;
1719
use cargo_test_support::registry::Package;
1820
use cargo_test_support::str;
1921
use cargo_test_support::{
20-
basic_bin_manifest, basic_lib_manifest, basic_manifest, cargo_exe, cargo_process, git,
21-
is_nightly, main_file, paths, process, project, rustc_host, sleep_ms, symlink_supported, t,
22-
Execs, ProjectBuilder,
22+
basic_bin_manifest, basic_lib_manifest, basic_manifest, git, is_nightly, main_file, paths,
23+
process, project, rustc_host, sleep_ms, symlink_supported, t, Execs, ProjectBuilder,
2324
};
2425
use cargo_util::paths::dylib_path_envvar;
2526

tests/testsuite/build_script.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use std::io;
66
use std::thread;
77

88
use crate::prelude::*;
9+
use crate::utils::cargo_exe;
910
use crate::utils::cross_compile::{
1011
can_run_on_host as cross_compile_can_run_on_host, disabled as cross_compile_disabled,
1112
};
@@ -14,9 +15,7 @@ use cargo_test_support::compare::assert_e2e;
1415
use cargo_test_support::paths::cargo_home;
1516
use cargo_test_support::registry::Package;
1617
use cargo_test_support::str;
17-
use cargo_test_support::{
18-
basic_manifest, cargo_exe, cross_compile, is_coarse_mtime, project, project_in,
19-
};
18+
use cargo_test_support::{basic_manifest, cross_compile, is_coarse_mtime, project, project_in};
2019
use cargo_test_support::{git, rustc_host, sleep_ms, slow_cpu_multiplier, symlink_supported};
2120
use cargo_util::paths::{self, remove_dir_all};
2221

tests/testsuite/cargo_command.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ use std::process::Stdio;
88
use std::str;
99

1010
use crate::prelude::*;
11+
use crate::utils::cargo_exe;
12+
use crate::utils::cargo_process;
1113
use crate::utils::tools::echo_subcommand;
1214
use cargo_test_support::basic_manifest;
1315
use cargo_test_support::registry::Package;
1416
use cargo_test_support::rustc_host;
1517
use cargo_test_support::str;
16-
use cargo_test_support::{
17-
basic_bin_manifest, cargo_exe, cargo_process, paths, project, project_in_home,
18-
};
18+
use cargo_test_support::{basic_bin_manifest, paths, project, project_in_home};
1919
use cargo_util::paths::join_paths;
2020

2121
fn path() -> Vec<PathBuf> {
@@ -601,7 +601,7 @@ fn overwrite_cargo_environment_variable() {
601601

602602
// Create two other cargo binaries in the project root, one with the wrong
603603
// name and one with the right name.
604-
let cargo_exe = cargo_test_support::cargo_exe();
604+
let cargo_exe = crate::utils::cargo_exe();
605605
let wrong_name_path = p
606606
.root()
607607
.join(format!("wrong_name{}", env::consts::EXE_SUFFIX));

tests/testsuite/cargo_config/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use std::path::PathBuf;
1010
mod help;
1111

1212
fn cargo_process(s: &str) -> cargo_test_support::Execs {
13-
let mut p = cargo_test_support::cargo_process(s);
13+
let mut p = crate::utils::cargo_process(s);
1414
// Clear out some of the environment added by the default cargo_process so
1515
// the tests don't need to deal with it.
1616
p.env_remove("CARGO_PROFILE_DEV_SPLIT_DEBUGINFO")

tests/testsuite/concurrent.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::thread;
88
use std::{env, str};
99

1010
use crate::prelude::*;
11-
use cargo_test_support::cargo_process;
11+
use crate::utils::cargo_process;
1212
use cargo_test_support::git;
1313
use cargo_test_support::install::assert_has_installed_exe;
1414
use cargo_test_support::paths;

tests/testsuite/credential_process.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
//! Tests for credential-process.
22
33
use crate::prelude::*;
4+
use crate::utils::cargo_process;
45
use cargo_test_support::registry::{Package, TestRegistry};
5-
use cargo_test_support::{basic_manifest, cargo_process, paths, project, registry, str, Project};
6+
use cargo_test_support::{basic_manifest, paths, project, registry, str, Project};
67

78
fn toml_bin(proj: &Project, name: &str) -> String {
89
proj.bin(name).display().to_string().replace('\\', "\\\\")

tests/testsuite/directory.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::fs;
55
use std::str;
66

77
use crate::prelude::*;
8-
use cargo_test_support::cargo_process;
8+
use crate::utils::cargo_process;
99
use cargo_test_support::git;
1010
use cargo_test_support::paths;
1111
use cargo_test_support::registry::{cksum, Package};

tests/testsuite/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! General error tests that don't belong anywhere else.
22
33
use crate::prelude::*;
4-
use cargo_test_support::cargo_process;
4+
use crate::utils::cargo_process;
55

66
#[cargo_test]
77
fn internal_error() {

tests/testsuite/feature_unification.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
//! Tests for workspace feature unification.
22
33
use crate::prelude::*;
4-
use cargo_test_support::{basic_manifest, cargo_process, project, str};
4+
use crate::utils::cargo_process;
5+
use cargo_test_support::{basic_manifest, project, str};
56

67
#[cargo_test]
78
fn workspace_feature_unification() {

0 commit comments

Comments
 (0)