scripts/tests/reproduction_cli/test_report.py
scripts/tests/reproduction_cli/test_report.pyBrowse 41 files
882 tokens
3,351 bytes
Token encoding: o200k_base
Snapshot a9fb1c3
← Back to SKILL.md
1import sys2from pathlib import Path3 4sys.path.insert(0, str(Path(__file__).resolve().parents[2]))5 6from cli_testlib import _chain, _write_stub_proof7from mechanical_refactor_reproduction_cli import main, render_report, verify_chain8 9 10def _mixed_chain_result(repo: Path, tmp_path: Path):11 proof = tmp_path / "proof"12 base, shas = _chain(13 repo,14 [15 "mechanical_provable: move foo",16 "non_mechanical_provable: rework bar",17 "mechanical_provable: move baz",18 ],19 )20 _write_stub_proof(proof, shas[0])21 result = verify_chain(base=base, branch="chain", proof=proof, repo_root=str(repo))22 return proof, base, shas, result23 24 25def test_report_has_header_table_row_per_commit_and_chain_verdict(26 repo: Path, tmp_path: Path27) -> None:28 """The report carries base/branch/proof, one table row per commit, and the verdict."""29 proof, base, shas, result = _mixed_chain_result(repo, tmp_path)30 report = render_report(result)31 32 assert "# Mechanical refactor chain report" in report33 assert f"`{base[:12]}`" in report34 assert "chain verdict: **FAIL**" in report35 assert "3 total — 2 mechanical_provable, 1 non_mechanical_provable" in report36 for sha in shas:37 assert f"`{sha[:9]}`" in report38 assert "| mechanical_provable | PASS |" in report39 assert "| non_mechanical_provable | HUMAN_REVIEW |" in report40 assert "| mechanical_provable | MISSING_PROOF |" in report41 42 43def test_report_lists_failure_details_for_each_non_ok_commit(44 repo: Path, tmp_path: Path45) -> None:46 """Every non-ok commit gets a failure-details section with its explanation."""47 proof, base, shas, result = _mixed_chain_result(repo, tmp_path)48 report = render_report(result)49 50 assert "## Failure details" in report51 assert f"### `{shas[2][:9]}` — MISSING_PROOF" in report52 assert "no proof script found" in report53 54 55def test_passing_report_has_no_failure_details_section(56 repo: Path, tmp_path: Path57) -> None:58 """A fully verified chain renders a PASS report without a failure section."""59 proof = tmp_path / "proof"60 base, shas = _chain(repo, ["mechanical_provable: move foo"])61 _write_stub_proof(proof, shas[0])62 result = verify_chain(base=base, branch="chain", proof=proof, repo_root=str(repo))63 report = render_report(result)64 65 assert "chain verdict: **PASS**" in report66 assert "proofs: 1/1 PASS" in report67 assert "## Failure details" not in report68 69 70def test_main_writes_the_report_into_the_proof_folder_by_default(71 repo: Path, tmp_path: Path, capsys72) -> None:73 """main prints the report and writes <proof>/chain_report.md (or --report PATH)."""74 proof = tmp_path / "proof"75 base, shas = _chain(repo, ["mechanical_provable: move foo"])76 _write_stub_proof(proof, shas[0])77 args = [78 "--base",79 base,80 "--branch",81 "chain",82 "--proof",83 str(proof),84 "--repo-root",85 str(repo),86 ]87 88 assert main(args) == 089 default_report = proof / "chain_report.md"90 assert "chain verdict: **PASS**" in default_report.read_text()91 assert "chain verdict: **PASS**" in capsys.readouterr().out92 93 custom = tmp_path / "custom_report.md"94 assert main([*args, "--report", str(custom)]) == 095 assert "chain verdict: **PASS**" in custom.read_text()96