Answer review: keep Rust test modules for bugs only, order imports, reword
CI / tests (pull_request) Has been cancelled

This commit is contained in:
2026-11-26 01:30:46 +01:00
parent 347368040e
commit cecabf324a
6 changed files with 49 additions and 33 deletions
+10 -9
View File
@@ -11,8 +11,8 @@ import typing
from mutate_changes.tool_process import failed, Ran
from failure import Failure
from mutate_changes.changed_lines import is_test
from task_bench.rust_test_modules import with_tests_of
from task_bench.api_proxy import PORT
from task_bench.rust_test_modules import with_tests_of
MODEL = "claude-haiku-5-5"
# Where each run's container mounts its copy of the code, and its home folder: the paths in a run's stream start there.
@@ -164,10 +164,11 @@ def in_tree(containers: Containers, tree: str) -> list[str]:
return [*containers.limits(), "--user", containers.user, "--env", f"HOME={HOME}", "--volume", f"{tree}:{WORK}", "--workdir", WORK]
def checked_tree(planted: str, copy: str, into: str) -> None:
def checked_tree(planted: str, copy: str, into: str, rust_tests_planted: bool = True) -> None:
"""Makes at `into` the tree the tests check a fix in: `planted`, the code with the bug as Haiku got it, with each file that is no
test as `copy` holds it after the fix. So a test Haiku changed, removed or added doesn't count, and neither does a file under
a `testdata` folder, where Go's tests keep the output they expect. A Rust file's `#[cfg(test)]` modules are the planted file's.
a `testdata` folder, where Go's tests keep the output they expect. Where rust_tests_planted, a Rust file's inline `#[cfg(test)]`
modules stand as the planted file has them too, as `with_tests_of` says.
Raises OSError where a file cannot be copied."""
shutil.copytree(planted, into, symlinks=True)
@@ -185,19 +186,19 @@ def checked_tree(planted: str, copy: str, into: str) -> None:
with contextlib.suppress(FileNotFoundError):
os.unlink(target)
shutil.copy2(os.path.join(copy, path), target, follow_symlinks=False)
if path.endswith(".rs"):
if rust_tests_planted and path.endswith(".rs"):
keep_rust_tests(os.path.join(planted, path), target)
def keep_rust_tests(planted_file: str, target: str) -> None:
"""Puts into the Rust file at target, a copy of Haiku's, the test modules of planted_file; see `with_tests_of`. A file the planted
tree lacks, as a link or as a file, is left as it is, since it has no test to keep.
"""Puts into the Rust file at target, a copy of Haiku's, the test modules of planted_file, as `with_tests_of` says. A planted tree
without the file has no test module, so a file Haiku added keeps none. A link, planted's or Haiku's, is left as it is.
Raises OSError where a file cannot be read or written."""
if os.path.islink(planted_file) or os.path.islink(target) or not os.path.isfile(planted_file):
if os.path.islink(planted_file) or os.path.islink(target):
return
planted, copied = (pathlib.Path(file).read_bytes() for file in (planted_file, target))
pathlib.Path(target).write_bytes(with_tests_of(planted, copied))
planted = pathlib.Path(planted_file).read_bytes() if os.path.isfile(planted_file) else b""
pathlib.Path(target).write_bytes(with_tests_of(planted, pathlib.Path(target).read_bytes()))
def of_tests(path: str) -> bool: