diff --git a/scripts/generate_site.py b/scripts/generate_site.py index 5a91f7754..9b73c9f8f 100644 --- a/scripts/generate_site.py +++ b/scripts/generate_site.py @@ -9335,6 +9335,19 @@ def _summary_table(files: list[dict], indexes: list[int], cell: Callable[[int, s ] +def _tested_file_hrefs(name: str, files: list[dict]) -> dict[str, str]: + """The card each file name a test varies leads to: its name, aliases + and path, folded to lower case, the first card of a name winning.""" + hrefs: dict[str, str] = {} + for f, anchor in zip(files, emulator_file_anchors(files)): + page = emulator_card_page(name, anchor) + href = f"#{anchor}" if page == name else markup.site_href(f"emulators/{page}/") + f"#{anchor}" + for label in (f.get("name"), *(f.get("aliases") or ()), f.get("path")): + if label: + hrefs.setdefault(Path(str(label)).name.casefold(), href) + return hrefs + + def plan_emulator_pages(profiles: dict) -> None: """Record which page holds each emulator card, before any page links one.""" stems = set() @@ -9726,7 +9739,8 @@ def emulator_pages( [files[i] for i in entries], [rows[i] for i in entries] if table_form else None) - lines.extend(sitemeasurements.tested_section(name, _MEASUREMENT_ITEMS.get(name, []))) + lines.extend(sitemeasurements.tested_section( + name, _MEASUREMENT_ITEMS.get(name, []), _tested_file_hrefs(name, files))) blocks = _render_structured_blocks(profile) if blocks: diff --git a/scripts/sitemeasurements.py b/scripts/sitemeasurements.py index 271d3139f..44ba31cc7 100644 --- a/scripts/sitemeasurements.py +++ b/scripts/sitemeasurements.py @@ -967,6 +967,11 @@ def _dots(item: dict) -> str: def _chip(item: dict) -> str: words, kind = RESULT_WORDS.get(item["status"], (item["status"], "muted")) + # A wrong-files test claims the core refuses zeros, half the file and + # other regions' dumps: when every one boots the claim fails, and + # "works" in green read as a pass. + if item["status"] == "boots" and str(item.get("subject") or "").startswith("negative-"): + words, kind = "accepts wrong files", "info" return f'{_cell(words)}' @@ -1051,18 +1056,23 @@ def summary_line(items: list[dict], page_host: str) -> str: run and its computer.""" counts = tested_counts(items) parts = [f"{counts['tests']} test{'s' if counts['tests'] != 1 else ''}"] - parts += [f"{counts[key]} {key}" for key in ("confirmed", "open") if counts[key]] + if counts["confirmed"]: + parts.append(f"{counts['confirmed']} confirmed in the profile") + if counts["open"]: + parts.append(f"{counts['open']} open finding{'s' if counts['open'] != 1 else ''}") parts.append(f"last run {counts['last']} on {page_host}") return " · ".join(parts) + "." -def tested_section(name: str, items: list[dict]) -> list[str]: +def tested_section(name: str, items: list[dict], + file_hrefs: dict[str, str] | None = None) -> list[str]: """The Tested block of an emulator page, empty when nothing was recorded. The answer first: one summary line, then the tests under the file each one varies, a row per test with its result chip, a dot per variant and its date. What proves it (method, claim, computer, core build, record) - waits in each row's details. Tests recorded before the boot oracle fold + waits in each row's details. ``file_hrefs`` links a file, by its name + folded to lower case, to its card on the page. Tests recorded before the boot oracle fold under one line, and benchmarks get their own table at the end. """ if not items: @@ -1090,6 +1100,9 @@ def tested_section(name: str, items: list[dict]) -> list[str]: "ResultVariantsDate") for file, group in by_file(current): label = f"{_cell(file)}" if file else "No file varied" + href = (file_hrefs or {}).get(file.casefold()) if file else None + if href: + label = f'{label}' lines.append(f'

{label}

') for item in group: lines += _row(item, titles[item["id"]], page_host, main_core) diff --git a/tests/test_measurements.py b/tests/test_measurements.py index faf1b2ec8..2cef3686b 100644 --- a/tests/test_measurements.py +++ b/tests/test_measurements.py @@ -451,9 +451,21 @@ class SitePages(unittest.TestCase): self.assertEqual(sm.tested_counts(items), {"tests": 3, "confirmed": 1, "open": 2, "benchmarks": 1, "last": "2026-10-28"}) text = "\n".join(sm.tested_section("beetle_saturn", items)) - self.assertIn("3 tests · 1 confirmed · 2 open · last run 2026-10-28 on Test CPU, Linux.", text) + self.assertIn("3 tests · 1 confirmed in the profile · 2 open findings · last run 2026-10-28 " + "on Test CPU, Linux.", text) self.assertIn("1.500660.0", text) + def test_wrong_files_that_all_boot_fail_the_claim(self) -> None: + negative = self.item(subject="negative-scph5501-bin-x", status="boots") + self.assertIn(">accepts wrong files", sm._chip(negative)) + self.assertIn('rb-badge-info', sm._chip(negative)) + self.assertIn(">works", sm._chip(self.item(subject="alone-scph5501-bin-x", status="boots"))) + + def test_the_file_label_links_its_card(self) -> None: + text = "\n".join(sm.tested_section("beetle_saturn", [self.ITEM], + {"mpeg_card.bin": "#file-mpeg-card-bin"})) + self.assertIn('mpeg_card.bin', text) + def test_short_titles(self) -> None: cases = [ ({"subject": "mpeg-card-lunar-cr2-build", "variable": "mpeg_card.bin", diff --git a/tests/test_site_r3_emulators.py b/tests/test_site_r3_emulators.py index e4a150187..17dfef007 100644 --- a/tests/test_site_r3_emulators.py +++ b/tests/test_site_r3_emulators.py @@ -192,5 +192,15 @@ class AnElementBudget(unittest.TestCase): self.assertLess(page.elements, validate_site.MAX_PAGE_ELEMENTS) +class TestedFilesLeadToTheirCard(unittest.TestCase): + def test_a_name_or_alias_finds_the_card(self): + files = [{"name": "scph5501.bin", "aliases": ["SCPH-5501.BIN"]}, {"name": "other.bin"}] + hrefs = gs._tested_file_hrefs("x", files) + self.assertEqual(hrefs["scph5501.bin"], "#file-scph5501-bin") + self.assertEqual(hrefs["scph-5501.bin"], "#file-scph5501-bin") + self.assertEqual(hrefs["other.bin"], "#file-other-bin") + + if __name__ == "__main__": unittest.main() +