Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(test)!: Clarify extension trait role with rename #14269

Merged
merged 1 commit into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions crates/cargo-test-support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ pub mod tools;
pub mod prelude {
pub use crate::cargo_test;
pub use crate::paths::CargoPathExt;
pub use crate::ArgLine;
pub use crate::CargoCommand;
pub use crate::ChannelChanger;
pub use crate::TestEnv;
pub use crate::ArgLineCommandExt;
pub use crate::CargoCommandExt;
pub use crate::ChannelChangerCommandExt;
pub use crate::TestEnvCommandExt;
pub use snapbox::IntoData;
}

Expand Down Expand Up @@ -1247,27 +1247,27 @@ fn _process(t: &OsStr) -> ProcessBuilder {
}

/// Enable nightly features for testing
pub trait ChannelChanger {
pub trait ChannelChangerCommandExt {
/// The list of reasons should be why nightly cargo is needed. If it is
/// because of an unstable feature put the name of the feature as the reason,
/// e.g. `&["print-im-a-teapot"]`.
fn masquerade_as_nightly_cargo(self, _reasons: &[&str]) -> Self;
}

impl ChannelChanger for &mut ProcessBuilder {
impl ChannelChangerCommandExt for &mut ProcessBuilder {
fn masquerade_as_nightly_cargo(self, _reasons: &[&str]) -> Self {
self.env("__CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS", "nightly")
}
}

impl ChannelChanger for snapbox::cmd::Command {
impl ChannelChangerCommandExt for snapbox::cmd::Command {
fn masquerade_as_nightly_cargo(self, _reasons: &[&str]) -> Self {
self.env("__CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS", "nightly")
}
}

/// Establish a process's test environment
pub trait TestEnv: Sized {
pub trait TestEnvCommandExt: Sized {
fn test_env(mut self) -> Self {
// In general just clear out all cargo-specific configuration already in the
// environment. Our tests all assume a "default configuration" unless
Expand Down Expand Up @@ -1357,7 +1357,7 @@ pub trait TestEnv: Sized {
fn env_remove(self, key: &str) -> Self;
}

impl TestEnv for &mut ProcessBuilder {
impl TestEnvCommandExt for &mut ProcessBuilder {
fn current_dir<S: AsRef<std::path::Path>>(self, path: S) -> Self {
let path = path.as_ref();
self.cwd(path)
Expand All @@ -1370,7 +1370,7 @@ impl TestEnv for &mut ProcessBuilder {
}
}

impl TestEnv for snapbox::cmd::Command {
impl TestEnvCommandExt for snapbox::cmd::Command {
fn current_dir<S: AsRef<std::path::Path>>(self, path: S) -> Self {
self.current_dir(path)
}
Expand All @@ -1383,11 +1383,11 @@ impl TestEnv for snapbox::cmd::Command {
}

/// Test the cargo command
pub trait CargoCommand {
pub trait CargoCommandExt {
fn cargo_ui() -> Self;
}

impl CargoCommand for snapbox::cmd::Command {
impl CargoCommandExt for snapbox::cmd::Command {
fn cargo_ui() -> Self {
Self::new(cargo_exe())
.with_assert(compare::assert_ui())
Expand All @@ -1397,7 +1397,7 @@ impl CargoCommand for snapbox::cmd::Command {
}

/// Add a list of arguments as a line
pub trait ArgLine: Sized {
pub trait ArgLineCommandExt: Sized {
fn arg_line(mut self, s: &str) -> Self {
for mut arg in s.split_whitespace() {
if (arg.starts_with('"') && arg.ends_with('"'))
Expand All @@ -1415,13 +1415,13 @@ pub trait ArgLine: Sized {
fn arg<S: AsRef<std::ffi::OsStr>>(self, s: S) -> Self;
}

impl ArgLine for &mut ProcessBuilder {
impl ArgLineCommandExt for &mut ProcessBuilder {
fn arg<S: AsRef<std::ffi::OsStr>>(self, s: S) -> Self {
self.arg(s)
}
}

impl ArgLine for snapbox::cmd::Command {
impl ArgLineCommandExt for snapbox::cmd::Command {
fn arg<S: AsRef<std::ffi::OsStr>>(self, s: S) -> Self {
self.arg(s)
}
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/cargo_bench/no_keep_going/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::CargoCommandExt;
use cargo_test_support::Project;

#[cargo_test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::CargoCommandExt;
use cargo_test_support::Project;

#[cargo_test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::CargoCommandExt;
use cargo_test_support::Project;

#[cargo_test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::CargoCommandExt;
use cargo_test_support::Project;

#[cargo_test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::CargoCommandExt;
use cargo_test_support::Project;

#[cargo_test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::CargoCommandExt;
use cargo_test_support::Project;

#[cargo_test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::CargoCommandExt;
use cargo_test_support::Project;

#[cargo_test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::CargoCommandExt;
use cargo_test_support::Project;

#[cargo_test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::CargoCommandExt;
use cargo_test_support::Project;

#[cargo_test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::CargoCommandExt;
use cargo_test_support::Project;

#[cargo_test]
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/cargo_new/empty_name/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::CargoCommandExt;
use cargo_test_support::Project;

#[cargo_test]
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/cargo_new/inherit_workspace_lints/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::CargoCommandExt;
use cargo_test_support::Project;

#[cargo_test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::CargoCommandExt;
use cargo_test_support::Project;

#[cargo_test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::CargoCommandExt;
use cargo_test_support::Project;

#[cargo_test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::CargoCommandExt;
use cargo_test_support::Project;

#[cargo_test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::CargoCommandExt;
use cargo_test_support::Project;

#[cargo_test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::CargoCommandExt;
use cargo_test_support::Project;

#[cargo_test]
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/cargo_remove/avoid_empty_tables/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::CargoCommandExt;
use cargo_test_support::Project;

#[cargo_test]
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/cargo_remove/build/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::CargoCommandExt;
use cargo_test_support::Project;

#[cargo_test]
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/cargo_remove/dev/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::CargoCommandExt;
use cargo_test_support::Project;

#[cargo_test]
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/cargo_remove/dry_run/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::CargoCommandExt;
use cargo_test_support::Project;

#[cargo_test]
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/cargo_remove/gc_keep_used_patch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::CargoCommandExt;
use cargo_test_support::Project;

#[cargo_test]
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/cargo_remove/gc_patch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use cargo_test_support::git;
use cargo_test_support::prelude::*;
use cargo_test_support::project;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::CargoCommandExt;

#[cargo_test]
fn case() {
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/cargo_remove/gc_profile/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::CargoCommandExt;
use cargo_test_support::Project;

#[cargo_test]
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/cargo_remove/gc_replace/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::CargoCommandExt;
use cargo_test_support::Project;

#[cargo_test]
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/cargo_remove/invalid_arg/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::CargoCommandExt;
use cargo_test_support::Project;

#[cargo_test]
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/cargo_remove/invalid_dep/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::CargoCommandExt;
use cargo_test_support::Project;

#[cargo_test]
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/cargo_remove/invalid_package/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::CargoCommandExt;
use cargo_test_support::Project;

#[cargo_test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::CargoCommandExt;
use cargo_test_support::Project;

#[cargo_test]
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/cargo_remove/invalid_section/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::CargoCommandExt;
use cargo_test_support::Project;

#[cargo_test]
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/cargo_remove/invalid_section_dep/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::CargoCommandExt;
use cargo_test_support::Project;

#[cargo_test]
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/cargo_remove/invalid_target/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::str;
use cargo_test_support::CargoCommand;
use cargo_test_support::CargoCommandExt;
use cargo_test_support::Project;

#[cargo_test]
Expand Down
Loading