Skip to content

Commit 9a3d99b

Browse files
committed
fix(test-support): Default the current_dir for snapbox
1 parent c9e82ec commit 9a3d99b

File tree

1 file changed

+9
-0
lines changed
  • crates/cargo-test-support/src

1 file changed

+9
-0
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,6 +1163,7 @@ pub trait TestEnv: Sized {
11631163
}
11641164

11651165
self = self
1166+
.current_dir(&paths::root())
11661167
.env("HOME", paths::home())
11671168
.env("CARGO_HOME", paths::home().join(".cargo"))
11681169
.env("__CARGO_TEST_ROOT", paths::root())
@@ -1198,11 +1199,16 @@ pub trait TestEnv: Sized {
11981199
self
11991200
}
12001201

1202+
fn current_dir<S: AsRef<std::path::Path>>(self, path: S) -> Self;
12011203
fn env<S: AsRef<std::ffi::OsStr>>(self, key: &str, value: S) -> Self;
12021204
fn env_remove(self, key: &str) -> Self;
12031205
}
12041206

12051207
impl TestEnv for &mut ProcessBuilder {
1208+
fn current_dir<S: AsRef<std::path::Path>>(self, path: S) -> Self {
1209+
let path = path.as_ref();
1210+
self.cwd(path)
1211+
}
12061212
fn env<S: AsRef<std::ffi::OsStr>>(self, key: &str, value: S) -> Self {
12071213
self.env(key, value)
12081214
}
@@ -1212,6 +1218,9 @@ impl TestEnv for &mut ProcessBuilder {
12121218
}
12131219

12141220
impl TestEnv for snapbox::cmd::Command {
1221+
fn current_dir<S: AsRef<std::path::Path>>(self, path: S) -> Self {
1222+
self.current_dir(path)
1223+
}
12151224
fn env<S: AsRef<std::ffi::OsStr>>(self, key: &str, value: S) -> Self {
12161225
self.env(key, value)
12171226
}

0 commit comments

Comments
 (0)