feat(generate_type_registry): AST-based registry generator with --check and --diff modes

This commit is contained in:
ed
2026-06-21 12:57:32 -04:00
parent 281cf0f01e
commit f7c16954d4
2 changed files with 283 additions and 2 deletions
+12 -2
View File
@@ -47,10 +47,20 @@ def test_check_mode_exits_nonzero_when_drifting() -> None:
subprocess.run([sys.executable, str(SCRIPT)], capture_output=True, text=True, cwd=REPO_ROOT, check=True)
index_path = REGISTRY_DIR / "index.md"
original = index_path.read_text()
index_path.write_text(original + "\n# fake drift marker\n", encoding="utf-8")
drift_marker = "\n# fake drift marker\n"
drift_cmd = (
f"from pathlib import Path; "
f"p = Path({str(index_path)!r}); "
f"p.write_text(p.read_text(encoding='utf-8') + {drift_marker!r}, encoding='utf-8')"
)
subprocess.run([sys.executable, "-c", drift_cmd], check=True, cwd=REPO_ROOT)
try:
result = subprocess.run([sys.executable, str(SCRIPT), "--check"], capture_output=True, text=True, cwd=REPO_ROOT)
assert result.returncode == 1, f"--check should fail on drift; got {result.returncode}; stderr: {result.stderr}"
finally:
index_path.write_text(original, encoding="utf-8")
restore_cmd = (
f"from pathlib import Path; "
f"Path({str(index_path)!r}).write_text({original!r}, encoding='utf-8')"
)
subprocess.run([sys.executable, "-c", restore_cmd], cwd=REPO_ROOT)
subprocess.run([sys.executable, str(SCRIPT)], capture_output=True, text=True, cwd=REPO_ROOT, check=True)