mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-12-02 14:28:54 -06:00
model.guides took its platforms folder from the site's inputs, so a pack built with --platforms-dir printed the manual and install commands of the repository's guides. The loaders now take the folder (or the install address) explicitly; sitegen.guidedata binds them to the site's inputs, the pack README to the run's platforms folder, the release notes and the site validation to the folder they were given.
151 lines
6.4 KiB
Python
151 lines
6.4 KiB
Python
"""The README inside a pack sends files where the platform reads them.
|
|
|
|
RetroDECK's pack holds bios/ and roms/ at its root, and its guide said to
|
|
extract into ~/retrodeck/bios/, giving ~/retrodeck/bios/bios/. MiSTer and
|
|
ROCKNIX had no guide and were told "your BIOS directory", a folder MiSTer
|
|
does not have, while the registry names the path.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import tests
|
|
|
|
import re
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
import yaml
|
|
|
|
from packs.readme import build_readme
|
|
|
|
REPO_ROOT = Path(__file__).resolve().parents[1]
|
|
|
|
|
|
def _extract_lines(text: str) -> list[str]:
|
|
return [line for line in text.splitlines() if "Extract all files" in line]
|
|
|
|
|
|
class GuidesPointAtTheReadPath(unittest.TestCase):
|
|
def test_retrodeck_is_extracted_at_its_root(self):
|
|
text = build_readme("retrodeck", "RetroDECK", "", 1, 1)
|
|
for line in _extract_lines(text):
|
|
self.assertNotIn("retrodeck/bios", line)
|
|
|
|
def test_unguided_platforms_name_the_registry_path(self):
|
|
registry = yaml.safe_load((REPO_ROOT / "platforms" / "_registry.yml").read_text())
|
|
for name, data in registry["platforms"].items():
|
|
detect = (data.get("install", {}) or {}).get("detect", [])
|
|
if not any(d.get("bios_path") for d in detect):
|
|
continue
|
|
text = build_readme(name, name, "", 1, 1, detect=detect)
|
|
with self.subTest(platform=name):
|
|
self.assertFalse(
|
|
any("your BIOS directory" in line for line in _extract_lines(text))
|
|
)
|
|
|
|
|
|
class ACardOpenedOnAComputerShowsItsShareDrive(unittest.TestCase):
|
|
"""The SD card steps said /userdata/bios/ and /recalbox/share/bios/,
|
|
paths of the running system. On a computer the SHARE drive opens at its
|
|
root, bios/ beside roms/ and system/, and no such folder exists."""
|
|
|
|
def test_the_card_steps_name_the_drive_folder(self):
|
|
for name in ("batocera", "recalbox"):
|
|
text = build_readme(name, name, "", 1, 1)
|
|
card = text[text.index("Manual (SD card)"):]
|
|
card = card[:card.index("\n\n", card.index("1."))]
|
|
with self.subTest(platform=name):
|
|
self.assertIn("bios folder at the root of the SHARE drive", card)
|
|
self.assertNotIn("/userdata/bios/ on", card)
|
|
self.assertNotIn("Navigate to /recalbox", card)
|
|
|
|
|
|
class GuidesNameShippedInstallers(unittest.TestCase):
|
|
def test_every_installer_named_exists(self):
|
|
"""RetroBat's guide sent users to an install.bat no release carries."""
|
|
source = (REPO_ROOT / "scripts" / "packs" / "readme.py").read_text(encoding="utf-8")
|
|
for name in set(re.findall(r"install\.(?:bat|ps1|sh|py)", source)):
|
|
with self.subTest(installer=name):
|
|
self.assertTrue((REPO_ROOT / name).is_file())
|
|
|
|
def _registry() -> dict:
|
|
return yaml.safe_load((REPO_ROOT / "platforms" / "_registry.yml").read_text())
|
|
|
|
|
|
def _guide(name: str) -> str:
|
|
install = _registry()["platforms"][name].get("install") or {}
|
|
return build_readme(name, name, "", 1, 1, detect=install.get("detect", []),
|
|
standalone_copies=install.get("standalone_copies", []))
|
|
|
|
|
|
class TheOneLinerFollowsTheRegistry(unittest.TestCase):
|
|
"""The guides were written per platform by hand: ROCKNIX and MiSTer,
|
|
which the installer detects, had no one-line install, EmuDeck's
|
|
Windows edition was told to open Konsole, and every RomM user was sent
|
|
to library/bios/ whatever its firmware template."""
|
|
|
|
def test_every_detected_system_gets_its_command(self):
|
|
for name, data in _registry()["platforms"].items():
|
|
systems = {rule["os"] for rule in (data.get("install") or {}).get("detect", [])}
|
|
if not systems:
|
|
continue
|
|
text = _guide(name)
|
|
with self.subTest(platform=name):
|
|
self.assertEqual("/i | sh" in text, bool(systems - {"windows"}))
|
|
self.assertEqual("/i.ps1 | iex" in text, "windows" in systems)
|
|
|
|
def test_rocknix_and_mister_run_it_on_the_device(self):
|
|
for name in ("rocknix", "misterfpga"):
|
|
with self.subTest(platform=name):
|
|
self.assertIn(f"On the machine running {name}", _guide(name))
|
|
|
|
def test_emudeck_is_not_steam_deck_only(self):
|
|
text = _guide("emudeck")
|
|
self.assertNotIn("Steam Deck / Linux", text)
|
|
self.assertNotIn("Konsole", text)
|
|
self.assertIn("/i.ps1 | iex", text)
|
|
self.assertIn("C:\\Emulation\\bios", text)
|
|
self.assertIn("--standalone-copies", text)
|
|
|
|
def test_romm_names_both_firmware_layouts(self):
|
|
text = _guide("romm")
|
|
self.assertIn("library/bios/", text)
|
|
self.assertIn("library/psx/bios/", text)
|
|
self.assertIn("--romm-firmware", text)
|
|
|
|
def test_the_commands_are_written_once(self):
|
|
"""The address comes from install_base in platforms/_guides.yml, and
|
|
the one-liner from install_command, the ones the site's commands use."""
|
|
from sitegen.guidedata import install_command
|
|
|
|
source = (REPO_ROOT / "scripts" / "packs" / "readme.py").read_text(encoding="utf-8")
|
|
for spelled in ("raw.githubusercontent.com", "abdess.github.io", "curl -fsSL",
|
|
"scriptblock", "| iex"):
|
|
self.assertNotIn(spelled, source)
|
|
text = build_readme("retroarch", "RetroArch", "system", 1, 1,
|
|
detect=[{"os": "linux"}, {"os": "windows"}])
|
|
self.assertIn(install_command("sh"), text)
|
|
self.assertIn(install_command("powershell"), text)
|
|
self.assertIn(install_command(
|
|
"powershell", "--platform retroarch --from-pack C:\\path\\to\\pack.zip"), text)
|
|
|
|
|
|
class GuidesInstallFromTheZipInHand(unittest.TestCase):
|
|
"""Option A sent a user holding the ZIP to the one-liner, which downloads
|
|
every file again. --from-pack installs from the archive itself."""
|
|
|
|
def test_every_automatic_guide_names_from_pack(self):
|
|
for name, data in _registry()["platforms"].items():
|
|
detect = (data.get("install", {}) or {}).get("detect", [])
|
|
if not detect:
|
|
continue
|
|
text = build_readme(name, name, "", 1, 1, detect=detect)
|
|
if "Option A: Automatic" not in text:
|
|
continue
|
|
with self.subTest(platform=name):
|
|
self.assertIn(f"--platform {name} --from-pack ", text)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|