From d73afff8527fee4b1efb07e792a87458b9da0f89 Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Sat, 21 Nov 2026 05:04:33 +0100 Subject: [PATCH] fix: find generated pages through sitepages test_release_packs looked for platforms/knulli.md, but the page is knulli.mdx, so test_a_built_setup_page_has_the_line always skipped, in CI too. Under the skip it asserted text the generator never writes: the glossary wraps ZIP in an , and the heading is '## On the device { #install }', not '## Install'. It now reads the page through sitepages.page() after sitepages.require(), strips the glossary markup and looks for the #install heading. The single-page helpers of test_site_reference and test_site_emulators go through sitepages too, so a missing page fails in CI instead of skipping or reading as empty. --- tests/test_release_packs.py | 15 +++++++++------ tests/test_site_emulators.py | 9 ++------- tests/test_site_reference.py | 12 +++--------- 3 files changed, 14 insertions(+), 22 deletions(-) diff --git a/tests/test_release_packs.py b/tests/test_release_packs.py index 6e7b21ec3..17458b82b 100644 --- a/tests/test_release_packs.py +++ b/tests/test_release_packs.py @@ -14,11 +14,13 @@ platform has a permanent page at get// instead. from __future__ import annotations import tests +from tests import sitepages from tests.sources import script_source import contextlib import io import json +import re import sys import tempfile import unittest @@ -270,13 +272,14 @@ class EverySurfaceSaysWhy(unittest.TestCase): self.assertNotIn("yet", block) def test_a_built_setup_page_has_the_line(self): - page = REPO_ROOT / "website" / "src" / "content" / "docs" / "platforms" / "knulli.md" - if not page.is_file(): - self.skipTest("the site is not generated") - text = page.read_text(encoding="utf-8") + sitepages.require() + page = sitepages.page("platforms/knulli.md").read_text(encoding="utf-8") + # The glossary wraps the first ZIP of the page in an . + text = re.sub(r"]*>(.*?)", r"\1", page) self.assertIn("No ZIP for KNULLI. The command installs every file and checks it.", text) - install = text.index("## Install") - self.assertLess(install, text.index("No ZIP for KNULLI")) + install = re.search(r"(?m)^## (?:Install|.+ \{ #install \})$", text) + self.assertIsNotNone(install) + self.assertLess(install.start(), text.index("No ZIP for KNULLI")) def test_get_your_files_explains_the_rows(self): page = _which_pack() diff --git a/tests/test_site_emulators.py b/tests/test_site_emulators.py index 22a396497..5e1c73e46 100644 --- a/tests/test_site_emulators.py +++ b/tests/test_site_emulators.py @@ -28,6 +28,7 @@ Linux, Windows and Android commands, for MAME4droid an Android-only app. from __future__ import annotations import tests +from tests import sitepages import re import unittest @@ -566,11 +567,7 @@ def _profiles_with_data_root() -> dict[str, dict]: def _built_page(name: str) -> str: - for suffix in (".mdx", ".md"): - path = EMULATORS / f"{name}{suffix}" - if path.exists(): - return path.read_text(encoding="utf-8") - return "" + return sitepages.page(f"emulators/{name}.md").read_text(encoding="utf-8") def _generated() -> bool: @@ -816,8 +813,6 @@ class AnEmulatorPageNamesItsSetups(unittest.TestCase): self.assertEqual(emulatorcards.emulator_setups(coverages, profiles)["handy"], ["a", "b"]) def test_the_page_names_them(self): - from tests import sitepages - sitepages.require() text = sitepages.page("emulators/handy.md").read_text(encoding="utf-8") row = next(line for line in text.splitlines() if line.startswith("| Run by |")) diff --git a/tests/test_site_reference.py b/tests/test_site_reference.py index d7160b7ca..0381f378d 100644 --- a/tests/test_site_reference.py +++ b/tests/test_site_reference.py @@ -32,6 +32,7 @@ it has not been generated. from __future__ import annotations import tests +from tests import sitepages from tests.sources import script_source import csv @@ -978,14 +979,6 @@ class SourceLinksGoWhereTheFileIs(unittest.TestCase): DOCS = REPO_ROOT / "website" / "src" / "content" / "docs" -def _page(stem: str) -> str: - for suffix in (".md", ".mdx"): - path = DOCS / f"{stem}{suffix}" - if path.is_file(): - return path.read_text(encoding="utf-8") - raise unittest.SkipTest(f"{stem} not generated") - - class LookupRecordsUnderEveryHash(unittest.TestCase): """8.1: a platform listing a file by MD5 is found by its SHA1 too.""" @@ -1274,7 +1267,8 @@ class NoEmptyCoreTable(unittest.TestCase): _built(DOCS / "cross-reference.md") for name in ("misterfpga", "bizhawk"): self.assertFalse((DOCS / f"cross-reference-{name}.md").exists()) - self.assertIn(platformpage.OWN_LIST_ONLY, _page(f"platforms/{name}")) + page = sitepages.page(f"platforms/{name}.md").read_text(encoding="utf-8") + self.assertIn(platformpage.OWN_LIST_ONLY, page) redirects = json.loads((REPO_ROOT / "website" / "src" / "generated" / "redirects.json").read_text()) self.assertEqual(redirects.get("/cross-reference-misterfpga/"), "/platforms/misterfpga/")