Run each side's tests in a committed copy, so tests that call git work
This commit is contained in:
@@ -103,12 +103,16 @@ 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 is
|
||||
committed first, since a project's tests may call git and a tree from `git archive` holds no repository."""
|
||||
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
|
||||
if failure := committed(git, str(copy)):
|
||||
shutil.rmtree(copy, ignore_errors=True)
|
||||
return failure
|
||||
try:
|
||||
return ran_tests(containers, str(copy))
|
||||
finally:
|
||||
|
||||
Reference in New Issue
Block a user