Skip to content

Commit 71f7c4a

Browse files
committed
chore: Moved remaining cargo_exe logic to testsuite
1 parent b2bdd3f commit 71f7c4a

File tree

462 files changed

+799
-623
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

462 files changed

+799
-623
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/advanced_env.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
use crate::prelude::*;
44
use cargo_test_support::{paths, project, registry::Package};
55

6-
76
#[cargo_test]
87
fn source_config_env() {
98
// Try to define [source] with environment variables.

tests/testsuite/alt_registry.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22
33
use std::fs;
44

5-
use cargo_test_support::compare::assert_e2e;
65
use crate::prelude::*;
6+
use cargo_test_support::compare::assert_e2e;
77
use cargo_test_support::publish::validate_alt_upload;
88
use cargo_test_support::registry::{self, Package, RegistryBuilder};
99
use cargo_test_support::str;
1010
use cargo_test_support::{basic_manifest, paths, project};
1111

12-
1312
#[cargo_test]
1413
fn depend_on_alt_registry() {
1514
registry::alt_init();

tests/testsuite/artifact_dep.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
//! Tests specific to artifact dependencies, designated using
22
//! the new `dep = { artifact = "bin", … }` syntax in manifests.
33
4+
use crate::prelude::*;
45
use crate::utils::cross_compile::{
56
can_run_on_host as cross_compile_can_run_on_host, disabled as cross_compile_disabled,
67
};
78
use cargo_test_support::compare::assert_e2e;
8-
use crate::prelude::*;
99
use cargo_test_support::registry::{Package, RegistryBuilder};
1010
use cargo_test_support::str;
1111
use cargo_test_support::{

tests/testsuite/artifact_dir.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use cargo_test_support::sleep_ms;
99
use cargo_test_support::str;
1010
use cargo_test_support::{basic_manifest, project};
1111

12-
1312
#[cargo_test]
1413
fn binary_with_debug() {
1514
let p = project()

tests/testsuite/bad_config.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
//! Tests for some invalid .cargo/config files.
22
3-
use cargo_test_support::git::cargo_uses_gitoxide;
43
use crate::prelude::*;
4+
use cargo_test_support::git::cargo_uses_gitoxide;
55
use cargo_test_support::registry::{self, Package};
66
use cargo_test_support::str;
77
use cargo_test_support::{basic_manifest, project, rustc_host};
88

9-
109
#[cargo_test]
1110
fn bad1() {
1211
let p = project()

tests/testsuite/bad_manifest_path.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
use crate::prelude::*;
44
use cargo_test_support::{basic_bin_manifest, main_file, project, str};
55

6-
76
#[track_caller]
87
fn assert_not_a_cargo_toml(command: &str, manifest_path_argument: &str) {
98
let p = project()

tests/testsuite/bench.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
use crate::prelude::*;
44
use cargo_test_support::{basic_bin_manifest, basic_lib_manifest, basic_manifest, project, str};
55

6-
76
#[cargo_test(nightly, reason = "bench")]
87
fn cargo_bench_simple() {
98
let p = project()

tests/testsuite/binary_name.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
//! Tests for `cargo-features = ["different-binary-name"]`.
22
3+
use crate::prelude::*;
34
use cargo_test_support::install::assert_has_installed_exe;
45
use cargo_test_support::install::assert_has_not_installed_exe;
56
use cargo_test_support::is_nightly;
67
use cargo_test_support::paths;
7-
use crate::prelude::*;
88
use cargo_test_support::project;
99
use cargo_test_support::str;
1010

11-
1211
#[cargo_test]
1312
fn gated() {
1413
let p = project()

tests/testsuite/build.rs

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

8+
use crate::prelude::*;
9+
use crate::utils::cargo_exe;
10+
use crate::utils::cargo_process;
811
use crate::utils::tools;
912
use cargo::core::compiler::UserIntent;
1013
use cargo::core::Shell;
@@ -13,13 +16,11 @@ use cargo::ops::CompileOptions;
1316
use cargo::GlobalContext;
1417
use cargo_test_support::compare::assert_e2e;
1518
use cargo_test_support::paths::root;
16-
use crate::prelude::*;
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

0 commit comments

Comments
 (0)