Answer stability round 1: 0 🔴, 8 🟡 (0 misread); check a reference patch as a build is checked, test the rule at the head, split the bench's setup by kind
This commit is contained in:
+21
-13
@@ -1,11 +1,11 @@
|
||||
"""What both kinds of task-bench's tasks share, a planted bug and a feature to build: the task itself, the bench it runs in, and the
|
||||
"""What task-bench's two kinds of task share. One kind is a planted bug, the other a feature to build. They share the task itself, the bench it runs in, and the
|
||||
steps that commit a task's tree and run the tests over a copy of one."""
|
||||
import dataclasses
|
||||
import pathlib
|
||||
import shutil
|
||||
import typing
|
||||
|
||||
from task_bench.runs import Containers, ran_tests
|
||||
from task_bench.runs import checked_tree, Containers, ran_tests
|
||||
from failure import Failure
|
||||
from git_cli.git_repo import Git
|
||||
from mutate_changes.tool_process import Ran
|
||||
@@ -16,8 +16,8 @@ COMMIT = ["-c", "user.name=task-bench", "-c", "user.email=task-bench@localhost",
|
||||
|
||||
|
||||
class Kind(typing.NamedTuple):
|
||||
"""A kind of task: what the report calls one, what Haiku is asked, with the task's own text for `{told}`, and what a side's
|
||||
tree is without one."""
|
||||
"""A kind of task: what the report calls one, what Haiku is asked, with the task's own text for `{told}`, and how a failure names a side's
|
||||
tree before the bench puts a task there, as in `without a planted bug`."""
|
||||
|
||||
noun: str
|
||||
prompt: str
|
||||
@@ -44,12 +44,9 @@ class Task:
|
||||
|
||||
|
||||
class Asked(typing.NamedTuple):
|
||||
"""What the caller asked of a bench: the kind of its tasks and how often to run each. For bugs also the seed that orders the
|
||||
mutants and how many bugs to plant; both are None for features, which the bench takes as their folder holds them."""
|
||||
"""What the caller asked of a bench: the kind of its tasks and how often to run each."""
|
||||
kind: Kind
|
||||
runs: int
|
||||
seed: int | None = None
|
||||
bugs: int | None = None
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
@@ -67,9 +64,11 @@ class Bench:
|
||||
|
||||
|
||||
class Planned(typing.NamedTuple):
|
||||
"""The tasks a bench runs, and a line for its report on each thing it left out."""
|
||||
"""The tasks a bench runs, a line for its report on each thing it left out, and what drew the tasks, as results.json records
|
||||
it: the seed for bugs. Features come as their folder holds them, so for them it is empty."""
|
||||
tasks: list[Task]
|
||||
left_out: list[str]
|
||||
drawn_by: dict[str, int]
|
||||
|
||||
|
||||
def on_disk[T](doing: str, act: typing.Callable[[], T]) -> T | Failure:
|
||||
@@ -89,19 +88,28 @@ def committed(git: Git, tree: str) -> Failure | None:
|
||||
return None
|
||||
|
||||
|
||||
def tests_in_copy(containers: Containers, tree: str, folder: pathlib.Path, prepare: typing.Callable[[str], Failure | None] = lambda copy: None) -> Ran | Failure:
|
||||
"""The test command's run in a copy of tree, removed afterwards, so what the tests write stays out of tree. prepare changes the
|
||||
copy before the tests run; where it fails, they don't run."""
|
||||
def tests_in_copy(containers: Containers, tree: str, folder: pathlib.Path) -> Ran | Failure:
|
||||
"""The test command's run in a copy of tree, removed afterwards, so what the tests write stays out of tree."""
|
||||
copy = folder / "tested"
|
||||
copied = on_disk(f"copy {tree} to test it", lambda: shutil.copytree(tree, copy, symlinks=True))
|
||||
if isinstance(copied, Failure):
|
||||
return copied
|
||||
try:
|
||||
return prepare(str(copy)) or ran_tests(containers, str(copy))
|
||||
return ran_tests(containers, str(copy))
|
||||
finally:
|
||||
shutil.rmtree(copy, ignore_errors=True)
|
||||
|
||||
|
||||
def check_made(tree: str, copy: str, check: str, acceptance: str | None) -> None:
|
||||
"""Makes at check the tree that checks what was built in copy, a copy of tree: `checked_tree`'s, then a feature's acceptance
|
||||
tests over it, where acceptance names their folder. A run of Haiku's and a feature's reference patch are checked alike.
|
||||
|
||||
Raises OSError where a file cannot be copied."""
|
||||
checked_tree(tree, copy, check)
|
||||
if acceptance:
|
||||
with_acceptance(check, acceptance)
|
||||
|
||||
|
||||
def with_acceptance(tree: str, acceptance: str) -> None:
|
||||
"""Puts a feature's acceptance tests into tree, each file at its path under `acceptance`, over any file the tree holds there.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user