test: fix Command::current_dir API

Every single call site wants to pass a path relative to the directory
the command was created for. So just make it do that automatically,
similar to `Dir::create` and friends.
This commit is contained in:
Andrew Gallant
2025-10-10 21:10:49 -04:00
parent 293ef80eaf
commit 924ba101ee
4 changed files with 24 additions and 25 deletions

View File

@@ -273,11 +273,14 @@ impl TestCommand {
/// Set the working directory for this command.
///
/// The path given is interpreted relative to the directory that this
/// command was created for.
///
/// Note that this does not need to be called normally, since the creation
/// of this TestCommand causes its working directory to be set to the
/// test's directory automatically.
pub fn current_dir<P: AsRef<Path>>(&mut self, dir: P) -> &mut TestCommand {
self.cmd.current_dir(dir);
self.cmd.current_dir(self.dir.path().join(dir));
self
}