Merge remote-tracking branch 'origin/main' into item-481
CI / tests (pull_request) Has been cancelled
CI / tests (pull_request) Has been cancelled
This commit is contained in:
@@ -514,7 +514,7 @@ def benched(bench: Bench, planned: Planner) -> list[str] | Failure:
|
||||
def baseline_failure(bench: Bench) -> Failure | None:
|
||||
"""Why a side's tests don't pass without a task; None where they pass at both sides."""
|
||||
for side, tree in bench.trees.items():
|
||||
ran = tests_in_copy(bench.containers, tree, bench.folder)
|
||||
ran = tests_in_copy(bench.containers, tree, bench.folder, bench.git)
|
||||
if isinstance(ran, Failure) or ran.code:
|
||||
return ran if isinstance(ran, Failure) else failed(f"The tests fail at the {side} without {bench.asked.kind.without}: the test command", ran)
|
||||
return None
|
||||
@@ -630,7 +630,7 @@ def planted_tree(bench: Bench, side: Side, tree: pathlib.Path, path: str, change
|
||||
(tree / path).write_bytes(changed)
|
||||
except OSError as failure:
|
||||
return Failure(f"could not plant the bug in {tree}: {failure}")
|
||||
ran = tests_in_copy(bench.containers, str(tree), bench.folder)
|
||||
ran = tests_in_copy(bench.containers, str(tree), bench.folder, bench.git)
|
||||
# Tests that never end under the bug have no message.
|
||||
if isinstance(ran, TimedOut):
|
||||
return None
|
||||
|
||||
@@ -103,14 +103,15 @@ def committed(git: Git, tree: str) -> Failure | None:
|
||||
return None
|
||||
|
||||
|
||||
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."""
|
||||
def tests_in_copy(containers: Containers, tree: str, folder: pathlib.Path, git: Git) -> Ran | Failure:
|
||||
"""The test command's run in a copy of tree, removed afterwards, so what the tests write stays out of tree. The copy gets a repository
|
||||
of its own with one commit first, since a project's tests may call git and a tree from `git archive` holds none."""
|
||||
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 ran_tests(containers, str(copy))
|
||||
return committed(git, str(copy)) or ran_tests(containers, str(copy))
|
||||
finally:
|
||||
shutil.rmtree(copy, ignore_errors=True)
|
||||
|
||||
|
||||
@@ -298,6 +298,11 @@ class BenchTest(unittest.TestCase):
|
||||
self.assertEqual(log, "task-bench Import\n")
|
||||
self.assertEqual(subprocess.run(["git", "status", "--porcelain"], cwd=tree, env=self.env, check=True, capture_output=True, text=True).stdout, "")
|
||||
|
||||
def test_tests_that_call_git_run_in_a_repository_at_each_side(self):
|
||||
# `git ls-files` fails in a tree that isn't a repository.
|
||||
found = self.bench(**{"--test": "git ls-files --error-unmatch calc.go >/dev/null && sh calc_test.go"})
|
||||
self.assertNotIsInstance(found, Failure, found)
|
||||
|
||||
def test_claude_runs_in_the_benchs_image_on_its_network_with_the_message_alone_and_the_token_by_name(self):
|
||||
self.bench(**{"--runs": "1"})
|
||||
calls = self.calls()
|
||||
@@ -589,7 +594,13 @@ class RunOutcomesTest(unittest.TestCase):
|
||||
|
||||
def test_a_tree_that_cannot_be_copied_for_its_tests_fails_the_bench_naming_it(self):
|
||||
gone = str(self.folder / "gone")
|
||||
self.assertFailsWith(main.tests_in_copy(self.containers(), gone, self.folder), f"could not copy {gone} to test it: ")
|
||||
self.assertFailsWith(main.tests_in_copy(self.containers(), gone, self.folder, self.bench().git), f"could not copy {gone} to test it: ")
|
||||
|
||||
def test_a_copy_that_cannot_be_committed_fails_the_bench_and_is_removed(self):
|
||||
tree = self.folder / "tree"
|
||||
tree.mkdir(exist_ok=True)
|
||||
self.assertFailsWith(main.tests_in_copy(self.containers(), str(tree), self.folder, lambda *args, **given: Failure("no git")), "no git")
|
||||
self.assertFalse((self.folder / "tested").exists())
|
||||
|
||||
def test_a_tree_whose_folder_cannot_be_made_fails_the_bench_naming_it(self):
|
||||
(self.folder / "file").write_text("")
|
||||
|
||||
Reference in New Issue
Block a user