Answer stability round 1: 0 🔴, 5 🟡 (0 misread); match a checkout through symlinks, test a linked worktree and -h, hold tests to facts

This commit is contained in:
2026-11-12 23:15:34 +01:00
parent c46a68c1c6
commit 9fbffbf5dd
2 changed files with 46 additions and 27 deletions
+29 -13
View File
@@ -71,6 +71,13 @@ class LoadTest(ConfigCase):
assert isinstance(found, ProjectConfig), found
self.assertEqual(found.paths["principles"], pathlib.Path("/srv/principles"))
def test_a_checkout_reached_through_a_symlink_or_dots_finds_its_config(self) -> None:
self.write("acme", CLIENT)
(self.home / "work").symlink_to(self.home / "code")
for case, main in {"a symlink": self.home / "work" / "acme-billing", "dots": self.home / "code" / "other" / ".." / "acme-billing"}.items():
with self.subTest(case=case):
self.assertIsInstance(load(main, main, self.home), ProjectConfig)
def test_no_config_fails_naming_the_checkout_and_the_file_to_write(self) -> None:
for write_other in (False, True):
with self.subTest(write_other=write_other):
@@ -85,10 +92,10 @@ class LoadTest(ConfigCase):
self.write("acme", kept)
reason = self.failure()
for name in ("plan", "changelog", "principles"):
self.assertIn(f"`{name}`", reason)
file = self.home / ".claude-projects" / "acme" / "config.toml"
settings = "plan, working-rules, decisions, score-anchors, comprehension-history, reading-cost, changelog, goals-and-audience, principles"
self.assertEqual(reason, f"{file}: `plan` is missing; `changelog` is missing; `principles` is missing. The settings are {settings}.")
with self.subTest(name=name):
self.assertIn(f"`{name}` is missing", reason)
self.assertNotIn("`decisions` is", reason)
self.assertIn("acme/config.toml", reason)
def test_every_fault_in_one_config_is_named_together(self) -> None:
cases = {
@@ -113,8 +120,9 @@ class LoadTest(ConfigCase):
def test_two_configs_naming_one_checkout_fail_naming_both(self) -> None:
self.write("acme", CLIENT)
self.write("acme-copy", CLIENT)
projects = self.home / ".claude-projects"
self.assertEqual(self.failure(), f"{projects}/acme/config.toml and {projects}/acme-copy/config.toml both name the checkout {self.checkout}; one config may")
reason = self.failure()
self.assertIn("acme/config.toml", reason)
self.assertIn("acme-copy/config.toml", reason)
def test_a_config_that_cannot_be_read_fails_whichever_checkout_asks(self) -> None:
cases = {"not TOML": "checkout = ", "no checkout": 'plan = "folder:todo.md"\n', "a checkout that is not text": "checkout = 3\n", "a relative checkout": 'checkout = "code/acme"\n'}
@@ -123,10 +131,7 @@ class LoadTest(ConfigCase):
self.home = pathlib.Path(made).resolve()
self.write("acme", CLIENT)
self.write("broken", text)
reason = self.failure()
self.assertIn("broken/config.toml", reason)
if case == "a relative checkout":
self.assertTrue(reason.endswith(", not 'code/acme'"), reason)
self.assertIn("broken/config.toml", self.failure())
def test_a_folder_with_no_config_is_skipped(self) -> None:
self.write("acme", CLIENT)
@@ -161,9 +166,20 @@ class ToolTest(ConfigCase):
self.assertIn(said, ran.stderr)
def test_help_shows_a_config(self) -> None:
ran = self.run_tool("--help")
self.assertEqual(ran.returncode, 0)
self.assertIn('plan = "folder:todo.md"', ran.stdout)
for flag in ("-h", "--help"):
with self.subTest(flag=flag):
ran = self.run_tool(flag)
self.assertEqual(ran.returncode, 0)
self.assertIn('plan = "folder:todo.md"', ran.stdout)
def test_a_linked_worktree_finds_the_config_and_prints_its_own_files(self) -> None:
self.write("acme", CLIENT)
worktree = self.home / "code" / "acme-billing-item-3"
git = ["git", "-C", str(self.checkout), "-c", "user.name=t", "-c", "user.email=t@example.com"]
subprocess.run([*git, "commit", "-q", "--allow-empty", "-m", "first"], check=True, env=isolated_env())
subprocess.run([*git, "worktree", "add", "-q", str(worktree)], check=True, env=isolated_env())
ran = self.run_tool("changelog", cwd=worktree)
self.assertEqual((ran.returncode, ran.stdout), (0, f"{worktree}/CHANGELOG.md\n"))
if __name__ == "__main__":