Skip to content

Commit d5e5a9c

Browse files
committed
Fix the env dev shell command
1 parent 81cb1a3 commit d5e5a9c

File tree

3 files changed

+34
-19
lines changed

3 files changed

+34
-19
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
88

99
## Unreleased
1010

11+
***Fixed:***
12+
13+
- Fix the `env dev shell` command when using the `linux-container` developer environment type
14+
1115
## 0.12.1 - 2025-05-02
1216

1317
***Fixed:***

src/dda/env/dev/types/linux_container.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,8 @@ def launch_shell(self, *, repo: str | None = None) -> NoReturn:
204204
self.ensure_ssh_config()
205205
ssh_command = self.ssh_base_command()
206206
ssh_command.append(self.shell.get_login_command(cwd=self.repo_path(repo)))
207-
self.app.subprocess.exit_with(ssh_command)
207+
process = self.app.subprocess.attach(ssh_command, check=False)
208+
self.app.abort(code=process.returncode)
208209

209210
def code(self, *, repo: str | None = None) -> None:
210211
self.ensure_ssh_config()

tests/env/dev/types/test_linux_container.py

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -609,15 +609,18 @@ def test_default(self, dda, helpers, mocker):
609609

610610

611611
class TestShell:
612-
def test_default(self, dda, mocker):
613-
mocker.patch(
612+
def test_default(self, dda, helpers, mocker):
613+
with helpers.hybrid_patch(
614614
"subprocess.run",
615-
return_value=CompletedProcess([], returncode=0, stdout=json.dumps([{"State": {"Status": "running"}}])),
616-
)
617-
write_server_config = mocker.patch("dda.utils.ssh.write_server_config")
618-
exit_with = mocker.patch("dda.utils.process.SubprocessRunner.exit_with")
615+
return_values={
616+
# Stop command checks the status
617+
1: CompletedProcess([], returncode=0, stdout=json.dumps([{"State": {"Status": "running"}}])),
618+
# Capture ssh command
619+
},
620+
) as calls:
621+
write_server_config = mocker.patch("dda.utils.ssh.write_server_config")
619622

620-
result = dda("env", "dev", "shell")
623+
result = dda("env", "dev", "shell")
621624

622625
assert result.exit_code == 0, result.output
623626
assert not result.output
@@ -630,17 +633,24 @@ def test_default(self, dda, mocker):
630633
"UserKnownHostsFile": "/dev/null",
631634
},
632635
)
633-
exit_with.assert_called_once_with([
634-
"ssh",
635-
"-A",
636-
"-q",
637-
"-t",
638-
"-p",
639-
"59730",
640-
"root@localhost",
641-
"--",
642-
"cd /root/repos/datadog-agent && zsh -l -i",
643-
])
636+
assert calls == [
637+
(
638+
(
639+
[
640+
helpers.locate("ssh"),
641+
"-A",
642+
"-q",
643+
"-t",
644+
"-p",
645+
"59730",
646+
"root@localhost",
647+
"--",
648+
"cd /root/repos/datadog-agent && zsh -l -i",
649+
],
650+
),
651+
{},
652+
),
653+
]
644654

645655

646656
class TestRun:

0 commit comments

Comments
 (0)