Files
libretro/tests/test_extract_targets.py
T
Abdessamad Derraz 4d3f589ef4 refactor: drop the archived platform status
RetroPie was the only platform with status: archived, which kept it out
of verify --all, slots, the pipeline and list_platforms unless
--include-archived was typed. release_pack already decides which packs a
release publishes and the installer serves every platform, so the status
set nothing apart. The field, its schema entry and the flag are gone, and
RetroPie is covered by every full run like any other platform.
2026-11-06 11:52:34 +01:00

82 lines
3.4 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 sys
import unittest
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(REPO_ROOT / "scripts"))
from common import load_platform_config, load_platform_registry # noqa: E402
from generate_readme import extract_notes, extract_targets # noqa: E402
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_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 = (REPO_ROOT / "scripts" / "generate_readme.py").read_text(encoding="utf-8")
site = (REPO_ROOT / "scripts" / "generate_site.py").read_text(encoding="utf-8")
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"
)
sys.path.insert(0, str(REPO_ROOT / "scripts"))
from siteguides import pack_manual # noqa: PLC0415
# 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")
self.assertEqual(first, "C:\\RetroBat\\bios")
self.assertIn("(default: C:\\RetroBat\\bios\\)", guide)
if __name__ == "__main__":
unittest.main()