Run each side's tests in a committed copy, so task-bench tests that call git pass #795

Merged
lilleman merged 6 commits from item-571 into main 2026-12-03 13:34:00 +01:00
2 changed files with 3 additions and 3 deletions
Showing only changes of commit 50dee4e933 - Show all commits
+2 -2
View File
@@ -104,8 +104,8 @@ def committed(git: Git, tree: str) -> Failure | None:
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 is
committed first, since a project's tests may call git and a tree from `git archive` holds no repository."""
"""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):
+1 -1
View File
@@ -299,7 +299,7 @@ class BenchTest(unittest.TestCase):
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):
# The sides' trees come from `git archive`, which leaves out `.git`; `git ls-files` exits 128 in a tree that isn't a repository.
# `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)