fix: allow harness codex command override
This commit is contained in:
@@ -405,6 +405,9 @@ class StepExecutor:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _codex_command() -> str:
|
def _codex_command() -> str:
|
||||||
|
override = os.environ.get("HARNESS_CODEX_COMMAND", "").strip()
|
||||||
|
if override:
|
||||||
|
return override
|
||||||
return (
|
return (
|
||||||
shutil.which("codex.cmd")
|
shutil.which("codex.cmd")
|
||||||
or shutil.which("codex.exe")
|
or shutil.which("codex.exe")
|
||||||
|
|||||||
@@ -296,7 +296,8 @@ class ExecuteRunnerSafetyTests(unittest.TestCase):
|
|||||||
|
|
||||||
with patch.object(execute.subprocess, "run", side_effect=fake_run) as run_mock:
|
with patch.object(execute.subprocess, "run", side_effect=fake_run) as run_mock:
|
||||||
with patch.object(executor, "_codex_command", return_value="codex.cmd"):
|
with patch.object(executor, "_codex_command", return_value="codex.cmd"):
|
||||||
executor._invoke_codex(step, long_preamble)
|
with patch.dict(os.environ, {"HARNESS_CODEX_MODEL": ""}):
|
||||||
|
executor._invoke_codex(step, long_preamble)
|
||||||
|
|
||||||
cmd = run_mock.call_args.args[0]
|
cmd = run_mock.call_args.args[0]
|
||||||
kwargs = run_mock.call_args.kwargs
|
kwargs = run_mock.call_args.kwargs
|
||||||
@@ -322,6 +323,12 @@ class ExecuteRunnerSafetyTests(unittest.TestCase):
|
|||||||
with patch.object(execute.shutil, "which", side_effect=fake_which):
|
with patch.object(execute.shutil, "which", side_effect=fake_which):
|
||||||
self.assertEqual(execute.StepExecutor._codex_command(), "C:/tools/codex.cmd")
|
self.assertEqual(execute.StepExecutor._codex_command(), "C:/tools/codex.cmd")
|
||||||
|
|
||||||
|
def test_codex_command_uses_env_override_first(self):
|
||||||
|
execute = load_execute()
|
||||||
|
|
||||||
|
with patch.dict(os.environ, {"HARNESS_CODEX_COMMAND": "C:/app/codex.exe"}):
|
||||||
|
self.assertEqual(execute.StepExecutor._codex_command(), "C:/app/codex.exe")
|
||||||
|
|
||||||
def test_codex_exec_command_uses_model_env_override(self):
|
def test_codex_exec_command_uses_model_env_override(self):
|
||||||
execute = load_execute()
|
execute = load_execute()
|
||||||
with tempfile.TemporaryDirectory() as tmp:
|
with tempfile.TemporaryDirectory() as tmp:
|
||||||
|
|||||||
Reference in New Issue
Block a user