This commit is contained in:
Kunall Banerjee 2026-05-31 12:10:19 +05:30 committed by GitHub
commit 90fbe86a72
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 15 additions and 0 deletions

View file

@ -1922,6 +1922,7 @@ RUN sed -i -E 's/((^|\s)PATH=)([^\$]*)$/\1\${PATH:-\3}/g' /etc/profile || true
let docker_cli = self.docker_client.docker_cli();
let mut command = Command::new(&docker_cli);
command.current_dir(&self.local_project_directory);
command.arg("run");
@ -3198,6 +3199,12 @@ mod test {
let docker_run_command = docker_run_command.expect("ok");
assert_eq!(docker_run_command.get_program(), "docker");
assert_eq!(
docker_run_command.get_current_dir(),
Some(Path::new(TEST_PROJECT_PATH)),
"docker run must execute with cwd set to the project directory so \
relative paths in `runArgs` (e.g. `--env-file .devcontainer/.env`) resolve correctly"
);
let expected_config_file_label = PathBuf::from(TEST_PROJECT_PATH)
.join(".devcontainer")
.join("devcontainer.json");

View file

@ -72,6 +72,10 @@ impl Command {
self.0.get_args()
}
pub fn get_current_dir(&self) -> Option<&Path> {
self.0.get_current_dir()
}
pub fn env(&mut self, key: impl AsRef<OsStr>, val: impl AsRef<OsStr>) -> &mut Self {
self.0.env(key, val);
self

View file

@ -225,6 +225,10 @@ impl Command {
pub fn get_program(&self) -> &OsStr {
self.program.as_os_str()
}
pub fn get_current_dir(&self) -> Option<&Path> {
self.current_dir.as_deref()
}
}
#[derive(Debug)]