diff options
| author | TG0000 <122870448+TG0000@users.noreply.github.com> | 2026-11-23 01:54:06 +0100 |
|---|---|---|
| committer | TG0000 <122870448+TG0000@users.noreply.github.com> | 2026-11-23 01:54:06 +0100 |
| commit | cfb4a6fbf45e5be964c3bf789fcd2951d481b00e (patch) | |
| tree | d656b6f9bad1a5e8a214a178a5144dee4ed53f5a /tests/test_progress_dashboard.py | |
| parent | 03b09a086592a197db64d91655c6e65c30764d96 (diff) | |
Check imported CTest reports for stale results
Diffstat (limited to 'tests/test_progress_dashboard.py')
| -rw-r--r-- | tests/test_progress_dashboard.py | 39 |
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 | |||
| 10 | import subprocess | 10 | import subprocess |
| 11 | import sys | 11 | import sys |
| 12 | import tempfile | 12 | import tempfile |
| 13 | from types import SimpleNamespace | ||
| 13 | import unittest | 14 | import unittest |
| 15 | from unittest import mock | ||
| 14 | 16 | ||
| 15 | HERE = os.path.dirname(os.path.abspath(__file__)) | 17 | HERE = os.path.dirname(os.path.abspath(__file__)) |
| 16 | ROOT = os.path.dirname(HERE) | 18 | ROOT = 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 | ||
| 116 | class GpuLog(unittest.TestCase): | 155 | class GpuLog(unittest.TestCase): |
| 117 | LOG = "\n".join([ | 156 | LOG = "\n".join([ |