test_large_freeze_artifact.py
file-level
1
files
1
commits
0
hotspots
0
🧊 dead
0
💥 blast risk
| 1 | """Stress tests for large freeze artifacts (§K5.12).""" |
| 2 | |
| 3 | from __future__ import annotations |
| 4 | |
| 5 | from pathlib import Path |
| 6 | |
| 7 | from cli.kit_root import kit_root |
| 8 | from tests.support import findings_provider_factory, git_status_runner, run_cli, write_config |
| 9 | from tools.freeze_reviewer.findings import assign_finding_ids |
| 10 | from tools.freeze_reviewer.types import Finding |
| 11 | |
| 12 | |
| 13 | def _large_artifact(path: Path, sections: int = 200) -> None: |
| 14 | lines = [ |
| 15 | "# Large freeze", |
| 16 | "", |
| 17 | "```yaml", |
| 18 | "phase: stress", |
| 19 | "outputs:", |
| 20 | " - id: out", |
| 21 | " path: docs/x.md", |
| 22 | " frozen: true", |
| 23 | "frozen_inputs:", |
| 24 | ] |
| 25 | for index in range(sections): |
| 26 | lines.append(f" - id: in-{index}") |
| 27 | lines.append(f" path: docs/in-{index}.md") |
| 28 | lines.extend(["```", "", "seven-tier test matrix", "file+line discipline"]) |
| 29 | for index in range(sections): |
| 30 | lines.append(f"## Section {index}") |
| 31 | lines.append(f"ground truth edge {index}") |
| 32 | path.write_text("\n".join(lines) + "\n", encoding="utf-8") |
| 33 | |
| 34 | |
| 35 | def test_large_artifact_stable_sort(tmp_path: Path) -> None: |
| 36 | write_config(tmp_path, "config-git-only.yaml") |
| 37 | artifact = tmp_path / "docs" / "BIG.md" |
| 38 | artifact.parent.mkdir(parents=True) |
| 39 | _large_artifact(artifact, sections=300) |
| 40 | rel = artifact.relative_to(tmp_path).as_posix() |
| 41 | findings = [ |
| 42 | Finding(check="C1", severity="MINOR", category="other", path=rel, line=i, message=f"m{i}").with_citation() |
| 43 | for i in range(1, 150) |
| 44 | ] |
| 45 | assigned = assign_finding_ids(findings) |
| 46 | assert assigned[0].id == "F1" |
| 47 | assert assigned[-1].id == "F149" |
| 48 | code = run_cli( |
| 49 | ["review", "--freeze", rel], |
| 50 | cwd=tmp_path, |
| 51 | runner=git_status_runner(), |
| 52 | kit=kit_root(), |
| 53 | review_provider_factory=findings_provider_factory(findings), |
| 54 | ) |
| 55 | assert code == 7 |