Merge pull request #4799 from ArjenS-LA/fix/trace-summary-selection

fix(tools): match explicit trace summaries to their capture
This commit is contained in:
Dean 2026-10-14 14:51:27 +13:00 committed by GitHub
commit a98d42d08c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 1 deletions

View File

@ -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)

View File

@ -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