Run the claude children at the root, and pin the root the tests hand on

This commit is contained in:
2026-09-25 18:11:27 +02:00
parent d64eaef9e7
commit 24ebeb0f94
2 changed files with 16 additions and 12 deletions
+8 -3
View File
@@ -100,6 +100,8 @@ class CheckoutRoot(unittest.TestCase):
os.makedirs("a/b")
with contextlib.chdir("a/b"):
self.assertEqual(loop.checkout_root(), root)
subprocess.run(["git", "init", "-q", "other"], check=True)
with contextlib.chdir("other"):
self.assertEqual(loop.checkouts(root), [root])
@@ -193,10 +195,12 @@ class Interrupt(unittest.TestCase):
with (
unittest.mock.patch("sys.stdin.isatty", return_value=True),
unittest.mock.patch("sys.stdout.isatty", return_value=True),
unittest.mock.patch.multiple(loop, checkouts=unittest.mock.DEFAULT, trust=unittest.mock.DEFAULT),
unittest.mock.patch.multiple(loop, checkouts=unittest.mock.DEFAULT, trust=unittest.mock.DEFAULT) as mocks,
unittest.mock.patch("subprocess.run") as run,
):
self.assertEqual(loop.interrupt(root, SESSION_ID, transcript, "q?"), "the interrupt ended without the human typing anything")
mocks["checkouts"].assert_called_with(root)
self.assertEqual(run.call_args.kwargs["cwd"], root)
run.side_effect = lambda *args, **kwargs: open(transcript, "a").write(json.dumps(human("typed")) + "\n")
self.assertEqual(loop.interrupt(root, SESSION_ID, transcript, "q?"), "")
@@ -257,7 +261,7 @@ class Verdict(unittest.TestCase):
STUB_CLAUDE = """#!/usr/bin/env python3
import json, os, sys
args = sys.argv[1:]
open(os.environ["STUB_CALLS"], "a").write(json.dumps(args) + "\\n")
open(os.environ["STUB_CALLS"], "a").write(json.dumps([os.getcwd(), *args]) + "\\n")
if "--json-schema" in args:
plan = open(os.environ["STUB_VERDICTS"]).read().split()
open(os.environ["STUB_VERDICTS"], "w").write(" ".join(plan[1:]))
@@ -288,7 +292,7 @@ class RunWorker(unittest.TestCase):
for failure, script in scripts.items():
open(stub, "w").write(f"#!/usr/bin/env python3\nimport json\nimport os\nimport sys\n{script}\n")
os.chmod(stub, 0o700)
self.assertEqual(loop.run_worker([]), failure)
self.assertEqual(loop.run_worker(bin, []), failure)
class RunCycle(unittest.TestCase):
@@ -319,6 +323,7 @@ class RunCycle(unittest.TestCase):
if plan.startswith("unquoted"):
self.assertIn("asking: q?", stopped.exception.code)
self.assertEqual(open(verdicts).read(), "")
self.assertEqual({json.loads(line)[0] for line in open(calls)}, {home})
starts = [args[args.index("-p") + 1:][:3] for args in map(json.loads, open(calls)) if "--json-schema" not in args]
self.assertEqual([start[1] for start in starts], ["--name", "--resume", "--name", "--resume", "--resume", "--resume"])
self.assertEqual(starts[1][2], SESSION_ID)