upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/tests/test_progress_dashboard.py
diff options
context:
space:
mode:
authorTG0000 <122870448+TG0000@users.noreply.github.com>2026-11-23 01:54:06 +0100
committerTG0000 <122870448+TG0000@users.noreply.github.com>2026-11-23 01:54:06 +0100
commitcfb4a6fbf45e5be964c3bf789fcd2951d481b00e (patch)
treed656b6f9bad1a5e8a214a178a5144dee4ed53f5a /tests/test_progress_dashboard.py
parent03b09a086592a197db64d91655c6e65c30764d96 (diff)
Check imported CTest reports for stale results
Diffstat (limited to 'tests/test_progress_dashboard.py')
-rw-r--r--tests/test_progress_dashboard.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/test_progress_dashboard.py b/tests/test_progress_dashboard.py
index dfa5e8e9c..298858fe2 100644
--- a/tests/test_progress_dashboard.py
+++ b/tests/test_progress_dashboard.py
@@ -10,7 +10,9 @@ import os
10import subprocess 10import subprocess
11import sys 11import sys
12import tempfile 12import tempfile
13from types import SimpleNamespace
13import unittest 14import unittest
15from unittest import mock
14 16
15HERE = os.path.dirname(os.path.abspath(__file__)) 17HERE = os.path.dirname(os.path.abspath(__file__))
16ROOT = os.path.dirname(HERE) 18ROOT = os.path.dirname(HERE)
@@ -112,6 +114,43 @@ class Freshness(unittest.TestCase):
112 got = self.collect(self.base(pd.file_digest("tests/test_progress_dashboard.py"), None)) 114 got = self.collect(self.base(pd.file_digest("tests/test_progress_dashboard.py"), None))
113 self.assertEqual(got["test_progress_dashboard.py"], ("verified", "unknown")) 115 self.assertEqual(got["test_progress_dashboard.py"], ("verified", "unknown"))
114 116
117 def test_ctest_junit_passes_age_like_lasttest_log(self):
118 ctest_suite = '<testsuite disabled="0" hostname="" timestamp="2026-11-22T10:00:00">{}</testsuite>'
119 sources = {
120 "runtime/build/Testing/Temporary/LastTest.log": (100, "1/1 Test: local\nTest Passed.\n"),
121 "before.xml": (100, ctest_suite.format(
122 '<testcase name="older" status="run"/><testcase name="failed" status="fail"/>'
123 '<testcase name="skipped" status="notrun"/>')),
124 "after.xml": (300, ctest_suite.format('<testcase name="newer" status="run"/>')),
125 "pytest.xml": (100, '<testsuites><testsuite name="pytest" hostname="host">'
126 '<testcase name="unrelated"/></testsuite></testsuites>'),
127 }
128 with tempfile.TemporaryDirectory() as root:
129 junit = []
130 for name, (mtime, text) in sources.items():
131 path = os.path.join(root, *name.split("/"))
132 os.makedirs(os.path.dirname(path), exist_ok=True)
133 with open(path, "w", encoding="utf-8", newline="\n") as f:
134 f.write(text)
135 os.utime(path, (mtime, mtime))
136 if name.endswith(".xml"):
137 junit.append(path)
138 col = pd.Collector()
139 with mock.patch.object(pd, "ROOT", root), mock.patch.object(pd, "last_commit_time", return_value=200):
140 pd.collect_ctest(col, SimpleNamespace(junit=junit))
141
142 outcomes = {c["name"]: (c["status"], c["freshness"]) for c in col.components}
143 self.assertEqual(outcomes, {
144 "local": ("partial", "revalidation_required"),
145 "older": ("partial", "revalidation_required"),
146 "failed": ("failed", "failed"),
147 "skipped": ("unknown", "unknown"),
148 "newer": ("verified", "current"),
149 "unrelated": ("verified", "current"),
150 })
151 metric = next(m for m in col.metrics if m["id"] == "runtime.current")
152 self.assertEqual((metric["numerator"], metric["denominator"]), (2, 6))
153
115 154
116class GpuLog(unittest.TestCase): 155class GpuLog(unittest.TestCase):
117 LOG = "\n".join([ 156 LOG = "\n".join([