Answer stability round 1: 0 🔴, 5 🟡 (0 misread); run both tools in a scratch copy, read Infection's two sources, end PHPUnit's list, spell glob characters
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
"""A copy of a tree for a mutation tool to run in, so that what the tool writes there goes with the copy."""
|
||||
import os
|
||||
import shutil
|
||||
|
||||
from failure import Failure
|
||||
from mutate_changes.tool_process import remove, scratch_folder
|
||||
|
||||
|
||||
def scratch_copy(top: str) -> tuple[str, str] | Failure:
|
||||
"""A new scratch folder in top, and in it a copy of top's other entries, links kept as links: the two folders' paths. The
|
||||
caller removes the scratch folder.
|
||||
|
||||
A mutation tool leaves files where it runs: its cache, and each log the project's config asks for, which tells where every
|
||||
mutant is. A bug's tree is a copy of top, so the tool runs in this copy and top stays as it was."""
|
||||
scratch = scratch_folder(top)
|
||||
if isinstance(scratch, Failure):
|
||||
return scratch
|
||||
copy = os.path.join(scratch, "copy")
|
||||
try:
|
||||
shutil.copytree(top, copy, symlinks=True, ignore=lambda folder, names: [os.path.basename(scratch)] if folder == top else [])
|
||||
except OSError as failure:
|
||||
remove(scratch)
|
||||
return Failure(f"could not copy {top} into {scratch}: {failure}")
|
||||
return scratch, copy
|
||||
Reference in New Issue
Block a user