mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-12-02 22:38:54 -06:00
fix: read the platform guides on first use
model.guides read and checked _registry.yml and _guides.yml at import, from the repository: a pack build died on a registry entry without a guide before parsing its options, and a site run on another platforms folder took the repository's guides. The guides now load on first use, keyed on siteinputs.current().platforms, behind accessor functions.
This commit is contained in:
1 parent
9f987adb8c
commit
e8b3cef5d5
31 files changed
+290
-204
No files matched your search
@@ -60,11 +60,11 @@ class ReadmeRegressions(unittest.TestCase):
|
||||
|
||||
def test_advertised_bootstrap_urls_are_the_shipped_ones(self):
|
||||
from sitegen import bootstrap as sitebootstrap
|
||||
from model.guides import INSTALL_BASE
|
||||
from model.guides import install_base
|
||||
|
||||
quick_install = self._quick_install()
|
||||
for name in sitebootstrap.SOURCES:
|
||||
url = f"{INSTALL_BASE}/{name}"
|
||||
url = f"{install_base()}/{name}"
|
||||
self.assertIn(f"{url} |", quick_install, f"{name} bootstrap URL missing")
|
||||
# The site serves each bootstrap with install.py read from the
|
||||
# commit it was built from, the raw form from main.
|
||||
@@ -891,11 +891,11 @@ class PackReadmesSayWhatTheInstallerDoes(unittest.TestCase):
|
||||
return text[text.index("INSTALLATION"):text.index("TROUBLESHOOTING")]
|
||||
|
||||
def test_retroarch_offers_the_windows_installer(self):
|
||||
from model.guides import INSTALL_PS1, INSTALL_SH
|
||||
from model.guides import install_ps1, install_sh
|
||||
|
||||
guide = self._guide("retroarch")
|
||||
self.assertIn(f"{INSTALL_SH} | sh", guide)
|
||||
self.assertIn(f"{INSTALL_PS1} | iex", guide)
|
||||
self.assertIn(f"{install_sh()} | sh", guide)
|
||||
self.assertIn(f"{install_ps1()} | iex", guide)
|
||||
|
||||
def test_emudeck_keys_match_the_registry_and_the_flag(self):
|
||||
import re
|
||||
@@ -918,10 +918,10 @@ class PackReadmesSayWhatTheInstallerDoes(unittest.TestCase):
|
||||
|
||||
def test_retropie_never_sends_a_pc_to_the_linux_partition(self):
|
||||
guide = self._guide("retropie")
|
||||
from model.guides import INSTALL_SH
|
||||
from model.guides import install_sh
|
||||
|
||||
self.assertNotIn("Put the SD card in your PC", guide)
|
||||
self.assertIn(f"{INSTALL_SH} | sh", guide)
|
||||
self.assertIn(f"{install_sh()} | sh", guide)
|
||||
|
||||
|
||||
class AutoFetchReadsListsAndPlacesWithoutClobbering(unittest.TestCase):
|
||||
|
||||
@@ -928,9 +928,9 @@ class RetroArchWindowsSystemFolder(unittest.TestCase):
|
||||
source = inspect.getsource(install)
|
||||
self.assertIn('ra_dir or exe_dir / "system"', source)
|
||||
self.assertTrue(str(install._os_default_dests("windows")["retroarch"]).replace("\\", "/").endswith("/system"))
|
||||
from model.guides import GUIDES
|
||||
from model.guides import platform_guides
|
||||
|
||||
guide = GUIDES["retroarch"]
|
||||
guide = platform_guides()["retroarch"]
|
||||
section = "\n".join([*(path for _label, path in guide.folders), *guide.notes])
|
||||
self.assertNotIn("%APPDATA%\\RetroArch\\system", section)
|
||||
self.assertIn("`system\\` next to `retroarch.exe`", section)
|
||||
@@ -941,11 +941,11 @@ class RetroArchWindowsSystemFolder(unittest.TestCase):
|
||||
(platform_darwin.m), Application Support only for a portable or
|
||||
Steam build, and install.py looks there in that order."""
|
||||
import install
|
||||
from model.guides import GUIDES
|
||||
from model.guides import platform_guides
|
||||
|
||||
source = inspect.getsource(install._macos_retroarch_base)
|
||||
self.assertIn('Path.home() / "Documents" / "RetroArch"', source)
|
||||
folders = dict(GUIDES["retroarch"].folders)
|
||||
folders = dict(platform_guides()["retroarch"].folders)
|
||||
self.assertEqual(folders["macOS"], "`~/Documents/RetroArch/system/`")
|
||||
|
||||
|
||||
@@ -1645,9 +1645,9 @@ def unserved_one_liners(page: str, text: str) -> list[str]:
|
||||
address of the repository stays as the fallback of the One line
|
||||
section, and must name a bootstrap the repository holds."""
|
||||
from sitegen import bootstrap as sitebootstrap
|
||||
from model.guides import INSTALL_BASE
|
||||
from model.guides import install_base
|
||||
|
||||
served = {f"{INSTALL_BASE}/{name}" for name in sitebootstrap.SOURCES}
|
||||
served = {f"{install_base()}/{name}" for name in sitebootstrap.SOURCES}
|
||||
fallback = _section(text, "One line") if page == "installer.md" else ""
|
||||
stale = []
|
||||
for line in text.splitlines():
|
||||
|
||||
@@ -116,15 +116,15 @@ class TheOneLinerFollowsTheRegistry(unittest.TestCase):
|
||||
def test_the_commands_are_written_once(self):
|
||||
"""The address comes from install_base in platforms/_guides.yml, the
|
||||
one the site's commands use."""
|
||||
from packs import readme as packreadme
|
||||
from model import guides
|
||||
from model.guides import INSTALL_BASE
|
||||
from model.guides import install_ps1, install_sh
|
||||
|
||||
source = (REPO_ROOT / "scripts" / "packs" / "readme.py").read_text(encoding="utf-8")
|
||||
self.assertNotIn("raw.githubusercontent.com", source)
|
||||
self.assertNotIn("abdess.github.io", source)
|
||||
self.assertEqual(packreadme.INSTALL_SH, f"{INSTALL_BASE}/{guides.SH_NAME}")
|
||||
self.assertEqual(packreadme.INSTALL_PS1, f"{INSTALL_BASE}/{guides.PS1_NAME}")
|
||||
text = build_readme("retroarch", "RetroArch", "system", 1, 1,
|
||||
detect=[{"os": "linux"}, {"os": "windows"}])
|
||||
self.assertIn(install_sh(), text)
|
||||
self.assertIn(install_ps1(), text)
|
||||
|
||||
|
||||
class GuidesInstallFromTheZipInHand(unittest.TestCase):
|
||||
|
||||
@@ -270,7 +270,7 @@ class EverySurfaceSaysWhy(unittest.TestCase):
|
||||
with contextlib.chdir(REPO_ROOT):
|
||||
block = guidepage.pack_buttons("knulli")
|
||||
guide = guidepage._guide_download(
|
||||
"knulli", "KNULLI", guides.GUIDES["knulli"], None, "## Download")
|
||||
"knulli", "KNULLI", guides.platform_guides()["knulli"], None, "## Download")
|
||||
self.assertIn(line, block)
|
||||
self.assertIn(guidepage.NO_ZIP_FAQ, block)
|
||||
self.assertIn(line, "\n".join(guide))
|
||||
|
||||
@@ -24,7 +24,7 @@ from unittest import mock
|
||||
import install
|
||||
from sitegen import bootstrap as sitebootstrap
|
||||
from model import guides
|
||||
from model.guides import INSTALL_BASE, INSTALL_PS1, INSTALL_SH, install_command
|
||||
from model.guides import install_base, install_ps1, install_sh, install_command
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
@@ -153,29 +153,29 @@ class DocumentedCommands(unittest.TestCase):
|
||||
config = (WEBSITE / "astro.config.mjs").read_text(encoding="utf-8")
|
||||
site = re.search(r"const SITE = '([^']+)'", config).group(1)
|
||||
base = re.search(r"const BASE = '([^']+)'", config).group(1)
|
||||
self.assertEqual(f"{INSTALL_BASE}/", site + base)
|
||||
self.assertEqual(INSTALL_SH, f"{site}{base}{guides.SH_NAME}")
|
||||
self.assertEqual(INSTALL_PS1, f"{site}{base}{guides.PS1_NAME}")
|
||||
self.assertEqual(install.BOOTSTRAP_URL, INSTALL_SH)
|
||||
self.assertEqual(f"{install.BOOTSTRAP_URL}.ps1", INSTALL_PS1)
|
||||
self.assertEqual(f"{install_base()}/", site + base)
|
||||
self.assertEqual(install_sh(), f"{site}{base}{guides.SH_NAME}")
|
||||
self.assertEqual(install_ps1(), f"{site}{base}{guides.PS1_NAME}")
|
||||
self.assertEqual(install.BOOTSTRAP_URL, install_sh())
|
||||
self.assertEqual(f"{install.BOOTSTRAP_URL}.ps1", install_ps1())
|
||||
|
||||
def test_the_installer_hints_give_the_short_command(self):
|
||||
with mock.patch.dict(os.environ, {"RETROBIOS_BOOTSTRAP": "sh"}):
|
||||
self.assertEqual(install.Invocation().launcher(), f"curl -fsSL {INSTALL_SH} | sh -s --")
|
||||
self.assertEqual(install.Invocation().launcher(), f"curl -fsSL {install_sh()} | sh -s --")
|
||||
with mock.patch.dict(os.environ, {"RETROBIOS_BOOTSTRAP": "ps1"}):
|
||||
self.assertEqual(install.Invocation().launcher(),
|
||||
f"&([scriptblock]::Create((irm {INSTALL_PS1})))")
|
||||
f"&([scriptblock]::Create((irm {install_ps1()})))")
|
||||
|
||||
def test_every_page_a_user_copies_from_gives_the_short_command(self):
|
||||
sources = {
|
||||
"wiki/installer.md": [install_command("sh"), install_command("powershell")],
|
||||
"wiki/first-install.md": [install_command("sh"), install_command("powershell")],
|
||||
"wiki/faq.md": [f"curl -fsSL {INSTALL_SH} | sh -s -- --dry-run"],
|
||||
"wiki/faq.md": [f"curl -fsSL {install_sh()} | sh -s -- --dry-run"],
|
||||
"wiki/troubleshooting.md": [install_command("sh", "--check")],
|
||||
"wiki/tools.md": [install_command("sh"), install_command("powershell")],
|
||||
"website/src/components/FilePicker.astro": [f"'curl -fsSL {INSTALL_SH} | sh -s --'"],
|
||||
"scripts/download.sh": [f"curl -fsSL {INSTALL_SH} | sh -s -- --platform <name>"],
|
||||
"scripts/release/packinfo.py": [f"curl -fsSL {INSTALL_SH} | sh -s -- --platform <name>"],
|
||||
"website/src/components/FilePicker.astro": [f"'curl -fsSL {install_sh()} | sh -s --'"],
|
||||
"scripts/download.sh": [f"curl -fsSL {install_sh()} | sh -s -- --platform <name>"],
|
||||
"scripts/release/packinfo.py": [f"curl -fsSL {install_sh()} | sh -s -- --platform <name>"],
|
||||
}
|
||||
for rel, commands in sources.items():
|
||||
text = (REPO_ROOT / rel).read_text(encoding="utf-8")
|
||||
@@ -202,7 +202,7 @@ class DocumentedCommands(unittest.TestCase):
|
||||
def test_no_command_drops_the_scheme(self):
|
||||
"""A first request in clear text lets anyone on the way serve another
|
||||
script, which the installer's pin cannot catch: the pin is in it."""
|
||||
bare = INSTALL_BASE.removeprefix("https://")
|
||||
bare = install_base().removeprefix("https://")
|
||||
for page in sorted((REPO_ROOT / "wiki").glob("*.md")):
|
||||
text = page.read_text(encoding="utf-8")
|
||||
with self.subTest(page=page.name):
|
||||
@@ -258,11 +258,11 @@ class GeneratedSurfaces(unittest.TestCase):
|
||||
from sitegen import consolecards
|
||||
|
||||
tail = " | sh -s -- --check"
|
||||
self.assertEqual(consolecards.install_box_weight([f"curl -fsSL {INSTALL_SH}{tail}"]),
|
||||
self.assertEqual(consolecards.install_box_weight([f"curl -fsSL {install_sh()}{tail}"]),
|
||||
len("curl -fsSL ") + 66 + len(tail) + 1)
|
||||
line = f"&([scriptblock]::Create((irm {INSTALL_PS1}))) --check"
|
||||
line = f"&([scriptblock]::Create((irm {install_ps1()}))) --check"
|
||||
self.assertEqual(consolecards.install_box_weight([line]),
|
||||
len(line) - len(INSTALL_PS1) + 67 + 1)
|
||||
len(line) - len(install_ps1()) + 67 + 1)
|
||||
|
||||
def test_the_readme_shows_the_short_form(self):
|
||||
readme = (REPO_ROOT / "README.md").read_text(encoding="utf-8")
|
||||
@@ -274,7 +274,7 @@ class GeneratedSurfaces(unittest.TestCase):
|
||||
@unittest.skipUnless(DOCS.is_dir(), "site not generated")
|
||||
def test_the_site_shows_the_short_form(self):
|
||||
pages = {path: path.read_text(encoding="utf-8") for path in DOCS.rglob("*.md*")}
|
||||
self.assertTrue(any(INSTALL_SH in text for text in pages.values()))
|
||||
self.assertTrue(any(install_sh() in text for text in pages.values()))
|
||||
long_form = sorted(str(path.relative_to(DOCS)) for path, text in pages.items()
|
||||
if OLD_SH in text or OLD_PS1 in text)
|
||||
self.assertEqual(long_form, ["wiki/installer.md"])
|
||||
|
||||
@@ -13,6 +13,8 @@ import tests
|
||||
import ast
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
@@ -21,9 +23,9 @@ import yaml
|
||||
|
||||
from sitegen import decorate
|
||||
from sitegen import nav as sitegen_nav
|
||||
from model import guides
|
||||
from model import guides, siteinputs
|
||||
from core.cli import SourceUnreadable
|
||||
from model.guides import GUIDES, GuideError, load_guides
|
||||
from model.guides import platform_guides, GuideError, load_guides
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||
|
||||
@@ -51,7 +53,7 @@ class GuidesLiveInYaml(unittest.TestCase):
|
||||
def test_every_registered_platform_has_a_guide_in_the_file(self):
|
||||
written = yaml.safe_load(_guides_text())["guides"]
|
||||
self.assertEqual(sorted(written), sorted(_registry()))
|
||||
self.assertEqual(sorted(GUIDES), sorted(_registry()))
|
||||
self.assertEqual(sorted(platform_guides()), sorted(_registry()))
|
||||
|
||||
def test_a_platform_without_a_guide_is_named(self):
|
||||
data = yaml.safe_load(_guides_text())
|
||||
@@ -88,7 +90,7 @@ class GuidesLiveInYaml(unittest.TestCase):
|
||||
registry = _registry()
|
||||
written = yaml.safe_load(_guides_text())["guides"]["batocera"]["folders"][0]
|
||||
self.assertNotIn("path", written)
|
||||
self.assertEqual(GUIDES["batocera"].folders[0],
|
||||
self.assertEqual(platform_guides()["batocera"].folders[0],
|
||||
(written["where"], f"`{registry['batocera']['extract_to']}`"))
|
||||
|
||||
def test_a_folder_row_without_path_needs_an_extract_folder(self):
|
||||
@@ -110,6 +112,41 @@ class GuidesLiveInYaml(unittest.TestCase):
|
||||
self.assertEqual(guides.pack_manual("minui"), "")
|
||||
|
||||
|
||||
class GuidesLoadOnFirstUse(unittest.TestCase):
|
||||
"""The guides were read and checked at import, from the repository's
|
||||
platforms folder: a pack build died on a registry entry with no guide
|
||||
before parsing its options, and a site run on another collection took
|
||||
the repository's guides."""
|
||||
|
||||
def test_importing_the_pack_builder_reads_no_guide(self):
|
||||
script = ("import sys\n"
|
||||
"opened = []\n"
|
||||
"sys.addaudithook(lambda event, args: opened.append(str(args[0]))"
|
||||
" if event == 'open' else None)\n"
|
||||
"import packs.platformpack, sitegen.build\n"
|
||||
"print([path for path in opened if path.endswith(('_guides.yml', '_registry.yml'))])\n")
|
||||
result = subprocess.run([sys.executable, "-c", script], cwd=REPO_ROOT / "scripts",
|
||||
capture_output=True, text=True, check=True)
|
||||
self.assertEqual(result.stdout.strip(), "[]")
|
||||
|
||||
def test_the_guides_follow_the_platforms_folder_of_the_run(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
folder = Path(tmp)
|
||||
for name in ("_registry.yml", "_guides.yml"):
|
||||
(folder / name).write_text(
|
||||
(REPO_ROOT / "platforms" / name).read_text(encoding="utf-8"), encoding="utf-8")
|
||||
data = yaml.safe_load(_guides_text())
|
||||
data["install_base"] = "https://example.org/x"
|
||||
(folder / "_guides.yml").write_text(yaml.safe_dump(data), encoding="utf-8")
|
||||
before = siteinputs.current()
|
||||
siteinputs.use(siteinputs.SiteInputs(platforms=folder))
|
||||
try:
|
||||
self.assertEqual(guides.install_sh(), f"https://example.org/x/{guides.SH_NAME}")
|
||||
finally:
|
||||
siteinputs.use(before)
|
||||
self.assertNotEqual(guides.install_base(), "https://example.org/x")
|
||||
|
||||
|
||||
# A table of prose keyed by platform: what the guides file replaced.
|
||||
_PLATFORM_BRANCH = re.compile(r"""(?:==|!=)\s*["']([a-z0-9-]+)["']|["']([a-z0-9-]+)["']\s*(?:==|!=)""")
|
||||
# The modules that write the site and the pack README.
|
||||
|
||||
@@ -729,7 +729,7 @@ class InstallBlockWhereItWorks(unittest.TestCase):
|
||||
def test_no_os_tab_outside_the_data_root(self) -> None:
|
||||
if not _generated():
|
||||
self.skipTest("site pages not generated")
|
||||
labels = {key: guides.TERMINALS[key][0] for key in guides.TERMINALS}
|
||||
labels = {key: guides.terminals()[key][0] for key in guides.terminals()}
|
||||
for name, profile in _profiles_with_data_root().items():
|
||||
allowed = {labels["device"]}
|
||||
for key in profile["data_root"]:
|
||||
|
||||
+31
-31
@@ -95,7 +95,7 @@ class TrustItemsSayWhereItWrites(unittest.TestCase):
|
||||
for entry in json.loads(path.read_text(encoding="utf-8")).get("files", []))
|
||||
]
|
||||
self.assertTrue(saves, "no manifest files an entry under root: save")
|
||||
text = " ".join(guides.TRUST_ITEMS).lower()
|
||||
text = " ".join(guides.trust_items()).lower()
|
||||
self.assertNotIn("only in your bios folder", text)
|
||||
self.assertIn("save folder", text)
|
||||
self.assertIn("--restore", text)
|
||||
@@ -103,7 +103,7 @@ class TrustItemsSayWhereItWrites(unittest.TestCase):
|
||||
def test_home_shows_the_same_items(self):
|
||||
# A term's first use on the page carries its gloss.
|
||||
home = re.sub(r"</?abbr[^>]*>", "", _page("index.md"))
|
||||
for item in guides.TRUST_ITEMS:
|
||||
for item in guides.trust_items():
|
||||
self.assertIn(f"- {item}", home)
|
||||
self.assertNotIn("only in your BIOS folder", home)
|
||||
|
||||
@@ -156,7 +156,7 @@ class SetupTiles(unittest.TestCase):
|
||||
for name in ("index.md", "which-pack.md"):
|
||||
text = _page(name)
|
||||
with self.subTest(page=name):
|
||||
extra = sum(len(tiles) for tiles in guides.GROUP_TILES.values())
|
||||
extra = sum(len(tiles) for tiles in guides.group_tiles().values())
|
||||
self.assertEqual(text.count('class="rb-card rb-tile"'), len(REGISTRY) + extra)
|
||||
for key in REGISTRY:
|
||||
self.assertIn(f'href="/retrobios/platforms/{key}/"', text)
|
||||
@@ -177,7 +177,7 @@ class SetupTiles(unittest.TestCase):
|
||||
home = _page("index.md")
|
||||
display = {k: load_platform_config(k, str(REPO_ROOT / "platforms")).get("platform", k)
|
||||
for k in REGISTRY}
|
||||
for group, (label, _description) in guides.DEVICE_GROUPS.items():
|
||||
for group, (label, _description) in guides.device_groups().items():
|
||||
members = [k for k in REGISTRY if REGISTRY[k].get("device_group") == group]
|
||||
if len(members) == 1:
|
||||
with self.subTest(group=group):
|
||||
@@ -185,9 +185,9 @@ class SetupTiles(unittest.TestCase):
|
||||
self.assertIn(f">{display[members[0]]}</strong>", home)
|
||||
|
||||
def test_hardware_is_named_and_cited(self):
|
||||
self.assertIn("Raspberry Pi", guides.GUIDES["batocera"].summary)
|
||||
self.assertIn("Raspberry Pi", guides.DEVICE_GROUPS["gaming-os"][0])
|
||||
self.assertIn("Anbernic", guides.DEVICE_GROUPS["handheld"][0])
|
||||
self.assertIn("Raspberry Pi", guides.platform_guides()["batocera"].summary)
|
||||
self.assertIn("Raspberry Pi", guides.device_groups()["gaming-os"][0])
|
||||
self.assertIn("Anbernic", guides.device_groups()["handheld"][0])
|
||||
lines = GUIDES_YAML.splitlines()
|
||||
for number, line in enumerate(lines):
|
||||
if re.match(r" (runs_on|terminal):", line):
|
||||
@@ -233,7 +233,7 @@ class GuideRoutes(unittest.TestCase):
|
||||
text = _page("platforms/batocera.md")
|
||||
self.assertLess(text.index("## From a computer"), text.index("## On the device"))
|
||||
self.assertIn("{ #install }", "\n".join(guidepage._guide_install(
|
||||
"batocera", guides.GUIDES["batocera"], "## On the device { #install }")))
|
||||
"batocera", guides.platform_guides()["batocera"], "## On the device { #install }")))
|
||||
self.assertIn("Unzip them all into the network folder above", text)
|
||||
|
||||
def test_a_computer_app_keeps_the_command_first(self):
|
||||
@@ -241,8 +241,8 @@ class GuideRoutes(unittest.TestCase):
|
||||
self.assertLess(text.index("## Install"), text.index("## Download"))
|
||||
|
||||
def test_each_device_tab_says_how_to_open_its_terminal(self):
|
||||
shared = guides.TERMINALS["device"][1]
|
||||
for name, guide in guides.GUIDES.items():
|
||||
shared = guides.terminals()["device"][1]
|
||||
for name, guide in guides.platform_guides().items():
|
||||
if "device" not in guide.run:
|
||||
continue
|
||||
with self.subTest(platform=name):
|
||||
@@ -265,7 +265,7 @@ class GuideRoutes(unittest.TestCase):
|
||||
|
||||
class PackManualReadsThePageFolders(unittest.TestCase):
|
||||
def test_every_path_in_a_pack_manual_is_a_folder_of_its_page(self):
|
||||
for name, guide in guides.GUIDES.items():
|
||||
for name, guide in guides.platform_guides().items():
|
||||
if not guide.pack_manual:
|
||||
continue
|
||||
known = " ".join(path.replace("`", "") for _w, path in guides.folder_list(name))
|
||||
@@ -326,7 +326,7 @@ class CommandBlocks(unittest.TestCase):
|
||||
self.assertEqual(sorted(set(sh_args)), sorted(set(ps_args)))
|
||||
self.assertEqual(len(set(sh_args)), 2)
|
||||
self.assertIn('```powershell title="PowerShell"', block)
|
||||
for key, guide in guides.GUIDES.items():
|
||||
for key, guide in guides.platform_guides().items():
|
||||
if "windows" in guide.run:
|
||||
with self.subTest(platform=key):
|
||||
self.assertIn("/i.ps1", _guide_part(_page(f"platforms/{key}.md")))
|
||||
@@ -360,7 +360,7 @@ class HomeLinksTheOtherTasks(unittest.TestCase):
|
||||
self.assertLess(home.index("/retrobios/wiki/troubleshooting/"), home.index("## Is it needed? { #do-i-need-it }"))
|
||||
|
||||
|
||||
GUIDE = guides.HANDHELD_GUIDE
|
||||
GUIDE = guides.handheld_guide()
|
||||
|
||||
|
||||
def _plain_guide_part(text: str) -> str:
|
||||
@@ -376,7 +376,7 @@ def _display(key: str) -> str:
|
||||
|
||||
class HandheldWayIn(unittest.TestCase):
|
||||
def test_android_and_linux_tiles_on_home_and_get_your_files(self):
|
||||
tiles = guides.GROUP_TILES.get("handheld", ())
|
||||
tiles = guides.group_tiles().get("handheld", ())
|
||||
self.assertEqual([tile.name for tile in tiles],
|
||||
["Android", "Linux handhelds", "iPhone and iPad"])
|
||||
for name in ("index.md", "which-pack.md"):
|
||||
@@ -432,7 +432,7 @@ class HandheldWayIn(unittest.TestCase):
|
||||
data = {"page": "x", "title": "X", "summary": "S", "uses": "retroarch",
|
||||
"systems": [{"name": "Onion"}]}
|
||||
with self.assertRaises(guides.GuideError):
|
||||
guides._handheld_guide(data, REGISTRY, guides.GUIDES, "x")
|
||||
guides._handheld_guide(data, REGISTRY, guides.platform_guides(), "x")
|
||||
|
||||
def test_devices_are_a_search_field_with_no_text(self):
|
||||
text = _page(GUIDE.path)
|
||||
@@ -450,7 +450,7 @@ class HandheldWayIn(unittest.TestCase):
|
||||
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 = guides.DEVICE_GROUPS["handheld"][0]
|
||||
label = guides.device_groups()["handheld"][0]
|
||||
self.assertIn({GUIDE.title: GUIDE.path}, groups[label])
|
||||
|
||||
def test_the_guide_fills_the_card_and_never_its_root(self):
|
||||
@@ -672,7 +672,7 @@ class DownloadLine(unittest.TestCase):
|
||||
self.assertRegex(line, r"\[SHA256SUMS\.txt\]\([^)]+\) and its \[signature\]\([^)]+\)\.$")
|
||||
|
||||
|
||||
HANDHELDS = guides.HANDHELD_GUIDE
|
||||
HANDHELDS = guides.handheld_guide()
|
||||
OFFLINE_ANCHOR = "#without-a-network-offline-install"
|
||||
|
||||
|
||||
@@ -686,7 +686,7 @@ def _with_zip(name: str) -> bool:
|
||||
return bool(pack and pack.get("assets"))
|
||||
|
||||
|
||||
SETUPS = [name for name in guides.GUIDES if name in REGISTRY]
|
||||
SETUPS = [name for name in guides.platform_guides() if name in REGISTRY]
|
||||
|
||||
|
||||
class NoZipNoUnzipText(unittest.TestCase):
|
||||
@@ -742,9 +742,9 @@ class NoZipNoUnzipText(unittest.TestCase):
|
||||
|
||||
def test_the_network_route_needs_a_share_and_no_zip(self):
|
||||
for name in SETUPS:
|
||||
share = guidepage._network_share(name, guides.GUIDES[name])
|
||||
share = guidepage._network_share(name, guides.platform_guides()[name])
|
||||
with self.subTest(setup=name):
|
||||
if _with_zip(name) or guides.GUIDES[name].run != ("device",):
|
||||
if _with_zip(name) or guides.platform_guides()[name].run != ("device",):
|
||||
self.assertEqual(share, "")
|
||||
if share:
|
||||
self.assertTrue(share.startswith("\\\\"))
|
||||
@@ -818,7 +818,7 @@ class EntryCopy(unittest.TestCase):
|
||||
|
||||
def test_the_setup_index_lists_the_handheld_tiles(self):
|
||||
text = _plain_page("platforms/index.md")
|
||||
for tile in guides.GROUP_TILES["handheld"]:
|
||||
for tile in guides.group_tiles()["handheld"]:
|
||||
target = tile.link.removesuffix(".md").replace(".md#", "/#")
|
||||
with self.subTest(tile=tile.name):
|
||||
self.assertIn(f"**[{tile.name}](/retrobios/{target}", text.replace("/)", ")"))
|
||||
@@ -827,7 +827,7 @@ class EntryCopy(unittest.TestCase):
|
||||
|
||||
class IphoneAndIpad(unittest.TestCase):
|
||||
def test_a_tile_in_the_handheld_group(self):
|
||||
tile = next(t for t in guides.GROUP_TILES["handheld"] if t.name == "iPhone and iPad")
|
||||
tile = next(t for t in guides.group_tiles()["handheld"] if t.name == "iPhone and iPad")
|
||||
self.assertEqual(tile.link, "which-pack.md#iphone-and-ipad")
|
||||
for name in ("index.md", "which-pack.md"):
|
||||
with self.subTest(page=name):
|
||||
@@ -884,18 +884,18 @@ class GetPagesGiveTheSetupsOwnRoutes(unittest.TestCase):
|
||||
|
||||
def test_a_card_setup_names_the_card(self):
|
||||
for name in SETUPS:
|
||||
if not guides.GUIDES[name].on_card:
|
||||
if not guides.platform_guides()[name].on_card:
|
||||
continue
|
||||
with self.subTest(setup=name):
|
||||
for command in COMMAND.findall(_plain_page(f"get/{name}.md")):
|
||||
self.assertIn("--dest ", command)
|
||||
|
||||
def test_no_tab_for_a_system_the_setup_does_not_run_from(self):
|
||||
labels = {key: entry[0] for key, entry in guides.TERMINALS.items()}
|
||||
labels = {key: entry[0] for key, entry in guides.terminals().items()}
|
||||
for name in SETUPS:
|
||||
if _with_zip(name):
|
||||
continue
|
||||
guide = guides.GUIDES[name]
|
||||
guide = guides.platform_guides()[name]
|
||||
allowed = {labels[key] for key in guide.run}
|
||||
allowed |= {labels[key] for key in guide.card_run or ("windows", "macos", "linux")}
|
||||
if guidepage._network_share(name, guide):
|
||||
@@ -938,7 +938,7 @@ class CheckNeedsTheFiles(unittest.TestCase):
|
||||
class ARouteWithoutANetwork(unittest.TestCase):
|
||||
def test_every_setup_page_has_the_offline_line_or_the_card_route(self):
|
||||
for name in SETUPS:
|
||||
guide = guides.GUIDES[name]
|
||||
guide = guides.platform_guides()[name]
|
||||
text = _guide_part(_plain_page(f"platforms/{name}.md"))
|
||||
with self.subTest(setup=name):
|
||||
if _with_zip(name):
|
||||
@@ -951,7 +951,7 @@ class ARouteWithoutANetwork(unittest.TestCase):
|
||||
|
||||
def test_every_device_setup_with_no_zip_links_the_card_answer(self):
|
||||
for name in SETUPS:
|
||||
guide = guides.GUIDES[name]
|
||||
guide = guides.platform_guides()[name]
|
||||
if _with_zip(name) or guide.run != ("device",):
|
||||
continue
|
||||
extract_to = REGISTRY[name]["extract_to"]
|
||||
@@ -968,7 +968,7 @@ class ARouteWithoutANetwork(unittest.TestCase):
|
||||
self.assertLess(text.index("## From a computer"), text.index("## On the device"))
|
||||
|
||||
def test_retropie_card_is_read_from_linux_only(self):
|
||||
self.assertEqual(guides.GUIDES["retropie"].card_run, ("linux",))
|
||||
self.assertEqual(guides.platform_guides()["retropie"].card_run, ("linux",))
|
||||
text = _plain_page("platforms/retropie.md")
|
||||
card = text.split("No network?", 1)[1].split("## On the device", 1)[0]
|
||||
# One system, so no tab bar: its label leads the command.
|
||||
@@ -981,7 +981,7 @@ class ARouteWithoutANetwork(unittest.TestCase):
|
||||
folder neither can open."""
|
||||
for name in ("lakka", "retropie"):
|
||||
with self.subTest(setup=name):
|
||||
self.assertEqual(guides.GUIDES[name].card_run, ("linux",))
|
||||
self.assertEqual(guides.platform_guides()[name].card_run, ("linux",))
|
||||
card = _plain_page(f"platforms/{name}.md").split("No network?", 1)[1]
|
||||
card = card.split("## On the device", 1)[0]
|
||||
self.assertEqual(_tab_labels(card), set())
|
||||
@@ -1039,7 +1039,7 @@ class GetPagesSayWhatTheyHold(unittest.TestCase):
|
||||
|
||||
class HandheldRowsSayWhere(unittest.TestCase):
|
||||
def test_retrooz_names_its_folder_with_a_pinned_source(self):
|
||||
system = next(s for s in guides.HANDHELD_GUIDE.systems if s.name == "RetroOZ")
|
||||
system = next(s for s in guides.handheld_guide().systems if s.name == "RetroOZ")
|
||||
self.assertIn("`/roms/bios`", system.folder)
|
||||
self.assertRegex(system.folder_source, r"/wiki/Home/[0-9a-f]{40}$")
|
||||
row = next(line for line in _plain_page("platforms/linux-handhelds.md").splitlines()
|
||||
@@ -1053,7 +1053,7 @@ class GetIndex(unittest.TestCase):
|
||||
for name in SETUPS:
|
||||
with self.subTest(setup=name):
|
||||
self.assertIn(f"(/retrobios/get/{name}/)", text)
|
||||
for label, _description in guides.DEVICE_GROUPS.values():
|
||||
for label, _description in guides.device_groups().values():
|
||||
self.assertIn(f"## {label}", text)
|
||||
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ from sitegen import whichpack
|
||||
from tests import sitepages
|
||||
from model.registry import list_registered_platforms, load_platform_registry
|
||||
from model.platforms import load_platform_config
|
||||
from model.guides import DEVICE_GROUPS, GROUP_ANCHORS, GUIDES
|
||||
from model.guides import device_groups, group_anchors, platform_guides
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||
|
||||
@@ -83,11 +83,11 @@ class EveryPlatformOnThePicker(unittest.TestCase):
|
||||
registry = load_platform_registry(str(REPO_ROOT / "platforms"))
|
||||
for key in _registered():
|
||||
with self.subTest(platform=key):
|
||||
self.assertIn(registry[key].get("device_group"), DEVICE_GROUPS)
|
||||
self.assertIn(key, GUIDES)
|
||||
self.assertIn(registry[key].get("device_group"), device_groups())
|
||||
self.assertIn(key, platform_guides())
|
||||
|
||||
def test_every_group_has_an_anchor(self):
|
||||
self.assertEqual(set(GROUP_ANCHORS), set(DEVICE_GROUPS))
|
||||
self.assertEqual(set(group_anchors()), set(device_groups()))
|
||||
|
||||
def test_every_platform_has_a_row(self):
|
||||
page = _which_pack()
|
||||
@@ -130,16 +130,16 @@ class EveryPlatformOnThePicker(unittest.TestCase):
|
||||
groups = {next(iter(item)): next(iter(item.values()))
|
||||
for item in setup if isinstance(item, dict)}
|
||||
for key in coverages:
|
||||
label = DEVICE_GROUPS[registry[key]["device_group"]][0]
|
||||
label = device_groups()[registry[key]["device_group"]][0]
|
||||
with self.subTest(platform=key):
|
||||
self.assertIn({coverages[key]["platform"]: f"platforms/{key}.md"}, groups[label])
|
||||
|
||||
def test_handheld_systems_that_run_retroarch_are_named(self):
|
||||
"""muOS, ArkOS and the rest are detected as RetroArch by the
|
||||
installer and were named on no page a user reads."""
|
||||
from model.guides import HANDHELD_GUIDE
|
||||
from model.guides import handheld_guide
|
||||
|
||||
page = guidepage.generate_handheld_guide(HANDHELD_GUIDE)
|
||||
page = guidepage.generate_handheld_guide(handheld_guide())
|
||||
self.assertIn("| muOS |", page)
|
||||
self.assertIn("`MUOS/bios` on the card", page)
|
||||
self.assertNotIn("| TrimUI |", page)
|
||||
|
||||
@@ -108,7 +108,7 @@ class WhereEachSystemFindsItsFile(unittest.TestCase):
|
||||
from sitegen import getpages
|
||||
from sitegen import guidepage
|
||||
|
||||
guide = guides.HANDHELD_GUIDE
|
||||
guide = guides.handheld_guide()
|
||||
self.assertEqual(handhelds.GROUP_PAGE, guide.page)
|
||||
with contextlib.chdir(REPO_ROOT):
|
||||
self.assertIn(f"(../get/{handhelds.GROUP_PAGE}.md)",
|
||||
|
||||
@@ -90,10 +90,10 @@ class PlatformLogos(unittest.TestCase):
|
||||
self.assertTrue(self.registry["minui"]["logo_flip"])
|
||||
|
||||
def test_every_logo_copy_has_a_registry_or_tile_logo(self):
|
||||
from model.guides import GROUP_TILES
|
||||
from model.guides import group_tiles
|
||||
|
||||
tiles = {re.sub(r"[^a-z0-9]+", "-", tile.name.lower()).strip("-"): tile.logo
|
||||
for group in GROUP_TILES.values() for tile in group}
|
||||
for group in group_tiles().values() for tile in group}
|
||||
sources = json.loads((REPO_ROOT / "docs_assets" / "logos" / "sources.json").read_text())
|
||||
for entry in sources["images"]:
|
||||
with self.subTest(platform=entry["platform"]):
|
||||
|
||||
@@ -43,7 +43,7 @@ from core import anchors as core_anchors
|
||||
from model.registry import list_registered_platforms, load_platform_registry
|
||||
from model.platforms import load_platform_config
|
||||
|
||||
from model.guides import DEVICE_GROUPS
|
||||
from model.guides import device_groups
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
@@ -82,7 +82,7 @@ def _index_anchors(markdown: str) -> set[str]:
|
||||
|
||||
|
||||
ANCHORS = {
|
||||
"platforms/index.md": {core_anchors.toc_slug(label) for label, _ in DEVICE_GROUPS.values()},
|
||||
"platforms/index.md": {core_anchors.toc_slug(label) for label, _ in device_groups().values()},
|
||||
"systems/index.md": {"consoles-and-computers"},
|
||||
"emulators/index.md": _index_anchors(emulatorsindex.generate_emulators_index({
|
||||
"duckstation": {"emulator": "DuckStation", "systems": ["sony-playstation"]},
|
||||
@@ -476,9 +476,10 @@ def _moved_platform_pages() -> list[Path]:
|
||||
return []
|
||||
# A guide page sits beside the setups (platforms/linux-handhelds) without
|
||||
# being a list moved off one of them.
|
||||
from model.guides import HANDHELD_GUIDE
|
||||
from model.guides import handheld_guide
|
||||
|
||||
guides = {Path(HANDHELD_GUIDE.path).stem} if HANDHELD_GUIDE else set()
|
||||
handhelds = handheld_guide()
|
||||
guides = {Path(handhelds.path).stem} if handhelds else set()
|
||||
return [path for path in sorted(folder.glob("*.md*"))
|
||||
if path.stem not in platforms and path.stem != "index" and path.stem not in guides]
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ from pathlib import Path
|
||||
from sitegen import diagrams
|
||||
from sitegen import entries as siteentries
|
||||
from sitegen import steps as sitesteps
|
||||
from model.guides import TERMINALS
|
||||
from model.guides import terminals
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
|
||||
@@ -166,7 +166,7 @@ class PageReadsOnce:
|
||||
for name, page in self.pages.items():
|
||||
text = _letters(page.text)
|
||||
for tab, (title, steps) in sitesteps.STEPS.items():
|
||||
prose = _letters(TERMINALS[tab][1])
|
||||
prose = _letters(terminals()[tab][1])
|
||||
with self.subTest(page=name, tab=tab):
|
||||
self.assertLessEqual(text.count(prose), 1)
|
||||
self.assertNotIn(_letters(title), text)
|
||||
|
||||
@@ -18,7 +18,7 @@ from pathlib import Path
|
||||
|
||||
from sitegen import diagrams
|
||||
from sitegen import steps as sitesteps
|
||||
from model.guides import TERMINALS
|
||||
from model.guides import terminals
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
|
||||
@@ -49,7 +49,7 @@ class EachDrawingNamesItsSteps(unittest.TestCase):
|
||||
|
||||
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("**", "")
|
||||
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:
|
||||
|
||||
@@ -46,7 +46,7 @@ from pathlib import Path
|
||||
import yaml
|
||||
|
||||
from sitegen import diagrams, ogcards, pageprep
|
||||
from model.guides import INSTALL_SH
|
||||
from model.guides import install_sh
|
||||
from tests import sitepages
|
||||
from installer_build import port
|
||||
from installer_build.module import installer_module
|
||||
@@ -133,7 +133,7 @@ class InstallCommandsHaveEveryForm(unittest.TestCase):
|
||||
def test_a_windows_path_replaces_the_unix_one(self):
|
||||
page = (
|
||||
"<!-- os-tabs windows: --platform retroarch --dest E:\\x -->\n```sh\n"
|
||||
f"curl -fsSL {INSTALL_SH} \\\n | sh -s -- --platform retroarch --dest /a/b\n```\n"
|
||||
f"curl -fsSL {install_sh()} \\\n | sh -s -- --platform retroarch --dest /a/b\n```\n"
|
||||
)
|
||||
text = pageprep.expand_commands(page)
|
||||
windows, rest = text.split('<TabItem label="macOS">', 1)
|
||||
@@ -1054,7 +1054,7 @@ class OsTabsTakeOptionsPerSystem(unittest.TestCase):
|
||||
"""The marker gives any tab its own options, and refuses words it cannot read."""
|
||||
|
||||
PAGE = ("<!-- os-tabs windows: --dest E:\\x macos: --dest /m steamdeck: --dest /d -->\n"
|
||||
f"```sh\ncurl -fsSL {INSTALL_SH} | sh -s -- --dest /l\n```\n")
|
||||
f"```sh\ncurl -fsSL {install_sh()} | sh -s -- --dest /l\n```\n")
|
||||
|
||||
def test_each_named_tab_uses_its_own(self):
|
||||
parts = re.split(r'<TabItem label="([^"]+)">', pageprep.expand_commands(self.PAGE))
|
||||
|
||||
Reference in new issue
Block a user