From 49deefe477a0b17fad3796c890c518434f7a892f Mon Sep 17 00:00:00 2001 From: Ed Page Date: Fri, 19 Jul 2024 10:54:17 -0500 Subject: [PATCH] refactor(test): Reuse 'cargo_home' in more cases --- crates/cargo-test-support/src/lib.rs | 2 +- crates/cargo-test-support/src/registry.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/cargo-test-support/src/lib.rs b/crates/cargo-test-support/src/lib.rs index 89ec5fc013e..6509c71d509 100644 --- a/crates/cargo-test-support/src/lib.rs +++ b/crates/cargo-test-support/src/lib.rs @@ -1308,7 +1308,7 @@ pub trait TestEnvCommandExt: Sized { self = self .current_dir(&paths::root()) .env("HOME", paths::home()) - .env("CARGO_HOME", paths::home().join(".cargo")) + .env("CARGO_HOME", paths::cargo_home()) .env("__CARGO_TEST_ROOT", paths::global_root()) // Force Cargo to think it's on the stable channel for all tests, this // should hopefully not surprise us as we add cargo features over time and diff --git a/crates/cargo-test-support/src/registry.rs b/crates/cargo-test-support/src/registry.rs index 6ddd59e38a8..b63ee44350e 100644 --- a/crates/cargo-test-support/src/registry.rs +++ b/crates/cargo-test-support/src/registry.rs @@ -279,7 +279,7 @@ impl RegistryBuilder { /// Initializes the registry. #[must_use] pub fn build(self) -> TestRegistry { - let config_path = paths::home().join(".cargo/config.toml"); + let config_path = paths::cargo_home().join("config.toml"); t!(fs::create_dir_all(config_path.parent().unwrap())); let prefix = if let Some(alternative) = &self.alternative { format!("{alternative}-") @@ -391,7 +391,7 @@ impl RegistryBuilder { } if self.configure_token { - let credentials = paths::home().join(".cargo/credentials.toml"); + let credentials = paths::cargo_home().join("credentials.toml"); match ®istry.token { Token::Plaintext(token) => { if let Some(alternative) = &self.alternative { @@ -1195,7 +1195,7 @@ impl Package { /// Creates a new package builder. /// Call `publish()` to finalize and build the package. pub fn new(name: &str, vers: &str) -> Package { - let config = paths::home().join(".cargo/config.toml"); + let config = paths::cargo_home().join("config.toml"); if !config.exists() { init(); }