mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-01 00:27:20 -05:00
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:
1 parent
b8144e4e71
commit
e19b82ea47
10 files changed
+168
-1307
No files matched your search
@@ -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("<script>alert(1)</script>", page)
|
||||
self.assertIn("{import x}", 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
@@ -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'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/", "<image>", "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("<script>", text)
|
||||
self.assertIn("{expr}", 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("<script>", line)
|
||||
|
||||
def test_hosts_table_on_the_method_page(self) -> None:
|
||||
page = sm.with_hosts(f"x\n\n{sm.HOSTS_MARKER}\n",
|
||||
|
||||
@@ -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_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_saturn</small>", text)
|
||||
self.assertIn("<strong>Files the core opened:</strong> sega_101.bin (sega_101.bin).", text)
|
||||
self.assertIn("<strong>Findings:</strong> missing_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("<script>", text)
|
||||
self.assertIn("{alert(1)}", 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/"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
@@ -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_psx**: Each region's game boots on its own BIOS only.", text)
|
||||
self.assertIn("The Japanese BIOS boots the Japanese game, the other regions' 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'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_psx |", text)
|
||||
self.assertIn("| sega-32x | B (World) | not yet: no run recorded |", text)
|
||||
self.assertIn("exit 1, <code>unknown_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's built-in BIOS", line)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in new issue
Block a user