Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/openadapt_agent/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,7 @@ def run(
try:
proc = subprocess.run(
cmd,
stdin=subprocess.DEVNULL,
capture_output=True,
text=True,
timeout=self.config.timeout_s,
Expand Down Expand Up @@ -591,7 +592,11 @@ def certify(self, bundle_dir: Path) -> dict:
cmd += ["--config", self.config.deployment_config]
try:
proc = subprocess.run(
cmd, capture_output=True, text=True, timeout=self.config.timeout_s
cmd,
stdin=subprocess.DEVNULL,
capture_output=True,
text=True,
timeout=self.config.timeout_s,
)
except subprocess.TimeoutExpired:
return {"certified": None, "detail": "certify timed out"}
Expand Down
4 changes: 3 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,15 @@ def __init__(self, exit_code: int = 0, report: dict | None = None):
self.exit_code = exit_code
self.report = report
self.calls: list[list[str]] = []
self.stdins: list[object] = []
self.stdout = "stub stdout"
self.stderr = ""

def __call__(self, cmd, capture_output=True, text=True, timeout=None):
def __call__(self, cmd, stdin=None, capture_output=True, text=True, timeout=None):
import subprocess

self.calls.append(list(cmd))
self.stdins.append(stdin)
if "--run-dir" in cmd:
run_dir = Path(cmd[cmd.index("--run-dir") + 1])
run_dir.mkdir(parents=True, exist_ok=True)
Expand Down
1 change: 1 addition & 0 deletions tests/test_bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ def test_certify_result_is_fixed_copy_unless_protected_export_enabled(
cmd = stub.calls[0]
assert cmd[1] == "certify"
assert cmd[cmd.index("--policy") + 1] == "clinical-write"
assert stub.stdins == [runner_mod.subprocess.DEVNULL]


def test_workflow_names_intents_recorded_values_and_paths_never_default_export(
Expand Down
5 changes: 3 additions & 2 deletions tests/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def test_success_mapping(monkeypatch, runner_config, bundle_dir, success_report)
assert cmd[0] == "openadapt-flow-stub" and cmd[1] == "run"
assert "--params-file" in cmd and "--run-dir" in cmd
assert "hello" not in " ".join(cmd)
assert stub.stdins == [subprocess.DEVNULL]


def test_halt_maps_to_structured_halt_not_success(
Expand Down Expand Up @@ -259,7 +260,7 @@ def test_exit_two_is_governed_refusal(monkeypatch, runner_config, bundle_dir):


def test_timeout_maps_to_timeout(monkeypatch, runner_config, bundle_dir):
def raise_timeout(cmd, capture_output=True, text=True, timeout=None):
def raise_timeout(cmd, stdin=None, capture_output=True, text=True, timeout=None):
raise subprocess.TimeoutExpired(cmd, timeout, output=b"partial", stderr=b"")

outcome = _run(monkeypatch, runner_config, raise_timeout, bundle_dir=bundle_dir)
Expand All @@ -269,7 +270,7 @@ def raise_timeout(cmd, capture_output=True, text=True, timeout=None):


def test_missing_cli_maps_to_error(monkeypatch, runner_config, bundle_dir):
def raise_missing(cmd, capture_output=True, text=True, timeout=None):
def raise_missing(cmd, stdin=None, capture_output=True, text=True, timeout=None):
raise FileNotFoundError(cmd[0])

outcome = _run(monkeypatch, runner_config, raise_missing, bundle_dir=bundle_dir)
Expand Down