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:
@@ -46,19 +46,19 @@ class Features(typing.NamedTuple):
|
||||
found: list[Feature]
|
||||
|
||||
|
||||
def read_features(home: pathlib.Path, kind: Kind) -> Features | Failure:
|
||||
def read_features(home: pathlib.Path, env: typing.Mapping[str, str], kind: Kind) -> Features | Failure:
|
||||
"""The features of the current directory's project, or its data sources where kind is DATA_SOURCE, read from the folder its
|
||||
config names."""
|
||||
folder = features_folder(home)
|
||||
folder = features_folder(home, env)
|
||||
if isinstance(folder, Failure):
|
||||
return folder
|
||||
found = features(folder, kind)
|
||||
return found if isinstance(found, Failure) else Features(folder, found)
|
||||
|
||||
|
||||
def features_folder(home: pathlib.Path) -> pathlib.Path | Failure:
|
||||
def features_folder(home: pathlib.Path, env: typing.Mapping[str, str]) -> pathlib.Path | Failure:
|
||||
"""The folder the config of the current directory's project names as `bench-tasks`."""
|
||||
config = located(None, home)
|
||||
config = located(None, home, env)
|
||||
if isinstance(config, Failure):
|
||||
return config
|
||||
return config.paths.get(BENCH_TASKS) or Failure(f"{config.folder / CONFIG} sets no `{BENCH_TASKS}`, the folder of the tasks to bench, as `project-config --help` describes it")
|
||||
|
||||
@@ -52,15 +52,15 @@ class ShippedFeatures(typing.NamedTuple):
|
||||
records: list[str]
|
||||
|
||||
|
||||
def read_shipped(home: pathlib.Path, checkout: str, base: str, git: Git) -> ShippedFeatures | Failure:
|
||||
def read_shipped(home: pathlib.Path, env: typing.Mapping[str, str], checkout: str, base: str, git: Git) -> ShippedFeatures | Failure:
|
||||
"""The features that the project in checkout shipped on the first-parent line of the commit base. A Failure where no config
|
||||
names the checkout, where its config puts the plan or a record at a path branch_chunks doesn't read, where git fails, and
|
||||
where that line shipped no item."""
|
||||
in_checkout = functools.partial(git, cwd=checkout)
|
||||
config = located(checkout, home, in_checkout)
|
||||
config = located(checkout, home, env, in_checkout)
|
||||
if isinstance(config, Failure):
|
||||
return config
|
||||
if why := unsupported(checkout, home, in_checkout):
|
||||
if why := unsupported(checkout, home, env, in_checkout):
|
||||
return Failure(f"task-bench cannot tell what the project shipped: {why}")
|
||||
cut = cut_with_shipped(base, in_checkout, config.titles)
|
||||
if isinstance(cut, Failure):
|
||||
|
||||
@@ -88,7 +88,7 @@ class BenchOfTasksCase(unittest.TestCase):
|
||||
self.addCleanup(folder.cleanup)
|
||||
self.root = pathlib.Path(folder.name).resolve()
|
||||
self.home, self.repo, fakes = self.root / "home", self.root / "repo", self.root / "fakes"
|
||||
for made in (self.home / ".claude-projects/calc", self.repo, fakes):
|
||||
for made in (self.home / ".config/build-release/calc", self.repo, fakes):
|
||||
made.mkdir(parents=True)
|
||||
(fakes / "docker").write_text(DOCKER)
|
||||
(fakes / "docker").chmod(0o755)
|
||||
@@ -96,7 +96,7 @@ class BenchOfTasksCase(unittest.TestCase):
|
||||
self.log = self.root / "docker.log"
|
||||
self.env = {**isolated_env(), "HOME": str(self.home), "PATH": f"{fakes}{os.pathsep}{os.environ['PATH']}", "FAKE_LOG": str(self.log), "FAKE_CLAUDE": str(fakes / "claude.py"), "CLAUDE_CODE_OAUTH_TOKEN": "sk-secret-token"}
|
||||
self.given = {"--image": "golang:1.27.4", "--test": TEST, "--tasks": "features", "--runs": "2", "--base": "main"}
|
||||
self.config = self.home / ".claude-projects/calc/config.toml"
|
||||
self.config = self.home / ".config/build-release/calc/config.toml"
|
||||
self.config.write_text(f'checkout = "{self.repo}"\n{CONFIG}bench-tasks = "checkout:bench-tasks"\n')
|
||||
self.tasks = self.repo / "bench-tasks"
|
||||
self.git("init", "--quiet", "--initial-branch", "main")
|
||||
@@ -188,7 +188,7 @@ class FeatureBenchTest(BenchOfTasksCase):
|
||||
])
|
||||
|
||||
def test_reads_the_features_from_a_folder_outside_the_checkout(self):
|
||||
outside = self.home / ".claude-projects/calc/bench-tasks"
|
||||
outside = self.home / ".config/build-release/calc/bench-tasks"
|
||||
self.tasks.rename(outside)
|
||||
self.config.write_text(self.config.read_text().replace("checkout:bench-tasks", "folder:bench-tasks"))
|
||||
self.head = self.commit("Move the features out")
|
||||
|
||||
@@ -236,7 +236,7 @@ class ShippedFeatureBenchTest(ShippedFeaturesCase):
|
||||
|
||||
class ReadShippedTest(ShippedFeaturesCase):
|
||||
def read(self, run=git):
|
||||
return read_shipped(self.home, str(self.repo), "main", functools.partial(run, env=self.env))
|
||||
return read_shipped(self.home, {}, str(self.repo), "main", functools.partial(run, env=self.env))
|
||||
|
||||
def test_reads_the_features_newest_first_with_the_paths_a_revert_leaves_alone(self):
|
||||
shipped = self.read()
|
||||
|
||||
@@ -30,10 +30,10 @@ def gather(env: typing.Mapping[str, str], home: pathlib.Path, claude: Claude) ->
|
||||
checkout = top(git)
|
||||
if isinstance(checkout, Failure):
|
||||
return checkout
|
||||
rung = project_rung(home, git)
|
||||
rung = project_rung(home, env, git)
|
||||
if isinstance(rung, Failure):
|
||||
return rung
|
||||
review = made_review_folder(checkout, home)
|
||||
review = made_review_folder(checkout, home, env)
|
||||
if isinstance(review, Failure):
|
||||
return review
|
||||
with held(review) as folder:
|
||||
@@ -61,20 +61,20 @@ def run_claude(args: list[str], cwd: str, prompt: str) -> subprocess.CompletedPr
|
||||
return subprocess.run(["claude", *args], capture_output=True, cwd=cwd, env=with_release_tools(os.environ), input=prompt, text=True)
|
||||
|
||||
|
||||
def project_rung(home: pathlib.Path, git: Git) -> Rung | Failure:
|
||||
def project_rung(home: pathlib.Path, env: typing.Mapping[str, str], git: Git) -> Rung | Failure:
|
||||
"""The cheapest rung for the model build-release runs the project on. The routing ladder is that of the project the process runs in."""
|
||||
common = git("rev-parse", "--path-format=absolute", "--git-common-dir")
|
||||
if isinstance(common, Failure):
|
||||
return common
|
||||
# A worktree's project is its main checkout's, which holds the folder every worktree shares.
|
||||
key = project_key(os.path.dirname(common.strip()), home)
|
||||
saved = paths_from(home).models_file
|
||||
saved = paths_from(home, env).models_file
|
||||
models = read_models_file(saved)
|
||||
if isinstance(models, Failure):
|
||||
return models
|
||||
if key not in models:
|
||||
return Failure(f"{saved} names no model for {key}: run build-release in the project once, which asks for it.")
|
||||
ladder = project_ladder(None, home)
|
||||
ladder = project_ladder(None, home, env)
|
||||
if isinstance(ladder, Failure):
|
||||
return ladder
|
||||
project = ladder.project_rung(models[key])
|
||||
|
||||
@@ -23,23 +23,23 @@ COMMIT_LENGTH = 8
|
||||
TASKS_NAMED = {f"| {kind.noun.capitalize()} |": f" {tasks}" for tasks, kind in KINDS.items() if kind is not BUG}
|
||||
|
||||
|
||||
def recorded_bench(run: typing.Callable[[], list[str] | Failure], folder: pathlib.Path, git: Git, home: pathlib.Path, now: typing.Callable[[], float]) -> list[str] | Failure:
|
||||
def recorded_bench(run: typing.Callable[[], list[str] | Failure], folder: pathlib.Path, git: Git, home: pathlib.Path, env: typing.Mapping[str, str], now: typing.Callable[[], float]) -> list[str] | Failure:
|
||||
"""The report of the bench that run runs in folder, plus the line that says where its figures went. It refuses before the bench where the history cannot be read, since a bench takes hours. A bench that fails or stops records nothing."""
|
||||
branch = git("rev-parse", "--abbrev-ref", "HEAD")
|
||||
if isinstance(branch, Failure):
|
||||
return branch
|
||||
if isinstance(unreadable := held_history(home), Failure):
|
||||
if isinstance(unreadable := held_history(home, env), Failure):
|
||||
return unreadable
|
||||
report = run()
|
||||
if isinstance(report, Failure):
|
||||
return report
|
||||
recorded = record_figures(folder, branch.strip(), home, now())
|
||||
recorded = record_figures(folder, branch.strip(), home, env, now())
|
||||
if isinstance(recorded, Failure):
|
||||
return Failure(f"the bench finished and {folder} holds its results, but its figures are not recorded: {recorded.reason}")
|
||||
return [*report, recorded]
|
||||
|
||||
|
||||
def record_figures(folder: pathlib.Path, branch: str, home: pathlib.Path, now: float) -> str | Failure:
|
||||
def record_figures(folder: pathlib.Path, branch: str, home: pathlib.Path, env: typing.Mapping[str, str], now: float) -> str | Failure:
|
||||
"""Appends the entry of the bench whose digest folder holds, stamped with now, and returns the line the tool prints."""
|
||||
try:
|
||||
digest = (folder / DIGEST).read_text(encoding="utf-8")
|
||||
@@ -48,7 +48,7 @@ def record_figures(folder: pathlib.Path, branch: str, home: pathlib.Path, now: f
|
||||
entry = bench_entry(digest, branch, now)
|
||||
if entry is None:
|
||||
return Failure(f"{folder / DIGEST} is no task-bench digest: it lacks the line that names its base and head, or the table's three All rows")
|
||||
read = held_history(home)
|
||||
read = held_history(home, env)
|
||||
return read if isinstance(read, Failure) else bench_appended(*read, *entry)
|
||||
|
||||
|
||||
|
||||
@@ -29,10 +29,10 @@ class GatherTest(unittest.TestCase):
|
||||
self.env = {**isolated_env(), "HOME": str(self.home)}
|
||||
self.git("init", "--quiet", "--initial-branch", "main")
|
||||
self.git("commit", "--quiet", "--allow-empty", "--message", "Base")
|
||||
self.models = self.home / ".claude/loop-claude-models.json"
|
||||
self.models.parent.mkdir()
|
||||
self.models = self.home / ".config/build-release/models.json"
|
||||
self.models.parent.mkdir(parents=True)
|
||||
self.models.write_text(json.dumps({"calc": "claude-opus-5-5"}))
|
||||
self.bench = self.home / ".local/state/larv-review/code/calc/task-bench"
|
||||
self.bench = self.home / ".local/state/build-release/larv-review/code/calc/task-bench"
|
||||
(self.bench / "runs").mkdir(parents=True)
|
||||
(self.bench / "digest.md").write_text("# task-bench digest\n\n## Bug 1: calc.go:4:11 ARITHMETIC_BASE\n")
|
||||
self.calls: list[tuple[list[str], str, str]] = []
|
||||
@@ -61,7 +61,7 @@ class GatherTest(unittest.TestCase):
|
||||
def test_a_worktrees_project_is_its_main_checkouts(self):
|
||||
worktree = self.home / "code/calc-item-7"
|
||||
self.git("worktree", "add", "--quiet", str(worktree), "-b", "item-7")
|
||||
bench = self.home / ".local/state/larv-review/code/calc-item-7/task-bench"
|
||||
bench = self.home / ".local/state/build-release/larv-review/code/calc-item-7/task-bench"
|
||||
bench.mkdir(parents=True)
|
||||
(bench / "digest.md").write_text("worktree's\n")
|
||||
with contextlib.chdir(worktree):
|
||||
@@ -77,7 +77,7 @@ class GatherTest(unittest.TestCase):
|
||||
def test_a_gather_before_any_review_makes_the_review_folders_private(self):
|
||||
shutil.rmtree(self.home / ".local")
|
||||
self.assertIsInstance(gather(self.env, self.home, self.claude), Failure)
|
||||
self.assertEqual((self.home / ".local/state/larv-review").stat().st_mode & 0o777, 0o700)
|
||||
self.assertEqual((self.home / ".local/state/build-release/larv-review").stat().st_mode & 0o777, 0o700)
|
||||
|
||||
def test_a_claude_that_fails_or_hits_a_limit_keeps_the_folder_for_another_try(self):
|
||||
self.code = 1
|
||||
|
||||
@@ -45,10 +45,10 @@ class RecordFiguresTest(unittest.TestCase):
|
||||
self.repo.mkdir(parents=True)
|
||||
# The project's config is found from the checkout's top, which git names.
|
||||
subprocess.run(["git", "init", "--quiet"], cwd=self.repo, env={**isolated_env(), "HOME": str(self.home)}, check=True)
|
||||
config = self.home / ".claude-projects/calc/config.toml"
|
||||
config = self.home / ".config/build-release/calc/config.toml"
|
||||
config.parent.mkdir(parents=True)
|
||||
config.write_text(PROJECT_CONFIG)
|
||||
self.bench = self.home / ".local/state/larv-review/code/calc/task-bench"
|
||||
self.bench = self.home / ".local/state/build-release/larv-review/code/calc/task-bench"
|
||||
self.bench.mkdir(parents=True)
|
||||
self.history = self.repo / "docs/comprehension-history.md"
|
||||
self.ran = 0
|
||||
@@ -67,7 +67,7 @@ class RecordFiguresTest(unittest.TestCase):
|
||||
return report
|
||||
|
||||
def recorded(self, run=None) -> list[str] | str:
|
||||
found = recorded_bench(run or self.left, self.bench, self.git, self.home, lambda: NOW)
|
||||
found = recorded_bench(run or self.left, self.bench, self.git, self.home, {}, lambda: NOW)
|
||||
return found.reason if isinstance(found, Failure) else found
|
||||
|
||||
def unrecorded(self, why: str) -> str:
|
||||
@@ -95,7 +95,7 @@ class RecordFiguresTest(unittest.TestCase):
|
||||
self.git = lambda *args: Failure("git failed")
|
||||
self.assertEqual(self.recorded(), "git failed")
|
||||
del self.git
|
||||
(self.home / ".claude-projects/calc/config.toml").unlink()
|
||||
(self.home / ".config/build-release/calc/config.toml").unlink()
|
||||
self.assertTrue(self.recorded().startswith(f"no config names the checkout {self.repo}"), self.recorded())
|
||||
self.assertEqual(self.ran, 0)
|
||||
|
||||
@@ -125,7 +125,7 @@ class RecordFiguresTest(unittest.TestCase):
|
||||
|
||||
def test_says_why_where_the_history_cannot_be_read_once_the_bench_has_run(self):
|
||||
def run():
|
||||
(self.home / ".claude-projects/calc/config.toml").unlink()
|
||||
(self.home / ".config/build-release/calc/config.toml").unlink()
|
||||
return self.left()
|
||||
self.assertTrue(self.recorded(run).startswith(self.unrecorded(f"no config names the checkout {self.repo}")))
|
||||
|
||||
|
||||
+10
-10
@@ -216,7 +216,7 @@ from failure import Failure
|
||||
from task_bench.features.feature_tasks import feature_tasks, Features, read_features
|
||||
from task_bench.figures.run_figures import Figures, figures, Result, table
|
||||
from git_cli import git_repo
|
||||
from review_rules.review_folder import made_review_folder, REPORTS
|
||||
from review_rules.review_folder import made_review_folder, reports_folder
|
||||
from larv_review.history_commands import read_places
|
||||
from task_bench.features.shipped_features import read_shipped, shipped_tasks
|
||||
from task_bench.figures.record_figures import recorded_bench
|
||||
@@ -258,7 +258,7 @@ class Call(typing.NamedTuple):
|
||||
and the home folder."""
|
||||
given: dict[str, str]
|
||||
env: typing.Mapping[str, str]
|
||||
read: typing.Callable[[pathlib.Path], str | Failure]
|
||||
read: typing.Callable[[pathlib.Path, typing.Mapping[str, str]], str | Failure]
|
||||
home: pathlib.Path
|
||||
|
||||
|
||||
@@ -272,7 +272,7 @@ def host_user() -> str:
|
||||
return f"{os.getuid()}:{os.getgid()}"
|
||||
|
||||
|
||||
def main(argv: list[str], env: typing.Mapping[str, str], read: typing.Callable[[pathlib.Path], str | Failure] = read_places, claude: Claude = run_claude, name: typing.Callable[[], str] = new_name, user: typing.Callable[[], str] = host_user) -> int:
|
||||
def main(argv: list[str], env: typing.Mapping[str, str], read: typing.Callable[[pathlib.Path, typing.Mapping[str, str]], str | Failure] = read_places, claude: Claude = run_claude, name: typing.Callable[[], str] = new_name, user: typing.Callable[[], str] = host_user) -> int:
|
||||
"""Runs task-bench with the arguments argv; git, docker and the mutation tool run in the environment env, `read` reads what
|
||||
`larv-review places` prints for the checkout, and `claude` runs the claude that gathers. `name` names a bench's containers,
|
||||
and `user` is the user they run as."""
|
||||
@@ -356,7 +356,7 @@ def progress(line: str) -> None:
|
||||
print(line, file=sys.stderr)
|
||||
|
||||
|
||||
def bench(given: dict[str, str], env: typing.Mapping[str, str], read: typing.Callable[[pathlib.Path], str | Failure], home: pathlib.Path, name: str, user: str) -> list[str] | Failure:
|
||||
def bench(given: dict[str, str], env: typing.Mapping[str, str], read: typing.Callable[[pathlib.Path, typing.Mapping[str, str]], str | Failure], home: pathlib.Path, name: str, user: str) -> list[str] | Failure:
|
||||
"""The report of one bench of the checkout the process runs in, where `read` reads what `larv-review places` prints. Its
|
||||
containers are named name and run as user. It tells its progress on stderr."""
|
||||
kind = KINDS[given[TASKS]]
|
||||
@@ -375,16 +375,16 @@ def bench(given: dict[str, str], env: typing.Mapping[str, str], read: typing.Cal
|
||||
if isinstance(planning, Failure):
|
||||
return planning
|
||||
progress(f"task-bench: base {sides['base'][:12]}, head {sides['head'][:12]}.")
|
||||
review = made_review_folder(checkout, home)
|
||||
review = made_review_folder(checkout, home, env)
|
||||
if isinstance(review, Failure):
|
||||
return review
|
||||
with held(review) as folder:
|
||||
if isinstance(folder, Failure):
|
||||
return folder
|
||||
clear_left(home / REPORTS)
|
||||
clear_left(reports_folder(home, env))
|
||||
containers = Containers(docker_cli(env), name, given["--test"], int(env.get(SHARE_VARIABLE) or MEMORY_MIB), user)
|
||||
run = functools.partial(bench_in, folder, given["--image"], containers, Asked(kind, int(given["--runs"])), planning, checkout, sides, git)
|
||||
return recorded_bench(run, folder, git, home, time.time) if RECORD in given else run()
|
||||
return recorded_bench(run, folder, git, home, env, time.time) if RECORD in given else run()
|
||||
|
||||
|
||||
def bench_in(folder: pathlib.Path, image: str, containers: Containers, asked: Asked, planning: Planning, checkout: str, sides: dict[Side, str], git: Git) -> list[str] | Failure:
|
||||
@@ -409,7 +409,7 @@ def bench_in(folder: pathlib.Path, image: str, containers: Containers, asked: As
|
||||
|
||||
def bugs_source(call: Call, kind: Kind) -> Source | Failure:
|
||||
"""Reads the seats' places, the only places bugs are planted."""
|
||||
places = call.read(call.home)
|
||||
places = call.read(call.home, call.env)
|
||||
if isinstance(places, Failure):
|
||||
return places
|
||||
return lambda checkout, sides, git: functools.partial(bugs_planner, call.given, call.env, places)
|
||||
@@ -417,7 +417,7 @@ def bugs_source(call: Call, kind: Kind) -> Source | Failure:
|
||||
|
||||
def features_source(call: Call, kind: Kind) -> Source | Failure:
|
||||
"""Reads the features, or the data sources where kind is DATA_SOURCE, from the project's folder."""
|
||||
features = read_features(call.home, kind)
|
||||
features = read_features(call.home, call.env, kind)
|
||||
if isinstance(features, Failure):
|
||||
return features
|
||||
return lambda checkout, sides, git: functools.partial(features_planner, features, checkout)
|
||||
@@ -426,7 +426,7 @@ def features_source(call: Call, kind: Kind) -> Source | Failure:
|
||||
def shipped_source(call: Call, kind: Kind) -> Source:
|
||||
"""Shipped features are read from the base's history, so only once the base is known."""
|
||||
def source(checkout: str, sides: dict[Side, str], git: Git) -> Planning | Failure:
|
||||
shipped = read_shipped(call.home, checkout, sides["base"], git)
|
||||
shipped = read_shipped(call.home, call.env, checkout, sides["base"], git)
|
||||
if isinstance(shipped, Failure):
|
||||
return shipped
|
||||
return lambda trees: functools.partial(shipped_tasks, shipped=shipped, count=int(call.given["--shipped"]))
|
||||
|
||||
@@ -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