MCPcopy Create free account
hub / github.com/idank/explainshell / diff_report

Function diff_report

tests/evals/render/render_eval.py:811–894  ·  view source on GitHub ↗
(args: argparse.Namespace)

Source from the content-addressed store, hash-verified

809
810
811def diff_report(args: argparse.Namespace) -> int:
812 base_dir = Path(args.baseline)
813 current_dir = Path(args.current)
814 baseline, current, paths, suspicious = _comparison_data(base_dir, current_dir)
815 base_pages = _page_map(baseline)
816 current_pages = _page_map(current)
817 report_dir = Path(args.output or current_dir / DEFAULT_DIFF_DIRNAME)
818 pages_dir = report_dir / "pages"
819 shots_dir = report_dir / "screenshots"
820 pages_dir.mkdir(parents=True, exist_ok=True)
821 shots_dir.mkdir(parents=True, exist_ok=True)
822
823 selected = paths if args.all else list(suspicious)
824 if args.limit is not None:
825 selected = selected[: args.limit]
826
827 cards: list[dict[str, Any]] = []
828 for path in selected:
829 old = base_pages.get(path)
830 new = current_pages.get(path)
831 if old is None or new is None:
832 side = "baseline" if new is None else "current"
833 print(f"skipping {path}: only present in {side}")
834 continue
835 stem = new["stem"]
836 expected_fragment = _artifact_path(base_dir, old, "html", "html").read_text()
837 actual_fragment = _artifact_path(current_dir, new, "html", "html").read_text()
838 expected_page = pages_dir / f"{stem}-expected.html"
839 actual_page = pages_dir / f"{stem}-actual.html"
840 expected_png = shots_dir / f"{stem}-expected.png"
841 actual_png = shots_dir / f"{stem}-actual.png"
842 _write_review_page(
843 expected_page,
844 title=f"expected: {path}",
845 source_path=path,
846 label=f"expected / {baseline['label']}",
847 fragment_html=expected_fragment,
848 )
849 _write_review_page(
850 actual_page,
851 title=f"actual: {path}",
852 source_path=path,
853 label=f"actual / {current['label']}",
854 fragment_html=actual_fragment,
855 )
856 try:
857 print(f"screenshot {path} expected")
858 _screenshot_with_clip_fallback(
859 expected_page, expected_png, timeout_ms=args.timeout
860 )
861 print(f"screenshot {path} actual")
862 _screenshot_with_clip_fallback(
863 actual_page, actual_png, timeout_ms=args.timeout
864 )
865 except RuntimeError as exc:
866 print(f" ! skipping {path}: {exc}")
867 continue
868 _pad_screenshots_to_match(expected_png, actual_png)

Callers

nothing calls this directly

Calls 10

_page_mapFunction · 0.90
_comparison_dataFunction · 0.85
_artifact_pathFunction · 0.85
_write_review_pageFunction · 0.85
_changed_metric_linesFunction · 0.85
_relFunction · 0.85
_summarize_comparisonFunction · 0.85
_write_diff_indexFunction · 0.85

Tested by

no test coverage detected