From 819c47526645de69eff1f8ed7b685dc95ec1dbcb Mon Sep 17 00:00:00 2001 From: ArjenS-LA Date: Mon, 12 Oct 2026 15:10:22 -0700 Subject: [PATCH] fix(tools): match explicit trace summaries to their capture --- tools/tests/test_trace_digest.py | 13 +++++++++++++ tools/trace_digest.py | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/tools/tests/test_trace_digest.py b/tools/tests/test_trace_digest.py index fd02c62e3..7917bc864 100644 --- a/tools/tests/test_trace_digest.py +++ b/tools/tests/test_trace_digest.py @@ -64,6 +64,19 @@ class TraceDigestTests(unittest.TestCase): def test_summary_is_the_line_of_this_trace(self): self.assertEqual(self.result()["summary"]["trace"], "aps5-trace-abc-7.json.gz") + def test_explicit_summary_selects_the_matching_trace(self): + summary = Path(self.directory.name) / "relocated-summary.jsonl" + other = dict(SUMMARY, trace="other.json.gz", presents=99) + summary.write_text(json.dumps(SUMMARY) + "\n" + json.dumps(other) + "\n", encoding="utf-8") + selected = trace_digest.load_summary(summary, self.trace) + self.assertEqual(selected["trace"], self.trace.name) + self.assertEqual(selected["presents"], 3) + + def test_explicit_summary_without_matching_trace_is_not_used(self): + summary = Path(self.directory.name) / "unrelated-summary.jsonl" + summary.write_text(json.dumps(dict(SUMMARY, trace="other.json.gz")) + "\n", encoding="utf-8") + self.assertIsNone(trace_digest.load_summary(summary, self.trace)) + def test_frames_end_at_the_window(self): result = self.result() self.assertEqual(result["frames"], 3) diff --git a/tools/trace_digest.py b/tools/trace_digest.py index 99011db35..a375a776b 100644 --- a/tools/trace_digest.py +++ b/tools/trace_digest.py @@ -67,7 +67,7 @@ def load_summary(path, trace_path): return None lines = [json.loads(line) for line in candidate.read_text(encoding="utf-8").splitlines() if line.strip()] for line in reversed(lines): - if path or line.get("trace") == Path(trace_path).name: + if line.get("trace") == Path(trace_path).name: return line return None