fix: pass harness prompts through stdin
This commit is contained in:
+2
-2
@@ -373,8 +373,8 @@ class StepExecutor:
|
|||||||
|
|
||||||
prompt = preamble + step_file.read_text(encoding="utf-8")
|
prompt = preamble + step_file.read_text(encoding="utf-8")
|
||||||
result = subprocess.run(
|
result = subprocess.run(
|
||||||
["codex", "exec", "--dangerously-bypass-approvals-and-sandbox", "--json", prompt],
|
["codex", "exec", "--dangerously-bypass-approvals-and-sandbox", "--json", "-"],
|
||||||
cwd=self._root, capture_output=True, text=True, timeout=1800,
|
cwd=self._root, capture_output=True, text=True, input=prompt, timeout=1800,
|
||||||
)
|
)
|
||||||
|
|
||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
|
|||||||
@@ -281,6 +281,30 @@ class ExecuteRunnerSafetyTests(unittest.TestCase):
|
|||||||
|
|
||||||
self.assertEqual(cm.exception.code, 1)
|
self.assertEqual(cm.exception.code, 1)
|
||||||
|
|
||||||
|
def test_invoke_codex_passes_prompt_through_stdin(self):
|
||||||
|
execute = load_execute()
|
||||||
|
with tempfile.TemporaryDirectory() as tmp:
|
||||||
|
root = Path(tmp)
|
||||||
|
write_phase(root)
|
||||||
|
executor = make_executor(execute, root)
|
||||||
|
step = {"step": 1, "name": "Docs"}
|
||||||
|
long_preamble = "x" * 40000
|
||||||
|
|
||||||
|
def fake_run(cmd, **kwargs):
|
||||||
|
return subprocess.CompletedProcess(cmd, 0, '{"event":"done"}\n', "")
|
||||||
|
|
||||||
|
with patch.object(execute.subprocess, "run", side_effect=fake_run) as run_mock:
|
||||||
|
executor._invoke_codex(step, long_preamble)
|
||||||
|
|
||||||
|
cmd = run_mock.call_args.args[0]
|
||||||
|
kwargs = run_mock.call_args.kwargs
|
||||||
|
self.assertEqual(
|
||||||
|
cmd,
|
||||||
|
["codex", "exec", "--dangerously-bypass-approvals-and-sandbox", "--json", "-"],
|
||||||
|
)
|
||||||
|
self.assertEqual(kwargs["input"], long_preamble + "# Step 1\n")
|
||||||
|
self.assertEqual(kwargs["cwd"], str(root))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|||||||
Reference in New Issue
Block a user