Keep configs in ~/.config/build-release/ and tool state in ~/.local/state/build-release/, under XDG_* where set
CI / tests (pull_request) Successful in 6m34s
CI / tests (pull_request) Successful in 6m34s
This commit is contained in:
@@ -139,7 +139,7 @@ class BenchTest(unittest.TestCase):
|
||||
|
||||
def bench(self, **given: str):
|
||||
with contextlib.redirect_stderr(io.StringIO()) as self.progress:
|
||||
return main.bench({**self.given, "--base": "main", **given}, self.env, lambda home: PLACES, self.home, NAME, USER)
|
||||
return main.bench({**self.given, "--base": "main", **given}, self.env, lambda home, env: PLACES, self.home, NAME, USER)
|
||||
|
||||
def calls(self) -> list[list[str]]:
|
||||
return [json.loads(line) for line in self.log.read_text().splitlines()]
|
||||
@@ -161,7 +161,7 @@ class BenchTest(unittest.TestCase):
|
||||
"| All | change | +2 | 0 % | 0 % | 0 % | 0 % | 0 | 0 % | 0 |",
|
||||
"",
|
||||
])
|
||||
self.assertTrue(folder.is_relative_to(self.home / ".local/state/larv-review") and folder.name == "task-bench", folder)
|
||||
self.assertTrue(folder.is_relative_to(self.home / ".local/state/build-release/larv-review") and folder.name == "task-bench", folder)
|
||||
results = json.loads((folder / "results.json").read_text())
|
||||
self.assertEqual((results["sides"], results["bugs"], len(results["runs"])), ({"base": self.base, "head": self.head}, {"1": "calc.go:4:11 ARITHMETIC_BASE"}, 4))
|
||||
self.assertEqual(results["runs"][0], {"bug": 1, "side": "base", "run": 1, "passed": False, "finished": True, "claude_code": "2.1.330", "model": "claude-haiku-5-5", "tokens": {"input": 40, "write_5m": 9000, "write_1h": 0, "read": 52000, "output": 800}, "turns": 3, "seconds": 61.5, "reads": 1})
|
||||
@@ -215,7 +215,7 @@ class BenchTest(unittest.TestCase):
|
||||
])
|
||||
|
||||
def test_removes_the_folders_other_benches_left_but_not_one_in_use_or_one_that_is_no_benchs(self):
|
||||
reports = self.home / ".local/state/larv-review"
|
||||
reports = self.home / ".local/state/build-release/larv-review"
|
||||
for name in ("crashed", "running", "a-project"):
|
||||
(reports / name / "task-bench/runs").mkdir(parents=True)
|
||||
(reports / "crashed/task-bench.lock").touch()
|
||||
@@ -237,7 +237,7 @@ class BenchTest(unittest.TestCase):
|
||||
self.assertEqual(main.host_user(), f"{os.getuid()}:{os.getgid()}")
|
||||
argv = [part for name, value in {**self.given, "--runs": "1"}.items() for part in (name, value)]
|
||||
with contextlib.redirect_stdout(io.StringIO()), contextlib.redirect_stderr(io.StringIO()):
|
||||
self.assertEqual(main.main(argv, self.env, lambda home: PLACES, name=lambda: "task-bench-other", user=lambda: "7:8"), 0)
|
||||
self.assertEqual(main.main(argv, self.env, lambda home, env: PLACES, name=lambda: "task-bench-other", user=lambda: "7:8"), 0)
|
||||
calls = self.calls()
|
||||
self.assertEqual(calls[1], ["network", "create", "--internal", "task-bench-other"])
|
||||
self.assertIn(["--user", "7:8"], [call[at:at + 2] for call in calls if "claude" in call for at in range(len(call))])
|
||||
@@ -249,7 +249,7 @@ class BenchTest(unittest.TestCase):
|
||||
argv = [part for name, value in self.given.items() for part in (name, value)]
|
||||
homes = []
|
||||
with contextlib.redirect_stdout(io.StringIO()) as out, contextlib.redirect_stderr(io.StringIO()):
|
||||
self.assertEqual(main.main(argv, self.env, lambda home: homes.append(home) or PLACES), 0)
|
||||
self.assertEqual(main.main(argv, self.env, lambda home, env: homes.append(home) or PLACES), 0)
|
||||
self.assertEqual(homes, [self.home])
|
||||
# Without --base, the base is the merge base with the default branch.
|
||||
self.assertEqual(out.getvalue().splitlines()[0], f"task-bench: base {self.base[:12]}, head {self.head[:12]}. 1 bug, each run 2 times at each side by claude-haiku-5-5 in Claude Code 2.1.330.")
|
||||
@@ -260,7 +260,7 @@ class BenchTest(unittest.TestCase):
|
||||
argv = [part for name, value in self.given.items() for part in (name, value)]
|
||||
for places, said in ((Failure("no history"), "no history\n"), ("- `gone.go:1` `Gone`: removed\n", "The places the seats found hard don't name any file at the base in a language the bench plants bugs in, so there is nowhere to plant a bug.\n")):
|
||||
with contextlib.redirect_stdout(io.StringIO()) as out, contextlib.redirect_stderr(io.StringIO()) as errors:
|
||||
self.assertEqual(main.main(argv, self.env, lambda home: places), 1)
|
||||
self.assertEqual(main.main(argv, self.env, lambda home, env: places), 1)
|
||||
self.assertEqual((out.getvalue(), errors.getvalue().splitlines(keepends=True)[-1]), ("", said))
|
||||
|
||||
def test_the_head_is_the_commit_asked_for(self):
|
||||
@@ -335,7 +335,7 @@ class BenchTest(unittest.TestCase):
|
||||
|
||||
def test_fails_where_the_places_name_no_file_of_the_base_in_a_language_the_bench_plants_in(self):
|
||||
with contextlib.redirect_stderr(io.StringIO()):
|
||||
found = main.bench({**self.given, "--base": "main"}, self.env, lambda home: "- `gone.go:1` `Gone`: removed\n- `README.md:1` `Calc`: thin\n", self.home, NAME, USER)
|
||||
found = main.bench({**self.given, "--base": "main"}, self.env, lambda home, env: "- `gone.go:1` `Gone`: removed\n- `README.md:1` `Calc`: thin\n", self.home, NAME, USER)
|
||||
self.assertEqual(found, Failure("The places the seats found hard don't name any file at the base in a language the bench plants bugs in, so there is nowhere to plant a bug."))
|
||||
self.assertFalse(self.log.exists())
|
||||
|
||||
@@ -361,14 +361,14 @@ class BenchTest(unittest.TestCase):
|
||||
found = self.bench()
|
||||
self.assertIsInstance(found, Failure)
|
||||
lines = found.reason.splitlines()
|
||||
folder = next(self.home.glob(".local/state/larv-review/**/task-bench"))
|
||||
folder = next(self.home.glob(".local/state/build-release/larv-review/**/task-bench"))
|
||||
self.assertEqual(lines[:3], ["claude could not use the API: API Error: 401", f"task-bench stopped after 2 of 4 runs, which results.json holds in {folder}:", ""])
|
||||
self.assertEqual(lines[-3:-1], ["| All | base | 0/1 | 40 | 9000 | 52000 | 800 | 3 | 61.5 | 1 |", "| All | head | 1/1 | 40 | 9000 | 52000 | 800 | 3 | 61.5 | 1 |"])
|
||||
self.assertEqual([(run["side"], run["run"]) for run in json.loads((folder / "results.json").read_text())["runs"]], [("base", 1), ("head", 1)])
|
||||
|
||||
def project_config(self) -> pathlib.Path:
|
||||
"""Writes the config that puts the project's records in the checkout, and returns its comprehension history's path."""
|
||||
config = self.home / ".claude-projects/calc/config.toml"
|
||||
config = self.home / ".config/build-release/calc/config.toml"
|
||||
config.parent.mkdir(parents=True)
|
||||
records = {"plan": "todo.md", "working-rules": "AGENTS.md", "decisions": "docs/decisions.md", "score-anchors": "docs/score-anchors.md", "comprehension-history": "docs/comprehension-history.md", "reading-cost": "docs/reading-cost.md", "changelog": "CHANGELOG.md", "goals-and-audience": "README.md"}
|
||||
config.write_text(f'checkout = "{self.repo}"\n' + "".join(f'{name} = "checkout:{path}"\n' for name, path in records.items()) + 'principles = "~/principles"\nstandards = "~/standards"\n')
|
||||
@@ -461,7 +461,7 @@ class MainTest(unittest.TestCase):
|
||||
|
||||
def test_takes_a_value_after_an_equals_sign_too(self):
|
||||
with contextlib.redirect_stderr(io.StringIO()) as errors:
|
||||
self.assertEqual(main.main(["--image=golang:1.27.4", "--test=go test ./...", "--bugs=2"], {"CLAUDE_CODE_OAUTH_TOKEN": "t", "HOME": "/nonexistent"}, lambda home: Failure("read the places")), 1)
|
||||
self.assertEqual(main.main(["--image=golang:1.27.4", "--test=go test ./...", "--bugs=2"], {"CLAUDE_CODE_OAUTH_TOKEN": "t", "HOME": "/nonexistent"}, lambda home, env: Failure("read the places")), 1)
|
||||
self.assertEqual(errors.getvalue(), "read the places\n")
|
||||
|
||||
def test_refuses_a_missing_image_or_test_command(self):
|
||||
|
||||
Reference in New Issue
Block a user