Skip to content

Commit

Permalink
refactor(test): Reuse 'cargo_home' in more cases
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Jul 19, 2024
1 parent b0e515a commit 49deefe
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion crates/cargo-test-support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions crates/cargo-test-support/src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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}-")
Expand Down Expand Up @@ -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 &registry.token {
Token::Plaintext(token) => {
if let Some(alternative) = &self.alternative {
Expand Down Expand Up @@ -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();
}
Expand Down

0 comments on commit 49deefe

Please sign in to comment.