From da223cd5ed15afa67b130c67643cda4c43216a7c Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Wed, 11 Nov 2026 21:31:00 +0100 Subject: [PATCH] fix: let the site tests read mdx pages Pages with tabs are written as MDX. The tests read .md alone and skipped eleven checks in silence on the SNK, Sega and Nintendo pages, which hid the two defects above. The ares Neo Geo check follows its profile: ares reads neogeo.zip itself (desktop-ui/emulator/arcade.cpp:456-464). --- tests/test_site_nav.py | 14 +++++++++----- tests/test_site_systems.py | 35 +++++++++++++++++++++++------------ 2 files changed, 32 insertions(+), 17 deletions(-) diff --git a/tests/test_site_nav.py b/tests/test_site_nav.py index 871631ea1..fe4b6fefb 100644 --- a/tests/test_site_nav.py +++ b/tests/test_site_nav.py @@ -500,16 +500,20 @@ class MetaFields(unittest.TestCase): self.assertEqual(sitestarlight.file_names_meta("
no card
"), "") def test_system_pages_carry_the_platforms_names(self) -> None: - page = DOCS / "systems" / "sony-playstation.md" - if not page.is_file(): + def page(stem: str) -> Path | None: + # A page with tabs is MDX: reading .md alone skipped this test. + return next((p for p in (DOCS / "systems" / f"{stem}.md", + DOCS / "systems" / f"{stem}.mdx") if p.is_file()), None) + + playstation = page("sony-playstation") + if playstation is None: self.skipTest("site pages not generated") - text = page.read_text(encoding="utf-8") + text = playstation.read_text(encoding="utf-8") match = re.search(r'data-pagefind-meta="aliases:([^"]*)"', text) self.assertIsNotNone(match, "no aliases field on the PlayStation page") self.assertIn("psx", unescape(match[1]).split()) # The Dreamcast section's page: its own, or Sega's when it fits there. - own = DOCS / "systems" / "sega-dreamcast.md" - dreamcast = (own if own.is_file() else DOCS / "systems" / "sega.md").read_text( + dreamcast = (page("sega-dreamcast") or page("sega") or DOCS / "systems" / "sega.md").read_text( encoding="utf-8") self.assertRegex(dreamcast, r'data-pagefind-meta="aliases:[^"]*\bdc\b') diff --git a/tests/test_site_systems.py b/tests/test_site_systems.py index 45131dea5..db73dacbb 100644 --- a/tests/test_site_systems.py +++ b/tests/test_site_systems.py @@ -988,11 +988,18 @@ def _consumers(reads: dict[str, list[tuple[str, dict]]]) -> types.SimpleNamespac ) +def _pages(pattern: str) -> list[Path]: + """The generated pages a stem pattern names: a page with tabs is MDX. + Reading .md alone skipped eleven tests in silence once the SNK, Sega + and Nintendo pages had tabs.""" + return sorted(SYSTEMS.glob(f"{pattern}.md")) + sorted(SYSTEMS.glob(f"{pattern}.mdx")) + + def _system_page(stem: str) -> str: - path = SYSTEMS / f"{stem}.md" - if not path.is_file(): + found = _pages(stem) + if not found: raise unittest.SkipTest(f"systems/{stem}.md not generated") - return _unlinked(path.read_text(encoding="utf-8")) + return _unlinked(found[0].read_text(encoding="utf-8")) def _start_line(text: str) -> str: @@ -1085,17 +1092,17 @@ class OtherNamesForOneSlotReadAsAlternatives(unittest.TestCase): class TheNeoGeoSetsSitWithTheNeoGeo(unittest.TestCase): """6.3: every neogeo.zip has its card on SNK's pages, side by side and - open, and the ares sentence names the card.""" + open, and ares is among the readers of the set.""" def test_every_neogeo_zip_is_on_snk(self) -> None: db = _database() sha1s = [sha1 for sha1, f in db["files"].items() if f["name"] == "neogeo.zip"] - held = "".join(path.read_text(encoding="utf-8") for path in SYSTEMS.glob("snk*.md")) + held = "".join(path.read_text(encoding="utf-8") for path in _pages("snk*")) if not held: self.skipTest("SNK pages not generated") self.assertEqual([s for s in sha1s if f'id="sha1-{s[:12]}"' not in held], []) others = "".join(path.read_text(encoding="utf-8") - for path in SYSTEMS.glob("arcade*.md")) + for path in _pages("arcade*")) self.assertEqual([s for s in sha1s if f'id="sha1-{s[:12]}"' in others], []) def test_the_sets_are_open_and_together(self) -> None: @@ -1108,7 +1115,11 @@ class TheNeoGeoSetsSitWithTheNeoGeo(unittest.TestCase): self.assertNotIn("neogeo.zip", variants)
def test_ares_is_told_the_card_it_reads(self) -> None:
- self.assertIn("ares reads `neo-epo.bin` and `sp-45.sp1` instead.", _system_page("snk"))
+ # ares reads neogeo.zip for an MVS game (desktop-ui/emulator/arcade.cpp:456-464):
+ # the lead names it among its readers, with no sentence of its own.
+ start = _system_page("snk").split("{ #neo-geo }", 1)[1]
+ self.assertRegex(_start_line(start), r"^\*\*Start with\*\* `neogeo.zip`\..* ares and .* read it\.$")
+ self.assertNotIn("ares reads", start.split("\n## ", 1)[0])
class ABoardIsAnArcadeMachine(unittest.TestCase):
@@ -1124,7 +1135,7 @@ class ABoardIsAnArcadeMachine(unittest.TestCase):
self.skipTest("pages not generated")
for stem in ("arcade-acorn-atom", "arcade-sharp-mz-2000", "arcade-sharp-mz-2500",
"arcade-yamaha-ym2608", "arcade-miuchiz"):
- self.assertFalse((SYSTEMS / f"{stem}.md").exists(), stem)
+ self.assertEqual(_pages(stem), [], stem)
def test_the_computers_sets_are_on_their_makers_page(self) -> None:
acorn = _system_page("acorn")
@@ -1171,13 +1182,13 @@ class EnginesGoByEngine(unittest.TestCase):
names = set(db["indexes"]["by_name"])
index = _system_page("index")
rows = re.findall(r"^\| \[([^\]]+)\]\(", index, re.M)
- headings = [h.strip() for path in SYSTEMS.glob("*.md")
+ headings = [h.strip() for path in _pages("*")
for h in re.findall(r"^## ([^{\n]+)", path.read_text(encoding="utf-8"), re.M)]
wrong = sorted({n for n in rows + headings if n.startswith(".") or n in names})
self.assertEqual(wrong, [])
def test_scummvm_has_one_page(self) -> None:
- self.assertFalse((SYSTEMS / "other-scummvm.md").exists())
+ self.assertEqual(_pages("other-scummvm"), [])
self.assertIn("## ScummVM {", _system_page("scummvm"))
self.assertNotIn("](/retrobios/systems/other/#scummvm)", _system_page("index"))
@@ -1228,13 +1239,13 @@ class OneLabelOnceOnABoardPage(unittest.TestCase):
def test_no_part_says_where_it_sits(self) -> None:
if not SYSTEMS.is_dir():
self.skipTest("pages not generated")
- said = sorted(p.name for p in SYSTEMS.glob("*.md")
+ said = sorted(p.name for p in _pages("*")
if "\nPart of [" in p.read_text(encoding="utf-8"))
self.assertEqual(said, [])
def test_a_part_goes_by_the_emulators_name(self) -> None:
titles = [re.search(r"^title: (.*)$", p.read_text(encoding="utf-8"), re.M)[1].strip("'")
- for p in SYSTEMS.glob("other-mame*.md")]
+ for p in _pages("other-mame*")]
if not titles:
self.skipTest("pages not generated")
self.assertEqual([t for t in titles if not t.startswith(("MAME files", "Other: MAME"))],