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.
97 lines
4.0 KiB
Python
97 lines
4.0 KiB
Python
"""Where a pack extracts is read from the registry, by the README and the site.
|
|
|
|
Both kept a hand table keyed by display name. RomM's row said
|
|
`bios/{platform_slug}/` while the pack already carries one folder per slug
|
|
at its root, so following it nested every file one level too deep. The
|
|
README's RetroDECK sentence sat inside a block about RetroPie and would
|
|
have vanished with it.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import tests
|
|
from tests.sources import script_source
|
|
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
from model.platforms import load_platform_config
|
|
from model.registry import load_platform_registry
|
|
from sitegen.extraction import extract_notes, extract_targets, own_root_packs
|
|
|
|
REPO_ROOT = Path(__file__).resolve().parent.parent
|
|
|
|
PLATFORMS = str(REPO_ROOT / "platforms")
|
|
|
|
|
|
class ExtractTargets(unittest.TestCase):
|
|
def test_every_registered_platform_says_where_it_extracts(self):
|
|
registry = load_platform_registry(PLATFORMS)
|
|
missing = sorted(k for k, v in registry.items() if not v.get("extract_to"))
|
|
self.assertEqual(missing, [])
|
|
self.assertEqual(len(extract_targets(PLATFORMS)), len(registry))
|
|
|
|
def test_a_folder_names_no_placeholder(self):
|
|
"""The pack lays out the per-system folders itself."""
|
|
templated = [d for d, folder in extract_targets(PLATFORMS) if "{" in folder]
|
|
self.assertEqual(templated, [])
|
|
|
|
def test_a_pack_with_its_own_root_is_explained(self):
|
|
rooted = sorted(
|
|
load_platform_config(key, PLATFORMS).get("platform", key)
|
|
for key in load_platform_registry(PLATFORMS)
|
|
if load_platform_config(key, PLATFORMS).get("base_destination") == ""
|
|
)
|
|
explained = sorted(
|
|
display for display in rooted
|
|
if any(note.startswith(f"The {display} pack") for note in extract_notes(PLATFORMS))
|
|
)
|
|
self.assertTrue(rooted)
|
|
self.assertEqual(explained, rooted)
|
|
|
|
def test_guide_and_which_pack_unzip_the_same_packs(self):
|
|
"""The guide's notes and the which-pack rows chose the packs with two
|
|
copies of one rule: both now format from own_root_packs."""
|
|
from sitegen import whichpack
|
|
|
|
packs = own_root_packs(PLATFORMS)
|
|
rows = whichpack._own_root_folders(load_platform_registry(PLATFORMS))
|
|
self.assertEqual(rows, {key: folder for key, (_root, folder) in packs.items()})
|
|
notes = extract_notes(PLATFORMS)
|
|
self.assertEqual(len(notes), len(packs))
|
|
for note, (root, folder) in zip(notes, packs.values()):
|
|
self.assertIn(f"`{root}/`", note)
|
|
self.assertTrue(note.endswith(f"Unzip it into `{folder}`."))
|
|
|
|
def test_no_generator_keeps_its_own_table(self):
|
|
"""The which-pack page describes setups per OS, and these two were the
|
|
per-platform copies of the registry."""
|
|
readme = script_source("generate_readme.py")
|
|
site = script_source("generate_site.py")
|
|
self.assertNotIn('"RetroDECK": "`~/retrodeck/`"', readme)
|
|
self.assertNotIn('" | RetroDECK | `~/retrodeck/` |"', site)
|
|
|
|
|
|
class ThePackGuideNamesTheInstallerDefault(unittest.TestCase):
|
|
"""The pack README, the registry and install.py each wrote RetroBat's
|
|
default folder by hand, and two of the three said the home directory
|
|
where the installer (installer.iss) says C:\\RetroBat."""
|
|
|
|
def test_retrobat_guide_matches_the_registry(self):
|
|
registry = load_platform_registry(PLATFORMS)
|
|
first = next(
|
|
rule["path"] for rule in registry["retrobat"]["install"]["detect"]
|
|
if rule["os"] == "windows" and rule["method"] == "path_exists"
|
|
)
|
|
from model.guides import pack_manual
|
|
|
|
# The pack guide text is data (platforms/_guides.yml): read what the
|
|
# pack README prints, not the source of the script that prints it.
|
|
guide = pack_manual("retrobat", PLATFORMS)
|
|
self.assertEqual(first, "C:\\RetroBat\\bios")
|
|
self.assertIn("(default: C:\\RetroBat\\bios\\)", guide)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|