fix: resolve codex shim for harness runner

This commit is contained in:
김경종
2026-06-12 17:33:23 +09:00
parent 2bab84beb6
commit 3ce43c8670
2 changed files with 27 additions and 3 deletions
+16 -2
View File
@@ -294,17 +294,31 @@ class ExecuteRunnerSafetyTests(unittest.TestCase):
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)
with patch.object(executor, "_codex_command", return_value="codex.cmd"):
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", "-"],
["codex.cmd", "exec", "--dangerously-bypass-approvals-and-sandbox", "--json", "-"],
)
self.assertEqual(kwargs["input"], long_preamble + "# Step 1\n")
self.assertEqual(kwargs["cwd"], str(root))
def test_codex_command_prefers_windows_cmd_or_exe_shim(self):
execute = load_execute()
def fake_which(name):
return {
"codex.cmd": "C:/tools/codex.cmd",
"codex.exe": "C:/tools/codex.exe",
"codex": "C:/tools/codex",
}.get(name)
with patch.object(execute.shutil, "which", side_effect=fake_which):
self.assertEqual(execute.StepExecutor._codex_command(), "C:/tools/codex.cmd")
if __name__ == "__main__":
unittest.main()