mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-21 17:17:51 -06:00
chore: merge origin/main
This commit is contained in:
commit
e6c83859d5
70 files changed
+1605
-896
No files matched your search
@@ -56,8 +56,8 @@ class ReadmeRegressions(unittest.TestCase):
|
||||
|
||||
def _quick_install(self) -> str:
|
||||
readme = (ROOT / "README.md").read_text(encoding="utf-8")
|
||||
return readme.split("## Quick install", 1)[1].split(
|
||||
"## Download BIOS packs", 1
|
||||
return readme.split("## Install in one line", 1)[1].split(
|
||||
"## Or download a ZIP", 1
|
||||
)[0]
|
||||
|
||||
def test_advertised_bootstrap_urls_are_the_shipped_ones(self):
|
||||
@@ -1121,7 +1121,10 @@ class CatalogRatioRegressions(unittest.TestCase):
|
||||
match = re.search(
|
||||
r"\*\*([\d,]+) of ([\d,]+) system files\*\* matched to", readme
|
||||
)
|
||||
self.assertIsNotNone(match, "README no longer states the catalog ratio")
|
||||
if match is None:
|
||||
# The README states no ratio since it leads to the site: a ratio
|
||||
# it states must still be the database's.
|
||||
return
|
||||
matched, total = (int(g.replace(",", "")) for g in match.groups())
|
||||
self.assertEqual(matched, count_catalog_matched(db))
|
||||
self.assertEqual(total, compute_composition(db)["systems"]["files"])
|
||||
|
||||
+10
-13
@@ -340,7 +340,7 @@ class FilesColumnParagraph(unittest.TestCase):
|
||||
paragraph = next(p for p in readme.split("\n\n") if "The Files column" in p)
|
||||
self.assertNotIn("\n", paragraph.strip())
|
||||
after = readme.split(paragraph, 1)[1].lstrip("\n")
|
||||
self.assertTrue(after.startswith("| Platform | Files |"))
|
||||
self.assertTrue(after.startswith("| Setup | Files |"))
|
||||
|
||||
|
||||
class PageOpenings(unittest.TestCase):
|
||||
@@ -769,14 +769,12 @@ class ReadmeInstallerOptions(unittest.TestCase):
|
||||
import generate_readme
|
||||
|
||||
source = inspect.getsource(generate_readme.generate_readme)
|
||||
self.assertIn('install_command("powershell", "--check")', source)
|
||||
self.assertIn("wiki/installer/#passing-options", source)
|
||||
self.assertIn("## Passing options", _page("installer.md"))
|
||||
readme = (ROOT / "README.md").read_text(encoding="utf-8")
|
||||
quick = _section(readme, "Quick install")
|
||||
from siteguides import INSTALL_PS1
|
||||
|
||||
self.assertIn(f"&([scriptblock]::Create((irm {INSTALL_PS1}))) --check", quick)
|
||||
quick = _section(readme, "Install in one line")
|
||||
# The README gives the bare line and sends options to the page that
|
||||
# writes their PowerShell form: an option after `| iex` reaches iex.
|
||||
self.assertIn("wiki/installer/#passing-options", quick)
|
||||
self.assertNotRegex(readme, r"(?m)^irm \S+ \| iex \S")
|
||||
|
||||
@@ -791,7 +789,7 @@ class PublishedNumbersShareOneFormat(unittest.TestCase):
|
||||
|
||||
readme_source = inspect.getsource(generate_readme.generate_readme)
|
||||
self.assertNotIn("size_mb", readme_source)
|
||||
self.assertIn("format_size(total_size)", readme_source)
|
||||
self.assertIn("format_size(size)", readme_source)
|
||||
self.assertIn("{total_files:,}", inspect.getsource(generate_site))
|
||||
self.assertEqual(generate_readme.format_size(16011 * 1024 * 1024), "15.6 GB")
|
||||
|
||||
@@ -1713,9 +1711,7 @@ class ReadmeKeepsItsPointers(unittest.TestCase):
|
||||
"""The README sent a reader to 'build your own pack below' for a bare
|
||||
minimum, and the block below never named --required-only."""
|
||||
readme = (ROOT / "README.md").read_text(encoding="utf-8")
|
||||
self.assertIn("For a bare minimum, build your own pack below.", readme)
|
||||
block = readme[readme.index("## Build your own pack"):]
|
||||
block = block[:block.index("\n## ", 1)]
|
||||
block = readme[readme.index("<summary><strong>For developers"):readme.index("</details>")]
|
||||
self.assertIn("--required-only", block)
|
||||
|
||||
def test_unsourceable_files_are_not_said_to_exist_nowhere(self):
|
||||
@@ -1725,7 +1721,8 @@ class ReadmeKeepsItsPointers(unittest.TestCase):
|
||||
readme = (ROOT / "README.md").read_text(encoding="utf-8")
|
||||
self.assertNotIn("sourced at all", readme)
|
||||
self.assertNotIn("nobody has made", readme)
|
||||
self.assertRegex(readme, r"more the collection does not hold and does not serve by name")
|
||||
# The README names no count: the gap analysis it links does, by reason.
|
||||
self.assertIn("gaps/", readme)
|
||||
|
||||
|
||||
class ArchitectureStatesTheArbitration(unittest.TestCase):
|
||||
@@ -2041,8 +2038,8 @@ class BuildYourOwnPackSaysWhatTheCloneCosts(unittest.TestCase):
|
||||
line = generate_readme.clone_line(db)
|
||||
self.assertIn("git clone --depth 1", line)
|
||||
self.assertRegex(line, r"over \d+(\.\d)? GB")
|
||||
section = _section((ROOT / "README.md").read_text(encoding="utf-8"),
|
||||
"Build your own pack")
|
||||
readme = (ROOT / "README.md").read_text(encoding="utf-8")
|
||||
section = readme[readme.index("<summary><strong>For developers"):readme.index("</details>")]
|
||||
self.assertIn("git clone --depth 1", section)
|
||||
|
||||
def test_advanced_usage_names_the_shallow_clone(self):
|
||||
|
||||
@@ -191,16 +191,17 @@ class DownloadLinksKeepTheirAddress(unittest.TestCase):
|
||||
from common import list_registered_platforms, list_release_pack_platforms
|
||||
|
||||
readme = _read("README.md")
|
||||
table = _section(readme, "## Download BIOS packs")
|
||||
table = _section(readme, "## Or download a ZIP")
|
||||
self.assertNotIn("/releases/download/", table)
|
||||
released = set(list_release_pack_platforms("platforms"))
|
||||
rows = [line for line in table.splitlines() if line.startswith("| ")]
|
||||
for key in list_registered_platforms("platforms"):
|
||||
with self.subTest(platform=key):
|
||||
# Every setup's lasting page is linked: a ZIP's from its row,
|
||||
# the others from the line that says they install by command.
|
||||
self.assertIn(f"]({SITE_URL}get/{key}/)", table)
|
||||
row = next(line for line in table.splitlines()
|
||||
if f"get/{key}/)" in line)
|
||||
if key not in released:
|
||||
self.assertIn("[Use the command]", row)
|
||||
in_rows = any(f"get/{key}/)" in row for row in rows)
|
||||
self.assertEqual(in_rows, key in released)
|
||||
|
||||
def test_the_download_page_rows_link_get_pages(self):
|
||||
page = _which_pack()
|
||||
@@ -258,7 +259,7 @@ class TheReadmeLeadsBeginnersToTheirPages(unittest.TestCase):
|
||||
def test_quick_install_links_the_start_pages(self):
|
||||
# The code block holds `#` comment lines, so the section runs to
|
||||
# the next level-two heading.
|
||||
section = _read("README.md").split("## Quick install", 1)[1].split("\n## ", 1)[0]
|
||||
section = _read("README.md").split("## Install in one line", 1)[1].split("\n## ", 1)[0]
|
||||
for page in ("first-install", "troubleshooting", "faq"):
|
||||
with self.subTest(page=page):
|
||||
self.assertIn(f"wiki/{page}/)", section)
|
||||
@@ -270,10 +271,10 @@ class EndUsersCheckTheirOwnFolder(unittest.TestCase):
|
||||
files points at the installer's --check, which hashes their folder."""
|
||||
|
||||
USER_SECTIONS = (
|
||||
("wiki/troubleshooting.md", "## 1. Check my BIOS folder { #checking-what-you-installed }"),
|
||||
("wiki/troubleshooting.md", "## 1. Check the BIOS folder { #checking-what-you-installed }"),
|
||||
("wiki/troubleshooting.md", "## 2. Fix the files"),
|
||||
("wiki/faq.md", "## My game shows a black screen"),
|
||||
("wiki/faq.md", "## How do I know which BIOS I need?"),
|
||||
("wiki/faq.md", "## A game shows a black screen { #my-game-shows-a-black-screen }"),
|
||||
("wiki/faq.md", "## How to tell which BIOS is needed? { #how-do-i-know-which-bios-i-need }"),
|
||||
)
|
||||
|
||||
def test_user_sections_never_send_to_verify(self):
|
||||
|
||||
@@ -284,13 +284,13 @@ class EverySurfaceSaysWhy(unittest.TestCase):
|
||||
|
||||
def test_the_readme_rows_read_use_the_command(self):
|
||||
readme = (REPO_ROOT / "README.md").read_text(encoding="utf-8")
|
||||
row = next(line for line in readme.splitlines() if line.startswith("| KNULLI |"))
|
||||
self.assertIn(f"[Use the command]({SITE}get/knulli/)", row)
|
||||
self.assertIn("ZIPs are made for the setups most people download.", readme)
|
||||
line = next(text for text in readme.split("\n\n") if "ZIPs are made for the setups most people download." in text)
|
||||
self.assertIn(f"[KNULLI]({SITE}get/knulli/)", line)
|
||||
self.assertIn("install with the line above", line)
|
||||
|
||||
def test_the_faq_answers_why(self):
|
||||
faq = (REPO_ROOT / "wiki" / "faq.md").read_text(encoding="utf-8")
|
||||
section = faq.split("## Why is there no ZIP for my setup?", 1)[1].split("\n## ", 1)[0]
|
||||
section = faq.split("## Why is there no ZIP for a setup?", 1)[1].split("\n## ", 1)[0]
|
||||
self.assertIn("most people download", section)
|
||||
self.assertIn("checks each one", section)
|
||||
self.assertIn("--dry-run", section)
|
||||
|
||||
@@ -124,7 +124,7 @@ class EveryPageHasAMarkdownCopy(unittest.TestCase):
|
||||
pages = sorted(DIST.rglob("index.html"))
|
||||
missing = [p for p in pages if not (p.parent / "index.md").is_file()]
|
||||
self.assertEqual(missing, [])
|
||||
self.assertIn("# Get your files", (DIST / "which-pack" / "index.md").read_text(encoding="utf-8"))
|
||||
self.assertIn("# Get the files", (DIST / "which-pack" / "index.md").read_text(encoding="utf-8"))
|
||||
self.assertTrue((DIST / "llms-full.txt").is_file())
|
||||
|
||||
|
||||
|
||||
@@ -271,7 +271,7 @@ class GeneratedSurfaces(unittest.TestCase):
|
||||
|
||||
def test_the_readme_shows_the_short_form(self):
|
||||
readme = (REPO_ROOT / "README.md").read_text(encoding="utf-8")
|
||||
quick = readme.split("## Quick install", 1)[1].split("\n## ", 1)[0]
|
||||
quick = readme.split("## Install in one line", 1)[1].split("\n## ", 1)[0]
|
||||
self.assertIn(f"\n{install_command('sh')}\n", quick)
|
||||
self.assertIn(f"\n{install_command('powershell')}\n", quick)
|
||||
self.assertNotIn("raw.githubusercontent.com", quick)
|
||||
|
||||
@@ -183,7 +183,7 @@ class SectionTabsInTheHeader(unittest.TestCase):
|
||||
nav = re.search(r'<nav class="rb-tabs[^"]*"[^>]*>(.*?)</nav>', html, re.S)
|
||||
self.assertIsNotNone(nav)
|
||||
labels = [re.sub(r"<[^>]+>", "", a).strip() for a in re.findall(r"<a\b[^>]*>.*?</a>", nav.group(1), re.S)]
|
||||
self.assertEqual(labels, ["Start here", "Your setup", "Explore", "Reference", "Contribute"])
|
||||
self.assertEqual(labels, ["Start here", "Setups", "Explore", "Reference", "Contribute"])
|
||||
self.assertEqual(nav.group(1).count('aria-current="true"'), 1)
|
||||
self.assertRegex(nav.group(1), r'aria-current="true"[^>]*>\s*Start here')
|
||||
|
||||
@@ -198,7 +198,7 @@ class LevelBadgeOnlyWhereItAddsSomething(unittest.TestCase):
|
||||
def test_badge_follows_the_crumb(self):
|
||||
# A tab root: the header tab already says it.
|
||||
self.assertNotIn('class="rb-level ', _title_block(_built("platforms")))
|
||||
# Under the "Start here" or "Your setup" crumb the badge repeated it.
|
||||
# Under the "Start here" or "Setups" crumb the badge repeated it.
|
||||
for page in ("which-pack", "platforms/batocera"):
|
||||
with self.subTest(page=page):
|
||||
block = _title_block(_built(page))
|
||||
|
||||
@@ -157,7 +157,7 @@ class NavFromFrontMatter(unittest.TestCase):
|
||||
tabs = self._nav(WIKI)
|
||||
self.assertEqual(tabs["Explore"][0], "explore.md")
|
||||
self.assertEqual([next(iter(e)) for e in tabs["Explore"][1:]], ["Systems", "Emulators"])
|
||||
self.assertEqual(tabs["Your setup"][-1], {"All installer options": "wiki/installer.md"})
|
||||
self.assertEqual(tabs["Setups"][-1], {"All installer options": "wiki/installer.md"})
|
||||
start = [e if isinstance(e, str) else next(iter(e)) for e in tabs["Start here"]]
|
||||
self.assertEqual(start.index("Is it legal?"), start.index("Common questions") + 1)
|
||||
self.assertEqual(tabs["Reference"][0], "wiki/index.md")
|
||||
|
||||
+145
-40
@@ -1,9 +1,12 @@
|
||||
"""The installer demo of the README and the site (scripts/make_demo.py).
|
||||
"""The installer demos of the README and the site (scripts/make_demo.py).
|
||||
|
||||
The home page and Get your files score 98 to 100 on a phone: the video must
|
||||
The home page and Get your files score 98 to 100 on a phone: a video must
|
||||
cost nothing before it is on screen, keep still under reduced motion, and say
|
||||
in words what it shows. The files are committed, so their sizes are held
|
||||
here, and the words come from what the recording measured.
|
||||
here, and the words come from what each recording measured. Get your files
|
||||
shows one recording per tab of its install box: the handheld's under "On the
|
||||
device", none under Windows (no Windows recording is published), the
|
||||
terminal recording under the others.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -29,43 +32,90 @@ COMPONENT = ROOT / "website" / "src" / "components" / "InstallDemo.astro"
|
||||
DIST = ROOT / "website" / "dist"
|
||||
|
||||
|
||||
def _facts() -> dict:
|
||||
def _all_facts() -> dict:
|
||||
return json.loads((DEMO / "demo.json").read_text(encoding="utf-8"))
|
||||
|
||||
|
||||
def _facts(variant: str = "default") -> dict:
|
||||
return _all_facts()[variant]
|
||||
|
||||
|
||||
class TheFilesAreThereAndSmall(unittest.TestCase):
|
||||
def test_each_output_is_under_its_target(self):
|
||||
for name, limit in make_demo.LIMITS.items():
|
||||
with self.subTest(name=name):
|
||||
self.assertLessEqual((DEMO / name).stat().st_size, limit)
|
||||
for variant in make_demo.VARIANTS.values():
|
||||
for name, limit in make_demo.limits(variant).items():
|
||||
with self.subTest(name=name):
|
||||
self.assertLessEqual((DEMO / name).stat().st_size, limit)
|
||||
|
||||
def test_the_gif_and_the_poster_have_the_recorded_size(self):
|
||||
def test_only_the_readme_variant_has_a_gif(self):
|
||||
gifs = sorted(p.name for p in DEMO.glob("*.gif"))
|
||||
self.assertEqual(gifs, [Path(generate_readme.DEMO_GIF).name])
|
||||
self.assertEqual([v.name for v in make_demo.VARIANTS.values() if v.gif], ["default"])
|
||||
|
||||
def test_the_gif_and_the_posters_have_the_recorded_size(self):
|
||||
facts = _facts()
|
||||
head = (DEMO / "install.gif").read_bytes()[:10]
|
||||
self.assertEqual(head[:6], b"GIF89a")
|
||||
self.assertEqual(struct.unpack("<HH", head[6:10]), (facts["width"], facts["height"]))
|
||||
png = (DEMO / "install.png").read_bytes()[:24]
|
||||
self.assertEqual(png[:8], b"\x89PNG\r\n\x1a\n")
|
||||
self.assertEqual(struct.unpack(">II", png[16:24]), (facts["width"], facts["height"]))
|
||||
for variant in make_demo.VARIANTS.values():
|
||||
facts = _facts(variant.name)
|
||||
png = (DEMO / f"{variant.stem}.png").read_bytes()[:24]
|
||||
with self.subTest(variant=variant.name):
|
||||
self.assertEqual(png[:8], b"\x89PNG\r\n\x1a\n")
|
||||
self.assertEqual(struct.unpack(">II", png[16:24]),
|
||||
(facts["width"], facts["height"]))
|
||||
|
||||
def test_the_videos_are_webm_and_mp4(self):
|
||||
self.assertEqual((DEMO / "install.webm").read_bytes()[:4], b"\x1a\x45\xdf\xa3")
|
||||
self.assertEqual((DEMO / "install.mp4").read_bytes()[4:8], b"ftyp")
|
||||
for variant in make_demo.VARIANTS.values():
|
||||
with self.subTest(variant=variant.name):
|
||||
self.assertEqual((DEMO / f"{variant.stem}.webm").read_bytes()[:4],
|
||||
b"\x1a\x45\xdf\xa3")
|
||||
self.assertEqual((DEMO / f"{variant.stem}.mp4").read_bytes()[4:8], b"ftyp")
|
||||
|
||||
def test_demo_json_holds_each_variant_and_its_alt_text(self):
|
||||
facts = _all_facts()
|
||||
self.assertEqual(list(facts), list(make_demo.VARIANTS))
|
||||
for name, entry in facts.items():
|
||||
with self.subTest(variant=name):
|
||||
self.assertEqual(entry["alt"], make_demo.describe(name, entry))
|
||||
# Written into an MDX attribute: no quote of either kind.
|
||||
self.assertNotRegex(entry["alt"], "[\"']")
|
||||
|
||||
|
||||
class TheTapeAndTheDriverAgree(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.tape = make_demo.TAPE.read_text(encoding="utf-8")
|
||||
|
||||
def test_the_tape_writes_what_the_driver_encodes(self):
|
||||
self.assertIn(f"Output {make_demo.RECORDED.relative_to(ROOT).as_posix()}\n", self.tape)
|
||||
self.assertIn(f"Screenshot {make_demo.POSTER_SHOT.relative_to(ROOT).as_posix()}\n",
|
||||
self.tape)
|
||||
def test_each_tape_writes_what_the_driver_encodes(self):
|
||||
for variant in make_demo.VARIANTS.values():
|
||||
tape = variant.tape.read_text(encoding="utf-8")
|
||||
with self.subTest(variant=variant.name):
|
||||
self.assertIn(f"Output {variant.recorded.relative_to(ROOT).as_posix()}\n", tape)
|
||||
self.assertIn(
|
||||
f"Screenshot {variant.poster_shot.relative_to(ROOT).as_posix()}\n", tape)
|
||||
|
||||
def test_the_size_in_demo_json_is_the_tapes(self):
|
||||
facts = _facts()
|
||||
self.assertIn(f"Set Width {facts['width']}\n", self.tape)
|
||||
self.assertIn(f"Set Height {facts['height']}\n", self.tape)
|
||||
def test_the_size_in_demo_json_is_each_tapes(self):
|
||||
for variant in make_demo.VARIANTS.values():
|
||||
facts, tape = _facts(variant.name), variant.tape.read_text(encoding="utf-8")
|
||||
with self.subTest(variant=variant.name):
|
||||
self.assertIn(f"Set Width {facts['width']}\n", tape)
|
||||
self.assertIn(f"Set Height {facts['height']}\n", tape)
|
||||
|
||||
def test_the_handheld_is_an_r36s_screen_driven_by_its_buttons(self):
|
||||
variant = make_demo.VARIANTS["handheld"]
|
||||
tape = variant.tape.read_text(encoding="utf-8")
|
||||
self.assertIn("Set Width 640\n", tape)
|
||||
self.assertIn("Set Height 480\n", tape)
|
||||
# Nothing typed but the hidden start of the session: the buttons
|
||||
# gptokeyb maps (ports/shared/retrobios.gptk: a = enter) do the rest.
|
||||
self.assertEqual(re.findall(r"^Type (.*)$", tape, re.M),
|
||||
["'exec \"$RETROBIOS_DEMO_SESSION\"'"])
|
||||
gptk = (ROOT / "ports" / "shared" / "retrobios.gptk").read_text(encoding="utf-8")
|
||||
self.assertRegex(gptk, r"(?m)^a = enter$")
|
||||
env = make_demo.session_env("http://127.0.0.1:1", ROOT / "tmp", ROOT / "tmp", variant)
|
||||
self.assertEqual(env["RETROBIOS_PAD"], "gptokeyb")
|
||||
self.assertEqual(env["RETROBIOS_OS"], "linux")
|
||||
self.assertEqual(variant.mount, "/roms")
|
||||
|
||||
def test_the_command_typed_is_the_one_the_pages_give(self):
|
||||
from siteguides import install_command # noqa: PLC0415
|
||||
@@ -84,8 +134,8 @@ class TheReadmeShowsTheGif(unittest.TestCase):
|
||||
readme = (ROOT / "README.md").read_text(encoding="utf-8")
|
||||
line = f""
|
||||
self.assertIn(line, readme)
|
||||
self.assertLess(readme.index("## Quick install"), readme.index(line))
|
||||
self.assertLess(readme.index(line), readme.index("## Download BIOS packs"))
|
||||
self.assertLess(readme.index("## Install in one line"), readme.index(line))
|
||||
self.assertLess(readme.index(line), readme.index("## Or download a ZIP"))
|
||||
|
||||
def test_the_description_names_what_the_recording_measured(self):
|
||||
facts = _facts()
|
||||
@@ -112,7 +162,13 @@ class TheVideoLoadsOnlyOnScreen(unittest.TestCase):
|
||||
self.assertRegex(self.markup, rf"\n\t\t{attribute}\n")
|
||||
|
||||
def test_webm_comes_before_mp4(self):
|
||||
self.assertLess(self.markup.index("install.webm"), self.markup.index("install.mp4"))
|
||||
self.assertLess(self.markup.index("asset('webm')"), self.markup.index("asset('mp4')"))
|
||||
|
||||
def test_each_variant_has_its_files_and_its_own_ids(self):
|
||||
self.assertIn("const stem = variant === 'default' ? 'install' : `install-${variant}`;",
|
||||
self.source)
|
||||
self.assertIn("const textId = name ? `rb-demo-text-${name}` : 'rb-demo-text';",
|
||||
self.source)
|
||||
|
||||
def test_reduced_motion_keeps_the_poster_with_a_button(self):
|
||||
self.assertIn("matchMedia('(prefers-reduced-motion: reduce)')", self.source)
|
||||
@@ -121,44 +177,93 @@ class TheVideoLoadsOnlyOnScreen(unittest.TestCase):
|
||||
self.markup)
|
||||
|
||||
def test_screen_readers_get_the_description(self):
|
||||
self.assertIn('aria-describedby="rb-demo-text"', self.markup)
|
||||
self.assertIn('<figcaption id="rb-demo-text" class="sr-only">{description}</figcaption>',
|
||||
self.assertIn("aria-describedby={textId}", self.markup)
|
||||
self.assertIn('<figcaption id={textId} class="sr-only">{description}</figcaption>',
|
||||
self.markup)
|
||||
|
||||
def test_the_component_is_registered(self):
|
||||
self.assertEqual(sitestarlight.COMPONENTS["InstallDemo"], "components/InstallDemo.astro")
|
||||
|
||||
|
||||
def _tab_bodies(markdown: str) -> dict[str, str]:
|
||||
"""Each tab of the quick install box of Get your files, by label."""
|
||||
box = markdown[markdown.index("{ #quick-install }"):]
|
||||
box = box[:box.index("</Tabs>")]
|
||||
return dict(re.findall(r'<TabItem label="([^"]+)">(.*?)</TabItem>', box, re.S))
|
||||
|
||||
|
||||
class TheTwoPagesShowIt(unittest.TestCase):
|
||||
def test_home_and_get_your_files(self):
|
||||
def test_home_shows_the_terminal_recording(self):
|
||||
import generate_site # noqa: PLC0415
|
||||
|
||||
tag = generate_site.install_demo()[0]
|
||||
self.assertIn(f'description="{generate_readme.demo_description()}"', tag)
|
||||
source = Path(generate_site.__file__).read_text(encoding="utf-8")
|
||||
for function in ("def generate_home(", "def generate_which_pack("):
|
||||
body = source[source.index(function):]
|
||||
body = body[:body.index("\ndef ", 1)]
|
||||
with self.subTest(function=function):
|
||||
self.assertIn("*install_demo(),", body)
|
||||
body = source[source.index("def generate_home("):]
|
||||
body = body[:body.index("\ndef ", 1)]
|
||||
self.assertIn("*install_demo(),", body)
|
||||
|
||||
def test_the_site_serves_the_video_not_the_gif(self):
|
||||
def test_each_tab_of_get_your_files_shows_its_variant(self):
|
||||
import generate_site # noqa: PLC0415
|
||||
|
||||
self.assertEqual(generate_site.DEMO_ASSETS, ("install.webm", "install.mp4", "install.png"))
|
||||
tabs = _tab_bodies(generate_site.generate_which_pack())
|
||||
expected = {"Windows": None, "macOS": "default", "Linux": "default",
|
||||
"Steam Deck": "default", "Android (Termux)": "default",
|
||||
"On the device": "handheld"}
|
||||
self.assertEqual(set(tabs), set(expected))
|
||||
for label, variant in expected.items():
|
||||
demos = re.findall(r"<InstallDemo [^>]*/>", tabs[label])
|
||||
with self.subTest(tab=label):
|
||||
if variant is None:
|
||||
self.assertEqual(demos, [])
|
||||
continue
|
||||
self.assertEqual(len(demos), 1)
|
||||
self.assertIn(f'description="{_facts(variant)["alt"]}"', demos[0])
|
||||
self.assertIn(f'width="{_facts(variant)["width"]}"', demos[0])
|
||||
self.assertIn(f'variant="{variant}"', demos[0])
|
||||
# The demo below the box moved into its tabs: one per tab, no other.
|
||||
page = generate_site.generate_which_pack()
|
||||
self.assertEqual(page.count("<InstallDemo "), len(expected) - 1)
|
||||
|
||||
def test_the_site_serves_the_videos_not_the_gif(self):
|
||||
import generate_site # noqa: PLC0415
|
||||
|
||||
expected = tuple(name for variant in make_demo.VARIANTS.values()
|
||||
for name in variant.outputs if not name.endswith(".gif"))
|
||||
self.assertEqual(sorted(generate_site.DEMO_ASSETS), sorted(expected))
|
||||
|
||||
def test_the_built_pages_fetch_nothing_of_it(self):
|
||||
if not (DIST / "index.html").is_file():
|
||||
self.skipTest("no built site")
|
||||
for page in ("index.html", "which-pack/index.html"):
|
||||
html = (DIST / page).read_text(encoding="utf-8")
|
||||
figure = re.search(r'<figure class="rb-demo[^"]*".*?</figure>', html, re.S)
|
||||
figures = re.findall(r'<figure class="rb-demo[^"]*".*?</figure>', html, re.S)
|
||||
with self.subTest(page=page):
|
||||
self.assertIsNotNone(figure)
|
||||
self.assertIn('preload="none"', figure.group(0))
|
||||
self.assertNotRegex(figure.group(0), r"\s(src|poster)=")
|
||||
for name in ("install.webm", "install.mp4", "install.png"):
|
||||
self.assertTrue((DIST / "assets" / "demo" / name).is_file())
|
||||
self.assertTrue(figures)
|
||||
for figure in figures:
|
||||
self.assertIn('preload="none"', figure)
|
||||
self.assertNotRegex(figure, r"\s(src|poster)=")
|
||||
for name in generate_site_assets():
|
||||
self.assertTrue((DIST / "assets" / "demo" / name).is_file())
|
||||
|
||||
def test_the_built_tabs_hold_their_variant(self):
|
||||
page = DIST / "which-pack" / "index.html"
|
||||
if not page.is_file():
|
||||
self.skipTest("no built site")
|
||||
html = page.read_text(encoding="utf-8")
|
||||
panel = r'<div[^>]*role="tabpanel"'
|
||||
panels = re.findall(rf"{panel}[^>]*>(.*?)(?={panel}|</starlight-tabs>)", html, re.S)
|
||||
variants = [re.findall(r'data-variant="([a-z]+)"', panel) for panel in panels]
|
||||
# The quick install box: Windows, macOS, Linux, Steam Deck, Android, device.
|
||||
self.assertIn([[], ["default"], ["default"], ["default"], ["default"], ["handheld"]],
|
||||
[variants[i:i + 6] for i in range(len(variants) - 5)])
|
||||
self.assertIn("assets/demo/install-handheld.png", html)
|
||||
|
||||
|
||||
def generate_site_assets() -> tuple[str, ...]:
|
||||
import generate_site # noqa: PLC0415
|
||||
|
||||
return generate_site.DEMO_ASSETS
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -258,7 +258,7 @@ class TheSetupListLooksLikeAList(unittest.TestCase):
|
||||
self.assertEqual(len(re.findall(r"--rb-select-arrow:", css)), 2)
|
||||
# The box's select sits in Markdown content, where the shared rule applies.
|
||||
box = "\n".join(gs._console_install_block("PlayStation Portable", PAIRS))
|
||||
self.assertIn('<label class="rb-install-setup">Your setup <select>', box)
|
||||
self.assertIn('<label class="rb-install-setup">Setup <select>', box)
|
||||
|
||||
def test_the_built_select_shows_the_arrow(self) -> None:
|
||||
if not (DIST / "systems").is_dir():
|
||||
|
||||
@@ -67,7 +67,7 @@ class TheIntroSaysWhatIsNeeded(unittest.TestCase):
|
||||
profile = _profile("duckstation")
|
||||
intro = gs._emulator_intro("DuckStation", profile)
|
||||
self.assertIn(
|
||||
"It picks the BIOS for your game's region: scph5500.bin (Japan), "
|
||||
"It picks the BIOS for the game's region: scph5500.bin (Japan), "
|
||||
"scph5501.bin (North America and Latin America) or scph5502.bin "
|
||||
"(Europe and Oceania).", intro)
|
||||
others = len(profile["files"]) - 3
|
||||
@@ -417,7 +417,7 @@ class AnAppThatReadsAnyBios(unittest.TestCase):
|
||||
# LRPS2 runs in RetroArch, whose BIOS folder the installer finds.
|
||||
page = _pages("lrps2")["lrps2"]
|
||||
self.assertIn("--emulator lrps2", page)
|
||||
self.assertIn("2. Put it in `pcsx2/bios/`, inside your BIOS folder.", page)
|
||||
self.assertIn("2. Put it in `pcsx2/bios/`, inside the BIOS folder.", page)
|
||||
self.assertIn("a Sony PlayStation 2 BIOS, any file name", page)
|
||||
|
||||
def test_only_found_by_content_with_one_bios(self):
|
||||
@@ -752,7 +752,7 @@ class SmallFixes(unittest.TestCase):
|
||||
|
||||
def test_region_choice_summary(self) -> None:
|
||||
lines = gs._emulator_file_summary(_profile("duckstation")["files"])
|
||||
self.assertIn("One of 3 is required, for your games' region.", lines[0])
|
||||
self.assertIn("One of 3 is required, for the games' region.", lines[0])
|
||||
self.assertNotIn("3 required", lines[0])
|
||||
|
||||
def test_no_emulator_part_says_where_it_sits(self) -> None:
|
||||
|
||||
+11
-11
@@ -190,7 +190,7 @@ class GetYourFilesOrder(unittest.TestCase):
|
||||
def test_choice_then_tables_then_picker_then_command(self):
|
||||
text = _page("which-pack.md")
|
||||
order = [text.index(mark) for mark in (
|
||||
"## Pick your setup", "| Setup | Runs on | BIOS folder | ZIP |", "<FilePicker",
|
||||
"## Pick the setup { #pick-your-setup }", "| Setup | Runs on | BIOS folder | ZIP |", "<FilePicker",
|
||||
"## Not in the list? One command finds it", "It asks **",
|
||||
"<summary>Is it safe?</summary>",
|
||||
)]
|
||||
@@ -221,7 +221,7 @@ class GetYourFilesOrder(unittest.TestCase):
|
||||
class GuideRoutes(unittest.TestCase):
|
||||
def test_a_device_system_opens_on_the_computer_route(self):
|
||||
text = _page("platforms/batocera.md")
|
||||
self.assertLess(text.index("## From your computer"), text.index("## On the device"))
|
||||
self.assertLess(text.index("## From a computer"), text.index("## On the device"))
|
||||
self.assertIn("{ #install }", "\n".join(generate_site._guide_install(
|
||||
"batocera", siteguides.GUIDES["batocera"], "## On the device { #install }")))
|
||||
self.assertIn("Unzip them all into the network folder above", text)
|
||||
@@ -347,7 +347,7 @@ class HomeLinksTheOtherTasks(unittest.TestCase):
|
||||
for target in ("/retrobios/wiki/troubleshooting/", "/retrobios/files/",
|
||||
"/retrobios/wiki/legal/"):
|
||||
self.assertIn(f"]({target})", home)
|
||||
self.assertLess(home.index("/retrobios/wiki/troubleshooting/"), home.index("## Do I need it?"))
|
||||
self.assertLess(home.index("/retrobios/wiki/troubleshooting/"), home.index("## Is it needed? { #do-i-need-it }"))
|
||||
|
||||
|
||||
GUIDE = siteguides.HANDHELD_GUIDE
|
||||
@@ -425,7 +425,7 @@ class HandheldWayIn(unittest.TestCase):
|
||||
def test_the_guide_is_in_the_handheld_group_of_the_navigation(self):
|
||||
coverages = {key: {"platform": _display(key)} for key in REGISTRY}
|
||||
nav = generate_site.generate_nav(coverages, {}, {}, REGISTRY)
|
||||
setup = next(tab["Your setup"] for tab in nav if "Your setup" in tab)
|
||||
setup = next(tab["Setups"] for tab in nav if "Setups" in tab)
|
||||
groups = {next(iter(item)): next(iter(item.values()))
|
||||
for item in setup if isinstance(item, dict)}
|
||||
label = siteguides.DEVICE_GROUPS["handheld"][0]
|
||||
@@ -526,7 +526,7 @@ class SafetyListIsLinked(unittest.TestCase):
|
||||
class OfflineLine(unittest.TestCase):
|
||||
def test_under_from_your_computer(self):
|
||||
text = _page("platforms/batocera.md")
|
||||
start = text.index("## From your computer")
|
||||
start = text.index("## From a computer")
|
||||
line = text.index("No internet on the device?")
|
||||
self.assertLess(start, line)
|
||||
self.assertLess(line, text.index("## On the device"))
|
||||
@@ -682,24 +682,24 @@ class NoZipNoUnzipText(unittest.TestCase):
|
||||
def test_the_minui_family_makes_each_folder(self):
|
||||
for name in ("minui", "myminui", "nextui"):
|
||||
with self.subTest(setup=name):
|
||||
self.assertIn("The command makes each console's folder for you.",
|
||||
self.assertIn("The command makes each console's folder.",
|
||||
_plain_page(f"platforms/{name}.md"))
|
||||
|
||||
def test_knulli_is_filled_over_the_network_with_the_samba_switch_cited(self):
|
||||
text = _guide_part(_plain_page("platforms/knulli.md"))
|
||||
self.assertIn("## From your computer { #from-your-computer }", text)
|
||||
self.assertIn("## From a computer { #from-your-computer }", text)
|
||||
self.assertIn("--platform knulli --dest \\\\KNULLI\\share\\bios\n", text)
|
||||
self.assertRegex(text, r"turn on \*\*SAMBA\*\* in \*\*System Settings > Services\*\*\s*"
|
||||
r"\(\[KNULLI docs\]\(https://github\.com/knulli-cfw/knulli\.org/blob/"
|
||||
r"[0-9a-f]{40}/docs/play/add-games/network-transfer\.md")
|
||||
# The computer route comes before the SSH one.
|
||||
self.assertLess(text.index("## From your computer"), text.index("## On the device"))
|
||||
self.assertLess(text.index("## From a computer"), text.index("## On the device"))
|
||||
|
||||
def test_the_elec_systems_say_they_need_the_network(self):
|
||||
for name, share in (("amberelec", "\\\\AmberELEC\\roms"), ("emuelec", "\\\\EMUELEC\\roms")):
|
||||
text = _guide_part(_plain_page(f"platforms/{name}.md"))
|
||||
with self.subTest(setup=name):
|
||||
self.assertIn("Needs the device on your network.", text)
|
||||
self.assertIn("Needs the device on the same network.", text)
|
||||
self.assertIn(f"--platform {name} --dest {share}\n", text)
|
||||
|
||||
def test_a_mac_and_a_linux_desktop_reach_the_share_too(self):
|
||||
@@ -935,14 +935,14 @@ class ARouteWithoutANetwork(unittest.TestCase):
|
||||
for page in (f"platforms/{name}.md", f"get/{name}.md"):
|
||||
text = _plain_page(page)
|
||||
with self.subTest(page=page):
|
||||
self.assertIn("## From your computer { #from-your-computer }", text)
|
||||
self.assertIn("## From a computer { #from-your-computer }", text)
|
||||
self.assertIn(CARD_FAQ, text)
|
||||
self.assertIn(f"the folder the device calls `{extract_to}`", text)
|
||||
self.assertIn(f"--platform {name} --dest /path/to/", text)
|
||||
|
||||
def test_rocknix_has_a_computer_route(self):
|
||||
text = _guide_part(_plain_page("platforms/rocknix.md"))
|
||||
self.assertLess(text.index("## From your computer"), text.index("## On the device"))
|
||||
self.assertLess(text.index("## From a computer"), text.index("## On the device"))
|
||||
|
||||
def test_retropie_card_is_read_from_linux_only(self):
|
||||
self.assertEqual(siteguides.GUIDES["retropie"].card_run, ("linux",))
|
||||
|
||||
@@ -56,14 +56,14 @@ class FiveTabs(unittest.TestCase):
|
||||
nav = generate_site.generate_nav({}, {}, {}, {})
|
||||
self.assertEqual(
|
||||
[next(iter(tab)) for tab in nav],
|
||||
["Start here", "Your setup", "Explore", "Reference", "Contribute"],
|
||||
["Start here", "Setups", "Explore", "Reference", "Contribute"],
|
||||
)
|
||||
|
||||
def test_each_tab_opens_on_an_index_or_a_first_page(self):
|
||||
nav = generate_site.generate_nav({}, {}, {}, {})
|
||||
tabs = {next(iter(tab)): next(iter(tab.values())) for tab in nav}
|
||||
self.assertEqual(tabs["Start here"][0], "index.md")
|
||||
self.assertEqual(tabs["Your setup"][0], "platforms/index.md")
|
||||
self.assertEqual(tabs["Setups"][0], "platforms/index.md")
|
||||
self.assertEqual(tabs["Reference"][0], "wiki/index.md")
|
||||
self.assertEqual(tabs["Contribute"][0], "contributing.md")
|
||||
|
||||
@@ -125,7 +125,7 @@ class EveryPlatformOnThePicker(unittest.TestCase):
|
||||
for key in _registered()
|
||||
}
|
||||
nav = generate_site.generate_nav(coverages, {}, {}, registry)
|
||||
setup = next(tab["Your setup"] for tab in nav if "Your setup" in tab)
|
||||
setup = next(tab["Setups"] for tab in nav if "Setups" in tab)
|
||||
groups = {next(iter(item)): next(iter(item.values()))
|
||||
for item in setup if isinstance(item, dict)}
|
||||
for key in coverages:
|
||||
@@ -278,7 +278,7 @@ class GuidePagesEndOnANextStep(unittest.TestCase):
|
||||
text = sitepages.page("platforms/batocera.md").read_text(encoding="utf-8")
|
||||
# Batocera runs on its own device: the computer route comes first.
|
||||
order = [text.index(h) for h in (
|
||||
"## Where the files go", "## From your computer", "## On the device",
|
||||
"## Where the files go", "## From a computer", "## On the device",
|
||||
"## How to check", "## Reference: every file by system",
|
||||
)]
|
||||
self.assertEqual(order, sorted(order))
|
||||
|
||||
@@ -210,7 +210,7 @@ class FaqInstallsFromWhatYouHold(unittest.TestCase):
|
||||
|
||||
def test_no_unzip_before_from_pack(self):
|
||||
section = " ".join(self._section("No internet on the device?").split())
|
||||
self.assertIn("point `--from-pack` at your ZIP:", section)
|
||||
self.assertIn("point `--from-pack` at the ZIP:", section)
|
||||
self.assertNotIn("unzip", section)
|
||||
install = (REPO_ROOT / "install.py").read_text(encoding="utf-8")
|
||||
self.assertIn("Install from a pack already downloaded: its ZIP, one of its parts",
|
||||
@@ -237,7 +237,7 @@ class FaqInstallsFromWhatYouHold(unittest.TestCase):
|
||||
word = rule.name.split()[0]
|
||||
with self.subTest(share=rule.name):
|
||||
self.assertIn(word, section)
|
||||
self.assertRegex(readme, rf"# SD card mounted on a PC: .*\b{word}\b")
|
||||
self.assertRegex(readme, rf"\b{word}\b[^.]*SD card plugged into the computer is found by itself")
|
||||
# The label the first screen gives a card found: "Onion SD card".
|
||||
self.assertEqual(install._card_word(("retroarch", Path("/x/BIOS"), "Onion")), "SD card")
|
||||
self.assertEqual(install._card_word(("batocera", Path("/x/bios"), "Batocera")),
|
||||
|
||||
@@ -118,7 +118,7 @@ class GroupsAreGroups(unittest.TestCase):
|
||||
self.groups = self.side["groups"]
|
||||
|
||||
def test_setup_groups_stay_groups_and_point_at_their_section(self):
|
||||
setup = {key: value for key, value in self.groups.items() if key.startswith("Your setup/")}
|
||||
setup = {key: value for key, value in self.groups.items() if key.startswith("Setups/")}
|
||||
self.assertTrue(setup)
|
||||
for key, group in setup.items():
|
||||
with self.subTest(group=key):
|
||||
@@ -206,7 +206,7 @@ class OneNextPerPage(unittest.TestCase):
|
||||
|
||||
def test_an_overview_is_named_after_what_it_opens(self):
|
||||
labels = {entry["link"]: entry["label"] for run in self.runs for entry in run}
|
||||
self.assertEqual(labels["/retrobios/platforms/"], "Your setup")
|
||||
self.assertEqual(labels["/retrobios/platforms/"], "Setups")
|
||||
self.assertEqual(labels["/retrobios/systems/"], "Systems")
|
||||
self.assertNotIn("Overview", labels.values())
|
||||
|
||||
|
||||
@@ -0,0 +1,204 @@
|
||||
"""The site speaks without personal pronouns.
|
||||
|
||||
Every page is written as an instruction or a plain statement: "Open the
|
||||
Start menu.", "The installer finds the BIOS folder." No I, we, you or their
|
||||
forms in the wiki sources, the pages the generators write, the README and
|
||||
CONTRIBUTING, llms.txt or the agent skill. Code, URLs, markup and anchor ids
|
||||
are not prose.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
|
||||
|
||||
import html
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
import unittest
|
||||
from functools import cache
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
DOCS = ROOT / "website" / "src" / "content" / "docs"
|
||||
|
||||
PRONOUN = re.compile(
|
||||
r"(?<![\w-])((?-i:I)|me|my|mine|myself|we|us|our|ours|ourselves"
|
||||
r"|you|your|yours|yourself|yourselves)(?![\w-])",
|
||||
re.I,
|
||||
)
|
||||
|
||||
FENCED = re.compile(r"^[ \t]*(```|~~~).*?^[ \t]*\1[^\n]*$", re.S | re.M)
|
||||
INLINE_CODE = re.compile(r"(`+)(?:(?!\n\n)[^`])*?\1")
|
||||
HTML_COMMENT = re.compile(r"<!--.*?-->", re.S)
|
||||
SCRIPT_STYLE = re.compile(r"<(script|style|pre|code)\b.*?</\1>", re.S | re.I)
|
||||
TAG = re.compile(r"</?[A-Za-z][^<>]*>")
|
||||
ENTITY = re.compile(r"&#(?:\d+|x[0-9a-fA-F]+);")
|
||||
URL = re.compile(r"(?:https?|ftp|smb)://\S+|\bwww\.\S+")
|
||||
LINK_TARGET = re.compile(r"\]\([^)\s]*(?:\s+\"[^\"]*\")?\)|^\[[^\]]+\]:\s*\S+.*$", re.M)
|
||||
ANCHOR = re.compile(r"\{[^{}\n]*#[^{}\n]*\}")
|
||||
PATHLIKE = re.compile(r"\S*[/\\]\S*")
|
||||
# File names, domains and dotted initials: baserom.us.z64, delete.me, A.I.R.
|
||||
DOTTED = re.compile(r"[\w-]+(?:\.[\w-]+)+\.?")
|
||||
# A list of single letters or digits (D, F, I, P), or of lowercase option
|
||||
# values in parentheses (euro, us, asia), names keys, not people.
|
||||
LETTERS = re.compile(r"(?<!\w)[A-Z0-9](?:,\s?[A-Z0-9#@^](?!\w))+")
|
||||
VALUES = re.compile(r"\((?:[a-z][\w-]*, )+[a-z][\w-]*\)")
|
||||
LETTER_HEADING = re.compile(r"^#+ [A-Z]\s*$", re.M)
|
||||
# Search keywords, written the way readers type a query. Pagefind matches
|
||||
# them, the page never shows them.
|
||||
TERMS = re.compile(r"^terms: .*$", re.M)
|
||||
# A capitalised "US" names the country and its region code.
|
||||
COUNTRY = re.compile(r"(?<![\w-])US(?![\w-])")
|
||||
|
||||
# Proper names that hold one of the words.
|
||||
NAMES: dict[str, str] = {
|
||||
r"I(?:'|''|'|')Max": "I'Max MACS, an arcade board maker",
|
||||
r"My (?:Old)?Boy!": "My Boy! and My OldBoy!, Android emulators",
|
||||
r"My Vision": "Nichibutsu My Vision, a console",
|
||||
r"On My iPhone": "the Files app location on iOS",
|
||||
r"Us vs Them": "a game title",
|
||||
r"Aliens Ate My Railway|Fell Apart On Me": "OpenTTD music track titles",
|
||||
r"\b(?:Model|Level|Series|Mk|MK|Ultima|Interface|Type) I\b(?!')":
|
||||
"a roman numeral in a machine or game name (Model I, Ultima I)",
|
||||
r"\bI(?= \([A-Z])": "a model letter, I (Palladium)",
|
||||
r"Java ME": "Java ME, the mobile Java platform",
|
||||
r"laseractive us(?=:)": "the LaserActive region key of geargrafx's BIOS list",
|
||||
}
|
||||
|
||||
# Program output quoted word for word. INSTALLER holds install.py's own
|
||||
# messages, which the pass over the installer's wording rewrites, and empties
|
||||
# this list with it. SOURCE holds what an emulator prints, quoted in its
|
||||
# profile from the emulator's code, which this project does not write.
|
||||
INSTALLER: dict[str, str] = {
|
||||
"Where do you play?": "title of the installer's first screen",
|
||||
"Copy the BIOS files from your old card or a folder": "installer menu row",
|
||||
"copy the BIOS files from your other card": "installer menu row on a two-card handheld",
|
||||
"if your files go there.": "installer hint for a card with no handheld system folder",
|
||||
"See [Files you already had]": (
|
||||
"link label in the generated options table of wiki/installer.md, "
|
||||
"kept by generate_installer_doc"),
|
||||
}
|
||||
SOURCE: dict[str, str] = {
|
||||
"You do not have a ROM image installed for Model": "sdltrs message, emulators/sdl2trs.yml",
|
||||
"You might not get sound because": "lindbergh-loader message, emulators/lindbergh-loader.yml",
|
||||
'"Your Card"': "KEGS disk name, emulators/kegs.yml",
|
||||
"How do I use SC3000": "MG.html question title, emulators/mastergear.yml",
|
||||
"How do I use SF7000 disk images?": "MG.html question title, emulators/mastergear.yml",
|
||||
"There is no version of MG for my Unix!": "MG.html question title, emulators/mastergear.yml",
|
||||
"rename your own SFX dat file to this name": "Zelda Classic README, emulators/zc210.yml",
|
||||
"Could not load ROM images! You must supply these.":
|
||||
"hypseus message, emulators/hypseus-singe.yml",
|
||||
"Please copy pak0.pk3 from the 'etmain' path of your":
|
||||
"ET: Legacy message, emulators/etlegacy.yml",
|
||||
'"keyconf.dat(us)"': "file name px68k ships, emulators/px68k-sdl.yml",
|
||||
}
|
||||
|
||||
_SPACED = [
|
||||
re.compile(r"\s+".join(map(re.escape, phrase.split())))
|
||||
for phrase in (*INSTALLER, *SOURCE)
|
||||
]
|
||||
_NAMES = [re.compile(pattern) for pattern in NAMES]
|
||||
|
||||
|
||||
def _blank(match: re.Match[str]) -> str:
|
||||
return re.sub(r"[^\n]", " ", match[0])
|
||||
|
||||
|
||||
def prose(text: str) -> str:
|
||||
"""The text of a page with everything that is not prose blanked."""
|
||||
for pattern in (HTML_COMMENT, SCRIPT_STYLE, TAG):
|
||||
text = pattern.sub(_blank, text)
|
||||
# _ and ' spell a file name or a name: read them as characters.
|
||||
text = ENTITY.sub(lambda m: html.unescape(m[0]), text)
|
||||
for pattern in (
|
||||
*_SPACED, FENCED, INLINE_CODE, LINK_TARGET, URL, ANCHOR, PATHLIKE,
|
||||
TERMS, *_NAMES, DOTTED, LETTERS, VALUES, LETTER_HEADING, COUNTRY,
|
||||
):
|
||||
text = pattern.sub(_blank, text)
|
||||
return text
|
||||
|
||||
|
||||
def pronouns(text: str) -> list[tuple[int, str]]:
|
||||
"""(line number, line) for each prose line holding a personal pronoun."""
|
||||
lines = text.splitlines()
|
||||
return [
|
||||
(number, lines[number - 1].strip())
|
||||
for number, line in enumerate(prose(text).splitlines(), 1)
|
||||
if PRONOUN.search(line)
|
||||
]
|
||||
|
||||
|
||||
def _hits(paths: list[Path]) -> list[str]:
|
||||
return [
|
||||
f"{path.relative_to(ROOT)}:{number}: {line}"
|
||||
for path in paths
|
||||
for number, line in pronouns(path.read_text(encoding="utf-8"))
|
||||
]
|
||||
|
||||
|
||||
@cache
|
||||
def _generated() -> bool:
|
||||
result = subprocess.run(
|
||||
[sys.executable, str(ROOT / "scripts" / "generate_site.py")],
|
||||
cwd=ROOT, capture_output=True, text=True, check=False,
|
||||
)
|
||||
return result.returncode == 0
|
||||
|
||||
|
||||
class Scanner(unittest.TestCase):
|
||||
def test_code_urls_and_anchors_are_not_prose(self):
|
||||
text = (
|
||||
"Run `install.py --help` first.\n"
|
||||
"```\nyou are here\n```\n"
|
||||
"See https://example.org/your/page and [a link](our-page.md).\n"
|
||||
"## Get the files { #get-your-files }\n"
|
||||
'<a title="your title">Open the menu</a>\n'
|
||||
"A US BIOS, Quake II I mean.\n"
|
||||
)
|
||||
self.assertEqual(pronouns(text), [(8, "A US BIOS, Quake II I mean.")])
|
||||
|
||||
def test_each_form_is_found_in_any_case(self):
|
||||
for word in ("I", "me", "My", "mine", "we", "Us", "OUR", "you", "Yours",
|
||||
"yourselves", "you're", "I'm"):
|
||||
with self.subTest(word=word):
|
||||
self.assertTrue(pronouns(f"Then {word} copy it."))
|
||||
|
||||
def test_a_word_holding_the_letters_passes(self):
|
||||
self.assertEqual(pronouns("Usage of the menu, mine-craft, youth."), [])
|
||||
|
||||
|
||||
class SitePronouns(unittest.TestCase):
|
||||
def test_wiki_sources(self):
|
||||
hits = _hits(sorted((ROOT / "wiki").glob("*.md")))
|
||||
self.assertEqual(hits, [], "\n".join(hits))
|
||||
|
||||
def test_readme_and_contributing(self):
|
||||
hits = _hits([ROOT / "README.md", ROOT / "CONTRIBUTING.md"])
|
||||
self.assertEqual(hits, [], "\n".join(hits))
|
||||
|
||||
def test_generated_pages(self):
|
||||
if not _generated():
|
||||
self.fail("scripts/generate_site.py failed")
|
||||
pages = sorted(p for p in DOCS.rglob("*") if p.suffix in (".md", ".mdx"))
|
||||
self.assertTrue(pages)
|
||||
hits = _hits(pages)
|
||||
self.assertEqual(hits, [], "\n".join(hits[:200]))
|
||||
|
||||
def test_agent_files(self):
|
||||
if not _generated():
|
||||
self.fail("scripts/generate_site.py failed")
|
||||
public = ROOT / "website" / "public"
|
||||
files = [public / "llms.txt", *sorted((public / "skills").rglob("*.md"))]
|
||||
self.assertTrue(all(path.is_file() for path in files))
|
||||
hits = _hits(files)
|
||||
self.assertEqual(hits, [], "\n".join(hits))
|
||||
|
||||
def test_every_allowed_quote_says_why(self):
|
||||
for quoted, reason in {**NAMES, **INSTALLER, **SOURCE}.items():
|
||||
with self.subTest(quoted=quoted):
|
||||
self.assertTrue(reason.strip())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -534,7 +534,7 @@ class NoTooltipInsideAName(unittest.TestCase):
|
||||
import sitestarlight
|
||||
|
||||
terms = {"Emulator": "An app that acts like a console.",
|
||||
"Terminal": "A window where you type commands.",
|
||||
"Terminal": "A window for typing commands.",
|
||||
"BIOS": "The console's built-in software."}
|
||||
for line in ("Fuse (Free Unix Spectrum Emulator) reads it.",
|
||||
"Open Windows Terminal (WSL).",
|
||||
|
||||
@@ -228,7 +228,7 @@ class Descriptions(unittest.TestCase):
|
||||
self.addCleanup(lambda: (gs.PAGE_DATA.clear(), gs.PAGE_DATA.update(saved)))
|
||||
gs.PAGE_DATA["emulators/duckstation.md"] = {"hasPart": [{"name": "scph5501.bin"}]}
|
||||
body = ("# DuckStation\n\nDuckStation emulates Sony PlayStation. It picks the BIOS for "
|
||||
"your game's region.\n\n<details>\n\nThe installer finds your platform.\n")
|
||||
"the game's region.\n\n<details>\n\nThe installer finds the platform.\n")
|
||||
text = gs._page_description(body, Path("emulators/duckstation.md"), "DuckStation")
|
||||
self.assertTrue(text.startswith("DuckStation emulates Sony PlayStation."))
|
||||
self.assertNotIn("source-pinned", text)
|
||||
@@ -308,10 +308,10 @@ class Descriptions(unittest.TestCase):
|
||||
self.assertEqual(text, "Dreamcast BIOS files (Sega). Start with dc_boot.bin, dc_flash.bin.")
|
||||
|
||||
def test_the_faq_is_described_by_its_questions(self) -> None:
|
||||
body = ("# Common questions\n\n## Do I need BIOS files?\n\nYes.\n\n## Which one?\n\n"
|
||||
body = ("# Common questions\n\n## Are BIOS files needed?\n\nYes.\n\n## Which one?\n\n"
|
||||
"Run the command with --dry-run.\n\n## Zip or not?\n\nZip.\n")
|
||||
text = gs._page_description(body, Path("wiki/faq.md"), "Common questions")
|
||||
self.assertTrue(text.startswith("Common questions: Do I need BIOS files?"))
|
||||
self.assertTrue(text.startswith("Common questions: Are BIOS files needed?"))
|
||||
|
||||
def test_a_written_description_wins(self) -> None:
|
||||
source = (REPO_ROOT / "scripts" / "generate_site.py").read_text(encoding="utf-8")
|
||||
@@ -359,7 +359,7 @@ class GetPagesSitInYourSetup(unittest.TestCase):
|
||||
def test_every_get_page_joins_your_setup(self):
|
||||
side, get_pages = _sidebar_with_get_pages()
|
||||
self.assertEqual(side["options"]["exclude"], [])
|
||||
setup = set(side["options"]["topics"].get("your-setup", []))
|
||||
setup = set(side["options"]["topics"].get("setups", []))
|
||||
for rel in get_pages:
|
||||
with self.subTest(page=rel):
|
||||
self.assertIn("/" + sitestarlight._sidebar_link(rel).strip("/"), setup)
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
"""The drawn steps of the install box (scripts/sitesteps.py).
|
||||
|
||||
Each drawing says in words what it shows, to a screen reader and to a
|
||||
reader whose images do not load: a title and a desc the SVG names. It tells
|
||||
the same steps as the text above it, the keys included, so the picture and
|
||||
the words never disagree. And it draws in the theme's colours.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
|
||||
|
||||
import re
|
||||
import sys
|
||||
import unittest
|
||||
import xml.etree.ElementTree as ET
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
sys.path.insert(0, str(ROOT / "scripts"))
|
||||
|
||||
import sitesteps # noqa: E402
|
||||
from siteguides import TERMINALS # noqa: E402
|
||||
|
||||
SVG = "{http://www.w3.org/2000/svg}"
|
||||
DIST = ROOT / "website" / "dist"
|
||||
|
||||
|
||||
class EachDrawingNamesItsSteps(unittest.TestCase):
|
||||
def test_title_and_desc_are_what_aria_points_at(self):
|
||||
for tab in sitesteps.STEPS:
|
||||
for layout in ("wide", "narrow"):
|
||||
root = ET.fromstring(sitesteps._svg(tab, layout))
|
||||
with self.subTest(tab=tab, layout=layout):
|
||||
self.assertEqual(root.get("role"), "img")
|
||||
title, desc = root.find(f"{SVG}title"), root.find(f"{SVG}desc")
|
||||
self.assertIsNotNone(title)
|
||||
self.assertIsNotNone(desc)
|
||||
self.assertEqual(root.get("aria-labelledby").split(),
|
||||
[title.get("id"), desc.get("id")])
|
||||
self.assertEqual(desc.text, sitesteps.description(tab))
|
||||
|
||||
def test_every_caption_drawn_is_in_the_desc(self):
|
||||
for tab, (_title, steps) in sitesteps.STEPS.items():
|
||||
desc = sitesteps.description(tab)
|
||||
for step in steps:
|
||||
with self.subTest(tab=tab, step=step.caption):
|
||||
self.assertIn(step.caption, desc)
|
||||
|
||||
def test_the_drawing_and_the_text_name_the_same_keys(self):
|
||||
for tab, (_title, steps) in sitesteps.STEPS.items():
|
||||
text = TERMINALS[tab][1].replace("**", "")
|
||||
keys = {step.word for step in steps if step.icon == "keys"}
|
||||
with self.subTest(tab=tab):
|
||||
for word in keys:
|
||||
self.assertIn(word, text)
|
||||
drawn = set(re.findall(r"\b(?:Ctrl|Cmd|Shift|Alt)\+\w+(?:\+\w+)?", text))
|
||||
self.assertLessEqual(drawn, keys)
|
||||
self.assertIn("Click Copy", text)
|
||||
|
||||
def test_one_drawing_per_computer_tab_none_elsewhere(self):
|
||||
self.assertEqual(set(sitesteps.STEPS), {"windows", "macos", "linux", "steamdeck"})
|
||||
self.assertEqual(sitesteps.steps_figure("device"), [])
|
||||
|
||||
def test_colours_come_from_the_theme(self):
|
||||
for tab in sitesteps.STEPS:
|
||||
root = ET.fromstring(sitesteps._svg(tab, "wide"))
|
||||
for node in root.iter():
|
||||
tag = node.tag.removeprefix(SVG)
|
||||
if tag in ("rect", "path", "circle"):
|
||||
with self.subTest(tab=tab, node=ET.tostring(node)[:60]):
|
||||
self.assertTrue(node.get("class", "").startswith("rb-d-"))
|
||||
|
||||
def test_ids_are_unique_on_the_page(self):
|
||||
ids = re.findall(r'id="([^"]+)"', "".join(
|
||||
sitesteps._svg(tab, layout) for tab in sitesteps.STEPS for layout in ("wide", "narrow")))
|
||||
self.assertEqual(len(ids), len(set(ids)))
|
||||
|
||||
|
||||
class TheBuiltPageHoldsThem(unittest.TestCase):
|
||||
def test_under_each_tab_of_get_your_files(self):
|
||||
page = DIST / "which-pack" / "index.html"
|
||||
if not page.is_file():
|
||||
self.skipTest("no built site")
|
||||
html = page.read_text(encoding="utf-8")
|
||||
for tab in sitesteps.STEPS:
|
||||
with self.subTest(tab=tab):
|
||||
self.assertIn(f'aria-labelledby="rb-steps-{tab}-wide-t rb-steps-{tab}-wide-d"',
|
||||
html)
|
||||
self.assertIn(f'<desc id="rb-steps-{tab}-narrow-d">', html)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -129,7 +129,7 @@ class TheConsoleBiosComesFirst(unittest.TestCase):
|
||||
|
||||
def test_the_section_opens_on_the_bios_by_region(self):
|
||||
lines = gs._start_with(self.files, self.required_only())
|
||||
self.assertEqual(lines[0], "**Start with** the BIOS for the region of your games:")
|
||||
self.assertEqual(lines[0], "**Start with** the BIOS for the region of the games:")
|
||||
self.assertIn("- **North America**: [`scph5501.bin`](#sha1-444444444444)", lines)
|
||||
self.assertIn("- **Japan**: [`scph5500.bin`](#sha1-555555555555)", lines)
|
||||
self.assertLess(lines.index("- **North America**: [`scph5501.bin`](#sha1-444444444444)"),
|
||||
|
||||
+15
-15
@@ -435,7 +435,7 @@ class TheFaqAnswersWithACommand(unittest.TestCase):
|
||||
is the lever the installer itself names."""
|
||||
|
||||
def test_every_file_of_a_console(self):
|
||||
section = _section(_wiki("faq.md"), "Do I need every file of a console?")
|
||||
section = _section(_wiki("faq.md"), "Is every file of a console needed?")
|
||||
self.assertIn("<!-- os-tabs -->", section)
|
||||
self.assertIn("--system sony-playstation --core pcsx1", section)
|
||||
self.assertNotIn("only your region", section)
|
||||
@@ -450,7 +450,7 @@ class LegalOpensInPlainWords(unittest.TestCase):
|
||||
|
||||
def test_the_answer_comes_before_the_reasoning(self):
|
||||
self.assertIn("## The reasoning in detail", self.text)
|
||||
self.assertIn("It depends on your country. Nothing here is legal advice.", self.opening)
|
||||
self.assertIn("It depends on the country. Nothing here is legal advice.", self.opening)
|
||||
for case in ("Connectix", "Accolade", "DMCA", "CFR", "Chamberlain", "Yuzu"):
|
||||
with self.subTest(case=case):
|
||||
self.assertNotIn(case, self.opening)
|
||||
@@ -500,7 +500,7 @@ class ArcadeAnswerWherePlayersLook(unittest.TestCase):
|
||||
self.assertIn(words, section)
|
||||
|
||||
def test_the_faq_links_the_technical_answer(self):
|
||||
section = _section(_wiki("faq.md"), "My arcade game fails (which MAME version?)")
|
||||
section = _section(_wiki("faq.md"), "An arcade game fails (which MAME version?)")
|
||||
anchor = "technical-faq.md#which-mame-version-do-the-arcade-bios-sets-match"
|
||||
self.assertIn(anchor, section)
|
||||
self.assertIn("## Which MAME version do the arcade BIOS sets match?", _wiki("technical-faq.md"))
|
||||
@@ -513,7 +513,7 @@ class ArcadeAnswerWherePlayersLook(unittest.TestCase):
|
||||
self.assertTrue(profile.get("core_version") or profile.get("version"))
|
||||
|
||||
def test_the_check_step_holds_the_searched_words(self):
|
||||
self.assertIn("## 1. Check my BIOS folder { #checking-what-you-installed }",
|
||||
self.assertIn("## 1. Check the BIOS folder { #checking-what-you-installed }",
|
||||
_wiki("troubleshooting.md"))
|
||||
|
||||
|
||||
@@ -583,7 +583,7 @@ class SetupsWithoutAPage(unittest.TestCase):
|
||||
"""N9, J13: ES-DE, LaunchBox and iOS found nothing."""
|
||||
|
||||
def test_the_answer(self):
|
||||
section = _flat(_section(_wiki("faq.md"), "My setup is not in the list"))
|
||||
section = _flat(_section(_wiki("faq.md"), "A setup is not in the list"))
|
||||
for words in ("--dest", "ES-DE", "LaunchBox", "iPhone"):
|
||||
with self.subTest(words=words):
|
||||
self.assertIn(words, section)
|
||||
@@ -604,7 +604,7 @@ class LinkLabelsMatchPages(unittest.TestCase):
|
||||
for name in ("first-install.md", "troubleshooting.md", "faq.md"):
|
||||
with self.subTest(page=name):
|
||||
for label in re.findall(r"\[([^\]]+)\]\(\.\./which-pack\.md\)", _wiki(name)):
|
||||
self.assertEqual(label, "Get your files")
|
||||
self.assertEqual(label, "Get the files")
|
||||
|
||||
|
||||
class ExitStatusAndPinnedInstaller(unittest.TestCase):
|
||||
@@ -712,7 +712,7 @@ class TroubleshootingSaysTheWordsOnScreen(unittest.TestCase):
|
||||
self.text = _wiki("troubleshooting.md")
|
||||
|
||||
def test_step_one_opens_on_the_messages(self):
|
||||
step = _flat(_section(self.text, "1. Check my BIOS folder"))
|
||||
step = _flat(_section(self.text, "1. Check the BIOS folder"))
|
||||
self.assertIn("**BIOS not found**, **BIOS missing** or **firmware missing**?", step)
|
||||
self.assertLess(step.index("BIOS not found"), step.index("```"))
|
||||
|
||||
@@ -792,7 +792,7 @@ class ArcadeVersionTable(unittest.TestCase):
|
||||
|
||||
def test_the_section_opens_on_the_answer(self):
|
||||
self.assertTrue(self.section.lstrip().startswith(
|
||||
"Your game sets and BIOS sets must come from the same version as your arcade\nemulator."))
|
||||
"Game sets and BIOS sets must come from the same version as the arcade\nemulator."))
|
||||
self.assertIn("| Emulator, as RetroArch names it | Sets from |", self.section)
|
||||
self.assertLess(self.section.index("| Emulator"), self.section.index("### How this is known"))
|
||||
|
||||
@@ -818,7 +818,7 @@ class ArcadeVersionTable(unittest.TestCase):
|
||||
self.assertIn(ARCADE_ANCHOR, arcade)
|
||||
self.assertNotIn("emulators/index.md", arcade)
|
||||
faq = _wiki("faq.md")
|
||||
self.assertIn("## My arcade game fails (which MAME version?) "
|
||||
self.assertIn("## An arcade game fails (which MAME version?) "
|
||||
"{ #my-arcade-game-does-not-start }", faq)
|
||||
|
||||
|
||||
@@ -830,7 +830,7 @@ class FaqLabels(unittest.TestCase):
|
||||
|
||||
def test_no_reference_label(self):
|
||||
self.assertNotRegex(self.text, r"(?m)^Reference:")
|
||||
arcade = _section(self.text, "My arcade game fails (which MAME version?)")
|
||||
arcade = _section(self.text, "An arcade game fails (which MAME version?)")
|
||||
self.assertIn(f"Game sets must match the emulator's version:\n[the list]({ARCADE_ANCHOR}).",
|
||||
arcade)
|
||||
|
||||
@@ -845,7 +845,7 @@ class CopyYourOwnBios(unittest.TestCase):
|
||||
"""C-other, need 12: no page answered the legal route."""
|
||||
|
||||
def test_each_console_has_a_guide(self):
|
||||
section = _section(_wiki("faq.md"), "Can I copy my own console's BIOS?")
|
||||
section = _section(_wiki("faq.md"), "Can an owned console's BIOS be copied?")
|
||||
links = re.findall(r"\[([^\]]+)\]\((https://[^)]+)\)", section)
|
||||
self.assertEqual(dict(links), {
|
||||
"PCSX2": "https://pcsx2.net/docs/setup/bios/",
|
||||
@@ -1093,15 +1093,15 @@ class FaqAnswersLeadSomewhere(unittest.TestCase):
|
||||
self.generator = (REPO_ROOT / "scripts" / "generate_site.py").read_text(encoding="utf-8")
|
||||
|
||||
def test_ios_goes_to_the_iphone_section(self):
|
||||
section = _flat(_section(self.text, "My setup is not in the list"))
|
||||
self.assertIn("iPhone, iPad (iOS): no terminal. [Pick your consoles and copy them "
|
||||
section = _flat(_section(self.text, "A setup is not in the list"))
|
||||
self.assertIn("iPhone, iPad (iOS): no terminal. [Pick the consoles and copy them "
|
||||
"to the app](../which-pack.md#iphone-and-ipad).", section)
|
||||
self.assertNotIn("Use the ZIP", section)
|
||||
self.assertIn('"## iPhone and iPad { #iphone-and-ipad }"', self.generator)
|
||||
|
||||
def test_antivirus_answer_covers_setups_without_a_zip(self):
|
||||
section = _flat(_section(self.text, "Windows or my antivirus blocks the command"))
|
||||
self.assertIn("Use your setup's ZIP. None? [Pick your consoles]"
|
||||
section = _flat(_section(self.text, "Windows or an antivirus blocks the command"))
|
||||
self.assertIn("Use the setup's ZIP. None? [Pick the consoles]"
|
||||
"(../which-pack.md#only-some-consoles) and download their files.",
|
||||
section)
|
||||
self.assertNotIn("if any", section)
|
||||
|
||||
Reference in new issue
Block a user