Test task-bench's docker calls, command line and planter where mutants survived
CI / tests (pull_request) Successful in 4m38s

This commit is contained in:
2026-11-21 01:39:12 +01:00
parent fed84cc510
commit ebbe926ab7
7 changed files with 316 additions and 35 deletions
+19 -18
View File
@@ -52,18 +52,17 @@ import tarfile
import typing
import uuid
from claude_code.tokens import Tokens
from failure import Failure
from git_cli import git_repo
from git_cli.git_repo import default_ref, Git, top
from larv_review.history_commands import read_places
from task_bench.runs import checked_tree, closed, Containers, docker_cli, fix_attempted, MEMORY_MIB, opened, ran_tests, TOKEN
from machine_load.slots import CPUS_PER_SLOT
from mutate_changes.tool_process import failed, Ran, run_tool
from review_rules.review_folder import made_review_folder
from run_heavy.capped_docker import SHARE_VARIABLE
from task_bench.figures import Figures, figures, Result, SIDES, table, WORK
from git_cli.git_repo import default_ref, Git, top
from task_bench.plant import drawn, killed_mutants, line_at_head, Mutant, mutated, place_files, task_text
from task_bench.runs import checked_tree, closed, Containers, docker_cli, fix_attempted, MEMORY_MIB, opened, tests_run, TOKEN
from mutate_changes.tool_process import failed, Ran, run_tool
from failure import Failure
from task_bench.figures import figures, Result, SIDES, table, WORK
from git_cli import git_repo
from review_rules.review_folder import made_review_folder
from larv_review.history_commands import read_places
from run_heavy.capped_docker import SHARE_VARIABLE
USAGE = "usage: task-bench --image <image> --test <shell text> [--base <ref>] [--head <ref>] [--prefix <shell text>] [--seed <n>] [--bugs <n>] [--runs <n>]"
# A panel of three readers, seated as the README's audience, picked these options on 2026-11-21, each 3 to 0.
@@ -85,8 +84,9 @@ class Task:
return f"{self.mutant.path}:{self.mutant.line}:{self.mutant.column} {self.mutant.mutator}"
def main(argv: list[str], env: typing.Mapping[str, str]) -> int:
"""Runs task-bench with the arguments argv; git, docker and Gremlins run in the environment env."""
def main(argv: list[str], env: typing.Mapping[str, str], read: typing.Callable[[pathlib.Path], str | Failure] = read_places) -> int:
"""Runs task-bench with the arguments argv; git, docker and Gremlins run in the environment env, and `read` reads what
`larv-review places` prints for the checkout."""
if argv in (["-h"], ["--help"]):
print(__doc__.strip())
return 0
@@ -95,7 +95,7 @@ def main(argv: list[str], env: typing.Mapping[str, str]) -> int:
print(f"{given.reason}; {USAGE}", file=sys.stderr)
return 1
home = pathlib.Path(env.get("HOME") or pathlib.Path.home())
places = read_places(home)
places = read(home)
report = places if isinstance(places, Failure) else bench(given, env, places, home)
if isinstance(report, Failure):
print(report.reason, file=sys.stderr)
@@ -269,7 +269,7 @@ def tests_in_copy(containers: Containers, tree: str, folder: pathlib.Path) -> Ra
copy = folder / "tested"
shutil.copytree(tree, copy, symlinks=True)
try:
return tests_run(containers, str(copy))
return ran_tests(containers, str(copy))
finally:
shutil.rmtree(copy, ignore_errors=True)
@@ -289,7 +289,7 @@ def fixed(task: Task, side: str, number: int, containers: Containers, folder: pa
if isinstance(found, Failure):
return found
checked_tree(task.trees[side], str(copy), str(check))
ran = tests_run(containers, str(check))
ran = ran_tests(containers, str(check))
return Result(task.number, side, number, not isinstance(ran, Failure) and ran.code == 0, found)
finally:
shutil.rmtree(copy, ignore_errors=True)
@@ -298,9 +298,10 @@ def fixed(task: Task, side: str, number: int, containers: Containers, folder: pa
def recorded(result: Result) -> dict:
"""A run as results.json holds it."""
found = result.figures or Figures("", "", Tokens(), 0, 0, None)
measured = {"claude_code": found.version, "model": found.model, "tokens": dataclasses.asdict(found.tokens), "turns": found.turns, "seconds": found.seconds, "reads": found.reads}
return {"bug": result.task, "side": result.side, "run": result.run, "passed": result.passed, "finished": result.figures is not None, **(measured if result.figures else {})}
run = {"bug": result.task, "side": result.side, "run": result.run, "passed": result.passed, "finished": result.figures is not None}
if not (found := result.figures):
return run
return {**run, "claude_code": found.version, "model": found.model, "tokens": dataclasses.asdict(found.tokens), "turns": found.turns, "seconds": found.seconds, "reads": found.reads}
def counted(count: int, noun: str) -> str: