Pin that an edited package file reloads the loop
This commit is contained in:
@@ -4,6 +4,7 @@ import io
|
||||
import json
|
||||
import os
|
||||
import pathlib
|
||||
import shutil
|
||||
import stat
|
||||
import subprocess
|
||||
import sys
|
||||
@@ -431,6 +432,24 @@ class RunCycle(unittest.TestCase):
|
||||
self.assertEqual({args[args.index("--model") + 1] for args in map(json.loads, pathlib.Path(calls).read_text().splitlines())}, {"claude-opus-5-5"})
|
||||
|
||||
|
||||
class Reload(unittest.TestCase):
|
||||
def test_an_edited_package_file_reloads_once_the_launcher_answers_help(self):
|
||||
with tempfile.TemporaryDirectory() as root:
|
||||
copy = pathlib.Path(root, "bin")
|
||||
shutil.copytree(LAUNCHER.parent, copy, ignore=shutil.ignore_patterns("__pycache__", "test_*"))
|
||||
launcher, edited = copy / "loop-claude", copy / "loop_claude" / "cycle.py"
|
||||
state = main.LoopState(1, 2, "/r", "do it")
|
||||
with unittest.mock.patch.object(main, "__file__", str(copy / "loop_claude" / "main.py")), unittest.mock.patch("os.execv") as execv, contextlib.redirect_stderr(io.StringIO()) as err:
|
||||
baseline = main.fingerprint(launcher)
|
||||
edited.write_text(edited.read_text() + "\ndef\n")
|
||||
main.reload_if_edited(launcher, baseline, state)
|
||||
execv.assert_not_called()
|
||||
self.assertIn("keeping the running script", err.getvalue())
|
||||
edited.write_text(edited.read_text().replace("\ndef\n", "\n# edited\n"))
|
||||
main.reload_if_edited(launcher, baseline, state)
|
||||
execv.assert_called_once_with(sys.executable, [sys.executable, str(launcher), main.RELOAD_FLAG, json.dumps({"cycle_number": 1, "failures": 2, "root": "/r", "task": "do it"})])
|
||||
|
||||
|
||||
class Main(unittest.TestCase):
|
||||
def test_returns_the_exit_code_of_the_stop_the_loop_returned(self):
|
||||
for argv, code, stream in ((["--help"], 0, "stdout"), ([], 1, "stderr"), ([main.RELOAD_FLAG, "3"], 1, "stderr")):
|
||||
|
||||
Reference in New Issue
Block a user