refactor: keep proof lines, drop the test showcase

Emulator pages show a run only when a profile's evidence names it or it
answers an issue, as one line naming the BIOS the core ran. The Tested
blocks, region outcomes, coverage, campaign and pack tables and the
benchmark figures are gone from the site; the records stay.
This commit is contained in:
Abdessamad Derraz committed 2026-10-28 07:29:58 +01:00
1 parent b8144e4e71
commit e19b82ea47
10 files changed
+168 -1307

No files matched your search

-1
View File
@@ -40,7 +40,6 @@ on:
- "scripts/provenance_report.py"
- "scripts/refresh_data_dirs.py"
- "scripts/region.py"
- "scripts/region_check.py"
- "scripts/release_record.py"
- "scripts/restore_large_files.py"
- "scripts/safeparse.py"
+4 -46
View File
@@ -2452,7 +2452,7 @@ def _page_description(markdown: str, relative: Path, title: str) -> str:
"cross-reference.md": "Every emulator core each retrogaming platform runs, the systems it emulates and the upstream project it comes from.",
"gaps.md": "Current RetroBIOS verification gaps, platform-to-emulator divergences, missing files and documented source limitations.",
"exports.md": "Each platform's own BIOS list (System.dat, batocera-systems, es_bios.xml and the rest) with the hashes and files the emulator source code shows, offered to its maintainers.",
sitemeasurements.EXPLORER_PAGE: "Emulator cores run headless in real conditions: each test with its claim, result, method, computer and full record, filterable, and as SQLite.",
sitemeasurements.EXPLORER_PAGE: "The records of emulator cores run headless on demand, each with its claim, verdict, the BIOS it ran, method, computer and full record, filterable, and as SQLite.",
"provenance.md": "Hash-based comparison of RetroBIOS metadata with No-Intro, Redump and TOSEC catalog snapshots.",
"explore.md": "Systems, emulators and installer options to explore, with the figures of the BIOS collection.",
"which-pack.md": "Pick your device or setup and get its BIOS files: the folder they go in, one command that installs and checks them, or a ZIP pack to extract.",
@@ -4329,9 +4329,6 @@ def generate_platform_page(
no_list = not cov["total"] and registry.get(name, {}).get("native_list") == "none"
if name in GUIDES:
lines += _platform_guide(name, display, cov, registry, no_list)
# Before the reference: the links below it are read under that heading.
lines.extend(sitemeasurements.pack_tested_section(_PACK_ITEMS.get(name, [])))
lines += [
"## Reference: every file by system { #reference-every-file-by-system }",
"",
@@ -7182,11 +7179,6 @@ def system_pages(
_section_label(manufacturer, console),
_install_pairs(installs.get(console, []), lead, consumers))
def region_block(console: str, level: int = 3) -> list[str]:
# Under the console's heading on a maker's page, a section of its
# own on the console's page.
return sitemeasurements.region_section(_REGION_RESULTS.get((slug, console), []), level)
def all_sections() -> dict[str, list[Card]]:
anchors: set[str] = set()
return {console: cards_of(console, anchors) for console in ordered}
@@ -7228,7 +7220,6 @@ def system_pages(
lines.append("")
lines.extend(start_of(console))
lines.extend(install_block(console))
lines.extend(region_block(console))
lines.extend(_cards_markdown(cards))
lines.append("")
lines.extend(_next_block([*_NEXT_FROM_SYSTEMS, json_next]))
@@ -7291,7 +7282,6 @@ def system_pages(
if console not in moved:
summary.extend(start_of(console))
summary.extend(install_block(console))
summary.extend(region_block(console))
summary.extend(_cards_markdown(cards_of(console, summary_anchors)))
summary.append("")
continue
@@ -7376,8 +7366,6 @@ def system_pages(
lines.extend(legend)
lines.extend(_romset_note({console: consoles[console]}))
lines.extend(install_block(console))
if index == 0:
lines.extend(region_block(console, 2))
lines.extend(["## Files", ""])
lines.extend(_cards_markdown(part))
lines.append("")
@@ -9106,13 +9094,8 @@ def _said_as_list(items: list[str]) -> str:
# Data directory members and revisions, read once per build.
_DATA_MEMBERS: dict[str, dict[str, dict]] = {}
_DATA_REVISIONS: dict[str, dict] = {}
# The measurement index items of each emulator, for its Tested block.
# The measurement index items of each emulator, for the proof lines of its page.
_MEASUREMENT_ITEMS: dict[str, list[dict]] = {}
# (manufacturer slug, console) -> the region outcomes of its systems
# (region_check.py), shown under the console on its system page.
_REGION_RESULTS: dict[tuple[str, str], list[dict]] = {}
# Pack probes by platform key, for the Tested block of a platform page.
_PACK_ITEMS: dict[str, list[dict]] = {}
# The emulator pages that list each data directory, by ref.
_DATA_READERS: dict[str, list[tuple[str, str]]] = {}
@@ -9339,19 +9322,6 @@ 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()
@@ -9743,8 +9713,7 @@ 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, []), _tested_file_hrefs(name, files)))
lines.extend(sitemeasurements.proof_section(_MEASUREMENT_ITEMS.get(name, [])))
blocks = _render_structured_blocks(profile)
if blocks:
@@ -11841,13 +11810,6 @@ def _generate(args: argparse.Namespace) -> None:
_system_pages_from_data(manufacturers, coverages, db, profiles)
)
print(f" {len(_system_page_map)} system IDs mapped to pages")
from siterender import _page_by_norm # noqa: PLC0415
_REGION_RESULTS.clear()
for result in sitemeasurements.site_region_results(repo=REPO_URL):
place = _system_page_map.get(result["system"]) or _page_by_norm(result["system"])
if place:
_REGION_RESULTS.setdefault(place, []).append(result)
set_console_sections(manufacturers, program_names(profiles))
from siterender import link_coverage, system_ids # noqa: PLC0415
@@ -11900,13 +11862,9 @@ def _generate(args: argparse.Namespace) -> None:
_record(path)
_MEASUREMENT_ITEMS.clear()
_MEASUREMENT_ITEMS.update(sitemeasurements.by_emulator(measured.index))
_PACK_ITEMS.clear()
_PACK_ITEMS.update(sitemeasurements.by_platform(measured.index))
print(f" {measured.index['records']} records, {measured.index['count']} tests")
write_if_changed(str(docs / sitemeasurements.EXPLORER_PAGE),
sitemeasurements.generate_explorer_page(
measured.index, {sys_id: system_name(sys_id) for sys_id in sorted(set(_system_page_map))})
+ reference_next())
sitemeasurements.generate_explorer_page(measured.index) + reference_next())
print("Generating static API and bulk data exports...")
exports = generate_data_exports(
File diff suppressed because it is too large. Load diff
-45
View File
@@ -34,7 +34,6 @@ import campaign
import campaign_profiles
import campaign_rules as rules
import measurement_records as mr
import sitemeasurements
TMP = REPO_ROOT / "tmp" / "tests"
@@ -1003,50 +1002,6 @@ class Registry(unittest.TestCase):
self.assertEqual(campaign.autorun.job_env(job)[campaign.LOCK_HELD_ENV], "1")
class SitePage(unittest.TestCase):
def test_last_pass_and_open_findings(self) -> None:
summary = {
"last_run": {"ended_at": "2026-10-27T10:00:00+00:00", "result": "complete", "detail": "",
"counts": {"done": 12, "failed": 1, "pending": 3},
"pending_reasons": {"standalone": 3},
"failed": [{"emulator": "fake", "check": "fake/x/y/bench", "reason": "timeout"}]},
"passes": 1, "applied": 2,
"open": [{"emulator": "fake", "file": "bios.bin", "field": "required", "status": "open",
"profile_says": True, "run_shows": False, "statement": "the core boots without it",
"evidence": ["2026-10-27-aaaaaaaaaaaa"], "links": ["https://x/l#L1"]}],
}
page = "\n".join(sitemeasurements.campaign_section(summary))
self.assertIn("12 tests done, 1 failed, 3 waiting", page)
self.assertIn("| standalone | 3 |", page)
self.assertIn("the profile says <code>true</code>, the run shows <code>false</code>", page)
self.assertIn("[2026-10-27-aaaaaaaaaaaa](https://x/l#L1)", page)
self.assertIn("<code>false</code>. The core boots without it. Records:", page)
self.assertEqual(sitemeasurements.campaign_section({"last_run": None}), [])
def test_observed_values_cannot_leave_their_place(self) -> None:
# A value comes from a core's output or a romfetch error: it may hold
# backticks, MDX braces and HTML.
hostile = "``}{import x}<script>alert(1)</script>`` | [a](javascript:x) *b*"
summary = {
"last_run": {"ended_at": "2026-10-27T10:00:00+00:00", "result": "paused", "detail": hostile,
"counts": {"done": 0, "failed": 1, "pending": 1},
"pending_reasons": {hostile: 1},
"failed": [{"emulator": hostile, "check": hostile, "reason": hostile}]},
"passes": 1, "applied": 0,
"open": [{"emulator": "fake", "file": hostile, "field": hostile, "status": "open",
"profile_says": {"k": hostile}, "run_shows": [hostile], "statement": hostile,
"evidence": ["2026-10-27-aaaaaaaaaaaa"], "links": [None]}],
}
page = "\n".join(sitemeasurements.campaign_section(summary))
for raw in ("<script", "{import", "}{", "``", "](javascript", "*b*", "| [a]"):
self.assertNotIn(raw, page)
self.assertIn("&lt;script&gt;alert(1)&lt;/script&gt;", page)
self.assertIn("&#123;import x&#125;", page)
# The JSON dumps are escaped too: no brace reaches the page as syntax.
self.assertNotIn("{", page)
self.assertNotIn("}", page)
@unittest.skipUnless(shutil.which("cc") and shutil.which("strace"), "no C compiler or no strace")
class FakeCorePasses(Workspace):
"""Whole passes against a core compiled from FAKE_CORE."""
+49 -159
View File
@@ -9,6 +9,7 @@ against HEAD.
from __future__ import annotations
import copy
import html
import json
import os
import re
@@ -216,12 +217,11 @@ class ReadAndIndex(Workspace):
index = self.built(self.tmp / "public").index
self.assertEqual({k: index[k] for k in ("schema_version", "kind", "repo", "commit", "records", "count")},
{"schema_version": 1, "kind": "measurements", "repo": REPO_URL,
"commit": COMMIT, "records": 3, "count": 3})
"commit": COMMIT, "records": 3, "count": 2})
keys = {"emulator", "emulator_name", "profiled", "systems", "system_names", "subject", "kind",
"claim", "method", "observable", "variable", "status", "statement", "content",
"variants", "repetitions", "flags", "date", "host", "core", "frontend_commit", "id",
"runs", "record_url", "sqlite", "verdicts", "title", "host_short", "groups",
"proves", "timing", "setup"}
"runs", "record_url", "sqlite", "verdicts", "proves"}
for item in index["items"]:
self.assertEqual(set(item), keys)
alpha = {i["subject"]: i for i in index["items"] if i["emulator"] == "alpha"}
@@ -229,9 +229,9 @@ class ReadAndIndex(Workspace):
self.assertEqual(alpha["card"]["system_names"], ["Sega Saturn"])
self.assertEqual(alpha["card"]["record_url"],
f"{REPO_URL}/blob/{COMMIT}/measurements/alpha.jsonl#L1")
self.assertEqual(alpha["speed"]["status"], "measured")
self.assertIn("ms per frame", alpha["speed"]["statement"])
self.assertIn("Test CPU", alpha["speed"]["host"])
# A benchmark stays in the records and the SQLite files, never in the index.
self.assertNotIn("speed", alpha)
self.assertNotIn("ms per frame", json.dumps(index))
written = json.loads((self.tmp / "public" / sm.INDEX_PATH).read_text())
self.assertEqual(written, index)
@@ -248,9 +248,6 @@ class ReadAndIndex(Workspace):
self.assertNotIn("differ", statement)
# A check on another observable keeps its comparison.
self.assertEqual(sm.result_of(full_record("alpha", "c", "2026-10-06T10:00:00+00:00"))[0], "differs")
groups = sm.variant_groups(record)
self.assertEqual([(g["variant"], g["result"], g["group"]) for g in groups],
[("v0", "works", 0), ("v1", "hang", 1)])
def test_a_boot_on_the_built_in_bios_is_named_so(self) -> None:
import core_probe # noqa: PLC0415
@@ -269,11 +266,12 @@ class ReadAndIndex(Workspace):
status, statement = sm.result_of(record)
self.assertEqual(status, sm.BOOTS_BUILTIN)
self.assertIn("built-in BIOS", statement)
item = {**SitePages.ITEM, "host_short": "h", "kind": "run", "status": status, "statement": statement,
"groups": sm.variant_groups(record), "verdicts": sm.verdicts_of(record)}
text = "\n".join(sm.tested_section("alpha", [item]))
self.assertIn("works on its built-in BIOS", text)
self.assertNotIn("other region", text)
# The proof line a profile field rests on names the BIOS the core ran.
item = {**SitePages.ITEM, "kind": "run", "status": status, "statement": statement,
"verdicts": sm.verdicts_of(record), "proves": ["required of scph5501.bin"]}
line = sm.proof_line(item)
self.assertIn("required of scph5501.bin: boots on the core&#x27;s built-in BIOS", line)
self.assertNotIn("other region", line)
def test_links_name_the_last_commit_that_touched_the_records(self) -> None:
first = self.repository()
@@ -467,157 +465,49 @@ class SitePages(unittest.TestCase):
"sqlite": "downloads/measurements/beetle_saturn.sqlite",
}
def test_tested_block(self) -> None:
self.assertEqual(sm.tested_section("beetle_saturn", []), [])
text = "\n".join(sm.tested_section("beetle_saturn", [self.ITEM]))
self.assertTrue(text.startswith("## Tested\n"))
for expected in ("same with every file", "<strong>Method:</strong> Twice per card. Every input fixed.",
"<strong>Ran on:</strong> Test CPU, 12 CPUs", self.ITEM["record_url"],
"1 flag raised", "2 runs", "downloads/measurements/beetle_saturn.sqlite",
"wiki/measurements/", "&lt;image&gt;", "1 test · last run 2026-10-27",
'<p class="rb-tested-file"><code>mpeg_card.bin</code></p>',
'class="rb-tested-legend"', "No file staged."):
self.assertIn(expected, text)
self.assertNotIn("confirmed", text)
self.assertNotIn(" open", text)
def item(self, **values: object) -> dict:
return {**self.ITEM, "host_short": "Test CPU, Linux", **values}
return {**self.ITEM, **values}
def test_summary_counts(self) -> None:
items = [self.item(proves=["hle_fallback of a.bin"], open_findings=2),
self.item(id="b", subject="b", date="2026-10-28T00:00:00+00:00", open_findings=2),
self.item(id="c", kind="bench", status="measured", subject="c",
timing={"ms_per_frame": 1.5, "fps": 660.0, "stdev": 0.01})]
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 in the profile · 2 open findings · last run 2026-10-28 "
"on Test CPU, Linux.", text)
self.assertIn("<td>1.500</td><td>660.0</td>", text)
def test_only_the_runs_a_page_rests_on_get_a_proof_line(self) -> None:
self.assertIsNone(sm.proof_line(self.item(proves=[])))
self.assertEqual(sm.proof_section([self.item(proves=[])]), [])
line = sm.proof_line(self.item(proves=["hle_fallback of mpeg_card.bin"], verdicts=[
{"variant": "default", "verdict": "boots", "bios_used": "staged:mpeg_card.bin", "detail": "d"}]))
self.assertEqual(html.unescape(line), f"- hle_fallback of mpeg_card.bin: boots on mpeg_card.bin "
f"([record]({self.ITEM['record_url']})).")
issue = sm.proof_line(self.item(subject="issue85-lunar-opening-movie", proves=[], verdicts=[],
claim=None, content="Lunar"))
self.assertTrue(issue.startswith("- issue 85: a run of Lunar, recorded before the boot oracle"))
section = sm.proof_section([self.item(proves=["required of a.bin"], verdicts=[])])
self.assertEqual(section[0], "## Proof")
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</span>", sm._chip(negative))
self.assertIn('rb-badge-info', sm._chip(negative))
self.assertIn(">works</span>", 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('<a href="#file-mpeg-card-bin"><code>mpeg_card.bin</code></a>', text)
def test_short_titles(self) -> None:
cases = [
({"subject": "mpeg-card-lunar-cr2-build", "variable": "mpeg_card.bin",
"content": "Redump: Lunar - Silver Star Story Complete (Japan), T-27904G V1.00"},
"mpeg_card.bin, Lunar (CR2 build)"),
({"subject": "negative-scph5501-bin-mednafen-psx-bust-a-move-2-arcade-edition-usa",
"variable": "scph5501.bin", "content": "Bust-A-Move 2 - Arcade Edition (USA)",
"core": {"file": "mednafen_psx_libretro.so"}},
"scph5501.bin, Bust-A-Move 2 (wrong files)"),
({"subject": "issue85-lunar-opening-movie", "variable": None,
"content": "Redump: Lunar - Silver Star Story Complete (Japan), T-27904G V1.00"},
"Lunar (issue 85 opening movie)"),
({"subject": "with-command-auth-device-and-command-get-9a211715", "variable": "mpeg_card.bin",
"content": "Redump: Lunar"},
"mpeg_card.bin, Lunar (with command auth device and get)"),
]
for item, title in cases:
self.assertEqual(sm.short_title(item), title)
self.assertEqual(sm.short_host({"cpu_model": "13th Gen Intel(R) Core(TM) i9-13900K",
"os": "Linux-6.18.54.1-microsoft-standard-WSL2-x86_64"}),
"Intel Core i9-13900K, Linux (WSL2)")
def test_rows_of_one_file_never_read_alike(self) -> None:
def item(rid: str, build: str, files: int, observable: str, clock: bool = True) -> dict:
record = {"core": {"build_command": build}, "subject": "mpeg-card-lunar", "kind": "check",
"check": {"observable": observable}, "variants": [{}] * files,
"inputs": {"options": {"beetle_saturn_mpeg_card": "enabled"},
"env": {"FAKETIME": "x"} if clock else {}}}
return self.item(id=rid, content="Redump: Lunar - Silver Star Story", setup=sm.setup_of(record))
items = [item("a", "make -j8", 11, "video_sha1"),
item("b", "make -j8 after editing cdb.c", 11, "video_sha1"),
item("c", "make -j10, with the CR2 patch to cdb.c", 3, "state:MPEG.AuthState"),
item("d", "make -j8", 11, "video_sha1", clock=False)]
titles = sm.distinct_titles(items)
self.assertEqual(titles, {
"a": "Lunar",
"b": "Lunar, patched build",
"c": "Lunar, CR2 patch, 3 files, MPEG.AuthState",
"d": "Lunar, running clock"})
self.assertEqual(len(set(titles.values())), len(items))
self.assertNotIn("...", " ".join(titles.values()))
# Alone in its file, a test is named by its game.
self.assertEqual(sm.distinct_titles(items[:1]), {"a": "Lunar"})
def test_the_removed_blocks_are_gone(self) -> None:
for name in ("tested_section", "region_section", "core_region_line", "campaign_section",
"coverage_section", "packs_section", "pack_tested_section", "bench_statement"):
self.assertFalse(hasattr(sm, name), name)
docs = REPO_ROOT / "website" / "src" / "content" / "docs"
pages = [*docs.glob("emulators/*.md*"), *docs.glob("systems/*.md*"),
*docs.glob("platforms/*.md*"), *docs.glob("measurements*.md*")]
if not pages:
self.skipTest("the site has not been generated")
for page in pages:
text = page.read_text(encoding="utf-8")
for removed in ("rb-tested", "rb-region-runs", "## Tested", "## Region check",
"ms per frame", "## Campaign", "## Coverage", "## Packs"):
self.assertNotIn(removed, text, f"{page.name}: {removed}")
def test_run_output_is_text_never_markup(self) -> None:
nasty = "`code` {expr} <script>alert(1)</script> [x](javascript:alert(1)) \"q\" 'q' **b**"
item = self.item(
claim=nasty, method=nasty, statement=nasty, host=nasty, host_short=nasty, content=nasty,
variable=f"{nasty}.bin", subject="s", title=nasty, proves=[nasty], runs=2, flags=1,
core={"library": nasty, "commit": "{`<x>`}", "file": f"{nasty}_libretro.so"},
groups=[{"variant": nasty, "group": 0, "result": nasty, "absent": False}],
record_url="javascript:alert(1)")
bench = self.item(id="b", kind="bench", status="measured", subject="bench", title=nasty,
content=nasty, record_url="java\nscript:x",
timing={"ms_per_frame": 1.0, "fps": 1.0, "stdev": 0.0})
earlier = self.item(id="e", status="no verdict", subject="e", content=nasty, claim=nasty)
text = "\n".join(sm.tested_section("alpha", [item, bench, earlier]))
self.assertNotIn("<script", text)
self.assertNotRegex(text, r'href="(?!https?://|/)')
self.assertNotIn("javascript:alert(1)\"", text)
self.assertNotRegex(text, r"[{}]")
self.assertNotIn("<strong>b</strong>", text)
self.assertNotIn("<code>code</code>", text)
self.assertNotRegex(text, r'="[^"]*"q"')
self.assertIn("&lt;script&gt;", text)
self.assertIn("&#123;expr&#125;", text)
def test_no_empty_sentence(self) -> None:
text = "\n".join(sm.tested_section("beetle_saturn", [self.item(claim=None, method=None, statement="",
kind="run", status="ran")]))
self.assertNotRegex(text, r"</strong>\s*\.|:\s*\.\s|`ran`\. \.")
self.assertNotIn("Claim:", text)
self.assertNotIn("Method:", text)
def test_dots_follow_the_result_groups(self) -> None:
record = full_record("alpha", "boot", "2026-10-06T10:00:00+00:00", values=("1" * 40, "2" * 40, "1" * 40))
record["check"]["variable"] = "card.bin"
record["variants"][2]["system_files"] = {"card.bin": None}
groups = sm.variant_groups(record)
self.assertEqual([g["group"] for g in groups],
[i for i, group in enumerate(record["check"]["result"]["groups"])
for _ in group["variants"]][:1] + [1, 0])
self.assertEqual([g["absent"] for g in groups], [False, False, True])
text = "\n".join(sm.tested_section("alpha", [self.item(groups=groups)]))
strip = text.split('class="rb-dots"', 1)[1].split("</span></span>", 1)[0]
self.assertEqual(re.findall(r'rb-dot rb-dot-(\d)( rb-dot-empty)?"', strip),
[("0", ""), ("1", ""), ("0", " rb-dot-empty")])
self.assertIn('aria-label="3 variants. v0: result A. v1: result B. v2: result A"', text)
def test_the_details_hold_the_method_and_the_host(self) -> None:
text = "\n".join(sm.tested_section("beetle_saturn", [self.item(runs=1)]))
details = text.split('<div class="rb-tested-more">', 1)[1].split("</div>", 1)[0]
self.assertIn("Twice per card", details)
self.assertIn("<strong>Ran on:</strong> Test CPU, Linux.", details)
self.assertIn(f'<a href="{self.ITEM["record_url"]}">Full record</a>.', details)
self.assertNotIn("1 run", details)
def test_the_beetle_saturn_block_stays_short(self) -> None:
stored = mr.read_records(REPO_ROOT)
profiles = sm.load_profiles(REPO_ROOT / "emulators")
index = sm.build_index(stored, {"repo": REPO_URL, "commit": COMMIT}, profiles)
items = sm.by_emulator(index).get("beetle_saturn")
if not items:
self.skipTest("no beetle_saturn record")
block = "\n".join(sm.tested_section("beetle_saturn", items))
# What a reader sees before opening anything: the closed details hide their body.
shown = re.sub(r'<div class="rb-tested-more">.*?</div>', " ", block, flags=re.S)
shown = re.sub(r'<details class="rb-tested-earlier">.*?</details>\s*</details>', " ", shown,
flags=re.S)
shown = re.sub(r"<[^>]+>", " ", shown)
self.assertLess(len(re.findall(r"[A-Za-z0-9][\w.'-]*", shown)), 120, shown)
line = sm.proof_line(self.item(proves=[nasty], verdicts=[
{"variant": nasty, "verdict": nasty, "bios_used": f"staged:{nasty}", "detail": nasty},
{"variant": nasty, "verdict": "boots", "bios_used": "builtin", "detail": nasty}],
record_url="javascript:alert(1)"))
self.assertNotIn("<script", line)
self.assertNotIn("(javascript:", line)
self.assertNotRegex(line, r"[{}`*]")
self.assertNotRegex(line, r"\[(?!record\])")
self.assertNotIn("](", line)
self.assertIn("&lt;script&gt;", line)
def test_hosts_table_on_the_method_page(self) -> None:
page = sm.with_hosts(f"x\n\n{sm.HOSTS_MARKER}\n",
+7 -52
View File
@@ -218,43 +218,14 @@ class Line(unittest.TestCase):
class SitePages(unittest.TestCase):
"""The Measurements page and the platform pages show the latest probe."""
"""A pack probe runs before a release: its records stay in measurements/
and reach no page."""
def test_latest_line_per_probe_with_its_link(self) -> None:
def test_the_pack_blocks_are_gone(self) -> None:
import sitemeasurements as sm
root = TMP / "site"
shutil.rmtree(root, ignore_errors=True)
root.mkdir(parents=True)
first = Line.line(None)
later = {**first, "probed_at": "2026-10-28T12:00:00+00:00", "verdict": "boots"}
other = {**first, "platform": "batocera", "install": "installer"}
for line in (first, later, other):
pp.append_line(line, root)
items = sm.pack_summary(root, {"repo": "https://example.org/r", "commit": "c" * 40})
self.assertEqual([(i["platform"], i["install"], i["verdict"]) for i in items],
[("batocera", "installer", "unknown"), ("retroarch", "pack", "boots")])
self.assertEqual(items[1]["record_url"],
f"https://example.org/r/blob/{'c' * 40}/measurements/pack-probes.jsonl#L2")
self.assertEqual(items[1]["core"], "mednafen_saturn")
explorer = "\n".join(sm.packs_section(items))
self.assertIn("| Platform | System |", explorer)
self.assertIn("| retroarch | sega-saturn | pack | <code>mednafen&#95;saturn</code> | Game (Japan) "
"| `boots` | 1 | [line](", explorer)
page = sm.pack_tested_section(sm.by_platform({"packs": items})["retroarch"])
text = "\n".join(page)
self.assertEqual(page[0], "## Tested")
self.assertIn("1 game start with this BIOS folder as you install it · 1 work · last run 2026-10-28.",
text)
self.assertIn("wiki/measurements/#packs", text)
# The emulator pages' row markup and chip, the install path in the third column.
self.assertIn('<span class="rb-tested-result"><span class="rb-badge rb-badge-success">works</span>',
text)
self.assertIn('<span class="rb-tested-variants">pack</span>', text)
self.assertIn("sega-saturn, Game <small>mednafen&#95;saturn</small>", text)
self.assertIn("<strong>Files the core opened:</strong> sega&#95;101.bin (sega&#95;101.bin).", text)
self.assertIn("<strong>Findings:</strong> missing&#95;declared x.bin.", text)
self.assertNotIn("| retroarch |", text)
for name in ("pack_summary", "packs_section", "pack_tested_section", "by_platform"):
self.assertFalse(hasattr(sm, name), name)
def test_pack_runs_stay_off_the_emulator_page(self) -> None:
import sitemeasurements as sm
@@ -266,30 +237,14 @@ class SitePages(unittest.TestCase):
self.assertEqual([i["subject"] for i in sm.by_emulator(index)["beetle_saturn"]],
["boot-sega-101-bin"])
def test_run_output_is_inert(self) -> None:
"""A file name or log line from a third-party core reaches the page
as text: no tag, link, code span or MDX expression comes out of it."""
def test_a_markdown_link_keeps_only_safe_targets(self) -> None:
"""A Markdown link in site text keeps only http(s) and relative targets."""
import sitemarkup
import sitemeasurements as sm
hostile = "`x` {alert(1)} <script>alert(1)</script> [x](javascript:alert(1)) \"q\" 'q' **b**"
item = {"platform": "retroarch", "platform_version": "1", "install": "pack",
"system": hostile, "emulator": hostile, "core": hostile, "content": hostile,
"verdict": "boots", "date": "2026-10-28T00:00:00+00:00", "opened": 1, "findings": 1,
"id": "2026-10-28-0123456789ab", "record_url": "https://example.org/r#L1",
"files": [hostile], "finding_list": [hostile], "detail": hostile}
text = "\n".join(sm.pack_tested_section([item]))
for raw in ("<script", "{alert", "`x`", "[x](", "<code>", "<strong>b", "**b",
"href=\"javascript", '"q"', "'q'"):
self.assertNotIn(raw, text)
self.assertIn("&lt;script&gt;", text)
self.assertIn("&#123;alert(1)&#125;", text)
# A Markdown link in other site text keeps only http(s) and relative targets.
self.assertEqual(sitemarkup.inline_html("[x](javascript:alert(1))"), "[x](javascript:alert(1))")
self.assertEqual(sitemarkup.inline_html('[x](https://a.org/"onmouseover=1)'),
'<a href="https://a.org/&quot;onmouseover=1">x</a>')
self.assertEqual(sitemarkup.inline_html("[x](../a.md)"), '<a href="../a.md">x</a>')
self.assertEqual(sm.pack_tested_section([]), [])
class Lock(unittest.TestCase):
+13 -67
View File
@@ -170,10 +170,6 @@ class Outcome(unittest.TestCase):
self.assertEqual(text, "The US BIOS boots the US game, and on its built-in BIOS with the "
"others' files refused.")
self.assertNotIn("so do the other regions", text)
import sitemeasurements as sm
line = sm.core_region_line([result])
self.assertIn("built-in BIOS", line)
self.assertNotIn("on the other regions' BIOS", line)
def test_no_own_run(self) -> None:
self.assertEqual(rc.sentence("japan", rc.outcome({}, self.ENTRIES, "japan")),
@@ -243,75 +239,25 @@ class RequiredFromTheRegionRuns(unittest.TestCase):
class SitePages(unittest.TestCase):
def test_region_section_links_every_record(self) -> None:
import sitemeasurements as sm
records = {"full": record("f", Outcome.ALL, ["scph5500.bin"], [[0, "a"]], "boots"),
"own": record("o", ["scph5500.bin"], ["scph5500.bin"], [[0, "a"]], "boots"),
"others": record("x", Outcome.ALL[1:], [], [[0, "b"]], "bios_error")}
result = rc.outcome(records, Outcome.ENTRIES, "japan")
result.update(core="mednafen_psx", game="Puzzle Bobble 2 (Japan)",
sentence=rc.sentence("japan", result))
for label, item in result["variants"].items():
item["url"] = f"https://example.org/{label}"
text = "\n".join(sm.region_section([result]))
self.assertIn("- **mednafen&#95;psx**: Each region's game boots on its own BIOS only.", text)
self.assertIn("The Japanese BIOS boots the Japanese game, the other regions&#x27; BIOS do not.", text)
# The per-game lines and their records wait in a closed fold.
self.assertIn('<details class="rb-region-runs">', text)
self.assertIn('<a href="https://example.org/own">its own region&#x27;s BIOS only</a>', text)
self.assertIn("<code>scph5500.bin</code>", text)
self.assertNotIn("reference frames are recorded", text)
self.assertEqual(sm.region_section([]), [])
def test_the_emulator_page_folds_region_runs_into_one_line(self) -> None:
def test_a_region_run_reaches_a_page_only_as_the_proof_of_a_field(self) -> None:
"""No page shows region outcomes. The Beetle PSX page names the runs
its required: false rests on, each with the BIOS the core ran."""
import measurement_records as mr
import sitemeasurements as sm
stored = mr.read_records(ROOT)
index = sm.build_index(stored, {"repo": sm.REPO, "commit": "0" * 40}, sm.load_profiles(ROOT / "emulators"))
items = sm.by_emulator(index).get("beetle_psx") or []
regional = [i for i in items if sm.REGION_SUBJECT.match(i["subject"])]
if not regional:
self.skipTest("no region record")
text = "\n".join(sm.tested_section("beetle_psx", items))
self.assertIn(f"Region check: {len(regional)} runs of 3 games, read on the system page.", text)
for item in regional:
self.assertNotIn(item["record_url"], text)
def test_coverage_names_tested_and_uncovered_systems(self) -> None:
import sitemeasurements as sm
cov = {"systems": [{"system": "sony-playstation", "tested": True, "games": [
{"name": "A (USA)", "region": "north-america", "emulators": ["beetle_psx"]}]},
{"system": "sega-32x", "tested": False, "games": [
{"name": "B (World)", "region": None, "emulators": []}]}],
"uncovered": [{"system": "msx", "want": "Gradius", "reason": "No MSX catalog.",
"romfetch": {"exit": 1, "code": "unknown_system"}}]}
text = "\n".join(sm.coverage_section(cov, {"sony-playstation": "PlayStation"}))
self.assertIn("1 of 2 listed systems have a recorded run, and 1 system has no test game", text)
self.assertIn("| PlayStation | A (USA) | beetle&#95;psx |", text)
self.assertIn("| sega-32x | B (World) | not yet: no run recorded |", text)
self.assertIn("exit 1, <code>unknown&#95;system</code>", text)
def test_one_catalog_name_on_two_systems_counts_only_where_it_ran(self) -> None:
import measurement_records as mr
import sitemeasurements as sm
label = "Bust-A-Move 2 - Arcade Edition (USA)"
stored = [mr.Stored("beetle_psx", 1, {"inputs": {"content": {"label": label}}})]
cov = sm.coverage(ROOT, stored, {"beetle_psx": {"systems": ["sony-playstation"]}})
by_system = {item["system"]: item for item in cov["systems"]}
self.assertTrue(by_system["sony-playstation"]["tested"])
self.assertFalse(by_system["sega-saturn"]["tested"])
def test_coverage_reads_the_real_content_list(self) -> None:
import sitemeasurements as sm
cov = sm.coverage(ROOT, [])
systems = {item["system"] for item in cov["systems"]}
self.assertIn("sony-playstation", systems)
self.assertTrue(all(item["romfetch"].get("exit") for item in cov["uncovered"]))
if not items:
self.skipTest("no beetle_psx record")
text = "\n".join(sm.proof_section(items))
self.assertNotIn("Region check", text)
lines = [line for line in text.splitlines() if line.startswith("- ")]
self.assertEqual(len(lines), sum(1 for i in items if i["proves"]))
required = [line for line in lines if line.startswith("- required of scph55")]
self.assertEqual(len(required), 3)
for line in required:
self.assertIn("boots on the core&#x27;s built-in BIOS", line)
if __name__ == "__main__":
-9
View File
@@ -192,15 +192,6 @@ 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()
@@ -105,11 +105,11 @@ const base = import.meta.env.BASE_URL.replace(/\/?$/, '/');
const tr = document.createElement('tr');
tr.append(text('td', item.date.slice(0, 10)));
const emu = document.createElement('td');
emu.append(item.profiled ? link(`${base}emulators/${item.emulator}/#tested`, item.emulator_name) : text('span', item.emulator_name));
emu.append(item.profiled ? link(`${base}emulators/${item.emulator}/`, item.emulator_name) : text('span', item.emulator_name));
if (item.system_names.length) emu.append(text('small', item.system_names.join(', ')));
tr.append(emu);
const test = document.createElement('td');
test.append(text('strong', item.claim ?? `Benchmark of ${item.content ?? 'the core alone'}`));
test.append(text('strong', item.claim ?? `A run of ${item.content ?? 'the core alone'}`));
if (item.method) {
const details = document.createElement('details');
details.append(text('summary', 'Method'), text('p', item.method));
-85
View File
@@ -1051,88 +1051,3 @@ starlight-tabs [role='tab'] { white-space: nowrap; }
@media (min-width: 50rem) {
header .site-title img { height: calc(4rem - 2 * var(--sl-nav-pad-y)); width: auto; }
}
/* The Tested block of an emulator page (scripts/sitemeasurements.py): a
summary line, then one row per test, each a <details> whose summary is
the row and whose body is the proof. Rows stack into two lines on a
phone. A dot per variant, its group in colour and its name in a title
and the strip's label; a variant that staged no file is a ring. */
.sl-markdown-content .rb-tested-summary { color: var(--rb-text-secondary); font-size: 0.9rem; }
.sl-markdown-content :is(.rb-tested-head, .rb-tested-row > summary) {
display: grid;
grid-template-columns: 1.25rem minmax(0, 1fr) 8.5rem 9rem 6rem;
gap: 0.5rem;
align-items: center;
}
.sl-markdown-content .rb-tested-head {
margin-top: 0.75rem;
padding: 0 0 0.25rem;
border-bottom: 1px solid var(--rb-border-strong);
color: var(--rb-text-secondary);
font-size: 0.8rem;
font-weight: 600;
}
.sl-markdown-content .rb-tested-head::before { content: ""; }
/* Starlight draws a side rule on every details: a row has a rule below only. */
.sl-markdown-content details:is(.rb-tested-row, .rb-tested-earlier) { border-inline-start: 0; padding-inline-start: 0; }
.sl-markdown-content details.rb-tested-row { margin: 0; border-bottom: 1px solid var(--rb-border); }
.sl-markdown-content details.rb-tested-row:has(> summary:hover) { border-color: var(--rb-border); }
.sl-markdown-content .rb-tested-row > summary {
min-height: 2.25rem;
padding: 0.3rem 0;
cursor: pointer;
font-size: 0.9rem;
}
.sl-markdown-content .rb-tested-row > summary::before { background-color: var(--rb-text-secondary); margin: 0; }
.sl-markdown-content .rb-tested-row > summary:hover { background: var(--rb-surface); }
.sl-markdown-content .rb-tested-test { font-weight: 600; overflow-wrap: anywhere; }
.sl-markdown-content :is(.rb-tested-test, .rb-tested-date) small { color: var(--rb-text-secondary); font-weight: 400; }
.sl-markdown-content .rb-tested-date { color: var(--rb-text-secondary); font-variant-numeric: tabular-nums; white-space: nowrap; }
.sl-markdown-content .rb-tested-more {
margin: 0 0 0.75rem 1.75rem;
padding: 0.5rem 0.75rem;
border: 1px solid var(--rb-border);
border-radius: 4px;
font-size: 0.875rem;
}
.sl-markdown-content .rb-tested-more p { margin: 0.35rem 0 0; }
.sl-markdown-content .rb-tested-more p:first-child { margin-top: 0; }
.sl-markdown-content details.rb-tested-earlier { margin-top: 0.75rem; }
.sl-markdown-content details.rb-tested-earlier > summary { font-size: 0.9rem; color: var(--rb-text-secondary); cursor: pointer; }
.sl-markdown-content .rb-dots { display: inline-flex; flex-wrap: wrap; gap: 3px; }
.sl-markdown-content .rb-dot {
width: 10px;
height: 10px;
border-radius: 3px;
border: 2px solid var(--rb-dot);
background: var(--rb-dot);
}
.sl-markdown-content .rb-dot-empty { background: transparent; }
.sl-markdown-content .rb-dot-0 { --rb-dot: var(--rb-ok-fg); }
.sl-markdown-content .rb-dot-1 { --rb-dot: var(--rb-info-fg); }
.sl-markdown-content .rb-dot-2 { --rb-dot: var(--rb-warn-fg); }
.sl-markdown-content .rb-dot-3 { --rb-dot: var(--rb-err-fg); }
.sl-markdown-content .rb-dot-4 { --rb-dot: var(--rb-muted-fg); }
.sl-markdown-content p.rb-tested-file {
margin: 0.9rem 0 0;
padding-bottom: 0.2rem;
border-bottom: 1px solid var(--rb-border-strong);
font-size: 0.85rem;
font-weight: 600;
}
.sl-markdown-content p.rb-tested-legend { margin-top: 0.5rem; color: var(--rb-text-secondary); font-size: 0.8rem; }
.sl-markdown-content p.rb-tested-legend .rb-dot { display: inline-block; vertical-align: -1px; }
.sl-markdown-content table.rb-tested-bench { margin-top: 1rem; font-size: 0.875rem; }
.sl-markdown-content table.rb-tested-bench td:not(:first-child) { font-variant-numeric: tabular-nums; text-align: right; }
@media (max-width: 50rem) {
.sl-markdown-content div.rb-tested-head { display: none; }
.sl-markdown-content details.rb-tested-row > summary {
grid-template-columns: 1.25rem auto minmax(0, 1fr) auto;
row-gap: 0.2rem;
}
.sl-markdown-content .rb-tested-row > summary::before { grid-row: 1; }
.sl-markdown-content .rb-tested-test { grid-column: 2 / -1; }
.sl-markdown-content .rb-tested-result { grid-column: 2; }
.sl-markdown-content .rb-tested-date { text-align: right; }
.sl-markdown-content .rb-tested-more { margin-left: 0.5rem; }
}