diff --git a/tests/test_progress_dashboard.py b/tests/test_progress_dashboard.py index ad22e81499..b5a15e80ce 100644 --- a/tests/test_progress_dashboard.py +++ b/tests/test_progress_dashboard.py @@ -618,6 +618,22 @@ def test_page_snapshot_history_and_dedupe(self): with open(os.path.join(out, "history.json"), encoding="utf-8") as f: self.assertEqual(len(json.load(f)), 1) + def test_different_snapshots_in_the_same_second_are_preserved(self): + first = {"generated_at": "2026-11-24T00:00:00Z", "git": {"head": "a" * 40}, + "metrics": [], "content_hash": "a" * 64} + second = {**first, "git": {"head": "b" * 40}, "content_hash": "b" * 64} + with tempfile.TemporaryDirectory() as out: + self.assertTrue(pd.write_outputs(first, out)) + self.assertTrue(pd.write_outputs(second, out)) + self.assertFalse(pd.write_outputs(second, out)) + + folder = Path(out) + snapshots = [json.loads(path.read_text(encoding="utf-8")) + for path in (folder / "snapshots").glob("progress_*.json")] + self.assertCountEqual(snapshots, [first, second]) + history = json.loads((folder / "history.json").read_text(encoding="utf-8")) + self.assertEqual(history, [pd.summary_line(first), pd.summary_line(second)]) + def test_unmatched_test_filter_preserves_cached_results(self): with tempfile.TemporaryDirectory() as out: cached = os.path.join(out, "unit_results.json") diff --git a/tools/progress_dashboard.py b/tools/progress_dashboard.py index 9e9d0eb28b..43d3fafdbb 100644 --- a/tools/progress_dashboard.py +++ b/tools/progress_dashboard.py @@ -5,7 +5,7 @@ Writes, into --out only (a folder inside the repository is refused, so nothing here can be committed by accident): progress.html one self-contained page (no network, no packages; open it from disk) - snapshots/progress_.json the data behind it; a snapshot equal to the previous one is not written again + snapshots/progress__.json the data behind it; an unchanged snapshot is not written again history.json one summary line per snapshot, for the trend chart unit_results.json the last --run-tests outcome, kept so a later run can show what changed since @@ -1025,7 +1025,8 @@ def write_outputs(snap, out_dir): new = not history or history[-1]["content_hash"] != snap["content_hash"][:16] if new: stamp = snap["generated_at"].replace("-", "").replace(":", "") - save_text(os.path.join(out_dir, "snapshots", f"progress_{stamp}.json"), dump_json(snap)) + archive = f"progress_{stamp}_{snap['content_hash']}.json" + save_text(os.path.join(out_dir, "snapshots", archive), dump_json(snap)) history.append(summary_line(snap)) save_text(hist_path, dump_json(history)) save_text(os.path.join(out_dir, "progress.html"), render_page(snap, history))