scripts/tests/reproduction_utils/reproduction_testlib.py
scripts/tests/reproduction_utils/reproduction_testlib.pyBrowse 41 files
316 tokens
1,233 bytes
Token encoding: o200k_base
Snapshot a9fb1c3
← Back to SKILL.md
1import subprocess2import sys3from pathlib import Path4 5import pytest6 7sys.path.insert(0, str(Path(__file__).resolve().parents[2]))8 9import mechanical_refactor_reproduction_utils as rr10from mechanical_refactor_reproduction_utils import (11 Repro,12 _def_span,13 _find_class,14 _find_def,15 _replace_span,16 _slice_span,17 dedent,18 exec_command,19 git_add_and_commit,20 verify_mechanical_refactor,21)22 23 24def _apply(repro: Repro, root: Path) -> None:25 """Run a built Repro's recorded operations against a plain directory (no git)."""26 for op in repro.ops:27 op(root)28 29 30def _git(repo: Path, *args: str) -> str:31 return subprocess.run(32 ["git", *args], cwd=repo, check=True, capture_output=True, text=True33 ).stdout.strip()34 35 36def _write(repo: Path, **files: str | None) -> None:37 for name, content in files.items():38 path = repo / name.replace("__", "/")39 if content is None:40 path.unlink()41 else:42 path.parent.mkdir(parents=True, exist_ok=True)43 path.write_text(content)44 45 46def _commit(repo: Path, message: str) -> str:47 _git(repo, "add", "-A")48 _git(repo, "commit", "-q", "-m", message)49 return _git(repo, "rev-parse", "HEAD")50