mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-27 20:08:51 -06:00
chore: merge origin/main
# Conflicts: # install.ps1 # install.sh # install/launchers/index.json # wiki/testing-guide.md
This commit is contained in:
commit
733b059712
377 files changed
+339375
-53793
No files matched your search
@@ -13,4 +13,18 @@
|
||||
<extension>.zip</extension>
|
||||
<command label="MAME">%EMULATOR_RETROARCH% -L %CORE_RETROARCH%/mame_libretro.so %ROM%</command>
|
||||
</system>
|
||||
<system>
|
||||
<name>tanodragon</name>
|
||||
<path>%ROMPATH%/tanodragon</path>
|
||||
<extension>.cas .CAS</extension>
|
||||
<command label="MAME [Tape] (Standalone)">%EMULATOR_MAME% -rompath %GAMEDIR%\;%ROMPATH%/dragon32 tanodr64 -cass %ROM%</command>
|
||||
<!-- <command label="MAME Legacy (Standalone)">%EMULATOR_MAME% -rompath %GAMEDIR%\;%ROMPATH%/tanodragon tanodr64 -cass %ROM%</command> -->
|
||||
</system>
|
||||
<system>
|
||||
<name>arcade</name>
|
||||
<path>%ROMPATH%/arcade</path>
|
||||
<extension>.zip .ZIP</extension>
|
||||
<command label="MAME - Current">%EMULATOR_RETROARCH% -L %CORE_RETROARCH%/mame_libretro.so "%BASENAME% -rompath \"%GAMEDIRRAW%;%ROMPATH%/arcade\""</command>
|
||||
<command label="MAME (Standalone)">%EMULATOR_MAME% -rompath %GAMEDIR%\;%ROMPATH%/arcade %BASENAME%</command>
|
||||
</system>
|
||||
</systemList>
|
||||
@@ -55,6 +55,96 @@ class AgnosticScan(unittest.TestCase):
|
||||
["pcsx2/bios/scph1.bin", "pcsx2/bios/scph2.bin"])
|
||||
|
||||
|
||||
def test_a_placeholder_scans_the_folder_another_profile_proves(self):
|
||||
"""LRPS2 and PCEE2 name their BIOS <bios>.bin, which resolves nowhere.
|
||||
|
||||
On RetroArch yaps2 anchored pcsx2/bios/ for them. On Batocera no
|
||||
other libretro PS2 core runs, and the pack held nothing there. The
|
||||
folder where another profile of the system resolves a hashed dump of
|
||||
that shape is the evidence, that folder only.
|
||||
"""
|
||||
from packextras import _agnostic_scan_extras
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
previous = os.getcwd()
|
||||
os.chdir(tmp)
|
||||
self.addCleanup(os.chdir, previous)
|
||||
files, by_name = {}, {}
|
||||
for path, data in (
|
||||
("bios/PS2/scph1.bin", b"a" * 64),
|
||||
("bios/PS2/scph2.bin", b"b" * 64),
|
||||
("bios/PS2/scph2.bin.rom1", b"r" * 8),
|
||||
("bios/PS2/scph1.nvm", b"n" * 8),
|
||||
("bios/PS2/.variants/scph3.bin", b"e" * 64),
|
||||
("bios/PS2/DVD/dvd.bin", b"f" * 64),
|
||||
):
|
||||
Path(path).parent.mkdir(parents=True, exist_ok=True)
|
||||
Path(path).write_bytes(data)
|
||||
sha1 = hashlib.sha1(data).hexdigest()
|
||||
name = path.rsplit("/", 1)[1]
|
||||
files[sha1] = {"path": path, "name": name, "size": len(data), "sha1": sha1}
|
||||
by_name.setdefault(name, []).append(sha1)
|
||||
db = {"files": files, "indexes": {"by_name": by_name, "by_md5": {}, "by_crc32": {},
|
||||
"by_path_suffix": {}}}
|
||||
placeholders = {"emulator": "L", "type": "libretro", "bios_mode": "agnostic",
|
||||
"bios_directory": "pcsx2/bios/", "systems": ["ps2"], "files": [
|
||||
{"name": "<bios>.bin", "found_by": "content",
|
||||
"path": "pcsx2/bios/<bios>.bin", "min_size": 32, "max_size": 64},
|
||||
{"name": "<bios>.rom1", "path": "pcsx2/bios/<bios>.rom1"},
|
||||
{"name": "<bios>.nvm", "path": "pcsx2/bios/<bios>.nvm", "size": 8},
|
||||
]}
|
||||
pinned = {"emulator": "S", "type": "standalone", "systems": ["ps2"], "files": [
|
||||
{"name": "scph1.bin", "size": 64,
|
||||
"sha1": hashlib.sha1(b"a" * 64).hexdigest()},
|
||||
]}
|
||||
extras = _agnostic_scan_extras(
|
||||
{"l": placeholders, "s": pinned}, {"l"}, db, by_name, set(), "")
|
||||
self.assertEqual(sorted(e["destination"] for e in extras), [
|
||||
"pcsx2/bios/scph1.bin", "pcsx2/bios/scph1.nvm", "pcsx2/bios/scph2.bin",
|
||||
"pcsx2/bios/scph2.bin.rom1",
|
||||
])
|
||||
self.assertTrue(all(e["source_profile"] == "l" for e in extras))
|
||||
# An image the platform already ships there still gets its
|
||||
# companion: RetroBat lists pcsx2/bios/scph39001.bin itself.
|
||||
shipped = {"pcsx2/bios/scph1.bin"}
|
||||
extras = _agnostic_scan_extras(
|
||||
{"l": placeholders, "s": pinned}, {"l"}, db, by_name, shipped, "")
|
||||
self.assertIn("pcsx2/bios/scph1.nvm", {e["destination"] for e in extras})
|
||||
# Nothing proves the folder: nothing is scanned.
|
||||
self.assertEqual(
|
||||
_agnostic_scan_extras({"l": placeholders}, {"l"}, db, by_name, set(), ""), [])
|
||||
|
||||
|
||||
class OneContentTwoPaths(unittest.TestCase):
|
||||
"""A standalone copy reads one file the manifest carries at two paths.
|
||||
|
||||
The libretro PS2 cores put DuckStation's ps2_scph50006.bin under
|
||||
pcsx2/bios/ beside the BIOS root copy, and the copy into DuckStation's
|
||||
folder was dropped as ambiguous on Batocera, Recalbox and RetroBat.
|
||||
"""
|
||||
|
||||
DUCK = {"data_root": {"linux": {"path": "~/.local/share/duckstation", "source_ref": "x"}},
|
||||
"files": [{"name": "ps2_scph50006.bin", "standalone_path": "bios/ps2_scph50006.bin"}]}
|
||||
|
||||
def _copies(self, entries):
|
||||
from generate_pack import _profile_copies
|
||||
|
||||
return _profile_copies({"duckstation": self.DUCK}, list(entries), [], entries)
|
||||
|
||||
def test_same_bytes_take_the_copy_that_serves_the_emulator(self):
|
||||
(copy,) = self._copies({
|
||||
"pcsx2/bios/ps2_scph50006.bin": {"sha1": "a", "cores": ["lrps2"]},
|
||||
"ps2_scph50006.bin": {"sha1": "a", "cores": ["duckstation", "pcsx2"]},
|
||||
})
|
||||
self.assertEqual(copy["file"], "ps2_scph50006.bin")
|
||||
|
||||
def test_other_bytes_under_one_name_designate_nothing(self):
|
||||
self.assertEqual(self._copies({
|
||||
"pcsx2/bios/ps2_scph50006.bin": {"sha1": "a", "cores": ["lrps2"]},
|
||||
"ps2_scph50006.bin": {"sha1": "b", "cores": ["duckstation"]},
|
||||
}), [])
|
||||
|
||||
|
||||
class BundledHashIsProof(unittest.TestCase):
|
||||
"""A bundled file with a declared hash is served by those bytes or flagged.
|
||||
|
||||
|
||||
@@ -52,6 +52,11 @@ class ListxmlIndex(unittest.TestCase):
|
||||
def test_device_with_roms_only(self) -> None:
|
||||
self.assertEqual(self.index["devices"], {"m68705p3": ["mslug"]})
|
||||
|
||||
def test_a_clone_lists_its_parent_game(self) -> None:
|
||||
# MAME looks a clone's shared ROMs up in its parent's archive
|
||||
# (src/emu/driver.cpp:31-38): mslugh reads mslug.zip.
|
||||
self.assertEqual(self.index["parents"], {"mslug": ["mslugh"]})
|
||||
|
||||
def test_chd_and_missing_parent(self) -> None:
|
||||
self.assertEqual(self.index["chd"], ["ikaruga"])
|
||||
self.assertEqual(self.index["missing_parents"], {"orphan": "gonebios"})
|
||||
|
||||
@@ -160,5 +160,56 @@ class APlatformsOwnBuildWinsItsName(unittest.TestCase):
|
||||
self.assertEqual(resolve_platform_cores(retropie, profiles), {"uae4all"})
|
||||
|
||||
|
||||
class APatchedLibretroBuildTakesItsNameOnly(unittest.TestCase):
|
||||
"""Batocera and Recalbox compile LRPS2 with a patch that reads the BIOS
|
||||
from ps2/ instead of pcsx2/bios/. Their own build replaces the buildbot
|
||||
LRPS2 under the name they ship, and Batocera's standalone PCSX2, under
|
||||
the same name, stays."""
|
||||
|
||||
def test_own_libretro_build_keeps_the_standalone_of_a_dual_name(self):
|
||||
from common import resolve_platform_cores
|
||||
|
||||
profiles = {
|
||||
"pcsx2": {"type": "standalone", "source": "s", "cores": ["pcsx2"]},
|
||||
"lrps2": {"type": "libretro", "source": "l", "cores": ["lrps2", "pcsx2"]},
|
||||
"lrps2-own": {"type": "libretro", "source": "l", "cores": ["pcsx2"],
|
||||
"built_by": ["x"]},
|
||||
}
|
||||
config = {"_key": "x", "cores": ["pcsx2"], "standalone_cores": ["pcsx2"],
|
||||
"dual_mode_cores": ["pcsx2"]}
|
||||
self.assertEqual(resolve_platform_cores(config, profiles), {"pcsx2", "lrps2-own"})
|
||||
del config["dual_mode_cores"]
|
||||
self.assertEqual(resolve_platform_cores(config, profiles), {"lrps2-own"})
|
||||
|
||||
def test_the_registry_resolves_each_platform_build(self):
|
||||
from common import load_emulator_profiles, load_platform_config, resolve_platform_cores
|
||||
|
||||
profiles = load_emulator_profiles(str(REPO_ROOT / "emulators"))
|
||||
platforms = str(REPO_ROOT / "platforms")
|
||||
|
||||
def ps2_cores(platform: str) -> set[str]:
|
||||
config = load_platform_config(platform, platforms)
|
||||
return {
|
||||
c for c in resolve_platform_cores(config, profiles)
|
||||
if c.startswith(("lrps2", "pcsx2", "pcee2"))
|
||||
}
|
||||
|
||||
self.assertEqual(ps2_cores("batocera"), {"lrps2-416291a", "pcsx2", "pcee2"})
|
||||
# Recalbox ships two libretro PS2 builds on x86_64: LRPS2 as ps2 and
|
||||
# the wxWidgets-era libretro PCSX2 as pcsx2, beside standalone PCSX2.
|
||||
self.assertEqual(
|
||||
ps2_cores("recalbox"), {"lrps2-9485a53", "pcsx2-libretro-408e3b2", "pcsx2"}
|
||||
)
|
||||
own_builds = {"lrps2-416291a", "lrps2-9485a53", "pcsx2-libretro-408e3b2"}
|
||||
for platform in ("retroarch", "retrobat", "emudeck", "retrodeck"):
|
||||
with self.subTest(platform=platform):
|
||||
cores = ps2_cores(platform)
|
||||
self.assertIn("lrps2", cores)
|
||||
self.assertFalse(own_builds & cores)
|
||||
self.assertNotIn("pcsx2-libretro-408e3b2", ps2_cores("batocera"))
|
||||
for name in sorted(own_builds):
|
||||
self.assertEqual(profiles[name]["files"][0]["path"], "ps2/<bios>.bin")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -79,7 +79,9 @@ class Companions(unittest.TestCase):
|
||||
}
|
||||
stored = {
|
||||
"ps2-0230a-20080220.bin": b"I" * 8,
|
||||
"SCPH-70004.BIN": b"B" * 8,
|
||||
"SCPH-70004.ROM1": b"R" * 6,
|
||||
"246C.ROM1": b"N" * 3,
|
||||
"cheats_ws.zip": b"Z",
|
||||
"GameIndex.yaml": b"Y",
|
||||
}
|
||||
@@ -107,6 +109,58 @@ class Companions(unittest.TestCase):
|
||||
names = {e["destination"] for e in extras}
|
||||
self.assertIn("SCPH-70004.rom1", names)
|
||||
self.assertFalse({"SCPH-70004.ROM1", "cheats_ws.zip", "GameIndex.yaml"} & names)
|
||||
# Read beside the image the core selected only: no 246C image here.
|
||||
self.assertNotIn("246C.rom1", names)
|
||||
|
||||
def test_a_shared_image_brings_each_cores_companions(self):
|
||||
"""Recalbox runs LRPS2 and the old libretro PCSX2 on one ps2/ folder.
|
||||
LRPS2's scan placed SCPH-70004.BIN and its rom1, and the second core's
|
||||
scan stopped at the taken image, so the .erom only it reads stayed out."""
|
||||
import os
|
||||
import tempfile
|
||||
|
||||
from packextras import _agnostic_scan_extras
|
||||
|
||||
def profile(name: str, ext: str) -> dict:
|
||||
return {"emulator": name, "bios_mode": "agnostic", "files": [
|
||||
{"name": "ps2-0230a-20080220.bin", "found_by": "content",
|
||||
"path": "ps2/ps2-0230a-20080220.bin", "min_size": 8, "max_size": 16},
|
||||
{"name": f"ps2-0230a-20080220.{ext}", "path": f"ps2/ps2-0230a-20080220.{ext}"},
|
||||
]}
|
||||
|
||||
stored = {
|
||||
"ps2-0230a-20080220.bin": b"I" * 8,
|
||||
"ps2-0230a-20080220.rom1": b"R",
|
||||
"ps2-0230a-20080220.erom": b"E",
|
||||
}
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
cwd = os.getcwd()
|
||||
os.chdir(tmp)
|
||||
try:
|
||||
files, by_name = {}, {}
|
||||
for name, payload in stored.items():
|
||||
path = f"bios/PS2/{name}"
|
||||
os.makedirs("bios/PS2", exist_ok=True)
|
||||
Path(path).write_bytes(payload)
|
||||
sha1 = f"{len(files):040d}"
|
||||
files[sha1] = {"path": path, "name": name, "size": len(payload),
|
||||
"sha1": sha1}
|
||||
by_name[name] = [sha1]
|
||||
db = {"files": files, "indexes": {
|
||||
"by_name": by_name, "by_md5": {}, "by_crc32": {}, "by_path_suffix": {},
|
||||
}}
|
||||
profiles = {"a": profile("A", "rom1"), "b": profile("B", "erom")}
|
||||
extras = _agnostic_scan_extras(
|
||||
profiles, {"a", "b"}, db, by_name, set(), "", taken={},
|
||||
)
|
||||
finally:
|
||||
os.chdir(cwd)
|
||||
placed = [(e["destination"], e["source_profile"]) for e in extras]
|
||||
self.assertEqual(sorted(placed), [
|
||||
("ps2/ps2-0230a-20080220.bin", "a"),
|
||||
("ps2/ps2-0230a-20080220.erom", "b"),
|
||||
("ps2/ps2-0230a-20080220.rom1", "a"),
|
||||
])
|
||||
|
||||
def test_pcsx2_profiles_name_no_free_standing_companion(self):
|
||||
for name in ("pcsx2", "pcsx2-legacy"):
|
||||
|
||||
+16
-14
@@ -15,6 +15,7 @@ from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "scripts"))
|
||||
|
||||
import build_port # noqa: E402
|
||||
from check_release import SIGNATURE, SUMS, Asset, compare_release, parse_sums
|
||||
|
||||
A = "a" * 64
|
||||
@@ -97,20 +98,21 @@ class ReleaseMatchesWhatWasBuilt(unittest.TestCase):
|
||||
self.assertIn(("unrecorded", "Other_BIOS_Pack.zip"), kinds)
|
||||
self.assertIn(("missing", "Other_BIOS_Pack.zip"), kinds)
|
||||
|
||||
def test_the_handheld_port_is_vouched_for_by_the_checksum_list(self):
|
||||
sums = {**SUMS_LIST, "RetroBIOS.zip": A}
|
||||
assets = _assets()
|
||||
self.assertEqual(
|
||||
_kinds(compare_release(RECORD, sums, assets, "v2026.10.10")),
|
||||
{("missing", "RetroBIOS.zip")},
|
||||
)
|
||||
assets["RetroBIOS.zip"] = Asset(70, A)
|
||||
self.assertEqual(compare_release(RECORD, sums, assets, "v2026.10.10"), [])
|
||||
assets["RetroBIOS.zip"] = Asset(70, B)
|
||||
self.assertEqual(
|
||||
_kinds(compare_release(RECORD, sums, assets, "v2026.10.10")),
|
||||
{("content", "RetroBIOS.zip")},
|
||||
)
|
||||
def test_a_handheld_launcher_is_no_release_file(self):
|
||||
"""The site serves the launchers built from its own commit: one in
|
||||
the checksum list or among the assets is refused."""
|
||||
for name in build_port.ARCHIVES:
|
||||
with self.subTest(name=name):
|
||||
sums = {**SUMS_LIST, name: A}
|
||||
assets = _assets()
|
||||
assets[name] = Asset(70, A)
|
||||
self.assertEqual(_kinds(compare_release(RECORD, sums, assets, "v2026.10.10")),
|
||||
{("unrecorded", name)})
|
||||
assets = _assets()
|
||||
assets[name] = Asset(70, A)
|
||||
self.assertEqual(
|
||||
_kinds(compare_release(RECORD, SUMS_LIST, assets, "v2026.10.10")),
|
||||
{("extra", name)})
|
||||
|
||||
def test_parts_must_add_up_to_the_printed_download_size(self):
|
||||
assets = _assets()
|
||||
|
||||
@@ -0,0 +1,322 @@
|
||||
"""Content tests a profile declares, run the way the emulator runs them.
|
||||
|
||||
The PCSX2 family lists every file of its BIOS folder whose ROM directory
|
||||
holds RESET and ROMVER, whatever its name and, in most forks, its size. A
|
||||
4 to 8 MB bound stood in for that test on Recalbox's libretro PCSX2: it
|
||||
dropped the 2 MB System 246 image the core lists and let the scan carry
|
||||
.nvm and .mec files that sit beside no image. Amiberry names a flash image
|
||||
by the SHA-1 of its bytes with the board configuration cleared, xemu maps
|
||||
any flash image whose size is a whole number of 64 KiB.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
|
||||
|
||||
import hashlib
|
||||
import struct
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||
sys.path.insert(0, str(REPO_ROOT / "scripts"))
|
||||
|
||||
import common # noqa: E402
|
||||
import generate_pack as builder # noqa: E402
|
||||
import packextras # noqa: E402
|
||||
from romdir import romdir_accepts, walk # noqa: E402
|
||||
from validation import _build_validation_index, check_file_validation # noqa: E402
|
||||
|
||||
# How each fork reads the table, as the profiles declare it.
|
||||
WX = {"reset_compare": 5, "missing_reset": "rejects", "terminated_names": False,
|
||||
"extinfo": False, "unreadable_romver": "rejects", "truncated_walk": "rejects",
|
||||
"offset_width": 32}
|
||||
AETHER = {"reset_compare": 5, "missing_reset": "ends_walk", "terminated_names": False,
|
||||
"extinfo": False, "unreadable_romver": "ignored", "truncated_walk": "ends_walk"}
|
||||
CLASSIC = {"reset_compare": 10, "missing_reset": "ends_walk", "terminated_names": True,
|
||||
"extinfo": False, "unreadable_romver": "ends_walk", "truncated_walk": "ends_walk"}
|
||||
MODERN = {"reset_compare": 10, "missing_reset": "ends_walk", "terminated_names": True,
|
||||
"extinfo": True, "unreadable_romver": "ends_walk", "truncated_walk": "ends_walk"}
|
||||
FORKS = {"wx": WX, "aether": AETHER, "classic": CLASSIC, "modern": MODERN}
|
||||
|
||||
ROMDIR_AT = 0x2700 # where retail images keep the table, inside RESET
|
||||
|
||||
|
||||
def entry(name: bytes, size: int) -> bytes:
|
||||
return name.ljust(10, b"\x00")[:10] + struct.pack("<HI", 0, size)
|
||||
|
||||
|
||||
def image(
|
||||
entries: list[tuple[bytes, int]] | None = None,
|
||||
romver: bytes = b"0230AC20080220",
|
||||
serial: bytes = b"20080220-000000",
|
||||
terminator: bool = True,
|
||||
tail: int = 0x100,
|
||||
) -> bytes:
|
||||
"""A BIOS laid out as a retail one: the table at 0x2700 inside RESET,
|
||||
then ROMDIR, EXTINFO and ROMVER, each file at the sum of the sizes
|
||||
before it rounded to 16 bytes."""
|
||||
if entries is None:
|
||||
entries = [(b"RESET", ROMDIR_AT), (b"ROMDIR", 0x50), (b"EXTINFO", 0x30), (b"ROMVER", 0x10)]
|
||||
table = b"".join(entry(n, s) for n, s in entries) + (entry(b"", 0) if terminator else b"")
|
||||
offsets, offset = {}, 0
|
||||
for name, size in entries:
|
||||
offsets[name] = offset
|
||||
offset += size if size % 16 == 0 else (size + 16) & 0xFFFFFFF0
|
||||
end = max(ROMDIR_AT + len(table), min(offset, 1 << 20)) + tail
|
||||
data = bytearray(end)
|
||||
data[ROMDIR_AT:ROMDIR_AT + len(table)] = table
|
||||
for name, payload, skip in ((b"EXTINFO", serial, 0x10), (b"ROMVER", romver, 0)):
|
||||
at = offsets.get(name, 1 << 40) + skip
|
||||
if at + len(payload) <= len(data):
|
||||
data[at:at + len(payload)] = payload
|
||||
return bytes(data)
|
||||
|
||||
|
||||
class RomdirWalk(unittest.TestCase):
|
||||
def test_a_retail_layout_passes_every_fork(self):
|
||||
data = image()
|
||||
for fork, spec in FORKS.items():
|
||||
with self.subTest(fork=fork):
|
||||
found = walk(data, spec)
|
||||
self.assertIsNotNone(found)
|
||||
self.assertEqual(found.romver, b"0230AC20080220")
|
||||
self.assertEqual(walk(data, MODERN).serial, "20080220-000000")
|
||||
|
||||
def test_a_file_without_romver_fails_every_fork(self):
|
||||
data = image([(b"RESET", ROMDIR_AT), (b"ROMDIR", 0x40), (b"EXTINFO", 0x30)])
|
||||
for fork, spec in FORKS.items():
|
||||
with self.subTest(fork=fork):
|
||||
self.assertFalse(romdir_accepts(data, spec))
|
||||
self.assertFalse(romdir_accepts(b"\x00" * 0x4000, MODERN))
|
||||
self.assertFalse(romdir_accepts(b"", MODERN))
|
||||
|
||||
def test_reset_compare_is_the_strncmp_length(self):
|
||||
"""strncmp(name, "RESET", 5) in the wxWidgets and AetherSX2 code takes
|
||||
RESETX, sizeof(fileName) wants RESET and a NUL."""
|
||||
data = image([(b"RESETX", ROMDIR_AT), (b"ROMDIR", 0x40), (b"ROMVER", 0x10)])
|
||||
self.assertTrue(romdir_accepts(data, WX))
|
||||
self.assertTrue(romdir_accepts(data, AETHER))
|
||||
self.assertFalse(romdir_accepts(data, MODERN))
|
||||
|
||||
def test_a_name_without_nul_ends_the_later_walk(self):
|
||||
data = image([(b"RESET", ROMDIR_AT), (b"ABCDEFGHIJ", 0x100), (b"ROMVER", 0x10)])
|
||||
self.assertTrue(romdir_accepts(data, WX))
|
||||
self.assertTrue(romdir_accepts(data, AETHER))
|
||||
self.assertFalse(romdir_accepts(data, CLASSIC))
|
||||
self.assertFalse(romdir_accepts(data, MODERN))
|
||||
|
||||
def test_romver_past_the_end_of_the_file(self):
|
||||
"""AetherSX2 zero-fills the 14 bytes and counts ROMVER found, the
|
||||
wxWidgets stream throws, the later code ends the walk."""
|
||||
data = image([(b"RESET", ROMDIR_AT), (b"ROMDIR", 0x200000), (b"ROMVER", 0x10)])
|
||||
self.assertTrue(romdir_accepts(data, AETHER))
|
||||
self.assertFalse(romdir_accepts(data, WX))
|
||||
self.assertFalse(romdir_accepts(data, CLASSIC))
|
||||
|
||||
def test_an_unreadable_extinfo_ends_the_walk_before_romver(self):
|
||||
data = image([(b"RESET", ROMDIR_AT), (b"ROMDIR", 0x200000), (b"EXTINFO", 0x30),
|
||||
(b"ROMVER", 0x10)])
|
||||
self.assertFalse(romdir_accepts(data, MODERN))
|
||||
self.assertTrue(romdir_accepts(data, AETHER))
|
||||
|
||||
def test_a_table_that_runs_off_the_file(self):
|
||||
"""Without the zero entry the next read fails: the wxWidgets stream
|
||||
throws, the later code keeps the ROMVER it met."""
|
||||
data = image([(b"RESET", 0x10), (b"ROMVER", 0x10)], terminator=False, tail=0)
|
||||
self.assertEqual(len(data), ROMDIR_AT + 2 * 16)
|
||||
self.assertTrue(romdir_accepts(data, MODERN))
|
||||
self.assertFalse(romdir_accepts(data, WX))
|
||||
|
||||
def test_the_wx_offset_is_a_32_bit_uint(self):
|
||||
wrap = (1 << 32) - ROMDIR_AT - 0x50
|
||||
data = image([(b"RESET", ROMDIR_AT), (b"ROMDIR", 0x50), (b"PAD", wrap), (b"ROMVER", 0x10)])
|
||||
romver_at = 0
|
||||
data = bytearray(data)
|
||||
data[romver_at:romver_at + 14] = b"0230AC20080220"
|
||||
self.assertTrue(romdir_accepts(bytes(data), WX))
|
||||
self.assertFalse(romdir_accepts(bytes(data), {**WX, "offset_width": 64}))
|
||||
|
||||
def test_512_ki_entries_without_reset(self):
|
||||
"""The later loop just ends and walks on from the last entry it read,
|
||||
the wxWidgets code throws."""
|
||||
data = bytearray(512 * 1024 * 16)
|
||||
data[-16:] = entry(b"ROMVER", 0x10)
|
||||
data[0:14] = b"0230AC20080220"
|
||||
self.assertTrue(romdir_accepts(bytes(data), MODERN))
|
||||
self.assertFalse(romdir_accepts(bytes(data), WX))
|
||||
|
||||
def test_serial_and_zone_tests(self):
|
||||
coh = image(romver=b"0100TZ20000306", serial=b"20040519-145634")
|
||||
stamp = image(serial=b"20111012-094243")
|
||||
self.assertTrue(romdir_accepts(coh, {**MODERN, "zones": ["TZ"]}))
|
||||
self.assertFalse(romdir_accepts(image(), {**MODERN, "zones": ["TZ"]}))
|
||||
self.assertFalse(romdir_accepts(coh, {**MODERN, "refused_zones": ["TZ"]}))
|
||||
self.assertTrue(romdir_accepts(image(romver=b"0100TC20000306"),
|
||||
{**MODERN, "refused_zones": ["TZ"]}))
|
||||
self.assertFalse(romdir_accepts(stamp, {**MODERN, "refused_serials": ["20111012-094243"]}))
|
||||
|
||||
def test_every_pcsx2_profile_declares_its_walk(self):
|
||||
"""A content-found PS2 image without its walk would be judged by the
|
||||
defaults, not by what its fork does."""
|
||||
import yaml
|
||||
for path in sorted((REPO_ROOT / "emulators").glob("*.yml")):
|
||||
profile = yaml.safe_load(path.read_text())
|
||||
if "sony-playstation-2" not in (profile.get("systems") or []):
|
||||
continue
|
||||
for f in profile.get("files") or []:
|
||||
if "romdir" in (f.get("validation") or []):
|
||||
with self.subTest(profile=path.stem, name=f.get("name")):
|
||||
self.assertTrue(set(f["romdir"]) >= {
|
||||
"reset_compare", "missing_reset", "terminated_names", "extinfo",
|
||||
"unreadable_romver", "truncated_walk"})
|
||||
|
||||
|
||||
class OtherContentTests(unittest.TestCase):
|
||||
def test_masked_sha1_clears_the_config_bytes(self):
|
||||
payload = bytearray(range(256)) * 512 # 131072 bytes
|
||||
cleared = bytearray(payload)
|
||||
cleared[0x10:0x30] = bytes(0x20)
|
||||
spec = {"zeroed": [16, 48], "reads": [{"size": 131072, "lengths": [0x1C000]}],
|
||||
"sha1": hashlib.sha1(cleared[:0x1C000]).hexdigest()}
|
||||
entry_ = {"validation": ["masked_sha1"], "masked_sha1": spec}
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
good = Path(tmp, "flash.rom")
|
||||
good.write_bytes(bytes(payload))
|
||||
other = Path(tmp, "other.rom")
|
||||
other.write_bytes(bytes(payload[:-1]) + b"\x01")
|
||||
short = Path(tmp, "short.rom")
|
||||
short.write_bytes(bytes(payload[:65536]))
|
||||
config = bytearray(payload)
|
||||
config[0x20] ^= 0xFF
|
||||
reconfigured = Path(tmp, "reconfigured.rom")
|
||||
reconfigured.write_bytes(bytes(config))
|
||||
self.assertTrue(common.content_fits(entry_, str(good)))
|
||||
self.assertTrue(common.content_fits(entry_, str(reconfigured)))
|
||||
self.assertTrue(common.content_fits(entry_, str(other))) # past 0x1c000
|
||||
self.assertFalse(common.content_fits(entry_, str(short)))
|
||||
payload[0x100] ^= 1
|
||||
good.write_bytes(bytes(payload))
|
||||
common._masked_sha1_verdict.cache_clear()
|
||||
self.assertFalse(common.content_fits(entry_, str(good)))
|
||||
|
||||
def test_size_multiple(self):
|
||||
flash = {"min_size": 65536, "size_multiple": 65536, "validation": ["size"]}
|
||||
self.assertTrue(common.size_fits(flash, 262144))
|
||||
self.assertTrue(common.size_fits(flash, 65536 * 3))
|
||||
self.assertFalse(common.size_fits(flash, 65536 + 1))
|
||||
self.assertFalse(common.size_fits(flash, 0))
|
||||
|
||||
|
||||
class ScannerVerifyManifestAgree(unittest.TestCase):
|
||||
"""The pack and manifest scan, the emulator pack and verify --emulator
|
||||
expansion, the name step of the resolver and verify's validation judge
|
||||
one folder the same way."""
|
||||
|
||||
IMAGES = {
|
||||
"SCPH-70004.BIN": image(),
|
||||
"246C.bin": image(romver=b"0100TZ20000306", serial=b"20021119-163841"),
|
||||
"GameIndex.yaml": b"GameIndex: not a BIOS\n" * 300,
|
||||
"ps2-dvd-311.bin": b"\x00" * 0x4000,
|
||||
}
|
||||
COMPANIONS = {"SCPH-70004.nvm": b"N" * 1024, "246C.mec": b"\x03\x06\x02\x00",
|
||||
"loose.nvm": b"L" * 1024}
|
||||
|
||||
def setUp(self):
|
||||
self._tmp = tempfile.TemporaryDirectory()
|
||||
self.root = Path(self._tmp.name)
|
||||
(self.root / "emulators").mkdir()
|
||||
files, by_name = {}, {}
|
||||
for name, payload in {**self.IMAGES, **self.COMPANIONS}.items():
|
||||
path = self.root / "bios" / "PS2" / name
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
path.write_bytes(payload)
|
||||
sha1 = hashlib.sha1(payload).hexdigest()
|
||||
files[sha1] = {"path": str(path), "name": name, "size": len(payload), "sha1": sha1,
|
||||
"md5": hashlib.md5(payload).hexdigest()}
|
||||
by_name.setdefault(name, []).append(sha1)
|
||||
self.sha1 = {r["name"]: s for s, r in files.items()}
|
||||
self.db = {"files": files, "indexes": {
|
||||
"by_name": by_name, "by_md5": {r["md5"]: s for s, r in files.items()},
|
||||
"by_sha256": {}, "by_crc32": {}, "by_path_suffix": {}}}
|
||||
spec = "\n".join(f" {k}: {str(v).lower() if isinstance(v, bool) else v}"
|
||||
for k, v in MODERN.items())
|
||||
# The anchor proves bios/PS2 holds this system's BIOS by content.
|
||||
(self.root / "emulators" / "anchor.yml").write_text(
|
||||
"emulator: anchor\ntype: libretro\nsystems: [sony-playstation-2]\ncores: [anchor]\n"
|
||||
"files:\n - name: SCPH-70004.BIN\n"
|
||||
f" sha1: {self.sha1['SCPH-70004.BIN']}\n"
|
||||
)
|
||||
(self.root / "emulators" / "demo.yml").write_text(
|
||||
"emulator: demo\ntype: libretro\nbios_mode: agnostic\n"
|
||||
"systems: [sony-playstation-2]\ncores: [demo]\nfiles:\n"
|
||||
" - name: \"<bios>.bin\"\n found_by: content\n path: \"ps2/<bios>.bin\"\n"
|
||||
" required: true\n validation: [romdir]\n romdir:\n" + spec + "\n"
|
||||
" - name: \"<bios>.nvm\"\n path: \"ps2/<bios>.nvm\"\n size: 1024\n"
|
||||
" - name: \"<bios>.mec\"\n path: \"ps2/<bios>.mec\"\n size: 4\n"
|
||||
)
|
||||
common._emulator_profiles_cache.clear()
|
||||
self.profiles = common.load_emulator_profiles(str(self.root / "emulators"))
|
||||
self.config = {"platform": "Demo", "verification_mode": "existence",
|
||||
"cores": ["demo", "anchor"], "base_destination": "", "systems": {}}
|
||||
|
||||
def tearDown(self):
|
||||
common._emulator_profiles_cache.clear()
|
||||
self._tmp.cleanup()
|
||||
|
||||
def accepted(self) -> set[str]:
|
||||
"""What the core lists: each image its walk accepts, each companion
|
||||
beside an accepted image of its stem."""
|
||||
seed = self.profiles["demo"]["files"][0]
|
||||
images = {n for n in self.IMAGES
|
||||
if common.content_fits(seed, str(self.root / "bios" / "PS2" / n))}
|
||||
stems = {n.rsplit(".", 1)[0] for n in images}
|
||||
return images | {n for n in self.COMPANIONS if n.rsplit(".", 1)[0] in stems}
|
||||
|
||||
def test_the_walk_settles_the_folder(self):
|
||||
self.assertEqual(self.accepted(), {"SCPH-70004.BIN", "246C.bin",
|
||||
"SCPH-70004.nvm", "246C.mec"})
|
||||
|
||||
def test_platform_pack_and_manifest_scan(self):
|
||||
extras = builder._collect_emulator_extras(
|
||||
self.config, str(self.root / "emulators"), self.db, set(), "", self.profiles,
|
||||
)
|
||||
placed = {e["name"] for e in extras if e.get("source_profile") == "demo"}
|
||||
self.assertEqual(placed, self.accepted())
|
||||
self.assertTrue(all(e["destination"].startswith("ps2/") for e in extras
|
||||
if e.get("source_profile") == "demo"))
|
||||
|
||||
def test_emulator_pack_and_verify_expansion(self):
|
||||
demo = self.profiles["demo"]
|
||||
expanded = packextras.expand_agnostic_entries(
|
||||
demo["files"], "demo", demo, self.db, False, self.profiles,
|
||||
)
|
||||
names = {f["name"] for f in expanded if f.get("agnostic_scan")}
|
||||
self.assertEqual(names, self.accepted())
|
||||
|
||||
def test_resolver_name_step_and_validation_agree(self):
|
||||
index = _build_validation_index(self.profiles_with_labels())
|
||||
for name in self.IMAGES:
|
||||
path = str(self.root / "bios" / "PS2" / name)
|
||||
entry_ = {"name": name, "found_by": "content", "validation": ["romdir"],
|
||||
"romdir": MODERN, "source_profile": "labels"}
|
||||
resolved, status = common.resolve_local_file(entry_, self.db)
|
||||
failure = check_file_validation(path, name, index)
|
||||
with self.subTest(name=name):
|
||||
accepted = name in self.accepted()
|
||||
# A name the walk refuses is a mismatch, never a name match.
|
||||
self.assertEqual(resolved, path)
|
||||
self.assertEqual(status, "name_exact" if accepted else "hash_mismatch")
|
||||
self.assertEqual(failure is None, accepted)
|
||||
|
||||
def profiles_with_labels(self) -> dict:
|
||||
return {"labels": {"emulator": "labels", "files": [
|
||||
{"name": name, "found_by": "content", "validation": ["romdir"], "romdir": MODERN}
|
||||
for name in self.IMAGES
|
||||
]}}
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,105 @@
|
||||
"""A files[] source_ref must cite the code that reads the file."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
|
||||
|
||||
import sys
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0, str(REPO_ROOT / "scripts"))
|
||||
|
||||
try:
|
||||
import validate_schemas
|
||||
except ImportError as exc:
|
||||
validate_schemas = None
|
||||
IMPORT_ERROR = str(exc)
|
||||
else:
|
||||
IMPORT_ERROR = ""
|
||||
|
||||
|
||||
def _profile(ref: object) -> dict:
|
||||
return {"files": [{"name": "doom.wad", "source_ref": ref}]}
|
||||
|
||||
|
||||
@unittest.skipIf(validate_schemas is None, f"validate_schemas unavailable: {IMPORT_ERROR}")
|
||||
class DataOnlySourceRefs(unittest.TestCase):
|
||||
path = REPO_ROOT / "emulators" / "synthetic.yml"
|
||||
|
||||
def errors(self, ref: object) -> list[str]:
|
||||
return validate_schemas._data_only_source_refs(self.path, _profile(ref))
|
||||
|
||||
def test_a_data_table_alone_is_refused(self):
|
||||
self.assertEqual(len(self.errors("wadsrc_extra/static/iwadinfo.txt:420, 437")), 1)
|
||||
|
||||
def test_a_build_file_alone_is_refused(self):
|
||||
for ref in ("pc-bios/meson.build:30", "wadsrc/CMakeLists.txt:1",
|
||||
"dists/engine-data/engine_data.mk (ENABLE_KYRA)", "src/configure:1933"):
|
||||
with self.subTest(ref=ref):
|
||||
self.assertEqual(len(self.errors(ref)), 1)
|
||||
|
||||
def test_a_file_in_the_tree_alone_is_refused(self):
|
||||
self.assertEqual(len(self.errors("fMSX/ROMs/MSX.ROM")), 1)
|
||||
|
||||
def test_the_table_with_its_reader_passes(self):
|
||||
self.assertEqual(self.errors(
|
||||
"wadsrc_extra/static/iwadinfo.txt:420, wadsrc_extra/CMakeLists.txt:1, "
|
||||
"src/d_iwad.cpp:286-296, 502-531"), [])
|
||||
|
||||
def test_a_role_prefix_is_read_through(self):
|
||||
self.assertEqual(self.errors("source pc-bios/meson.build:30, source hw/i386/pc_piix.c:466"), [])
|
||||
|
||||
def test_a_binary_with_an_address_passes(self):
|
||||
for ref in ("libemucore.so 0x1a2b3c", "Fusion.exe 0x00401000",
|
||||
"bigpemu FUN_006d8be0 (BootROM read)",
|
||||
"CSpect.exe 3.3.1.0 a.H::e() IL_00bd-IL_00c9",
|
||||
"GameAssembly.dll DSP1..ctor (name and CRC32)",
|
||||
"libpizzaboy-jni.so pizza.c:931-937 (path buffer)"):
|
||||
with self.subTest(ref=ref):
|
||||
self.assertEqual(self.errors(ref), [])
|
||||
|
||||
def test_a_binary_named_without_a_place_in_it_is_refused(self):
|
||||
for ref in ("ArcadeFlashWeb v1.0.2 pepflashplayer.dll string table",
|
||||
"Future Pinball.exe 1.9.1.20101231 import directory",
|
||||
"Main.java:27302, libfpse.so readelf -d",
|
||||
"nethersx2 v2.2n classes.dex icons/star-%d.png",
|
||||
"Fusion.exe 0x00401000, PS3Eye.dll .rdata"):
|
||||
with self.subTest(ref=ref):
|
||||
self.assertEqual(len(self.errors(ref)), 1)
|
||||
|
||||
def test_a_binary_file_of_a_source_tree_is_a_path(self):
|
||||
self.assertEqual(self.errors(
|
||||
"src/loader/elfLoader/elfLoader.cpp:365, libs/win32/ll-deps/zlib1.dll"), [])
|
||||
self.assertEqual(self.errors(
|
||||
"src/emu/kernel/src/libmanager.cpp:549-566, src/patch/ecam/group/ecam.dll.map:190-193"), [])
|
||||
|
||||
def test_each_build_mode_is_judged(self):
|
||||
self.assertEqual(len(self.errors({"standalone": "src/main.cpp:10", "libretro": "data/list.txt:3"})), 1)
|
||||
|
||||
def test_an_excepted_profile_is_not_judged(self):
|
||||
path = REPO_ROOT / "emulators" / "synthetic.yml"
|
||||
exceptions = validate_schemas.DATA_ONLY_REF_EXCEPTIONS
|
||||
exceptions["synthetic"] = "binary found nowhere"
|
||||
try:
|
||||
self.assertEqual(validate_schemas._data_only_source_refs(path, _profile("history.txt:38")), [])
|
||||
finally:
|
||||
del exceptions["synthetic"]
|
||||
|
||||
def test_every_exception_names_a_profile_and_a_reason(self):
|
||||
for name, reason in validate_schemas.DATA_ONLY_REF_EXCEPTIONS.items():
|
||||
with self.subTest(profile=name):
|
||||
self.assertTrue((REPO_ROOT / "emulators" / f"{name}.yml").is_file())
|
||||
self.assertTrue(reason.strip())
|
||||
|
||||
def test_the_profiles_cite_their_readers(self):
|
||||
errors: list[str] = []
|
||||
for path in sorted((REPO_ROOT / "emulators").glob("*.yml")):
|
||||
errors.extend(validate_schemas._data_only_source_refs(
|
||||
path, validate_schemas._load_source(path)))
|
||||
self.assertEqual(errors, [])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -137,7 +137,7 @@ class InstallerOutputExample(unittest.TestCase):
|
||||
manifest = json.loads((ROOT / "install" / "retroarch.json").read_text(encoding="utf-8"))
|
||||
# The line as the installer writes it (not_installable_words), or
|
||||
# its earlier "(1 required, not found: 37)" form.
|
||||
omitted = re.search(r"Not installable: \d+ files? (?:\(\d+ required, (.*)\)\.|(?:is|are) "
|
||||
omitted = re.search(r"Not installable: \d+ files?(?: \(\d+ required, (.*)\)\.| (?:is|are) "
|
||||
r"not in the collection|.*Why: (.*)\.)", run)
|
||||
self.assertEqual(omitted is not None, bool(manifest.get("omitted_files")))
|
||||
if omitted and (omitted.group(1) or omitted.group(2)):
|
||||
|
||||
@@ -374,10 +374,16 @@ class TheArchives(unittest.TestCase):
|
||||
with self.subTest(archive=name), self.assertRaises(ValueError):
|
||||
build_port.build_archive(name, self.out / name, root)
|
||||
|
||||
def test_the_release_process_attaches_each(self):
|
||||
def test_the_site_serves_each_and_the_release_none(self):
|
||||
"""Each archive carries install.py: the site serves it from its own
|
||||
commit (sitehandheld.py), and the release steps never build one."""
|
||||
text = (REPO_ROOT / "wiki" / "release-process.md").read_text(encoding="utf-8")
|
||||
self.assertNotIn("scripts/build_port.py", text)
|
||||
installer = (REPO_ROOT / "wiki" / "installer.md").read_text(encoding="utf-8")
|
||||
for name in build_port.ARCHIVES:
|
||||
self.assertIn(name, text)
|
||||
with self.subTest(archive=name):
|
||||
self.assertNotIn(name, text)
|
||||
self.assertIn(f"](../get/handheld/{name})", installer)
|
||||
|
||||
|
||||
FAKE_INSTALL = r'''
|
||||
|
||||
@@ -488,6 +488,8 @@ class AReleaseProfileDescribesItsOwnRelease(unittest.TestCase):
|
||||
self.assertEqual(files["neogeo.zip"]["system"], "snk-neogeo-mvs")
|
||||
self.assertNotIn("system", files["newset.zip"])
|
||||
self.assertEqual(files["neogeo.zip"]["source_ref"], "upstream src/mame/neogeo/neogeo.cpp:10")
|
||||
# The libretro build reads <system>/mame/bios, never the system root.
|
||||
self.assertEqual(files["neogeo.zip"]["path"], "mame/bios/neogeo.zip")
|
||||
|
||||
def test_a_set_the_release_runs_without_is_not_required(self):
|
||||
"""recel is undumped at 0.258: the current profile's true does not apply."""
|
||||
|
||||
@@ -145,6 +145,52 @@ class ACoreOnlyTheDownloaderBrings(unittest.TestCase):
|
||||
self.assertEqual([f["dest"] for f in files], ["kick31.rom", "roms/a4091.rom"])
|
||||
|
||||
|
||||
|
||||
class CoreOfferedOnSomeBoards(unittest.TestCase):
|
||||
"""ROCKNIX writes uae4arm for roms/amiga under the devices it builds it
|
||||
for (emulators/package.mk:188), and s922x runs uae4arm for amigacd32:
|
||||
the core list alone would keep its roms/amiga files there."""
|
||||
|
||||
MANIFEST = {
|
||||
"core_names": {"uae4arm": [], "puae": []},
|
||||
"offered_boards": {
|
||||
"uae4arm": [{"root": "roms", "folder": "amiga", "boards": ["h700", "rk3326"]}],
|
||||
},
|
||||
"files": [
|
||||
{"dest": "amiga/kick.rom", "cores": ["uae4arm"], "root": "roms"},
|
||||
{"dest": "amigacd32/kick.rom", "cores": ["uae4arm"], "root": "roms"},
|
||||
{"dest": "amiga/shared.rom", "cores": ["uae4arm", "puae"], "root": "roms"},
|
||||
],
|
||||
"omitted_files": [],
|
||||
}
|
||||
|
||||
def dests(self, target):
|
||||
files, _ = install.narrow_to_cores(self.MANIFEST, ["uae4arm"], target=target)
|
||||
return [f["dest"] for f in files]
|
||||
|
||||
def test_a_board_it_is_offered_on_keeps_the_folder(self):
|
||||
self.assertEqual(self.dests("rk3326"),
|
||||
["amiga/kick.rom", "amigacd32/kick.rom", "amiga/shared.rom"])
|
||||
|
||||
def test_another_board_keeps_only_the_folders_offering_it(self):
|
||||
self.assertEqual(self.dests("s922x"), ["amigacd32/kick.rom"])
|
||||
|
||||
def test_a_core_offered_everywhere_keeps_a_shared_file(self):
|
||||
files, _ = install.narrow_to_cores(self.MANIFEST, ["uae4arm", "puae"], target="s922x")
|
||||
self.assertEqual([f["dest"] for f in files], ["amigacd32/kick.rom", "amiga/shared.rom"])
|
||||
|
||||
def test_installed_cores_are_no_board(self):
|
||||
files, _ = install.narrow_to_cores(self.MANIFEST, ["uae4arm"])
|
||||
self.assertEqual(len(files), 3)
|
||||
|
||||
def test_the_manifest_check_refuses_a_malformed_map(self):
|
||||
base = {"manifest_version": 2, "platform": "rocknix", "files": [], "omitted_files": []}
|
||||
install._validate_manifest(
|
||||
{**base, "offered_boards": self.MANIFEST["offered_boards"]}, "rocknix")
|
||||
with self.assertRaisesRegex(ValueError, "offered_boards"):
|
||||
install._validate_manifest(
|
||||
{**base, "offered_boards": {"uae4arm": [{"folder": "amiga"}]}}, "rocknix")
|
||||
|
||||
class ACoreTheListDoesNotKnow(unittest.TestCase):
|
||||
"""A core newer than the list (parallel_dc, issue 87) loses nothing its .info declares."""
|
||||
|
||||
|
||||
@@ -0,0 +1,415 @@
|
||||
"""A launcher record resting on a config file binds only when its chain holds.
|
||||
|
||||
The platform's code installs the file (installs), its launch code was read
|
||||
for what replaces it (overrides), and the emulator's profile says where the
|
||||
build the platform ships loads the file and reads each key (config_reads).
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
|
||||
|
||||
import sys
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "scripts"))
|
||||
|
||||
import yaml # noqa: E402
|
||||
|
||||
from common import load_platform_config # noqa: E402
|
||||
from launchers import ( # noqa: E402
|
||||
bound_launchers,
|
||||
config_evidence,
|
||||
config_target,
|
||||
handed_directories,
|
||||
launcher_places,
|
||||
launcher_unproven,
|
||||
)
|
||||
from profile_sync import _check_build_refs, shipped_build_holders # noqa: E402
|
||||
from scraper.retrobat_launchers import _choices_apart # noqa: E402
|
||||
from scraper.shell_launchers import ( # noqa: E402
|
||||
LauncherPatternMissing,
|
||||
Script,
|
||||
config_placement,
|
||||
config_ref,
|
||||
is_feature_ref,
|
||||
)
|
||||
REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
|
||||
def schema_checks(test: unittest.TestCase):
|
||||
"""validate_schemas, or a skip: it needs jsonschema, the build does not."""
|
||||
try:
|
||||
import validate_schemas # noqa: PLC0415
|
||||
except ImportError as exc:
|
||||
test.skipTest(f"validate_schemas needs jsonschema: {exc}")
|
||||
return validate_schemas
|
||||
|
||||
|
||||
def record(**fields: object) -> dict:
|
||||
"""A ROCKNIX-like DuckStation record citing its shipped settings.ini."""
|
||||
base = {
|
||||
"emulator": "duck", "build": "standalone", "kind": "scans_dir", "names": [],
|
||||
"search_dir": "/storage/roms/bios",
|
||||
"passes_to": "settings.ini [BIOS] SearchDirectory = /storage/roms/bios, [BIOS] PathPAL unset",
|
||||
"installs": {"path": "/storage/.config/duck/settings.ini", "source_ref": "setup.sh:13"},
|
||||
"overrides": [],
|
||||
"source_ref": "duck/config/settings.ini:4, duck/package.mk:33",
|
||||
}
|
||||
return {**base, **fields}
|
||||
|
||||
|
||||
def profile(**fields: object) -> dict:
|
||||
base = {
|
||||
"emulator": "Duck", "type": "standalone", "cores": ["duck"],
|
||||
"standalone_directories": ["[BIOS] SearchDirectory"],
|
||||
"config_reads": [{
|
||||
"file": "settings.ini", "source_ref": "src/core.cpp:10",
|
||||
"keys": [
|
||||
{"key": "[BIOS] SearchDirectory", "source_ref": "src/settings.cpp:20"},
|
||||
{"key": ["[BIOS] PathPAL", "[BIOS] PathNTSCU"], "source_ref": "src/bios.cpp:30"},
|
||||
],
|
||||
}],
|
||||
}
|
||||
return {**base, **fields}
|
||||
|
||||
|
||||
class ConfigRefs(unittest.TestCase):
|
||||
def test_config_option_and_feature_files_are_cited_apart(self) -> None:
|
||||
ref = "a/settings.ini:4, 6, a/start.sh:3, b/MAME.opt:19, .emulationstation/es_features.cfg:9"
|
||||
self.assertEqual(
|
||||
config_ref(ref),
|
||||
["a/settings.ini:4, 6", "b/MAME.opt:19", ".emulationstation/es_features.cfg:9"],
|
||||
)
|
||||
self.assertEqual([is_feature_ref(p) for p in config_ref(ref)], [False, True, True])
|
||||
|
||||
def test_passes_to_names_the_file_and_its_keys(self) -> None:
|
||||
cases = {
|
||||
"settings.ini [BIOS] SearchDirectory (-settings), [BIOS] PathNTSCU, PathPAL unset":
|
||||
("settings.ini", ["[BIOS] SearchDirectory", "[BIOS] PathNTSCU", "[BIOS] PathPAL"]),
|
||||
"melonDS.toml [DS] BIOS9Path [DSi] NANDPath, first file whose name holds the region":
|
||||
("melonDS.toml", ["[DS] BIOS9Path", "[DSi] NANDPath"]),
|
||||
"settings.ini [BIOS] PathNTSCJ = PathNTSCU = <value>":
|
||||
("settings.ini", ["[BIOS] PathNTSCJ", "[BIOS] PathNTSCU"]),
|
||||
"AmigaA500-default.uae kickstart_rom_file, $(FILE_PATH) = /storage/k/":
|
||||
("AmigaA500-default.uae", ["kickstart_rom_file", "$(FILE_PATH)"]),
|
||||
"command line -rompath bios/coco": ("command line", ["-rompath"]),
|
||||
"core option pcsx2_bios": ("core options", ["pcsx2_bios"]),
|
||||
}
|
||||
for passes_to, expected in cases.items():
|
||||
with self.subTest(passes_to=passes_to):
|
||||
self.assertEqual(config_target({"passes_to": passes_to}), expected)
|
||||
core = {"build": "libretro", "kind": "core_option", "passes_to": "hatarib_tos = x/<value>"}
|
||||
self.assertEqual(config_target(core), ("core options", ["hatarib_tos"]))
|
||||
|
||||
def test_a_record_naming_no_file_takes_the_config_it_installs(self) -> None:
|
||||
romlist = record(
|
||||
passes_to="romlist coco",
|
||||
installs={"path": "$xroar_config", "source_ref": "prepare.sh:13"},
|
||||
source_ref="xroar/rd_config/xroar.conf:305, xroar/prepare.sh:13",
|
||||
)
|
||||
self.assertEqual(config_target(romlist), ("xroar.conf", ["romlist coco"]))
|
||||
|
||||
|
||||
class Evidence(unittest.TestCase):
|
||||
profiles = {"duck": profile()}
|
||||
|
||||
def test_a_record_resting_on_code_holds(self) -> None:
|
||||
code = {"emulator": "duck", "kind": "fixed_name", "source_ref": "start.sh:3"}
|
||||
self.assertTrue(config_evidence(code, {}).proven)
|
||||
|
||||
def test_the_whole_chain_holds(self) -> None:
|
||||
evidence = config_evidence(record(), self.profiles, "rocknix")
|
||||
self.assertTrue(evidence.proven, evidence.missing)
|
||||
self.assertEqual(evidence.readers, ("duck",))
|
||||
|
||||
def test_each_missing_link_is_named(self) -> None:
|
||||
bare = {k: v for k, v in record().items() if k not in ("installs", "overrides")}
|
||||
missing = config_evidence(bare, self.profiles).missing
|
||||
self.assertEqual(len(missing), 2)
|
||||
self.assertTrue(missing[0].startswith("installs"))
|
||||
self.assertTrue(missing[1].startswith("overrides"))
|
||||
|
||||
def test_a_profile_that_reads_no_such_file_proves_nothing(self) -> None:
|
||||
missing = config_evidence(record(), {"duck": profile(config_reads=[])}).missing
|
||||
self.assertEqual(missing, ("config_reads: an emulator that loads settings.ini",))
|
||||
|
||||
def test_a_key_the_build_does_not_read_is_named(self) -> None:
|
||||
unread = record(passes_to="settings.ini [BIOS] PathNTSCJ")
|
||||
self.assertEqual(
|
||||
config_evidence(unread, self.profiles).missing,
|
||||
("config_reads: no read of [BIOS] PathNTSCJ",),
|
||||
)
|
||||
|
||||
def test_a_handle_with_its_code_ref_reads_the_key(self) -> None:
|
||||
handled = profile(
|
||||
config_reads=[{"file": "settings.ini", "source_ref": "src/core.cpp:10", "keys": [
|
||||
{"key": "[BIOS] PathPAL", "source_ref": "src/bios.cpp:30"}]}],
|
||||
standalone_directories=[
|
||||
{"handle": "[BIOS] SearchDirectory", "source_ref": "src/settings.cpp:20"}
|
||||
],
|
||||
)
|
||||
self.assertTrue(config_evidence(record(), {"duck": handled}).proven)
|
||||
|
||||
def test_an_option_list_is_never_the_source(self) -> None:
|
||||
listed = record(source_ref="gen.cs:3, .emulationstation/es_features.cfg:9")
|
||||
self.assertIn(
|
||||
"an option list cited as source, not as choices_from",
|
||||
config_evidence(listed, self.profiles).missing,
|
||||
)
|
||||
|
||||
def test_an_option_choice_needs_the_emulator_side_too(self) -> None:
|
||||
chosen = {
|
||||
"emulator": "duck", "kind": "core_option", "passes_to": "settings.ini [BIOS] PathPAL = <value>",
|
||||
"choices_from": "es_features.cfg:9", "source_ref": "gen.cs:3",
|
||||
}
|
||||
self.assertTrue(config_evidence(chosen, self.profiles).proven)
|
||||
self.assertFalse(config_evidence(chosen, {"duck": profile(config_reads=[])}).proven)
|
||||
|
||||
def test_reads_written_for_a_shipped_build_apply_to_its_platform_only(self) -> None:
|
||||
built = profile(
|
||||
source_commit="a" * 40,
|
||||
pin_build=[{"platform": "rocknix", "value": "b" * 40}],
|
||||
config_reads=[{**profile()["config_reads"][0], "platforms": ["rocknix"]}],
|
||||
)
|
||||
self.assertTrue(config_evidence(record(), {"duck": built}, "rocknix").proven)
|
||||
self.assertFalse(config_evidence(record(), {"duck": built}, "emuelec").proven)
|
||||
|
||||
def test_reads_at_the_pin_skip_a_platform_shipping_another_build(self) -> None:
|
||||
other = profile(source_commit="a" * 40, pin_build=[{"platform": "rocknix", "value": "b" * 40}])
|
||||
self.assertFalse(config_evidence(record(), {"duck": other}, "rocknix").proven)
|
||||
self.assertTrue(config_evidence(record(), {"duck": other}, "emuelec").proven)
|
||||
|
||||
|
||||
class Gate(unittest.TestCase):
|
||||
def config(self, *records: dict) -> dict:
|
||||
return {"_key": "rocknix", "base_destination": "bios", "launchers": list(records)}
|
||||
|
||||
def test_an_unproven_record_hands_no_directory(self) -> None:
|
||||
proven = handed_directories(self.config(record()), {"duck": profile()})
|
||||
self.assertEqual([h.folder for h in proven], [""])
|
||||
self.assertEqual(handed_directories(self.config(record()), {"duck": profile(config_reads=[])}), [])
|
||||
|
||||
def test_an_unproven_record_places_no_file(self) -> None:
|
||||
named = record(
|
||||
kind="fixed_name", names=["tos.img"], passes_to="settings.ini [BIOS] PathPAL",
|
||||
)
|
||||
self.assertEqual(len(launcher_places(self.config(named), {"duck": profile()})), 1)
|
||||
self.assertEqual(launcher_places(self.config(named), {"duck": profile(config_reads=[])}), [])
|
||||
|
||||
def test_the_unproven_are_reported_with_what_they_lack(self) -> None:
|
||||
config = self.config({"emulator": "x", "kind": "links", "source_ref": "a.sh:1"}, record())
|
||||
self.assertEqual(launcher_unproven({"rocknix": config}, {"duck": profile()}), [])
|
||||
(row,) = launcher_unproven({"rocknix": config}, {"duck": profile(config_reads=[])})
|
||||
self.assertEqual((row["platform"], row["index"], row["emulator"]), ("rocknix", 1, "duck"))
|
||||
self.assertEqual(row["config"], ["duck/config/settings.ini:4"])
|
||||
self.assertEqual(len(bound_launchers(config, {"duck": profile(config_reads=[])})), 1)
|
||||
|
||||
|
||||
class StartScripts(unittest.TestCase):
|
||||
SCRIPT = (
|
||||
'CONF_DIR="/storage/.config/duck"\n'
|
||||
'CONF_FILE="${CONF_DIR}/settings.ini"\n'
|
||||
'[ ! -d "${CONF_DIR}" ] && cp -r /usr/config/duck /storage/.config\n'
|
||||
'if [ ! -f "${CONF_FILE}" ]; then\n'
|
||||
' cp /usr/config/duck/settings.ini ${CONF_FILE}\n'
|
||||
'fi\n'
|
||||
"sed -i '/^AspectRatio/c\\\\AspectRatio = 4:3' ${CONF_FILE}\n"
|
||||
"sed -i '/^PathPAL/c\\\\PathPAL = x.bin' ${CONF_FILE}\n"
|
||||
'cp /usr/config/duck/other.ini ${CONF_DIR}/ >/dev/null 2>&1\n'
|
||||
)
|
||||
|
||||
def test_a_guarded_copy_keeps_the_file_and_a_key_rewrite_is_an_override(self) -> None:
|
||||
placement = config_placement(
|
||||
Script("start.sh", self.SCRIPT), "/storage/.config/duck/settings.ini", ["[BIOS] PathPAL"]
|
||||
)
|
||||
self.assertEqual(placement.install, {3, 5})
|
||||
self.assertTrue(placement.kept_if_present)
|
||||
self.assertEqual(placement.overrides, {8})
|
||||
|
||||
def test_a_copy_at_each_launch_replaces_the_file(self) -> None:
|
||||
script = Script("start.sh", 'cp /usr/config/duck/settings.ini /storage/.config/duck/settings.ini\n')
|
||||
self.assertFalse(config_placement(script, "/storage/.config/duck/settings.ini").kept_if_present)
|
||||
|
||||
def test_a_script_installing_nothing_raises(self) -> None:
|
||||
with self.assertRaises(LauncherPatternMissing):
|
||||
config_placement(Script("start.sh", "echo hi\n"), "/storage/.config/duck/settings.ini")
|
||||
|
||||
def test_retrobat_moves_the_option_list_to_choices_from(self) -> None:
|
||||
moved = _choices_apart({
|
||||
"emulator": "x", "passes_to": "p",
|
||||
"source_ref": "Gen.cs:3-4, .emulationstation/es_features.cfg:9-12",
|
||||
})
|
||||
self.assertEqual(moved["source_ref"], "Gen.cs:3-4")
|
||||
self.assertEqual(moved["choices_from"], ".emulationstation/es_features.cfg:9-12")
|
||||
self.assertEqual(list(moved)[-1], "source_ref")
|
||||
|
||||
|
||||
class Invariants(unittest.TestCase):
|
||||
def test_a_config_record_without_its_platform_links_is_an_error(self) -> None:
|
||||
_config_records_without_evidence = schema_checks(self)._config_records_without_evidence
|
||||
path = REPO_ROOT / "platforms" / "x.yml"
|
||||
bare = {k: v for k, v in record().items() if k not in ("installs", "overrides")}
|
||||
listed = record(source_ref="gen.cs:3, es_features.yml:9")
|
||||
errors = _config_records_without_evidence(path, {"launchers": [record(), bare, listed]})
|
||||
self.assertEqual(len(errors), 2)
|
||||
self.assertIn("without installs and overrides", errors[0])
|
||||
self.assertIn("choices_from holds it", errors[1])
|
||||
|
||||
def test_reads_naming_a_platform_need_its_build(self) -> None:
|
||||
_config_reads_without_build = schema_checks(self)._config_reads_without_build
|
||||
path = REPO_ROOT / "emulators" / "x.yml"
|
||||
reads = [{"file": "a.ini", "platforms": ["rocknix"], "source_ref": "a:1", "keys": []}]
|
||||
self.assertEqual(len(_config_reads_without_build(path, {"config_reads": reads})), 1)
|
||||
self.assertEqual(_config_reads_without_build(
|
||||
path, {"config_reads": reads, "pin_build": [{"platform": "rocknix"}]}
|
||||
), [])
|
||||
pinned = [{**reads[0], "revision": "c" * 40, "revision_from": "the exe"}]
|
||||
self.assertEqual(_config_reads_without_build(path, {"config_reads": pinned}), [])
|
||||
closed = [{**reads[0], "binary_sha256": "d" * 64, "revision_from": "the archive"}]
|
||||
self.assertEqual(_config_reads_without_build(path, {"config_reads": closed}), [])
|
||||
|
||||
|
||||
class ShippedBuild(unittest.TestCase):
|
||||
def test_a_platform_an_entry_names_is_read_there_only(self) -> None:
|
||||
"""RetroDECK ships GZDoom 4.14.2: the entry read at the pin does not
|
||||
also stand for it, so a key only the pin reads proves nothing there."""
|
||||
duck = profile(config_reads=[
|
||||
{"file": "settings.ini", "source_ref": "src/core.cpp:10",
|
||||
"keys": [{"key": "[BIOS] SearchDirectory", "source_ref": "src/settings.cpp:20"},
|
||||
{"key": ["[BIOS] PathPAL", "[BIOS] PathNTSCU"], "source_ref": "src/bios.cpp:30"}]},
|
||||
{"file": "settings.ini", "platforms": ["rocknix"], "revision": "a" * 40,
|
||||
"revision_from": "the AppImage", "source_ref": "src/core.cpp:12",
|
||||
"keys": [{"key": "[BIOS] SearchDirectory", "source_ref": "src/settings.cpp:22"}]},
|
||||
])
|
||||
evidence = config_evidence(record(), {"duck": duck}, "rocknix")
|
||||
self.assertEqual(evidence.missing, ("config_reads: no read of [BIOS] PathPAL",))
|
||||
self.assertTrue(config_evidence(record(), {"duck": duck}, "emuelec").proven)
|
||||
|
||||
|
||||
class CoreOptions(unittest.TestCase):
|
||||
def test_a_core_option_is_read_by_the_core_not_the_frontend(self) -> None:
|
||||
"""RetroDECK's retroarch component writes pcsx2_bios: the frontend
|
||||
names the record, the core RetroArch runs reads the option."""
|
||||
profiles = {
|
||||
"retroarch": {"emulator": "RetroArch", "type": "utility", "cores": ["retroarch"],
|
||||
"config_reads": [{"file": "retroarch.cfg", "source_ref": "a.c:1",
|
||||
"keys": [{"key": "system_directory",
|
||||
"source_ref": "a.c:2"}]}]},
|
||||
"lrps2": {"emulator": "LRPS2", "type": "libretro", "cores": ["lrps2"],
|
||||
"config_reads": [{"file": "core options", "source_ref": "main.cpp:1",
|
||||
"keys": [{"key": "pcsx2_bios",
|
||||
"source_ref": "main.cpp:2"}]}]},
|
||||
}
|
||||
option = {
|
||||
"emulator": "retroarch", "build": "libretro", "kind": "core_option",
|
||||
"names": ["scph10000.bin"], "passes_to": "core option pcsx2_bios",
|
||||
"installs": {"path": "$core_options", "source_ref": "prepare.sh:24"},
|
||||
"overrides": [], "source_ref": "rd_config/retroarch-core-options.cfg:515",
|
||||
}
|
||||
evidence = config_evidence(option, profiles, "retrodeck")
|
||||
self.assertTrue(evidence.proven, evidence.missing)
|
||||
self.assertEqual(evidence.readers, ("lrps2",))
|
||||
system = {**option, "kind": "passes_path", "passes_to": "retroarch.cfg system_directory",
|
||||
"source_ref": "rd_config/retroarch.cfg:44"}
|
||||
self.assertEqual(config_evidence(system, profiles, "retrodeck").readers, ("retroarch",))
|
||||
|
||||
|
||||
class BuildRefs(unittest.TestCase):
|
||||
def test_reads_for_a_shipped_build_are_read_at_that_build(self) -> None:
|
||||
document = {
|
||||
"pin_build": [{"platform": "rocknix", "value": "b" * 40}],
|
||||
"config_reads": [{
|
||||
"file": "a.ini", "platforms": ["rocknix"], "source_ref": "src/a.c:2",
|
||||
"keys": [{"key": "k", "source_ref": "src/a.c:9, ROCKNIX x.patch:1"}],
|
||||
}],
|
||||
}
|
||||
held = shipped_build_holders(document)
|
||||
self.assertEqual(len(held), 2)
|
||||
|
||||
class View:
|
||||
repo, field = "repo", "source"
|
||||
|
||||
class Citation:
|
||||
def __init__(self, ref: str, field: str) -> None:
|
||||
self.ref, self.field = ref, field
|
||||
|
||||
asked: list[tuple[str, str]] = []
|
||||
|
||||
def fetch(_repo: str, revision: str, path: str) -> list[str] | None:
|
||||
asked.append((revision, path))
|
||||
return ["line"] * 5 if path == "src/a.c" else None
|
||||
|
||||
rows = _check_build_refs(
|
||||
document,
|
||||
[(Citation("src/a.c:2", "c"), document["config_reads"][0]),
|
||||
(Citation("src/a.c:9, ROCKNIX x.patch:1", "k"), document["config_reads"][0])],
|
||||
[View()], fetch,
|
||||
)
|
||||
self.assertEqual([r["status"] for r in rows], ["BUILD_OK", "BUILD_GONE"])
|
||||
self.assertTrue(all(revision == "b" * 40 for revision, _ in asked))
|
||||
self.assertNotIn(("b" * 40, "ROCKNIX x.patch"), asked)
|
||||
|
||||
|
||||
def test_a_closed_build_is_read_in_its_binary(self) -> None:
|
||||
"""An address ref is read in the binary binary_sha256 names, never
|
||||
fetched. A source path cannot exist at a closed build."""
|
||||
read = {
|
||||
"file": "SSF.ini", "platforms": ["retrobat"], "binary_sha256": "e" * 64,
|
||||
"revision_from": "the archive", "source_ref": "SSF.exe 0x10-0x20", "keys": [],
|
||||
}
|
||||
|
||||
class View:
|
||||
repo, field = "repo", "source"
|
||||
|
||||
class Citation:
|
||||
def __init__(self, ref: str) -> None:
|
||||
self.ref, self.field = ref, "c"
|
||||
|
||||
asked: list[str] = []
|
||||
|
||||
def fetch(_repo: str, _revision: str, path: str) -> list[str] | None:
|
||||
asked.append(path)
|
||||
return None
|
||||
|
||||
rows = _check_build_refs(
|
||||
{"config_reads": [read]},
|
||||
[(Citation("SSF.exe 0x10-0x20"), read), (Citation("src/a.c:3"), read)],
|
||||
[View()], fetch,
|
||||
)
|
||||
self.assertEqual([r["status"] for r in rows], ["BUILD_OK", "BUILD_GONE"])
|
||||
self.assertEqual({r["revision"] for r in rows}, {"e" * 64})
|
||||
self.assertEqual(asked, ["src/a.c"])
|
||||
|
||||
|
||||
class RepositoryRecords(unittest.TestCase):
|
||||
"""The placement chains the audit of 2026-11-10 found moving files."""
|
||||
|
||||
def test_the_chains_that_move_placements_still_bind(self) -> None:
|
||||
platforms = REPO_ROOT / "platforms"
|
||||
cases = (
|
||||
("rocknix", "armsx2", "/storage/roms/bios/armsx2"),
|
||||
("retrodeck", "gzdoom", "$roms_path/doom"),
|
||||
("retrodeck", "xroar", "$roms_path/coco"),
|
||||
("retrobat", "xroar", "bios/coco"),
|
||||
)
|
||||
for platform, emulator, directory in cases:
|
||||
with self.subTest(platform=platform, emulator=emulator):
|
||||
handed = handed_directories(load_platform_config(platform, str(platforms)))
|
||||
self.assertIn(
|
||||
directory, {h.directory for h in handed if h.emulator == emulator}
|
||||
)
|
||||
|
||||
def test_every_config_record_carries_its_platform_links(self) -> None:
|
||||
_config_records_without_evidence = schema_checks(self)._config_records_without_evidence
|
||||
for path in sorted((REPO_ROOT / "platforms").glob("*.yml")):
|
||||
if path.name.startswith("_"):
|
||||
continue
|
||||
with self.subTest(platform=path.stem):
|
||||
document = yaml.safe_load(path.read_text(encoding="utf-8"))
|
||||
self.assertEqual(_config_records_without_evidence(path, document), [])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -33,6 +33,7 @@ import verify # noqa: E402
|
||||
from common import _emulator_profiles_cache, load_emulator_profiles, load_platform_config # noqa: E402
|
||||
from cross_reference import ( # noqa: E402
|
||||
LAUNCHER_READS_KEY,
|
||||
LAUNCHER_UNPROVEN_KEY,
|
||||
launcher_file_names,
|
||||
launcher_reads_not_held,
|
||||
print_launcher_reads,
|
||||
@@ -278,7 +279,11 @@ class LauncherGapTest(unittest.TestCase):
|
||||
names = {r["name"] for r in report[LAUNCHER_READS_KEY]}
|
||||
self.assertEqual(names, {"absent.bin", "mixed.rom", "labelled.rom", "user.sf2"})
|
||||
# The emulator rows keep their own shape and counts.
|
||||
self.assertEqual(set(report) - {LAUNCHER_READS_KEY}, {"aliasemu", "missemu", "setemu"})
|
||||
self.assertEqual(
|
||||
set(report) - {LAUNCHER_READS_KEY, LAUNCHER_UNPROVEN_KEY},
|
||||
{"aliasemu", "missemu", "setemu"},
|
||||
)
|
||||
self.assertEqual(report[LAUNCHER_UNPROVEN_KEY], [])
|
||||
|
||||
def test_verify_counts_and_exit_code_are_unchanged(self) -> None:
|
||||
"""A launcher name is reported, not judged: nothing else moves."""
|
||||
|
||||
@@ -314,9 +314,9 @@ class LauncherLayerTest(unittest.TestCase):
|
||||
config = {"base_destination": "bios", "launchers": [{
|
||||
"emulator": "e", "build": "libretro", "kind": "fixed_name",
|
||||
"names": ["a.rom", "b.rom"], "search_dir": "/storage/roms/bios",
|
||||
"passes_to": "e.cfg ROM_A, ROM_B", "source_ref": "e.cfg:1",
|
||||
"passes_to": "e.cfg ROM_A, ROM_B", "source_ref": "launch.sh:1",
|
||||
}]}
|
||||
places = {p.paths[0]: p.passes_to for p in launcher_places(config)}
|
||||
places = {p.paths[0]: p.passes_to for p in launcher_places(config, {})}
|
||||
self.assertEqual(places, {"a.rom": "e.cfg ROM_A", "b.rom": "e.cfg ROM_B"})
|
||||
|
||||
def test_a_core_option_names_the_dump_of_a_model(self) -> None:
|
||||
@@ -341,12 +341,16 @@ class LauncherLayerTest(unittest.TestCase):
|
||||
"files": [{"name": "<bios>.bin", "path": "ps2/bios/<bios>.bin", "required": True,
|
||||
"min_size": 32, "max_size": 64, "validation": ["size"],
|
||||
"config_key": "emu_bios"}],
|
||||
"config_reads": [{"file": "core options", "source_ref": "core.c:1",
|
||||
"keys": [{"key": "emu_bios", "source_ref": "core.c:2"}]}],
|
||||
}
|
||||
with open(os.path.join(self.emulators_dir, "optemu.yml"), "w") as fh:
|
||||
yaml.dump(profile, fh)
|
||||
self.config["launchers"].append({
|
||||
"emulator": "retroarch", "build": "libretro", "kind": "core_option",
|
||||
"names": ["scph10000.bin"], "passes_to": "core option emu_bios",
|
||||
"installs": {"path": "retroarch-core-options.cfg", "source_ref": "prepare.sh:24"},
|
||||
"overrides": [],
|
||||
"source_ref": "core-options.cfg:515",
|
||||
})
|
||||
_emulator_profiles_cache.clear()
|
||||
|
||||
@@ -13,6 +13,7 @@ import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
|
||||
|
||||
import hashlib
|
||||
import io
|
||||
import json
|
||||
import shutil
|
||||
import sys
|
||||
import tempfile
|
||||
@@ -553,5 +554,819 @@ class EachProgramItsOwnProfile(unittest.TestCase):
|
||||
self.assertEqual(resolve_platform_cores(config, profiles), {"emu"})
|
||||
|
||||
|
||||
BIOS_SETTING = {
|
||||
"emulator": "ps2emu", "build": "standalone", "kind": "passes_path", "names": [],
|
||||
"search_dir": "/userdata/bios/ps2",
|
||||
"passes_to": "inis/PCSX2.ini [Folders] Bios = ../../../bios/ps2, relative to the data root",
|
||||
"source_ref": "ps2emuGenerator.py:219",
|
||||
}
|
||||
# The same folder through a scans_dir record, and a record setting the image
|
||||
# name alone, which hands no folder.
|
||||
BIOS_SCAN = {**BIOS_SETTING, "kind": "scans_dir", "passes_to": "PCSX2.ini [Folders] Bios"}
|
||||
BIOS_NAME = {**BIOS_SETTING, "passes_to": "PCSX2.ini [Filenames] BIOS"}
|
||||
|
||||
|
||||
class ASettingSetsTheBiosFolder(unittest.TestCase):
|
||||
"""KNULLI sets AetherSX2's [Folders] Bios to bios/ps2.
|
||||
|
||||
The profile reads its BIOS images by content from bios/ under its data
|
||||
root, and names that setting in standalone_directories. Every image the
|
||||
scan finds goes to ps2/ in the pack, the manifest and verify, and a file
|
||||
the layout keeps outside its bios/ folder is named, never packed.
|
||||
"""
|
||||
|
||||
def setUp(self) -> None:
|
||||
_emulator_profiles_cache.clear()
|
||||
(REPO_ROOT / "tmp").mkdir(exist_ok=True)
|
||||
self.root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
self.addCleanup(shutil.rmtree, self.root, True)
|
||||
files, by_md5, by_name = {}, {}, {}
|
||||
for folder, name, data in (
|
||||
("Sony/PlayStation 2", "img-a.bin", b"PS2 IMAGE A....."),
|
||||
("Sony/PlayStation 2", "img-b.bin", b"PS2 IMAGE B....."),
|
||||
("Other/ps2emu/arcade", "boot.zip", b"BOOT PROGRAMS"),
|
||||
):
|
||||
where = self.root / "bios" / folder
|
||||
where.mkdir(parents=True, exist_ok=True)
|
||||
(where / name).write_bytes(data)
|
||||
sha1 = hashlib.sha1(data).hexdigest()
|
||||
md5 = hashlib.md5(data).hexdigest()
|
||||
files[sha1] = {"path": str(where / name), "name": name, "sha1": sha1,
|
||||
"md5": md5, "crc32": "", "size": len(data)}
|
||||
by_md5[md5] = sha1
|
||||
by_name[name] = [sha1]
|
||||
self.db = {
|
||||
"files": files,
|
||||
"indexes": {"by_md5": by_md5, "by_name": by_name, "by_crc32": {},
|
||||
"by_path_suffix": {}},
|
||||
}
|
||||
self.platforms = self.root / "platforms"
|
||||
self.emulators = self.root / "emulators"
|
||||
self.platforms.mkdir()
|
||||
self.emulators.mkdir()
|
||||
platforms = {"setplat": [BIOS_SETTING], "scanplat": [BIOS_SCAN],
|
||||
"nameplat": [BIOS_NAME], "plainplat": []}
|
||||
for name, launchers in platforms.items():
|
||||
(self.platforms / f"{name}.yml").write_text(yaml.safe_dump({
|
||||
"platform": name, "version": "1", "verification_mode": "existence",
|
||||
"base_destination": "bios", "cores": ["ps2emu"],
|
||||
"standalone_cores": ["ps2emu"], "launchers": launchers,
|
||||
"systems": {"sony-playstation-2": {"files": []}},
|
||||
}))
|
||||
(self.platforms / "_registry.yml").write_text(yaml.safe_dump({"platforms": {
|
||||
name: {"config": f"{name}.yml"} for name in platforms
|
||||
}}))
|
||||
(self.emulators / "ps2emu.yml").write_text(yaml.safe_dump({
|
||||
"emulator": "PS2Emu", "type": "standalone", "bios_mode": "agnostic",
|
||||
"cores": ["ps2emu"], "systems": ["sony-playstation-2"],
|
||||
"bios_directory": "bios/",
|
||||
"standalone_directories": ["[Folders] Bios = bios"],
|
||||
"files": [
|
||||
{"name": "img-a.bin", "path": "bios/img-a.bin", "required": True,
|
||||
"min_size": 16, "max_size": 16, "validation": ["size"]},
|
||||
# Read below the data root, never below its bios/ folder.
|
||||
{"name": "boot.zip", "standalone_path": "arcade/boot.zip",
|
||||
"mode": "standalone", "required": False},
|
||||
],
|
||||
}))
|
||||
|
||||
def pack_names(self, platform: str) -> list[str]:
|
||||
with redirect_stdout(io.StringIO()):
|
||||
zip_path = generate_pack(
|
||||
platform, str(self.platforms), self.db, str(self.root / "bios"),
|
||||
str(self.root / "out" / platform), emulators_dir=str(self.emulators),
|
||||
offline=True,
|
||||
)
|
||||
with zipfile.ZipFile(zip_path) as zf:
|
||||
return sorted(n for n in zf.namelist() if n.endswith((".bin", ".zip")))
|
||||
|
||||
def manifest(self, platform: str) -> dict:
|
||||
with redirect_stdout(io.StringIO()):
|
||||
return generate_manifest(
|
||||
platform, str(self.platforms), self.db, str(self.root / "bios"),
|
||||
str(self.platforms / "_registry.yml"),
|
||||
emulators_dir=str(self.emulators), offline=True,
|
||||
)
|
||||
|
||||
def verify_dests(self, platform: str) -> list[str]:
|
||||
config = load_platform_config(platform, str(self.platforms))
|
||||
result = verify_platform(config, self.db, str(self.emulators))
|
||||
return sorted(d for d in result["pack_destinations"] if d.endswith((".bin", ".zip")))
|
||||
|
||||
def assert_placed(self, platform: str, expected: list[str]) -> None:
|
||||
self.assertEqual(self.pack_names(platform), expected)
|
||||
self.assertEqual(
|
||||
sorted(f["dest"] for f in self.manifest(platform)["files"]), expected
|
||||
)
|
||||
self.assertEqual(self.verify_dests(platform), expected)
|
||||
|
||||
def test_every_scanned_image_lands_in_the_folder_set(self) -> None:
|
||||
self.assert_placed("setplat", ["ps2/img-a.bin", "ps2/img-b.bin"])
|
||||
|
||||
def test_a_scans_dir_record_sets_it_too(self) -> None:
|
||||
self.assert_placed("scanplat", ["ps2/img-a.bin", "ps2/img-b.bin"])
|
||||
|
||||
def test_the_image_name_setting_hands_no_folder(self) -> None:
|
||||
self.assert_placed("nameplat", ["img-a.bin", "img-b.bin"])
|
||||
|
||||
def test_a_platform_without_the_record_keeps_the_layout(self) -> None:
|
||||
self.assert_placed("plainplat", ["img-a.bin", "img-b.bin"])
|
||||
|
||||
def test_a_file_outside_the_bios_folder_is_named(self) -> None:
|
||||
omitted = [o for o in self.manifest("setplat")["omitted_files"]
|
||||
if o["name"] == "boot.zip"]
|
||||
self.assertEqual(
|
||||
[(o["dest"], o["root"], o["reason"], o["cores"]) for o in omitted],
|
||||
[("arcade/boot.zip", "emulator", "outside_bios_folder", ["ps2emu"])],
|
||||
)
|
||||
|
||||
def test_the_ini_key_carries_its_section(self) -> None:
|
||||
from launchers import ini_keys
|
||||
|
||||
self.assertEqual(
|
||||
ini_keys("PCSX2.ini [Folders] Bios = /storage/roms/bios/armsx2, [Filenames] BIOS"),
|
||||
{"[Folders] Bios", "[Filenames] BIOS"},
|
||||
)
|
||||
self.assertEqual(ini_keys("command line -rompath"), frozenset())
|
||||
|
||||
|
||||
class AetherSX2OnKnulli(unittest.TestCase):
|
||||
"""The real profile against KNULLI's aethersx2Generator.py:219 record."""
|
||||
|
||||
def test_the_bios_images_land_in_ps2(self) -> None:
|
||||
profile = load_emulator_profiles(str(REPO_ROOT / "emulators"))["aethersx2"]
|
||||
config = load_platform_config("knulli", str(REPO_ROOT / "platforms"))
|
||||
(view, standalone), = platform_layouts("aethersx2", profile, standalone_set(config))
|
||||
self.assertTrue(standalone)
|
||||
for entry in view["files"]:
|
||||
path = entry.get("path") or ""
|
||||
if path.startswith("bios/"):
|
||||
self.assertEqual(entry["standalone_path"], "ps2/" + path.removeprefix("bios/"))
|
||||
elif path:
|
||||
self.assertEqual(entry.get("unplaced"), "outside_bios_folder", path)
|
||||
|
||||
|
||||
class Quasi88OnRetroPie(unittest.TestCase):
|
||||
"""RetroPie writes `-romdir` $biosdir/pc88 into quasi88.ini (quasi88.sh:67)."""
|
||||
|
||||
def test_the_roms_land_in_pc88(self) -> None:
|
||||
profile = load_emulator_profiles(str(REPO_ROOT / "emulators"))["quasi88kai"]
|
||||
config = load_platform_config("retropie", str(REPO_ROOT / "platforms"))
|
||||
(view, standalone), = platform_layouts("quasi88kai", profile, standalone_set(config))
|
||||
self.assertTrue(standalone)
|
||||
paths = [e["path"] for e in view["files"]]
|
||||
self.assertTrue(paths and all(p.startswith("rom/") for p in paths))
|
||||
self.assertEqual(
|
||||
[e["standalone_path"] for e in view["files"]],
|
||||
["pc88/" + p.removeprefix("rom/") for p in paths],
|
||||
)
|
||||
|
||||
|
||||
class FlycastOnEmuELEC(unittest.TestCase):
|
||||
"""EmuELEC links /storage/.local/share/flycast to bios/dc (flycast.sh:11-14),
|
||||
and root's home is /storage (busybox profile.d/98-busybox.conf:4)."""
|
||||
|
||||
def test_the_home_directory_is_spelled_as_home(self) -> None:
|
||||
from launchers import normalize_handle
|
||||
|
||||
self.assertEqual(
|
||||
normalize_handle("/storage/.local/share/flycast", "/storage"), "~/.local/share/flycast"
|
||||
)
|
||||
self.assertEqual(normalize_handle("/storage", "/storage/"), "~")
|
||||
self.assertEqual(normalize_handle("/storagex/a", "/storage"), "/storagex/a")
|
||||
self.assertEqual(
|
||||
normalize_handle("/storage/.local/share/flycast"), "/storage/.local/share/flycast"
|
||||
)
|
||||
|
||||
def test_the_bios_lands_in_dc(self) -> None:
|
||||
profile = load_emulator_profiles(str(REPO_ROOT / "emulators"))["flycast"]
|
||||
config = load_platform_config("emuelec", str(REPO_ROOT / "platforms"))
|
||||
layouts = platform_layouts("flycast", profile, standalone_set(config))
|
||||
(view,) = [v for v, standalone in layouts if standalone]
|
||||
self.assertTrue(view["files"])
|
||||
for entry in view["files"]:
|
||||
self.assertEqual(entry["standalone_path"], "dc/" + entry["layout_path"])
|
||||
|
||||
|
||||
def standalone_view(emulator: str, platform: str) -> dict:
|
||||
profile = load_emulator_profiles(str(REPO_ROOT / "emulators"))[emulator]
|
||||
config = load_platform_config(platform, str(REPO_ROOT / "platforms"))
|
||||
(view,) = [v for v, standalone in platform_layouts(emulator, profile, standalone_set(config))
|
||||
if standalone]
|
||||
return view
|
||||
|
||||
|
||||
class Eka2l1OnRetroBat(unittest.TestCase):
|
||||
"""RetroBat writes data-storage = bios/eka2l1/data (Eka2l1.Generator.cs:153, 156)."""
|
||||
|
||||
def test_the_device_rom_lands_in_eka2l1_data(self) -> None:
|
||||
view = standalone_view("eka2l1", "retrobat")
|
||||
(rom,) = [e for e in view["files"] if e["name"] == "SYM.ROM"]
|
||||
self.assertEqual(rom["standalone_path"], "eka2l1/data/roms/nem-4/SYM.ROM")
|
||||
# Shipped beside the executable, in RetroBat's emulator folder.
|
||||
for entry in view["files"]:
|
||||
if entry.get("mode") == "standalone":
|
||||
self.assertEqual(entry.get("unplaced"), "outside_bios_folder", entry["name"])
|
||||
|
||||
|
||||
class CemuOnRetroDECK(unittest.TestCase):
|
||||
"""RetroDECK sets mlc_path to $bios_path/cemu (cemu/component_prepare.sh:14, 29)
|
||||
and keeps Cemu's user data in its Flatpak's $XDG_DATA_HOME/Cemu."""
|
||||
|
||||
def test_the_mlc_lands_in_cemu(self) -> None:
|
||||
view = standalone_view("cemu", "retrodeck")
|
||||
mlc = [e for e in view["files"] if (e.get("layout_path") or "").startswith("mlc01/")]
|
||||
self.assertTrue(mlc)
|
||||
for entry in mlc:
|
||||
self.assertEqual(
|
||||
entry["standalone_path"], "cemu/" + entry["layout_path"].removeprefix("mlc01/")
|
||||
)
|
||||
(otp,) = [e for e in view["files"] if e["name"] == "otp.bin"]
|
||||
self.assertEqual(otp.get("unplaced"), "outside_bios_folder")
|
||||
|
||||
|
||||
class DolphinUserDirectory(unittest.TestCase):
|
||||
"""EmuELEC runs Dolphin with XDG_DATA_HOME=/storage/roms/dolphin (dolphin.sh:28),
|
||||
RetroDECK links $XDG_DATA_HOME/dolphin-emu/Triforce to bios/Triforce
|
||||
(dolphin/component_prepare.sh:30, 49)."""
|
||||
|
||||
def test_emuelec_installs_the_user_directory_below_its_roms(self) -> None:
|
||||
view = standalone_view("dolphin", "emuelec")
|
||||
placed = {e["name"]: e["standalone_path"] for e in view["files"] if e.get("layout_path")}
|
||||
self.assertEqual(placed["segaboot.gcm"], "dolphin/dolphin-emu/Triforce/segaboot.gcm")
|
||||
# A standalone-only entry's path is its place in the User directory.
|
||||
self.assertEqual(
|
||||
placed["rtl8723a_fw.bin"], "dolphin/dolphin-emu/Load/Firmware/rtl_bt/rtl8723a_fw.bin"
|
||||
)
|
||||
self.assertTrue(all(e.get("unprefixed") for e in view["files"] if e.get("layout_path")))
|
||||
|
||||
def test_retrodeck_places_triforce_alone(self) -> None:
|
||||
view = standalone_view("dolphin", "retrodeck")
|
||||
placed = {e["name"]: e["standalone_path"] for e in view["files"] if e.get("layout_path")}
|
||||
self.assertEqual(placed, {"segaboot.gcm": "Triforce/segaboot.gcm"})
|
||||
(ipl, *_) = [e for e in view["files"] if e["name"] == "IPL.bin"]
|
||||
self.assertEqual(ipl.get("unplaced"), "outside_bios_folder")
|
||||
|
||||
|
||||
class MameSearchPaths(unittest.TestCase):
|
||||
"""MAME reads each semicolon-separated search path in turn
|
||||
(src/emu/fileio.cpp:53-58, 330-392)."""
|
||||
|
||||
def sets(self, view: dict) -> list[dict]:
|
||||
return [e for e in view["files"] if e.get("category") == "bios_zip"]
|
||||
|
||||
def test_retrobat_keeps_the_sets_at_the_bios_root(self) -> None:
|
||||
# -rp bios;<rom directory> (Mame64.Generator.cs:93-96).
|
||||
view = standalone_view("mame", "retrobat")
|
||||
sets = self.sets(view)
|
||||
self.assertGreater(len(sets), 1000)
|
||||
for entry in sets:
|
||||
self.assertEqual(entry["standalone_path"], entry["name"])
|
||||
self.assertNotIn("unplaced", entry)
|
||||
(bbc,) = [e for e in view["files"] if e["name"] == "bbc.zip"]
|
||||
# `-sp` bios/mame/samples, hbmame's folder being another record
|
||||
# (Mame64.Generator.cs:30, 101, 106-107).
|
||||
self.assertEqual(bbc["standalone_path"], "mame/samples/bbc.zip")
|
||||
|
||||
def test_knulli_keeps_the_root_listed_after_bios_mame(self) -> None:
|
||||
# `-rompath` <romDirname>;/userdata/bios/mame;/userdata/bios (mameGenerator.py:116-122).
|
||||
view = standalone_view("mame", "knulli")
|
||||
self.assertTrue(all(e["standalone_path"] == e["name"] for e in self.sets(view)))
|
||||
(bbc,) = [e for e in view["files"] if e["name"] == "bbc.zip"]
|
||||
self.assertEqual(bbc["standalone_path"], "mame/samples/bbc.zip")
|
||||
|
||||
def test_retropie_moves_the_sets_to_bios_mame(self) -> None:
|
||||
# rompath $romdir/mame;$romdir/arcade;$biosdir/mame (mame.sh:133).
|
||||
view = standalone_view("mame", "retropie")
|
||||
self.assertTrue(all(
|
||||
e["standalone_path"] == "mame/" + e["name"] for e in self.sets(view)
|
||||
))
|
||||
|
||||
def test_retrodeck_reads_samples_in_mame_sa(self) -> None:
|
||||
# samplepath $bios_path/mame-sa/samples (mame/component_prepare.sh:94, 117).
|
||||
view = standalone_view("mame", "retrodeck")
|
||||
(bbc,) = [e for e in view["files"] if e["name"] == "bbc.zip"]
|
||||
self.assertEqual(bbc["standalone_path"], "mame-sa/samples/bbc.zip")
|
||||
# ES-DE hands `-rompath` %GAMEDIR%;%ROMPATH%/<system>: no BIOS folder.
|
||||
self.assertTrue(all(
|
||||
e.get("unplaced") == "outside_bios_folder"
|
||||
or str(e.get("standalone_path")).startswith("roms/")
|
||||
for e in self.sets(view)
|
||||
))
|
||||
|
||||
def test_a_passed_search_setting_leaves_the_bundled_tree_unread(self) -> None:
|
||||
# RetroBat passes `-hash` bios/mame/hash and `-sp` bios/mame/samples
|
||||
# (Mame64.Generator.cs:30, 101, 106-107, 172, 177-178), RetroDECK
|
||||
# writes samplepath $bios_path/mame-sa/samples (component_prepare.sh:94):
|
||||
# the trees beside the executable are not read, the pack brings them.
|
||||
for platform, tree, place in (
|
||||
("retrobat", "hash/", "mame/hash/"),
|
||||
("retrobat", "floppy/", "mame/samples/floppy/"),
|
||||
("knulli", "floppy/", "mame/samples/floppy/"),
|
||||
("retrodeck", "floppy/", "mame-sa/samples/floppy/"),
|
||||
):
|
||||
view = standalone_view("mame", platform)
|
||||
(entry,) = [e for e in view["files"]
|
||||
if e["name"] == tree and e.get("mode") == "standalone"]
|
||||
self.assertEqual(entry["standalone_path"], place, platform)
|
||||
self.assertNotIn("bundled", entry, platform)
|
||||
# Where no launcher passes the setting, the bundled copy is read.
|
||||
view = standalone_view("mame", "emudeck")
|
||||
(entry,) = [e for e in view["files"]
|
||||
if e["name"] == "hash/" and e.get("mode") == "standalone"]
|
||||
self.assertTrue(entry.get("bundled"))
|
||||
|
||||
def test_retropie_reads_samples_below_its_roms(self) -> None:
|
||||
# samplepath $romdir/mame/samples;$romdir/arcade/samples (mame.sh:135).
|
||||
view = standalone_view("mame", "retropie")
|
||||
(bbc,) = [e for e in view["files"] if e["name"] == "bbc.zip"]
|
||||
self.assertEqual((bbc["standalone_path"], bbc.get("root")),
|
||||
("mame/samples/bbc.zip", "roms"))
|
||||
(tree,) = [e for e in view["files"]
|
||||
if e["name"] == "floppy/" and e.get("mode") == "standalone"]
|
||||
self.assertEqual((tree["standalone_path"], tree.get("root")),
|
||||
("mame/samples/floppy/", "roms"))
|
||||
self.assertNotIn("bundled", tree)
|
||||
|
||||
def test_batocera_keeps_the_sets_at_the_root_and_samples_in_bios_mame(self) -> None:
|
||||
# `-rompath` <romDirname>;/userdata/bios/mame;/userdata/bios and
|
||||
# `-samplepath` /userdata/bios/mame/samples (mameGenerator.py:129-142).
|
||||
view = standalone_view("mame", "batocera")
|
||||
self.assertTrue(all(e["standalone_path"] == e["name"] for e in self.sets(view)))
|
||||
(bbc,) = [e for e in view["files"] if e["name"] == "bbc.zip"]
|
||||
self.assertEqual(bbc["standalone_path"], "mame/samples/bbc.zip")
|
||||
|
||||
def test_a_moved_tree_is_found_by_its_layout_path(self) -> None:
|
||||
from common import expand_directory_entries, load_database
|
||||
|
||||
db = load_database(str(REPO_ROOT / "database.json"))
|
||||
view = standalone_view("mame", "retrodeck")
|
||||
(tree,) = [e for e in view["files"]
|
||||
if e["name"] == "floppy/" and e.get("mode") == "standalone"]
|
||||
members = expand_directory_entries([tree], db, standalone=True)
|
||||
self.assertEqual(len(members), 19)
|
||||
for member in members:
|
||||
self.assertTrue(member["path"].startswith("mame-sa/samples/floppy/"))
|
||||
|
||||
def test_psxmame_reads_bios_psxmame_bios(self) -> None:
|
||||
# `-rompath` bios/psxmame/bios;<rom directory> (PSXMame.Generator.cs:38-48).
|
||||
view = standalone_view("psxmame", "retrobat")
|
||||
self.assertTrue(view["files"])
|
||||
for entry in view["files"]:
|
||||
self.assertEqual(entry["standalone_path"], "psxmame/bios/" + entry["name"])
|
||||
|
||||
|
||||
class LibretroMameSetsInMameBios(unittest.TestCase):
|
||||
"""libretro/mame searches the content folder, then <system>/mame/bios and
|
||||
<system>/mame/roms, never the system folder itself
|
||||
(src/osd/libretro/libretro-internal/retro_init.cpp:580-597)."""
|
||||
|
||||
def test_every_libretro_mame_set_is_read_in_mame_bios(self) -> None:
|
||||
profiles = load_emulator_profiles(str(REPO_ROOT / "emulators"))
|
||||
for key in ("mame", "mame0258", "mame0278", "mamearcade", "mamemess"):
|
||||
sets = [f for f in profiles[key]["files"] if f.get("category") == "bios_zip"
|
||||
and f.get("mode") != "standalone" and f["name"] != "bbc.zip"]
|
||||
self.assertTrue(sets, key)
|
||||
for entry in sets:
|
||||
self.assertEqual(entry.get("path"), "mame/bios/" + entry["name"], key)
|
||||
|
||||
def test_the_standalone_build_keeps_its_rompath_layout(self) -> None:
|
||||
profile = load_emulator_profiles(str(REPO_ROOT / "emulators"))["mame"]
|
||||
for entry in profile["files"]:
|
||||
if str(entry.get("path", "")).startswith("mame/bios/"):
|
||||
self.assertEqual(entry.get("standalone_path"), entry["name"])
|
||||
|
||||
def test_retrobat_lays_out_both_builds(self) -> None:
|
||||
# es_systems.cfg offers the libretro core mame and the standalone
|
||||
# mame64, two names of one profile.
|
||||
profile = load_emulator_profiles(str(REPO_ROOT / "emulators"))["mame"]
|
||||
config = load_platform_config("retrobat", str(REPO_ROOT / "platforms"))
|
||||
builds = sorted(s for _v, s in platform_layouts("mame", profile, standalone_set(config)))
|
||||
self.assertEqual(builds, [False, True])
|
||||
|
||||
|
||||
class GzdoomOnRetroDECK(unittest.TestCase):
|
||||
"""RetroDECK writes RETRODECKROMSDIR/doom into [IWADSearch.Directories]
|
||||
(gzdoom.ini:9, component_prepare.sh:27)."""
|
||||
|
||||
def test_the_iwads_land_in_roms_doom(self) -> None:
|
||||
view = standalone_view("gzdoom", "retrodeck")
|
||||
iwads = [e for e in view["files"] if e.get("system")]
|
||||
self.assertEqual(len(iwads), 43)
|
||||
for entry in iwads:
|
||||
self.assertEqual(entry["standalone_path"], "roms/doom/" + entry["name"])
|
||||
self.assertTrue(entry.get("unprefixed"))
|
||||
# The engine pk3s are read beside the executable first.
|
||||
(pk3,) = [e for e in view["files"] if e["name"] == "gzdoom.pk3"]
|
||||
self.assertNotIn("standalone_path", pk3)
|
||||
|
||||
def test_another_platform_keeps_them(self) -> None:
|
||||
view = standalone_view("gzdoom", "batocera")
|
||||
self.assertFalse(any(e.get("standalone_path") for e in view["files"]))
|
||||
|
||||
|
||||
def _reads_configs(profile: str) -> bool:
|
||||
"""Whether a repository profile carries config_reads."""
|
||||
path = REPO_ROOT / "emulators" / f"{profile}.yml"
|
||||
return bool((yaml.safe_load(path.read_text(encoding="utf-8")) or {}).get("config_reads"))
|
||||
|
||||
|
||||
# EmuELEC hands AdvanceMAME its folders through advmame.rc: the chain binds
|
||||
# once the profile says where the build reads them (config_reads).
|
||||
@unittest.skipUnless(
|
||||
_reads_configs("advancemame"), "advancemame.yml carries no config_reads, dir_rom is unproven"
|
||||
)
|
||||
class AdvanceMameOnEmuELEC(unittest.TestCase):
|
||||
"""advmame.rc sets dir_rom /storage/roms/mame, /storage/roms/arcade for
|
||||
the arcade system (advmame.rc:11, advmame.sh:26-30)."""
|
||||
|
||||
def test_the_sets_land_in_roms_mame_and_roms_arcade(self) -> None:
|
||||
# Started for arcade it reads roms/arcade, for mame and cps1-3
|
||||
# roms/mame (es_systems.json, advmame.sh:26-30): an arcade set is
|
||||
# read in both.
|
||||
view = standalone_view("advancemame", "emuelec")
|
||||
sets = [e for e in view["files"] if e.get("category") == "bios_zip"]
|
||||
self.assertEqual(len(sets), 52)
|
||||
places: dict[str, set[str]] = {}
|
||||
for entry in sets:
|
||||
self.assertTrue(entry.get("unprefixed"))
|
||||
places.setdefault(entry["name"], set()).add(entry["standalone_path"])
|
||||
self.assertEqual(len(places), 26)
|
||||
for name, paths in places.items():
|
||||
self.assertEqual(paths, {"mame/" + name, "arcade/" + name})
|
||||
|
||||
def test_both_copies_are_one_file(self) -> None:
|
||||
# Outside the BIOS tree the folder is no proof of content: each copy
|
||||
# resolves by its layout path, so both folders hold the same file.
|
||||
from common import load_database
|
||||
|
||||
db = load_database(str(REPO_ROOT / "database.json"))
|
||||
with redirect_stdout(io.StringIO()):
|
||||
manifest = generate_manifest(
|
||||
"emuelec", str(REPO_ROOT / "platforms"), db, str(REPO_ROOT / "bios"),
|
||||
str(REPO_ROOT / "platforms" / "_registry.yml"),
|
||||
emulators_dir=str(REPO_ROOT / "emulators"), offline=True,
|
||||
)
|
||||
# mame2003_plus reads its own sets in arcade/ too (es_systems.cfg):
|
||||
# the copy AdvanceMAME reads there is the one its claim names.
|
||||
def advancemame_copy(entry: dict) -> str | None:
|
||||
for copy in (entry, *(entry.get("alternatives") or [])):
|
||||
if "advancemame" in (copy.get("cores") or []):
|
||||
return copy["sha1"]
|
||||
return None
|
||||
|
||||
by_dest = {f["dest"]: advancemame_copy(f) for f in manifest["files"]}
|
||||
sets = [d.removeprefix("arcade/") for d, sha1 in by_dest.items()
|
||||
if d.startswith("arcade/") and sha1]
|
||||
self.assertEqual(len(sets), 26)
|
||||
for name in sets:
|
||||
self.assertEqual(by_dest["arcade/" + name], by_dest["mame/" + name], name)
|
||||
|
||||
def test_the_roms_folder_is_no_proof_of_content(self) -> None:
|
||||
# bios/Arcade/MAME/konamigv.zip is MAME 0.289's set, not AdvanceMAME's.
|
||||
from common import load_database, resolve_local_file
|
||||
|
||||
db = load_database(str(REPO_ROOT / "database.json"))
|
||||
view = standalone_view("advancemame", "emuelec")
|
||||
entry = next(e for e in view["files"]
|
||||
if e["name"] == "konamigv.zip" and e["standalone_path"].startswith("mame/"))
|
||||
moved, _status = resolve_local_file(entry, db, dest_hint=entry["standalone_path"])
|
||||
plain = {k: v for k, v in entry.items()
|
||||
if k not in ("layout_path", "standalone_path", "unprefixed")}
|
||||
root, _status = resolve_local_file(plain, db, dest_hint=entry["name"])
|
||||
self.assertEqual(moved, root)
|
||||
self.assertNotIn("/MAME/", moved)
|
||||
|
||||
|
||||
def libretro_view(emulator: str, platform: str) -> dict:
|
||||
profile = load_emulator_profiles(str(REPO_ROOT / "emulators"))[emulator]
|
||||
config = load_platform_config(platform, str(REPO_ROOT / "platforms"))
|
||||
(view,) = [v for v, standalone in platform_layouts(emulator, profile, standalone_set(config))
|
||||
if not standalone]
|
||||
return view
|
||||
|
||||
|
||||
class SetsReadBesideTheGame(unittest.TestCase):
|
||||
"""MAME 2016 and older search the folder of the loaded game for their
|
||||
sets and never the system folder (mame2003 src/fileio.c:217-220,
|
||||
mame2010 src/emu/romload.c:667-685, mame2016
|
||||
src/osd/retro/retromain.cpp:1364-1402)."""
|
||||
|
||||
CORES = ("mame2000", "mame2003", "mame2003_plus", "mame2009", "mame2010",
|
||||
"mame2014", "mame2015", "mame2016", "ume2015")
|
||||
|
||||
def test_each_set_is_read_beside_the_game(self) -> None:
|
||||
profiles = load_emulator_profiles(str(REPO_ROOT / "emulators"))
|
||||
for key in self.CORES:
|
||||
sets = [f for f in profiles[key]["files"] if f.get("category") == "bios_zip"]
|
||||
self.assertTrue(sets, key)
|
||||
for entry in sets:
|
||||
self.assertEqual(entry.get("load_from"), "content_dir", (key, entry["name"]))
|
||||
|
||||
def test_batocera_places_them_in_the_folders_it_launches_the_core_for(self) -> None:
|
||||
# es_systems.yml offers mame078plus under mame and neogeo.
|
||||
view = libretro_view("mame2003_plus", "batocera")
|
||||
neogeo = [e for e in view["files"] if e["name"] == "neogeo.zip"]
|
||||
self.assertEqual(sorted(e["path"] for e in neogeo), ["mame/neogeo.zip", "neogeo/neogeo.zip"])
|
||||
self.assertTrue(all(e["root"] == "roms" and "load_from" not in e for e in neogeo))
|
||||
|
||||
def test_retroarch_names_them_outside_the_bios_folder(self) -> None:
|
||||
# RetroArch keeps no folder per system: the game's folder is the user's.
|
||||
view = libretro_view("mame2003", "retroarch")
|
||||
sets = [e for e in view["files"] if e.get("category") == "bios_zip"]
|
||||
self.assertTrue(sets)
|
||||
self.assertTrue(all(e.get("unplaced") == "outside_bios_folder" for e in sets))
|
||||
|
||||
def test_game_data_beside_the_content_is_left_to_the_game(self) -> None:
|
||||
view = libretro_view("mame2000", "retroarch")
|
||||
(hiscore,) = [e for e in view["files"] if e["name"] == "hiscore.dat"]
|
||||
self.assertEqual(hiscore.get("load_from"), "content_dir")
|
||||
self.assertNotIn("unplaced", hiscore)
|
||||
|
||||
def test_a_mess_build_takes_no_arcade_set(self) -> None:
|
||||
# lr-mess2016 builds mame2016 with SUBTARGET=mess (lr-mess2016.sh:31).
|
||||
view = libretro_view("mame2016", "retropie")
|
||||
folders = {e["path"].split("/")[0] for e in view["files"] if e.get("root") == "roms"}
|
||||
self.assertEqual(folders, {"arcade", "mame-libretro"})
|
||||
|
||||
def test_emulatorjs_writes_the_bios_beside_the_game(self) -> None:
|
||||
# data/src/emulator.js:845, 990, 1054: one filesystem root for both.
|
||||
view = libretro_view("mame2003_plus", "romm")
|
||||
sets = [e for e in view["files"] if e.get("category") == "bios_zip"]
|
||||
self.assertTrue(all("load_from" not in e and "root" not in e for e in sets))
|
||||
|
||||
def test_the_manifest_drops_the_root_copy_no_core_reads(self) -> None:
|
||||
from common import load_database
|
||||
|
||||
db = load_database(str(REPO_ROOT / "database.json"))
|
||||
with redirect_stdout(io.StringIO()):
|
||||
manifest = generate_manifest(
|
||||
"rocknix", str(REPO_ROOT / "platforms"), db, str(REPO_ROOT / "bios"),
|
||||
str(REPO_ROOT / "platforms" / "_registry.yml"),
|
||||
emulators_dir=str(REPO_ROOT / "emulators"), offline=True,
|
||||
)
|
||||
dests = {(f.get("root") or "", f["dest"]) for f in manifest["files"]}
|
||||
# ROCKNIX starts mame2003_plus for arcade and mame (arcade.conf, mame.conf),
|
||||
# and no core it runs reads coh1000c.zip at the BIOS root.
|
||||
self.assertIn(("roms", "arcade/coh1000c.zip"), dests)
|
||||
self.assertIn(("roms", "mame/coh1000c.zip"), dests)
|
||||
self.assertNotIn(("", "coh1000c.zip"), dests)
|
||||
|
||||
|
||||
class MameOnRetroDeckRomPaths(unittest.TestCase):
|
||||
"""ES-DE starts standalone MAME with `-rompath` %GAMEDIR%;%ROMPATH%/<system>
|
||||
(resources/systems/linux/es_systems.xml), which outranks mame.ini."""
|
||||
|
||||
def test_the_rom_folders_file_records_each_search_path(self) -> None:
|
||||
with (REPO_ROOT / "platforms" / "romfolders" / "retrodeck.yml").open() as f:
|
||||
rows = yaml.safe_load(f)["folders"]
|
||||
found = {r["folder"]: s for r in rows for s in r.get("searched_by") or []}
|
||||
self.assertEqual(len(found), 54)
|
||||
self.assertEqual(found["tanodragon"]["reads"], ["dragon32"])
|
||||
self.assertEqual(found["adam"]["machines"], ["adam"])
|
||||
self.assertTrue(found["neogeo"]["any_machine"])
|
||||
|
||||
def test_a_machine_reads_its_own_set_and_its_devices(self) -> None:
|
||||
from common import rom_search_sets
|
||||
|
||||
self.assertIn("adam", rom_search_sets("mame", "adam", ["adam"], False))
|
||||
neogeo = rom_search_sets("mame", "neogeo", [], True)
|
||||
self.assertIn("neogeo", neogeo)
|
||||
self.assertNotIn("stvbios", neogeo)
|
||||
# A folder that holds any machine reads every BIOS set.
|
||||
self.assertIn("stvbios", rom_search_sets("mame", "mame", [], True))
|
||||
|
||||
def test_sets_land_in_the_folders_that_read_them(self) -> None:
|
||||
# RetroDECK's roms/ sits beside bios/ in the install tree.
|
||||
view = standalone_view("mame", "retrodeck")
|
||||
places = {}
|
||||
for e in view["files"]:
|
||||
if e.get("unprefixed") and e["standalone_path"].startswith("roms/"):
|
||||
places.setdefault(e["name"], set()).add(e["standalone_path"].split("/")[1])
|
||||
self.assertEqual(places["adam.zip"], {"adam"})
|
||||
self.assertIn("neogeo", places["neogeo.zip"])
|
||||
self.assertNotIn("adam", places["neogeo.zip"])
|
||||
self.assertEqual(places["stvbios.zip"] - {"arcade", "mame", "consolearcade"}, {"stv"})
|
||||
|
||||
|
||||
class LibretroMameOnEsdeRomPaths(unittest.TestCase):
|
||||
"""ES-DE hands the libretro MAME core a command line as its content,
|
||||
with `-rompath` "%GAMEDIRRAW%;%ROMPATH%/<system>" after the machine. The
|
||||
core passes it to MAME after its own <system>/mame/bios, and the later
|
||||
value wins (retro_init.cpp:580-597, 902-940, options.cpp:260-276)."""
|
||||
|
||||
def test_the_rom_folders_file_records_the_core(self) -> None:
|
||||
with (REPO_ROOT / "platforms" / "romfolders" / "retrodeck.yml").open() as f:
|
||||
rows = yaml.safe_load(f)["folders"]
|
||||
found = {r["folder"]: s for r in rows for s in r.get("searched_by") or []
|
||||
if s.get("core") == "mame"}
|
||||
self.assertEqual(len(found), 21)
|
||||
self.assertEqual(found["apple2"]["machines"], ["apple2e"])
|
||||
self.assertEqual(found["atari7800"]["reads"], ["atari7800"])
|
||||
self.assertEqual(found["atari7800"]["emulator"], "retroarch")
|
||||
|
||||
def test_sets_also_land_in_the_folder_the_command_names(self) -> None:
|
||||
# RetroDECK's roms/ sits beside bios/ in the install tree.
|
||||
for platform, read in (("retrodeck", ("", "roms/gamate/gamate.zip")),
|
||||
("emudeck", ("roms", "gamate/gamate.zip"))):
|
||||
view = libretro_view("mame", platform)
|
||||
places = {(e.get("root") or "", e["path"]) for e in view["files"]
|
||||
if e["name"] == "gamate.zip"}
|
||||
self.assertEqual(places, {("", "mame/bios/gamate.zip"), read}, platform)
|
||||
|
||||
|
||||
class StandaloneMameOnEmuDeck(unittest.TestCase):
|
||||
"""EmuDeck writes mame.ini rompath roms/arcade;bios;bios/mame
|
||||
(emuDeckMAME.sh:66-68), read when Steam ROM Manager starts MAME with no
|
||||
`-rompath` (tools/launchers/mame.sh). ES-DE's commands pass their own."""
|
||||
|
||||
def test_a_set_keeps_its_ini_place_and_gains_the_command_folder(self) -> None:
|
||||
view = standalone_view("mame", "emudeck")
|
||||
places = {(e.get("root") or "", e["standalone_path"]) for e in view["files"]
|
||||
if e["name"] == "adam.zip"}
|
||||
self.assertIn(("", "adam.zip"), places)
|
||||
self.assertIn(("roms", "adam/adam.zip"), places)
|
||||
|
||||
|
||||
class EveryCoreAFolderOffers(unittest.TestCase):
|
||||
"""AmberELEC's es_systems.cfg, EmuELEC's es_systems.json and ROCKNIX's
|
||||
add_emu_core calls offer several cores per folder, the user's choice
|
||||
starting any of them."""
|
||||
|
||||
def test_the_rom_folders_files_record_the_offers(self) -> None:
|
||||
for setup, folder, core in (("amberelec", "arcade", "mame2010"),
|
||||
("emuelec", "arcade", "mame2010"),
|
||||
("rocknix", "arcade", "mame2010")):
|
||||
with (REPO_ROOT / "platforms" / "romfolders" / f"{setup}.yml").open() as f:
|
||||
rows = {r["folder"]: r for r in yaml.safe_load(f)["folders"]}
|
||||
self.assertIn(core, {o["core"] for o in rows[folder].get("offers") or []}, setup)
|
||||
|
||||
def test_an_offered_core_reads_its_sets_in_that_folder(self) -> None:
|
||||
for platform in ("amberelec", "rocknix"):
|
||||
view = libretro_view("mame2010", platform)
|
||||
folders = {e["path"].split("/")[0] for e in view["files"]
|
||||
if e.get("category") == "bios_zip" and e.get("layout_path")}
|
||||
self.assertIn("arcade", folders, platform)
|
||||
|
||||
|
||||
class CloneReadsItsParent(unittest.TestCase):
|
||||
"""ES-DE starts odyssey2 with `-rompath` on roms/odyssey2 alone, and MAME
|
||||
finds o2bios.rom in the parent's videopac.zip (src/emu/driver.cpp:31-38)."""
|
||||
|
||||
def test_the_parent_set_goes_to_the_clone_folder(self) -> None:
|
||||
from common import rom_search_sets
|
||||
|
||||
self.assertIn("videopac", rom_search_sets("mame", "odyssey2", ["odyssey2"], False))
|
||||
for platform, dest in (("emudeck", "odyssey2/videopac.zip"),
|
||||
("retrodeck", "roms/odyssey2/videopac.zip")):
|
||||
with self.subTest(platform=platform):
|
||||
dests = {f["dest"] for f in platform_manifest(platform)["files"]}
|
||||
self.assertIn(dest, dests)
|
||||
|
||||
|
||||
class AdvanceMameOnRetroPie(unittest.TestCase):
|
||||
"""RetroPie writes dir_rom $romdir/mame-advmame:$romdir/arcade into each
|
||||
AdvanceMAME build's rc (advmame.sh:100), the list the code splits on ':'
|
||||
(advance/linux/file.c:138-141)."""
|
||||
|
||||
def test_the_sets_go_to_the_first_folder_searched(self) -> None:
|
||||
config = load_platform_config("retropie", str(REPO_ROOT / "platforms"))
|
||||
profiles = load_emulator_profiles(str(REPO_ROOT / "emulators"))
|
||||
tags = standalone_set(config)
|
||||
for emu in ("advmame", "advmame-1.4", "advmame-0.94"):
|
||||
with self.subTest(emu=emu):
|
||||
placed = [
|
||||
(f.get("root"), f.get("standalone_path"))
|
||||
for view, standalone in platform_layouts(emu, profiles[emu], tags)
|
||||
if standalone
|
||||
for f in view["files"] if isinstance(f, dict) and f["name"] == "neogeo.zip"
|
||||
]
|
||||
self.assertEqual(placed, [("roms", "mame-advmame/neogeo.zip")])
|
||||
|
||||
|
||||
class CoreOfferedOnSomeBoards(unittest.TestCase):
|
||||
"""ROCKNIX writes some add_emu_core calls under a `case "${DEVICE}"`
|
||||
branch (emulators/package.mk:188 offers uae4arm for amiga on the devices
|
||||
it builds it for). A board's pack places such a core in that folder only
|
||||
when the branch names the board, and a manifest for every board says
|
||||
where it does."""
|
||||
|
||||
ROW = {
|
||||
"folder": "amiga", "core": "puae", "emulator": "retroarch",
|
||||
"offers": [
|
||||
{"emulator": "retroarch", "core": "puae"},
|
||||
{"emulator": "retroarch", "core": "uae4arm", "when": "DEVICE H700|RK3326"},
|
||||
{"emulator": "retroarch", "core": "puae2021",
|
||||
"when": 'if [ "${PREFER_GLES}" = "yes" ]; then'},
|
||||
],
|
||||
}
|
||||
|
||||
def config(self, **extra) -> dict:
|
||||
base = load_platform_config("rocknix", str(REPO_ROOT / "platforms"))
|
||||
return {**base, "_rom_folders": [self.ROW], **extra}
|
||||
|
||||
def test_a_branch_names_the_boards(self) -> None:
|
||||
from common import when_admits
|
||||
|
||||
self.assertTrue(when_admits("DEVICE H700|RK3326", "rk3326"))
|
||||
self.assertFalse(when_admits("DEVICE H700|RK3326", "s922x"))
|
||||
self.assertTrue(when_admits("DEVICE AMD64; DEVICE RK3588*", "rk3588"))
|
||||
self.assertTrue(when_admits('if [ "${PREFER_GLES}" = "yes" ]; then', "h700"))
|
||||
|
||||
def test_an_offer_carries_the_boards_its_branch_names(self) -> None:
|
||||
from common import offer_boards
|
||||
|
||||
boards = offer_boards(self.config())
|
||||
self.assertEqual(boards[("uae4arm", "amiga")], frozenset({"h700", "rk3326"}))
|
||||
self.assertIsNone(boards[("puae", "amiga")])
|
||||
self.assertIsNone(boards[("puae2021", "amiga")])
|
||||
|
||||
def test_a_board_pack_places_the_core_where_the_board_offers_it(self) -> None:
|
||||
from common import CONTENT_FOLDER_PREFIX, TARGET_KEY, content_folder_tags
|
||||
|
||||
def placed(config: dict) -> dict:
|
||||
rows = [json.loads(t[len(CONTENT_FOLDER_PREFIX):]) for t in content_folder_tags(config)
|
||||
if t.startswith(CONTENT_FOLDER_PREFIX)]
|
||||
return {core: on for core, _folder, _where, on in rows}
|
||||
|
||||
every = placed(self.config())
|
||||
self.assertEqual(every["uae4arm"], ["h700", "rk3326"])
|
||||
self.assertIsNone(every["puae"])
|
||||
self.assertIn("uae4arm", placed(self.config(**{TARGET_KEY: "rk3326"})))
|
||||
self.assertNotIn("uae4arm", placed(self.config(**{TARGET_KEY: "s922x"})))
|
||||
self.assertIn("puae", placed(self.config(**{TARGET_KEY: "s922x"})))
|
||||
|
||||
|
||||
def platform_manifest(platform: str) -> dict:
|
||||
from common import load_database
|
||||
|
||||
db = load_database(str(REPO_ROOT / "database.json"))
|
||||
with redirect_stdout(io.StringIO()):
|
||||
return generate_manifest(
|
||||
platform, str(REPO_ROOT / "platforms"), db, str(REPO_ROOT / "bios"),
|
||||
str(REPO_ROOT / "platforms" / "_registry.yml"),
|
||||
emulators_dir=str(REPO_ROOT / "emulators"), offline=True,
|
||||
)
|
||||
|
||||
|
||||
class ArchiveSharedByOfferedCores(unittest.TestCase):
|
||||
"""One path holds one file: several cores reading an archive in one roms
|
||||
folder get the copy of the core the folder starts by default, then the
|
||||
copy serving the most of them."""
|
||||
|
||||
def test_the_default_core_copy_takes_the_folder(self) -> None:
|
||||
# EmuELEC's arcade folder starts MAME 2003-Plus by default
|
||||
# (es_systems.json:82), AdvanceMAME reads its sets there too.
|
||||
(entry,) = [f for f in platform_manifest("emuelec")["files"]
|
||||
if f["dest"] == "arcade/neogeo.zip"]
|
||||
self.assertEqual(entry["cores"], ["mame2003_plus"])
|
||||
self.assertTrue(entry["repo_path"].endswith("neogeo.zip.74df3258"))
|
||||
others = {c for a in entry.get("alternatives", []) for c in a["cores"]}
|
||||
self.assertIn("advancemame", others)
|
||||
|
||||
def test_offered_cores_join_the_default_one(self) -> None:
|
||||
# AmberELEC's arcade folder starts MAME 2003-Plus and offers MAME
|
||||
# 2000, 2010, 2015 and 2016 (es_systems.cfg:116-150).
|
||||
(entry,) = [f for f in platform_manifest("amberelec")["files"]
|
||||
if f["dest"] == "arcade/neogeo.zip"]
|
||||
self.assertEqual(entry["cores"], ["mame2003_plus"])
|
||||
self.assertTrue(entry["repo_path"].endswith("neogeo.zip.74df3258"))
|
||||
others = {c for a in entry.get("alternatives", []) for c in a["cores"]}
|
||||
self.assertLessEqual({"mame2000", "mame2010", "mame2015", "mame2016"}, others)
|
||||
|
||||
def test_the_copy_serving_most_cores_wins_without_a_default(self) -> None:
|
||||
# RetroDECK's cps folders start the libretro MAME core, whose sets are
|
||||
# in mame/bios. Of the cores reading nss.zip in cps1, MAME 2003-Plus
|
||||
# alone lists members, and only its copy holds them.
|
||||
(entry,) = [f for f in platform_manifest("retrodeck")["files"]
|
||||
if f["dest"] == "roms/cps1/nss.zip"]
|
||||
self.assertEqual(entry["cores"], ["mame2003_plus"])
|
||||
self.assertTrue(entry["repo_path"].endswith("nss.zip.cba0bd8c"))
|
||||
|
||||
|
||||
class MacBootDisksOnKnulli(unittest.TestCase):
|
||||
def test_the_hard_records_bind(self) -> None:
|
||||
# mameGenerator.py and libretroMAMEConfig.py pass the boot disk as
|
||||
# -hard, the brief name of the LC III's one hard disk image
|
||||
# (harddriv.h:43, diimage.cpp:1131-1165, maclc3.cpp:266).
|
||||
from launchers import bound_launchers
|
||||
|
||||
config = load_platform_config("knulli", str(REPO_ROOT / "platforms"))
|
||||
profiles = load_emulator_profiles(str(REPO_ROOT / "emulators"))
|
||||
bound = [r for r in bound_launchers(config, profiles)
|
||||
if r.get("emulator") == "mame" and "-hard" in str(r.get("passes_to"))]
|
||||
self.assertEqual(sorted(r["build"] for r in bound), ["libretro", "standalone"])
|
||||
|
||||
|
||||
class ArcadeParentSources(unittest.TestCase):
|
||||
def test_the_index_names_each_driver_source(self) -> None:
|
||||
import json
|
||||
|
||||
with (REPO_ROOT / "games" / "arcade" / "mame.json").open() as f:
|
||||
index = json.load(f)
|
||||
self.assertIn("sf2", index["sources"]["capcom/cps1.cpp"])
|
||||
self.assertIn("qsound_hle", {d for sets in index["sources"].values() for d in sets})
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -529,6 +529,46 @@ OPENMSX_FILEPOOL = ''' def generate(self, system, rom):
|
||||
file.write("filepool add -path /userdata/bios/openmsx -types system_rom -position 2\\n")'''
|
||||
|
||||
|
||||
MAME = f"{GENERATORS}/mame/mameGenerator.py"
|
||||
MAME_PATHS = f"{GENERATORS}/mame/mamePaths.py"
|
||||
MAME_HEAD = """from __future__ import annotations
|
||||
from ...batoceraPaths import BIOS
|
||||
from .mamePaths import MAME_BIOS
|
||||
class MameGenerator:
|
||||
def generate(self, system, rom, playersControllers, metadata, guns, wheels, gameResolution):"""
|
||||
MAME_COMMAND = """ if messMode == -1:
|
||||
commandArray += [ "-rompath", f"{romDirname};{MAME_BIOS};{BIOS}" ]"""
|
||||
MAME_SAMPLES = """ commandArray += [ "-samplepath", MAME_BIOS / "samples" ]"""
|
||||
MAME_BOOT = """ if boot_disk:
|
||||
bootDisk = f"/userdata/bios/{boot_disk}.img"
|
||||
commandArray += [ bootType, bootDisk ]"""
|
||||
|
||||
|
||||
class MameSearchPaths(unittest.TestCase):
|
||||
"""mameGenerator.py:129-142 at batocera-43.1: `-rompath` and `-samplepath`."""
|
||||
|
||||
def test_the_command_line_search_paths_are_recorded(self):
|
||||
from scraper.batocera_launchers import search_paths
|
||||
|
||||
cg = configgen({
|
||||
MAME: placed({1: MAME_HEAD, 129: MAME_COMMAND, 142: MAME_SAMPLES, 378: MAME_BOOT}),
|
||||
MAME_PATHS: "from ...batoceraPaths import BIOS\nMAME_BIOS = BIOS / 'mame'\n",
|
||||
})
|
||||
records = [r.entry() for r in search_paths(cg)]
|
||||
self.assertEqual(
|
||||
[(r["emulator"], r["search_dir"], r["passes_to"], r.get("depends_on_option"))
|
||||
for r in records],
|
||||
[
|
||||
("mame", "<romDirname>;/userdata/bios/mame;/userdata/bios",
|
||||
"command line -rompath", "messMode == -1"),
|
||||
("mame", "/userdata/bios/mame/samples", "command line -samplepath", None),
|
||||
],
|
||||
)
|
||||
self.assertEqual(records[0]["source_ref"], f"{MAME}:129-130")
|
||||
# The boot disk the command names is a file, no search path.
|
||||
self.assertFalse([r for r in records if "boot_disk" in r["search_dir"]])
|
||||
|
||||
|
||||
class ConfigDirectories(unittest.TestCase):
|
||||
"""A BIOS directory written into the emulator's config, at batocera-43.1."""
|
||||
|
||||
|
||||
@@ -105,22 +105,6 @@ HATARI_CFG = text(
|
||||
"""
|
||||
)
|
||||
|
||||
ATARI800_CFG = text(
|
||||
"""
|
||||
Atari 800 Emulator, Version 3.1.0
|
||||
ROM_OS_A_NTSC=
|
||||
ROM_OS_A_PAL=/storage/roms/bios/ATARIOSA.ROM
|
||||
ROM_5200=/storage/roms/bios/5200.rom
|
||||
"""
|
||||
)
|
||||
|
||||
ATARI800_PATCH = text(
|
||||
"""
|
||||
+ LDFLAGS += -static-libgcc
|
||||
+ CFLAGS += -DDEFAULT_CFG_NAME="\\"/storage/.config/distribution/configs/atari800.cfg\\""
|
||||
"""
|
||||
)
|
||||
|
||||
AMIBERRY_MK = text(
|
||||
"""
|
||||
makeinstall_target() {
|
||||
@@ -141,6 +125,17 @@ AMIBERRY_SH = text(
|
||||
cp $AMIBERRY_CONFIG_DIR/AmigaA500-default.uae "$AMIBERRY_TMP_CONFIG"
|
||||
fi
|
||||
}
|
||||
amiberry -f "$AMIBERRY_TMP_CONFIG" --autoload "$1" >> $AMIBERRY_LOG 2>&1
|
||||
"""
|
||||
)
|
||||
|
||||
USERCONFIG = text(
|
||||
"""
|
||||
#!/bin/bash
|
||||
if [ ! -e "/storage/.configured" ]
|
||||
then
|
||||
rsync -a --ignore-existing --exclude=es_systems.cfg /usr/config/* /storage/.config/ || exit 1
|
||||
fi
|
||||
"""
|
||||
)
|
||||
|
||||
@@ -195,8 +190,7 @@ def tree(**overrides: str) -> dict[str, str]:
|
||||
al.SCRIPTS["piemu"]: PIEMU,
|
||||
al.SCRIPTS["HATARISA"]: HATARI_SH,
|
||||
al.HATARI_CONFIG: HATARI_CFG,
|
||||
al.ATARI800_CONFIG: ATARI800_CFG,
|
||||
al.ATARI800_PATCH: ATARI800_PATCH,
|
||||
al.USERCONFIG: USERCONFIG,
|
||||
al.AMIBERRY_PACKAGE: AMIBERRY_MK,
|
||||
al.SCRIPTS["AMIBERRY"]: AMIBERRY_SH,
|
||||
f"{al.AMIBERRY_CONFIGS}/AmigaA1200-default.uae": uae("kick40068.A1200.rom"),
|
||||
@@ -218,6 +212,13 @@ class Frontends(unittest.TestCase):
|
||||
(record,) = al.retroarch(read())
|
||||
self.assertEqual(record.search_dir, "~/roms/bios")
|
||||
self.assertEqual(record.source_ref, f"{al.RETROARCH_CFG}:2")
|
||||
# The first boot copies /usr/config and leaves a file already there.
|
||||
self.assertEqual(record.installs, {
|
||||
"path": "/storage/.config/retroarch/retroarch.cfg",
|
||||
"source_ref": f"{al.USERCONFIG}:4",
|
||||
})
|
||||
self.assertIs(record.kept_if_present, True)
|
||||
self.assertEqual(record.overrides, [])
|
||||
|
||||
def test_retrorun_directory(self):
|
||||
(record,) = al.retrorun(read())
|
||||
@@ -266,6 +267,9 @@ class Standalone(unittest.TestCase):
|
||||
record.source_ref,
|
||||
f"{al.RUNEMU}:3, {al.SCRIPTS['HATARISA']}:3-4, {al.HATARI_CONFIG}:2",
|
||||
)
|
||||
# Copied over at each launch: nothing the user edits survives.
|
||||
self.assertEqual(record.installs["source_ref"], f"{al.SCRIPTS['HATARISA']}:3")
|
||||
self.assertIs(record.kept_if_present, False)
|
||||
|
||||
def test_amiberry_link_and_one_kickstart_per_config(self):
|
||||
link, a1200, a500 = al.amiberry(read(), al.Runemu(read()))
|
||||
@@ -273,7 +277,11 @@ class Standalone(unittest.TestCase):
|
||||
self.assertEqual(link.passes_to, "/usr/config/amiberry/kickstarts is a symlink to it")
|
||||
self.assertEqual((a1200.slot, a1200.names), ("A1200", ["kick40068.A1200.rom"]))
|
||||
self.assertEqual((a500.slot, a500.names), ("A500", ["kick34005.A500.rom"]))
|
||||
self.assertEqual(a500.depends_on_option, f"not ({a1200.depends_on_option})")
|
||||
self.assertTrue(a500.depends_on_option.startswith("not ("))
|
||||
# A WHDLoad boot replaces the setup the config gives.
|
||||
self.assertIn("--autoload", a1200.depends_on_option)
|
||||
self.assertEqual(a1200.installs["source_ref"], f"{al.SCRIPTS['AMIBERRY']}:5")
|
||||
self.assertEqual(a500.installs["source_ref"], f"{al.SCRIPTS['AMIBERRY']}:7")
|
||||
|
||||
def test_a_table_running_another_script_raises(self):
|
||||
broken = RUNEMU.replace("/usr/bin/yabasanshiro.sh", "/usr/bin/yaba.sh")
|
||||
@@ -287,15 +295,9 @@ class Standalone(unittest.TestCase):
|
||||
|
||||
|
||||
class Cores(unittest.TestCase):
|
||||
def test_atari800_built_to_read_the_shipped_config(self):
|
||||
(record,) = al.atari800(read())
|
||||
self.assertEqual(record.names, ["ATARIOSA.ROM", "5200.rom"])
|
||||
self.assertEqual(record.source_ref, f"{al.ATARI800_PATCH}:2, {al.ATARI800_CONFIG}:3-4")
|
||||
|
||||
def test_atari800_built_for_another_config_raises(self):
|
||||
broken = ATARI800_PATCH.replace("atari800.cfg", "other.cfg")
|
||||
with self.assertRaises(LauncherShapeError):
|
||||
al.atari800(read(**{al.ATARI800_PATCH: broken}))
|
||||
def test_atari800_config_is_no_record(self):
|
||||
# The core reads atari800.cfg only under an option that is off.
|
||||
self.assertFalse(any(r["emulator"] == "atari800" for r in al.extract_launchers(read())))
|
||||
|
||||
def test_scummvm_paths_written_under_bios(self):
|
||||
theme, extra = al.scummvm(read())
|
||||
@@ -319,7 +321,7 @@ class Cores(unittest.TestCase):
|
||||
def test_every_extractor_runs_on_the_fixture(self):
|
||||
records = al.extract_launchers(read())
|
||||
# One easyrpg runtime in the fixture, two at the pinned commit.
|
||||
self.assertEqual(len(records), 16)
|
||||
self.assertEqual(len(records), 15)
|
||||
|
||||
|
||||
class PlatformFile(unittest.TestCase):
|
||||
|
||||
@@ -40,6 +40,9 @@ ARES_SH = text(
|
||||
UserBIOSPath='/home/deck/Emulation/bios/'
|
||||
sed -i "s|$UserBIOSPath|${biosPath}\\/|g" "$ares_configFile"
|
||||
}
|
||||
ares_init(){
|
||||
configEmuFP "${ares_emuName}" "${ares_emuPath}" "true"
|
||||
}
|
||||
"""
|
||||
)
|
||||
|
||||
@@ -87,6 +90,9 @@ MELONDS_SH = text(
|
||||
buttonA='Joy_A='
|
||||
changeLine "$buttonA" "$buttonA""0" "${melonDS_configFile}"
|
||||
}
|
||||
melonDS_update(){
|
||||
configEmuFP "${melonDS_emuName}" "${melonDS_emuPath}"
|
||||
}
|
||||
"""
|
||||
)
|
||||
|
||||
@@ -103,6 +109,7 @@ MELONDS_TOML = text(
|
||||
LastROMFolder = "/run/media/mmcblk0p1/Emulation/roms/ds"
|
||||
[Emu]
|
||||
ExternalBIOSEnable = false
|
||||
ConsoleType = 0
|
||||
[DS]
|
||||
FirmwarePath = "/run/media/mmcblk0p1/Emulation/bios/firmware.bin"
|
||||
BIOS7Path = "/run/media/mmcblk0p1/Emulation/bios/bios7.bin"
|
||||
@@ -206,8 +213,23 @@ SHADPS4_SH = text(
|
||||
)
|
||||
|
||||
|
||||
CONFIG_EMU_FP = text(
|
||||
"""
|
||||
configEmuFP(){
|
||||
if [[ $overwrite == 'true' ]]; then
|
||||
overwrite="--backup --suffix=.bak"
|
||||
else
|
||||
overwrite="--ignore-existing"
|
||||
fi
|
||||
rsync -avhp --mkpath "$emudeckBackend/configs/${ID}" "$HOME/.var/app/" $overwrite
|
||||
}
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
def tree(**scripts: str) -> RepoTree:
|
||||
files = {f"{S}/{name}": body for name, body in scripts.items()}
|
||||
files[el.CONFIG_EMU_FP] = CONFIG_EMU_FP
|
||||
files[f"{el.CONFIGS}/dev.ares.ares/data/ares/settings.bml"] = ARES_BML
|
||||
files[f"{el.CONFIGS}/net.kuribo64.melonDS/config/melonDS/melonDS.ini"] = MELONDS_INI
|
||||
files[f"{el.CONFIGS}/net.kuribo64.melonDS/config/melonDS/melonDS.toml"] = MELONDS_TOML
|
||||
@@ -253,8 +275,17 @@ class WrittenIntoTheConfig(unittest.TestCase):
|
||||
self.assertEqual(
|
||||
toml["passes_to"], "melonDS.toml [DS] FirmwarePath, BIOS7Path [DSi] NANDPath"
|
||||
)
|
||||
# The DS keys wait for ExternalBIOSEnable, the DSi keys for a DSi.
|
||||
self.assertEqual(
|
||||
toml["depends_on_option"], "ExternalBIOSEnable = false in the shipped melonDS.toml"
|
||||
toml["depends_on_option"],
|
||||
"[DS] keys: ExternalBIOSEnable = true, false in the shipped melonDS.toml; "
|
||||
"[DSi] keys: ConsoleType = 1, 0 in the shipped melonDS.toml",
|
||||
)
|
||||
# configEmuFP's update call passes --ignore-existing.
|
||||
self.assertIs(toml["kept_if_present"], True)
|
||||
self.assertEqual(
|
||||
toml["installs"]["path"],
|
||||
"${HOME}/.var/app/net.kuribo64.melonDS/config/melonDS/melonDS.toml",
|
||||
)
|
||||
|
||||
def test_a_config_the_setters_rewrite_keeps_their_values(self):
|
||||
|
||||
@@ -228,6 +228,23 @@ DUCKSTATION_SH = text(
|
||||
"""
|
||||
CONFIG_DIR="/emuelec/configs/duckstation"
|
||||
duckstation-nogui -fullscreen -settings "${CONFIG_DIR}/settings.ini" -- "${1}"
|
||||
if [ ! -d "${CONFIG_DIR}" ]; then
|
||||
cp -rf "/usr/config/emuelec/configs/duckstation/*" "${CONFIG_DIR}"
|
||||
fi
|
||||
"""
|
||||
)
|
||||
|
||||
# packages/sysutils/systemd/scripts/userconfig-setup:11-12 at v4.8.
|
||||
USERCONFIG = text(
|
||||
"""
|
||||
# Copy config files, but don't overwrite - this should replace our sample files
|
||||
false | cp -iRp /usr/config/* /storage/.config/ &>/dev/null
|
||||
"""
|
||||
)
|
||||
|
||||
EMUELEC_MK = text(
|
||||
"""
|
||||
ln -sf /storage/.config/emuelec ${INSTALL}/emuelec
|
||||
"""
|
||||
)
|
||||
|
||||
@@ -313,7 +330,15 @@ ADVMAME_RC = text(
|
||||
|
||||
ADVMAME_SH = text(
|
||||
"""
|
||||
if [[ "${1}" = "arcade" ]]; then
|
||||
sed -i "s|/roms/mame|/roms/arcade|g" ${CONFIG_DIR}/advmame.rc
|
||||
else
|
||||
sed -i "s|/roms/arcade|/roms/mame|g" ${CONFIG_DIR}/advmame.rc
|
||||
fi
|
||||
SDL_AUDIODRIVER=alsa advmame ${ARG} -quiet
|
||||
if [ ! -d "${CONFIG_DIR}" ]; then
|
||||
cp -rf /usr/config/emuelec/configs/advmame/* "${CONFIG_DIR}/"
|
||||
fi
|
||||
"""
|
||||
)
|
||||
|
||||
@@ -389,6 +414,8 @@ FILES = {
|
||||
f"{EMU}/duckstation/config/settings.ini": DUCKSTATION_INI,
|
||||
f"{EMU}/duckstation/package.mk": DUCKSTATION_MK,
|
||||
f"{EMU}/duckstation/scripts/duckstation.sh": DUCKSTATION_SH,
|
||||
el.USERCONFIG: USERCONFIG,
|
||||
el.EMUELEC_MK: EMUELEC_MK,
|
||||
el.YABASANSHIRO_SCRIPTS[0]: yabasanshiro_sh("yabasanshiro"),
|
||||
el.YABASANSHIRO_SCRIPTS[1]: yabasanshiro_sh("yabasanshiro1_5"),
|
||||
f"{EMU}/jzintv/scripts/jzintv.sh": JZINTV_SH,
|
||||
@@ -475,24 +502,12 @@ class LibretroRecords(unittest.TestCase):
|
||||
self.assertEqual(jar["passes_to"], "${HOME}/roms/bios")
|
||||
self.assertEqual(jar["depends_on_option"], "/storage/roms/bios/jdk/eeversion exists")
|
||||
|
||||
def test_mame_copies_its_own_files_and_reads_only_path_options(self):
|
||||
def test_mame_copies_its_own_files_and_hands_no_folder(self):
|
||||
# The core passes no path option and reads no mame.ini: only the
|
||||
# copies are the launcher's.
|
||||
found = records(el.mame)
|
||||
copies = [r for r in found if r["kind"] == "copies"]
|
||||
self.assertEqual([r["names"] for r in copies], [["fm*"], ["mame*"]])
|
||||
folders = [(r["passes_to"], r["search_dir"]) for r in found if r["kind"] == "passes_path"]
|
||||
self.assertEqual(
|
||||
folders,
|
||||
[
|
||||
("mame.ini rompath", "/storage/roms/bios/mame/bios"),
|
||||
("mame.ini samplepath", "/storage/roms/bios/mame/samples"),
|
||||
],
|
||||
)
|
||||
self.assertTrue(all(r["depends_on_option"] == "mame_read_config = enabled"
|
||||
for r in found if r["kind"] == "passes_path"))
|
||||
|
||||
def test_mame_without_the_read_config_option_raises(self):
|
||||
with self.assertRaises(LauncherPatternMissing):
|
||||
records(el.mame, **{f"{el.LIBRETRO}/mame/config/MAME/MAME.opt": "x = 1\n"})
|
||||
self.assertEqual([r["kind"] for r in found], ["copies", "copies"])
|
||||
self.assertEqual([r["names"] for r in found], [["fm*"], ["mame*"]])
|
||||
|
||||
|
||||
class StandaloneRecords(unittest.TestCase):
|
||||
@@ -541,6 +556,37 @@ class StandaloneRecords(unittest.TestCase):
|
||||
(record,) = records(el.duckstation)
|
||||
self.assertEqual((record["kind"], record["search_dir"]), ("scans_dir", "/storage/roms/bios"))
|
||||
|
||||
def test_duckstation_config_comes_from_the_boot_copy(self):
|
||||
"""duckstation.sh quotes its glob: its copy names a file called *, so
|
||||
the settings.ini in place is the one userconfig-setup copies from
|
||||
/usr/config, an existing file kept (false | cp -i)."""
|
||||
(record,) = records(el.duckstation)
|
||||
self.assertEqual(
|
||||
record["installs"],
|
||||
{"path": "/storage/.config/emuelec/configs/duckstation/settings.ini",
|
||||
"source_ref": f"{EMU}/duckstation/package.mk:1, {el.USERCONFIG}:2"},
|
||||
)
|
||||
self.assertIs(record["kept_if_present"], True)
|
||||
self.assertEqual(record["overrides"], [])
|
||||
|
||||
def test_an_unquoted_glob_in_the_start_script_installs_too(self):
|
||||
unquoted = DUCKSTATION_SH.replace(
|
||||
'"/usr/config/emuelec/configs/duckstation/*"', "/usr/config/emuelec/configs/duckstation/*"
|
||||
)
|
||||
(record,) = records(el.duckstation, **{f"{EMU}/duckstation/scripts/duckstation.sh": unquoted})
|
||||
self.assertEqual(record["installs"]["path"], "/emuelec/configs/duckstation/settings.ini")
|
||||
self.assertIs(record["kept_if_present"], True)
|
||||
|
||||
def test_without_a_boot_copy_the_quoted_glob_installs_nothing(self):
|
||||
with self.assertRaises(LauncherPatternMissing):
|
||||
records(el.duckstation, **{el.USERCONFIG: "#!/bin/sh\n"})
|
||||
|
||||
def test_an_overwriting_boot_copy_does_not_keep_the_file(self):
|
||||
(record,) = records(el.duckstation, **{
|
||||
el.USERCONFIG: "cp -Rp /usr/config/* /storage/.config/ &>/dev/null\n",
|
||||
})
|
||||
self.assertIs(record["kept_if_present"], False)
|
||||
|
||||
def test_duckstation_with_a_fixed_bios_path_raises(self):
|
||||
changed = DUCKSTATION_INI.replace("PathPAL =", "PathPAL = /storage/roms/bios/scph5502.bin")
|
||||
with self.assertRaises(LauncherPatternMissing):
|
||||
@@ -580,9 +626,17 @@ class StandaloneRecords(unittest.TestCase):
|
||||
)
|
||||
|
||||
def test_advancemame_one_record_when_every_device_agrees(self):
|
||||
(record,) = records(el.advancemame)
|
||||
self.assertEqual(record["search_dir"], "/storage/roms/bios/advmame/samples")
|
||||
self.assertNotIn("device", record)
|
||||
roms, arcade, samples = records(el.advancemame)
|
||||
self.assertEqual(samples["search_dir"], "/storage/roms/bios/advmame/samples")
|
||||
self.assertNotIn("device", samples)
|
||||
# advmame.sh rewrites /roms/mame to /roms/arcade for the arcade system.
|
||||
self.assertEqual(
|
||||
(roms["search_dir"], roms["passes_to"], roms["depends_on_option"]),
|
||||
("/storage/roms/mame", "advmame.rc dir_rom", "system != arcade"),
|
||||
)
|
||||
self.assertNotIn("systems", roms)
|
||||
self.assertEqual((arcade["search_dir"], arcade["systems"]), ("/storage/roms/arcade", ["arcade"]))
|
||||
self.assertTrue(arcade["source_ref"].endswith("bin/advmame.sh:1-2, 6"))
|
||||
|
||||
def test_advancemame_devices_that_disagree_raise(self):
|
||||
changed = ADVMAME_RC.replace("bios/advmame", "bios/other")
|
||||
@@ -618,6 +672,7 @@ class StandaloneRecords(unittest.TestCase):
|
||||
|
||||
def test_every_extractor_runs_on_the_fixtures(self):
|
||||
found = el.extract_launchers(tree())
|
||||
# The two mame.ini folders are no longer records.
|
||||
self.assertEqual(len(found), 26)
|
||||
|
||||
|
||||
|
||||
@@ -598,10 +598,11 @@ class BootDisks(unittest.TestCase):
|
||||
self.assertEqual((hard.names, hard.passes_to), (["{bootdisk}.chd"], "command line -hard"))
|
||||
self.assertEqual(hard.expands, {"bootdisk": ["macos3", "mac755"]})
|
||||
self.assertTrue(hard.depends_on_option.startswith("bootdisk (system.name == 'macintosh'"))
|
||||
self.assertEqual(
|
||||
hard.source_ref,
|
||||
f"{G}/mame/mameGenerator.py:3-4, 9-10, {kl.ES_FEATURES}:8-10",
|
||||
)
|
||||
# The menu's values are where the choices come from, the generator
|
||||
# writing the choice is the evidence.
|
||||
self.assertEqual(hard.source_ref, f"{G}/mame/mameGenerator.py:3-4, 9-10")
|
||||
self.assertEqual(hard.choices_from, f"{kl.ES_FEATURES}:8-10")
|
||||
self.assertIsNone(floppy.choices_from)
|
||||
|
||||
def test_a_name_built_another_way_raises(self):
|
||||
broken = MAME.replace('"/userdata/bios/" + system.config["bootdisk"] + ".chd"', "disk")
|
||||
|
||||
@@ -11,6 +11,7 @@ from __future__ import annotations
|
||||
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
|
||||
|
||||
import sys
|
||||
import tempfile
|
||||
import textwrap
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
@@ -637,6 +638,57 @@ YMIR = """
|
||||
}
|
||||
"""
|
||||
|
||||
# emulatorLauncher f681f435: the default falls back to the regional BIOS.
|
||||
KRONOS_FALLBACK = """
|
||||
private void SetupConfig(string path)
|
||||
{
|
||||
string iniFile = Path.Combine(path, "kronos.ini");
|
||||
using (var ini = new IniFile(iniFile, IniOptions.KeepEmptyValues))
|
||||
{
|
||||
bool hleBios = false;
|
||||
string bios = Path.Combine(AppConfig.GetFullPath("bios"), "saturn_bios.bin");
|
||||
if (SystemConfig.isOptSet("kronos_force_bios") && !string.IsNullOrEmpty(SystemConfig["kronos_force_bios"]))
|
||||
{
|
||||
if (SystemConfig["kronos_force_bios"] != "hle")
|
||||
bios = Path.Combine(AppConfig.GetFullPath("bios"), SystemConfig["kronos_force_bios"]);
|
||||
else
|
||||
hleBios = true;
|
||||
}
|
||||
if (!hleBios && !File.Exists(bios))
|
||||
bios = new[] { "sega_101.bin", "mpr-17933.bin" }.Select(f => Path.Combine(AppConfig.GetFullPath("bios"), f)).FirstOrDefault(File.Exists) ?? bios;
|
||||
|
||||
if (File.Exists(bios))
|
||||
ini.WriteValue("1.0", "General\\\\Bios", bios.Replace("\\\\", "/"));
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
# emulatorLauncher f681f435: a forced BIOS only, written under a flag, and
|
||||
# a folder below bios for the CD block ROM.
|
||||
YMIR_OVERRIDE = """
|
||||
private void SetupConfiguration(string path)
|
||||
{
|
||||
string iniFile = Path.Combine(path, "Ymir.toml");
|
||||
using (var ini = new IniFile(iniFile))
|
||||
{
|
||||
string saturnBiosPath = null;
|
||||
if (SystemConfig.isOptSet("ymir_force_bios") && !string.IsNullOrEmpty(SystemConfig["ymir_force_bios"]))
|
||||
saturnBiosPath = Path.Combine(AppConfig.GetFullPath("bios"), SystemConfig["ymir_force_bios"]);
|
||||
|
||||
bool overrideIpl = saturnBiosPath != null && File.Exists(saturnBiosPath);
|
||||
ini.WriteValue("System.IPL", "Override", overrideIpl ? "true" : "false");
|
||||
if (overrideIpl)
|
||||
ini.WriteValue("System.IPL", "Path", "'" + saturnBiosPath + "'");
|
||||
|
||||
string iplPath = AppConfig.GetFullPath("bios");
|
||||
ini.WriteValue("General.PathOverrides", "IPLROMImages", "'" + iplPath + "'");
|
||||
string cdbPath = Path.Combine(iplPath, "cdb");
|
||||
FileTools.TryCreateDirectory(cdbPath);
|
||||
ini.WriteValue("General.PathOverrides", "CDBlockROMImages", "'" + cdbPath + "'");
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
SSF = """
|
||||
private void SetupConfiguration(string path)
|
||||
{
|
||||
@@ -1043,6 +1095,46 @@ class OptionReplacesThePath(unittest.TestCase):
|
||||
folder["passes_to"], "Ymir.toml [General.PathOverrides] IPLROMImages = bios"
|
||||
)
|
||||
|
||||
def test_kronos_falls_back_to_the_regional_bios(self):
|
||||
path = f"{G}/Kronos.Generator.cs"
|
||||
sources = _feature_sources(path, KRONOS_FALLBACK, SATURN_FEATURES)
|
||||
fixed, option, fallback = rl._option_path_in(
|
||||
sources[path], sources[rl.FEATURES], "kronos"
|
||||
)
|
||||
self.assertEqual(
|
||||
fixed["fails_when_missing"],
|
||||
"sega_101.bin, then mpr-17933.bin, instead, else General\\Bios not written",
|
||||
)
|
||||
self.assertEqual(option["fails_when_missing"], fixed["fails_when_missing"])
|
||||
self.assertEqual(fallback["kind"], "names_searched")
|
||||
self.assertEqual(fallback["names"], ["sega_101.bin", "mpr-17933.bin"])
|
||||
self.assertEqual(
|
||||
fallback["passes_to"],
|
||||
"kronos.ini [1.0] General\\Bios = <first found>, only if the file exists",
|
||||
)
|
||||
self.assertEqual(
|
||||
fallback["depends_on_option"],
|
||||
"saturn_bios.bin absent with kronos_force_bios unset"
|
||||
" or the kronos_force_bios file absent, kronos_force_bios not hle",
|
||||
)
|
||||
self.assertEqual(fallback["source_ref"], f"{path}:15-19")
|
||||
|
||||
def test_ymir_writes_a_forced_bios_under_its_flag(self):
|
||||
path = f"{G}/Ymir.Generator.cs"
|
||||
sources = _feature_sources(path, YMIR_OVERRIDE, SATURN_FEATURES)
|
||||
option, ipl, cdb = rl._option_path_in(sources[path], sources[rl.FEATURES], "ymir")
|
||||
self.assertEqual(
|
||||
option["passes_to"],
|
||||
"Ymir.toml [System.IPL] Path = <bios>/<value>, only if the file exists",
|
||||
)
|
||||
self.assertEqual(option["source_ref"], f"{path}:7-13, {rl.FEATURES}:10-13")
|
||||
self.assertEqual(ipl["passes_to"], "Ymir.toml [General.PathOverrides] IPLROMImages = bios")
|
||||
self.assertEqual(cdb["search_dir"], "bios/cdb")
|
||||
self.assertEqual(
|
||||
cdb["passes_to"], "Ymir.toml [General.PathOverrides] CDBlockROMImages = bios/cdb"
|
||||
)
|
||||
self.assertEqual(cdb["source_ref"], f"{path}:15-19")
|
||||
|
||||
def test_ssf_has_no_default_name(self):
|
||||
path = f"{G}/SSF.Generator.cs"
|
||||
sources = _feature_sources(path, SSF, SATURN_FEATURES)
|
||||
@@ -1488,6 +1580,21 @@ class Helpers(unittest.TestCase):
|
||||
src = rl.Source("x.cs", 'void f()\n{\n s = "}";\n}\n')
|
||||
self.assertEqual(src.lines(*src.block_at(0)), (2, 4))
|
||||
|
||||
def test_a_rescrape_reads_the_pinned_commit(self):
|
||||
from scraper import retrobat_scraper as rs # noqa: PLC0415
|
||||
|
||||
pin = "ca486005f598551600d04a33b3156a5d764368d6"
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as scratch:
|
||||
yml = Path(scratch) / "retrobat.yml"
|
||||
yml.write_text(
|
||||
"source: https://raw.githubusercontent.com/RetroBat-Official/emulatorlauncher/"
|
||||
f"{pin}/batocera-systems/Resources/batocera-systems.json\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
self.assertEqual(rs.pinned_revision(yml), pin)
|
||||
self.assertEqual(rs.resolve_revision(pin), pin)
|
||||
self.assertEqual(rs.resolve_revision(None), rs.pinned_revision())
|
||||
|
||||
def test_revision_comes_from_the_pinned_url(self):
|
||||
url = (
|
||||
"https://raw.githubusercontent.com/RetroBat-Official/emulatorlauncher/"
|
||||
|
||||
@@ -289,7 +289,7 @@ class Presets(unittest.TestCase):
|
||||
self.assertEqual(lists["dragon64"]["names"][-1], "dragon")
|
||||
self.assertEqual(
|
||||
lists["d64_1"]["source_ref"],
|
||||
"xroar/rd_assets/rd_config/xroar.conf:292, xroar/component_prepare.sh:13, 15",
|
||||
"xroar/rd_assets/rd_config/xroar.conf:292, xroar/component_prepare.sh:13-15",
|
||||
)
|
||||
|
||||
def test_a_reference_to_an_unknown_romlist_raises(self):
|
||||
|
||||
@@ -239,6 +239,77 @@ class LinksAndCopies(unittest.TestCase):
|
||||
self.assertEqual(base[0]["names"], ["hiscore.dat", "cheat.dat"])
|
||||
|
||||
|
||||
MAME = module("mame", """
|
||||
function configure_mame() {
|
||||
local system="mame"
|
||||
local temp_ini_mame="$(mktemp)"
|
||||
iniConfig " " "" "$temp_ini_mame"
|
||||
iniSet "rompath" "$romdir/$system;$romdir/arcade;$biosdir/$system"
|
||||
iniSet "hashpath" "$md_inst/hash"
|
||||
iniSet "samplepath" "$romdir/$system/samples;$romdir/arcade/samples"
|
||||
iniSet "cfg_directory" "$romdir/$system/cfg"
|
||||
copyDefaultConfig "$temp_ini_mame" "$md_conf_root/$system/mame.ini"
|
||||
addEmulator 0 "$md_id" "arcade" "$md_inst/mame %BASENAME%"
|
||||
addSystem "arcade"
|
||||
}
|
||||
""", 109)
|
||||
|
||||
|
||||
class IniSearchLists(unittest.TestCase):
|
||||
"""MAME's mame.ini lists folders below $romdir (mame.sh:133-136)."""
|
||||
|
||||
def test_a_list_below_the_roms_root_is_a_search_path(self):
|
||||
found = [r for r in records({f"{EMULATORS}/mame.sh": MAME}, "mame")
|
||||
if r["kind"] == "passes_path"]
|
||||
self.assertEqual(
|
||||
[(r["search_dir"], r["passes_to"].split(" in ")[0]) for r in found],
|
||||
[
|
||||
("$romdir/mame;$romdir/arcade;$biosdir/mame", "rompath"),
|
||||
("$romdir/mame/samples;$romdir/arcade/samples", "samplepath"),
|
||||
],
|
||||
)
|
||||
self.assertEqual(found[1]["source_ref"], f"{EMULATORS}/mame.sh:115")
|
||||
|
||||
def test_one_folder_written_to_is_no_search_path(self):
|
||||
# cfg_directory is where MAME writes, $md_inst/hash a folder of the
|
||||
# package itself.
|
||||
found = records({f"{EMULATORS}/mame.sh": MAME}, "mame")
|
||||
self.assertFalse([r for r in found if "cfg" in str(r.get("search_dir"))])
|
||||
self.assertFalse([r for r in found if "hash" in str(r.get("search_dir"))])
|
||||
|
||||
|
||||
ADVMAME = module("advmame", """
|
||||
function configure_advmame() {
|
||||
iniConfig " " "" "$md_conf_root/mame-advmame/$md_id.rc"
|
||||
iniSet "dir_rom" "$romdir/mame-advmame:$romdir/arcade"
|
||||
iniSet "dir_artwork" "$romdir/mame-advmame/artwork"
|
||||
addEmulator 1 "$md_id" "arcade" "$md_inst/bin/advmame %BASENAME%"
|
||||
addSystem "arcade"
|
||||
}
|
||||
""", 95)
|
||||
|
||||
|
||||
class AdvanceMameSearchList(unittest.TestCase):
|
||||
"""AdvanceMAME splits dir_rom on ':' (advance/linux/file.c:138-141,
|
||||
advance/osd/fileio.c:696-699), and advmame.sh:100 lists two folders."""
|
||||
|
||||
def test_a_colon_list_below_the_roms_root_is_a_search_path(self):
|
||||
found = [r for r in records({f"{EMULATORS}/advmame.sh": ADVMAME}, "advmame")
|
||||
if r["kind"] == "passes_path"]
|
||||
self.assertEqual(
|
||||
[(r["search_dir"], r["passes_to"].split(" in ")[0]) for r in found],
|
||||
[("$romdir/mame-advmame:$romdir/arcade", "dir_rom")],
|
||||
)
|
||||
|
||||
def test_mame_does_not_read_a_colon_as_a_separator(self):
|
||||
from scraper.retropie_launchers import LIST_SEPARATORS
|
||||
|
||||
self.assertNotIn("mame", LIST_SEPARATORS)
|
||||
self.assertEqual(
|
||||
{LIST_SEPARATORS[p] for p in ("advmame", "advmame-0.94", "advmame-1.4")}, {":"}
|
||||
)
|
||||
|
||||
|
||||
class CommandLines(unittest.TestCase):
|
||||
def test_sdltrs_passes_one_rom_per_machine(self):
|
||||
found = records({f"{EMULATORS}/sdltrs.sh": SDLTRS}, "sdltrs")
|
||||
|
||||
@@ -85,13 +85,14 @@ MELONDS_SH = text(
|
||||
sed -i '/^ExternalBIOSEnable=/c\\ExternalBIOSEnable=0' /storage/.config/melonDS/melonDS.ini
|
||||
fi
|
||||
fi
|
||||
CONF_DIR="/storage/.config/melonDS"
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
def melonds_tree() -> RepoTree:
|
||||
pkg = f"{SA}/melonds-sa"
|
||||
return RepoTree.from_files(
|
||||
return rocknix_tree(
|
||||
{
|
||||
**devices("AMD64", "H700", "RK3576", "S922X"),
|
||||
f"{pkg}/package.mk": MELONDS_MK,
|
||||
@@ -148,6 +149,7 @@ AMIBERRY_SH = text(
|
||||
cp -rf /usr/config/amiberry ${AMIBERRY_DIR}
|
||||
fi
|
||||
cd ${AMIBERRY_DIR}
|
||||
amiberry -f "${AMIBERRY_TMP_CONFIG}" --autoload "$1" >> ${AMIBERRY_LOG} 2>&1
|
||||
"""
|
||||
)
|
||||
|
||||
@@ -291,6 +293,22 @@ FLYCAST_SH = text(
|
||||
)
|
||||
|
||||
|
||||
USERCONFIG = text(
|
||||
"""
|
||||
#!/bin/bash
|
||||
if [ ! -e "/storage/.configured" ]
|
||||
then
|
||||
rsync -a --ignore-existing --exclude={es_features.cfg,es_systems.cfg} /usr/config/* /storage/.config/ >/var/log/configure.log 2>&1
|
||||
fi
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
def rocknix_tree(files: dict[str, str], links: dict[str, str] | None = None) -> RepoTree:
|
||||
"""A ROCKNIX tree holding the first-boot copy every config record cites."""
|
||||
return RepoTree.from_files({rl.USERCONFIG: USERCONFIG, **files}, links)
|
||||
|
||||
|
||||
def by(records: list[dict], emulator: str) -> list[dict]:
|
||||
return [r for r in records if r["emulator"] == emulator]
|
||||
|
||||
@@ -302,23 +320,26 @@ class ConfigsPerDevice(unittest.TestCase):
|
||||
empty, named = records
|
||||
self.assertEqual(empty["names"], [])
|
||||
self.assertTrue(empty["passes_to"].endswith("DSiNANDPath left empty"))
|
||||
# melonDS opens the DSi BIOS and firmware keys only under
|
||||
# DSiExternalBIOSEnable, which no shipped config sets.
|
||||
self.assertEqual(
|
||||
named["names"],
|
||||
[
|
||||
"bios9.bin",
|
||||
"bios7.bin",
|
||||
"firmware.bin",
|
||||
"dsi_bios9.bin",
|
||||
"dsi_bios7.bin",
|
||||
"dsi_firmware.bin",
|
||||
"dsi_nand.bin",
|
||||
],
|
||||
named["names"], ["bios9.bin", "bios7.bin", "firmware.bin", "dsi_nand.bin"]
|
||||
)
|
||||
self.assertEqual(named["search_dir"], "/storage/roms/bios")
|
||||
self.assertEqual(named["installs"]["path"], "/storage/.config/melonDS/melonDS.ini")
|
||||
self.assertIs(named["kept_if_present"], True)
|
||||
self.assertEqual(named["overrides"], [])
|
||||
|
||||
def test_a_config_setting_the_dsi_switch_keeps_the_dsi_keys(self):
|
||||
tree = melonds_tree()
|
||||
path = f"{SA}/melonds-sa/config/S922X/melonDS.ini"
|
||||
tree._texts[path] = tree.read(path) + "DSiExternalBIOSEnable=1\n"
|
||||
named = rl.melonds(tree)[1].entry()
|
||||
self.assertIn("dsi_bios9.bin", named["names"])
|
||||
|
||||
def test_a_linked_device_directory_reads_its_target(self):
|
||||
named = rl.melonds(melonds_tree())[1].entry()
|
||||
self.assertIn(f"{SA}/melonds-sa/config/InputPlumber/melonDS.ini:2-8", named["source_ref"])
|
||||
self.assertIn(f"{SA}/melonds-sa/config/InputPlumber/melonDS.ini:2-4, 8", named["source_ref"])
|
||||
self.assertNotIn("config/RK3576", named["source_ref"])
|
||||
|
||||
def test_the_external_bios_switch_is_the_option(self):
|
||||
@@ -330,11 +351,14 @@ class ConfigsPerDevice(unittest.TestCase):
|
||||
|
||||
def test_identical_configs_give_one_record_without_device(self):
|
||||
pkg = f"{SA}/dsperate-sa"
|
||||
tree = RepoTree.from_files(
|
||||
tree = rocknix_tree(
|
||||
{
|
||||
**devices("H700", "RK3576", "S922X"),
|
||||
f"{pkg}/package.mk": DSPERATE_MK,
|
||||
f"{pkg}/scripts/start_dsperate.sh": '${EMUPERF} /usr/bin/dsperate --config "${DSPERATE_INI}" "${ROM}"\n',
|
||||
f"{pkg}/scripts/start_dsperate.sh": (
|
||||
'${EMUPERF} /usr/bin/dsperate --config "${DSPERATE_INI}" "${ROM}"\n'
|
||||
'DSPERATE_INI="/storage/.config/dsperate/dsperate.ini"\n'
|
||||
),
|
||||
f"{pkg}/config/H700/dsperate.ini": DSPERATE_INI,
|
||||
f"{pkg}/config/InputPlumber/dsperate.ini": DSPERATE_INI,
|
||||
f"{pkg}/config/S922X/dsperate.ini": DSPERATE_INI,
|
||||
@@ -352,10 +376,11 @@ class ConfigsPerDevice(unittest.TestCase):
|
||||
|
||||
def test_an_absent_key_and_an_empty_one_hand_over_the_same(self):
|
||||
pkg = f"{SA}/duckstation-sa"
|
||||
tree = RepoTree.from_files(
|
||||
tree = rocknix_tree(
|
||||
{
|
||||
**devices("AMD64", "S922X"),
|
||||
f"{pkg}/package.mk": DUCKSTATION_MK,
|
||||
f"{pkg}/scripts/start_duckstation.sh": "#!/bin/bash\n",
|
||||
f"{pkg}/config/AMD64/settings.ini": "[BIOS]\nSearchDirectory = /storage/roms/bios\n",
|
||||
f"{pkg}/config/S922X/settings.ini": text(
|
||||
"""
|
||||
@@ -375,10 +400,11 @@ class ConfigsPerDevice(unittest.TestCase):
|
||||
|
||||
def test_a_bios_written_into_a_path_key_is_an_unknown_shape(self):
|
||||
pkg = f"{SA}/duckstation-sa"
|
||||
tree = RepoTree.from_files(
|
||||
tree = rocknix_tree(
|
||||
{
|
||||
**devices("S922X"),
|
||||
f"{pkg}/package.mk": DUCKSTATION_MK,
|
||||
f"{pkg}/scripts/start_duckstation.sh": "#!/bin/bash\n",
|
||||
f"{pkg}/config/S922X/settings.ini": "[BIOS]\nSearchDirectory = /storage/roms/bios\nPathNTSCU = scph5501.bin\n",
|
||||
}
|
||||
)
|
||||
@@ -387,7 +413,7 @@ class ConfigsPerDevice(unittest.TestCase):
|
||||
|
||||
def test_a_package_without_a_device_copy_raises(self):
|
||||
pkg = f"{SA}/duckstation-sa"
|
||||
tree = RepoTree.from_files(
|
||||
tree = rocknix_tree(
|
||||
{
|
||||
**devices("S922X"),
|
||||
f"{pkg}/package.mk": "makeinstall_target() {\n true\n}\n",
|
||||
@@ -402,7 +428,7 @@ class NamesTheConfigsFix(unittest.TestCase):
|
||||
def test_amiberry_machine_follows_the_game_name(self):
|
||||
pkg = f"{SA}/amiberry"
|
||||
uae = "amiberry.rom_path=/storage/.config/amiberry/kickstarts/\nkickstart_rom_file=@BIOS_PATH@/{}\nkickstart_ext_rom_file=\n"
|
||||
tree = RepoTree.from_files(
|
||||
tree = rocknix_tree(
|
||||
{
|
||||
f"{pkg}/scripts/start_amiberry.sh": AMIBERRY_SH,
|
||||
f"{pkg}/package.mk": AMIBERRY_MK,
|
||||
@@ -412,9 +438,15 @@ class NamesTheConfigsFix(unittest.TestCase):
|
||||
)
|
||||
a1200, a500, link, entered, copied = (r.entry() for r in rl.amiberry(tree))
|
||||
self.assertEqual((a1200["slot"], a1200["names"]), ("A1200", ["kick40068.A1200.rom"]))
|
||||
self.assertEqual(a1200["depends_on_option"], "game name matches AGA|CD32")
|
||||
self.assertEqual(
|
||||
a1200["depends_on_option"],
|
||||
"game name matches AGA|CD32, content not booted with --autoload, "
|
||||
"a WHDLoad .lha or .zip (start_amiberry.sh:17)",
|
||||
)
|
||||
self.assertEqual(a1200["installs"]["path"], "${AMIBERRY_TMP_CONFIG}")
|
||||
self.assertIs(a1200["kept_if_present"], False)
|
||||
self.assertEqual((a500["slot"], a500["names"]), ("A500", ["kick34005.A500.rom"]))
|
||||
self.assertEqual(a500["depends_on_option"], "game name does not match AGA|CD32")
|
||||
self.assertTrue(a500["depends_on_option"].startswith("game name does not match AGA|CD32"))
|
||||
self.assertEqual(a500["search_dir"], "/storage/roms/bios")
|
||||
self.assertEqual(
|
||||
a1200["source_ref"],
|
||||
@@ -443,7 +475,7 @@ class NamesTheConfigsFix(unittest.TestCase):
|
||||
|
||||
def test_mednafen_one_record_per_module(self):
|
||||
pkg = f"{SA}/mednafen"
|
||||
tree = RepoTree.from_files(
|
||||
tree = rocknix_tree(
|
||||
{
|
||||
f"{pkg}/config/common/mednafen.template": MEDNAFEN_TEMPLATE,
|
||||
f"{pkg}/scripts/start_mednafen.sh": MEDNAFEN_SH,
|
||||
@@ -461,7 +493,7 @@ class NamesTheConfigsFix(unittest.TestCase):
|
||||
|
||||
def test_mednafen_without_a_firmware_directory_raises(self):
|
||||
pkg = f"{SA}/mednafen"
|
||||
tree = RepoTree.from_files(
|
||||
tree = rocknix_tree(
|
||||
{
|
||||
f"{pkg}/config/common/mednafen.template": "psx.bios_eu scph5502.bin\n",
|
||||
f"{pkg}/scripts/start_mednafen.sh": MEDNAFEN_SH,
|
||||
@@ -473,7 +505,7 @@ class NamesTheConfigsFix(unittest.TestCase):
|
||||
|
||||
class SearchedNames(unittest.TestCase):
|
||||
def tree(self, script: str) -> RepoTree:
|
||||
return RepoTree.from_files({f"{SA}/yabasanshiro-sa/scripts/start_yabasanshiro.sh": script})
|
||||
return rocknix_tree({f"{SA}/yabasanshiro-sa/scripts/start_yabasanshiro.sh": script})
|
||||
|
||||
def test_yabasanshiro_tries_its_names_in_order(self):
|
||||
(record,) = [r.entry() for r in rl.yabasanshiro(self.tree(YABASANSHIRO_SH))]
|
||||
@@ -514,7 +546,7 @@ class Links(unittest.TestCase):
|
||||
|
||||
def tree(self) -> RepoTree:
|
||||
scripts = self.all_scripts()
|
||||
return RepoTree.from_files({p: scripts[e] for e, p in rl.LINK_SCRIPTS})
|
||||
return rocknix_tree({p: scripts[e] for e, p in rl.LINK_SCRIPTS})
|
||||
|
||||
def emulator(self, name: str) -> list[dict]:
|
||||
return by([r.entry() for r in rl.links(self.tree())], name)
|
||||
@@ -566,7 +598,7 @@ class Links(unittest.TestCase):
|
||||
def test_a_script_without_a_bios_link_raises(self):
|
||||
scripts = self.all_scripts()
|
||||
scripts["flycast"] = 'ln -sf "/storage/.config/flycast" "/storage/.local/share/flycast"\n'
|
||||
tree = RepoTree.from_files({p: scripts[e] for e, p in rl.LINK_SCRIPTS})
|
||||
tree = rocknix_tree({p: scripts[e] for e, p in rl.LINK_SCRIPTS})
|
||||
with self.assertRaises(LauncherPatternMissing):
|
||||
rl.links(tree)
|
||||
|
||||
@@ -603,7 +635,7 @@ class ProgramsRunOutsideTheBiosFolder(unittest.TestCase):
|
||||
PATH = f"{SA}/pico-8/scripts/start_pico8.sh"
|
||||
|
||||
def test_pico8_runs_its_binary_from_roms(self):
|
||||
(record,) = [r.entry() for r in rl.pico8(RepoTree.from_files({self.PATH: START_PICO8}))]
|
||||
(record,) = [r.entry() for r in rl.pico8(rocknix_tree({self.PATH: START_PICO8}))]
|
||||
self.assertEqual(
|
||||
(record["emulator"], record["kind"], record["names"], record["search_dir"],
|
||||
record["passes_to"]),
|
||||
@@ -615,7 +647,7 @@ class ProgramsRunOutsideTheBiosFolder(unittest.TestCase):
|
||||
def test_a_script_without_its_binary_choice_raises(self):
|
||||
broken = START_PICO8.replace('STATIC_BIN="pico8_dyn"', "STATIC_BIN=$OTHER")
|
||||
with self.assertRaises(LauncherPatternMissing):
|
||||
rl.pico8(RepoTree.from_files({self.PATH: broken}))
|
||||
rl.pico8(rocknix_tree({self.PATH: broken}))
|
||||
|
||||
|
||||
class Revision(unittest.TestCase):
|
||||
|
||||
@@ -299,6 +299,23 @@ class RecordsNameNoLocalPath(unittest.TestCase):
|
||||
self.assertEqual(summary, "Copy it from an owned copy of the game into <dest>/jazz2/Source/. "
|
||||
"Saves go to <save-dir>.")
|
||||
|
||||
def test_a_probe_error_names_the_checkout(self) -> None:
|
||||
"""A core_probe traceback spelled the worktree it ran from."""
|
||||
import subprocess
|
||||
import unittest.mock
|
||||
|
||||
work = TMP / "error-paths"
|
||||
script = pp.ROOT / "scripts" / "core_probe.py"
|
||||
|
||||
def fake_run(command, **kwargs):
|
||||
return subprocess.CompletedProcess(command, 1, "", f' File "{script}", line 9\n')
|
||||
|
||||
with unittest.mock.patch.object(pp, "PROBE_LOCK", work / "probe.lock"), \
|
||||
unittest.mock.patch.object(pp.subprocess, "run", fake_run):
|
||||
code, record, error = pp.core_probe(["run"], set(), layout({}), work)
|
||||
self.assertEqual((code, record), (1, None))
|
||||
self.assertEqual(error, 'File "<repo>/scripts/core_probe.py", line 9')
|
||||
|
||||
def test_no_committed_record_holds_a_local_path(self) -> None:
|
||||
"""Ten records cut at 400 characters inside the scratch path kept
|
||||
its tail, which no absolute-path pattern sees."""
|
||||
|
||||
+10
-1
@@ -145,11 +145,20 @@ class EveryBuildReferenceNamesThePin(unittest.TestCase):
|
||||
else {str(versions)} if versions else set()
|
||||
)
|
||||
|
||||
source = str(profile.get("source") or "").rstrip("/").removesuffix(".git")
|
||||
|
||||
def names_it(value: str) -> bool:
|
||||
if profile.get("pin_follows"):
|
||||
# A build of the branch tip names the repository it
|
||||
# clones, at no revision: RetroPie's advmame.
|
||||
return value.split()[-1].rstrip("/").removesuffix(".git") == source
|
||||
token = value.split()[-1].rsplit("/", 1)[-1].removesuffix(".tar.gz")
|
||||
return value in pins or any(token in v or v in value for v in versions)
|
||||
|
||||
if not any(names_it(str(r["value"])) for r in references):
|
||||
# A reference that only dates a config_reads entry names the build
|
||||
# the platform reads that file at, not this profile's pin.
|
||||
justifies_pin = profile.get("pin_frozen") or profile.get("pin_follows")
|
||||
if justifies_pin and not any(names_it(str(r["value"])) for r in references):
|
||||
disagree.append(name)
|
||||
for reference in references:
|
||||
if not cf.pin_build_revision(reference, REPO_ROOT / "platforms"):
|
||||
|
||||
@@ -3077,9 +3077,14 @@ class TestDeliberatelyFrozenPin(TestBuildReport):
|
||||
# live build can add a system its frozen revision lacked
|
||||
# (advancemame's coh1002v, after advmame-1.4), so the frozen one's
|
||||
# systems are a subset, not an equal set. A live build can also drop
|
||||
# a system upstream deleted: advancemame removed its Hyper Neo Geo 64
|
||||
# driver in dff25b6ee7, which advmame-1.4 still carries.
|
||||
removed_upstream = {("advmame-1.4", "advancemame"): {"hyper-neogeo64"}}
|
||||
# a system upstream deleted: AdvanceMAME removed its Hyper Neo Geo 64
|
||||
# driver in dff25b6ee7, which advmame-1.4 and advancemame (AmberELEC's
|
||||
# 0f6a767) still carry.
|
||||
removed_upstream = {
|
||||
("advmame-1.4", "advancemame"): {"hyper-neogeo64"},
|
||||
("advmame-1.4", "advmame"): {"hyper-neogeo64"},
|
||||
("advancemame", "advmame"): {"hyper-neogeo64"},
|
||||
}
|
||||
pairs = 0
|
||||
for names in by_source.values():
|
||||
frozen = [
|
||||
@@ -3373,6 +3378,61 @@ class TestBumpCommit(unittest.TestCase):
|
||||
self.assertFalse(bump_commit(self.path, report))
|
||||
self.assertNotIn("newhead", self.path.read_text())
|
||||
|
||||
def test_a_build_of_the_branch_tip_follows_it(self):
|
||||
# RetroPie builds AdvanceMAME from the tip of master
|
||||
# (advmame.sh:16, 39-41): HEAD is the build it ships.
|
||||
self.path.write_text(
|
||||
SAMPLE + "built_by: [retropie]\n"
|
||||
+ 'pin_follows: "RetroPie builds the branch tip"\n',
|
||||
encoding="utf-8",
|
||||
)
|
||||
part = PartResult(
|
||||
RefPart("a.c", 10, 12, "a.c:10-12"), "ANCHORED", None, 10, 12, []
|
||||
)
|
||||
report = ProfileReport(
|
||||
name="p", repo="o/n", pin="pin", head="newhead",
|
||||
entries=[
|
||||
EntryReport("a.bin", "a.c:10-12, (just a note)", "ANCHORED", [part])
|
||||
],
|
||||
counts={"ANCHORED": 1},
|
||||
)
|
||||
self.assertTrue(bump_commit(self.path, report))
|
||||
self.assertIn("newhead", self.path.read_text())
|
||||
|
||||
def test_a_config_read_at_the_pin_follows_it(self):
|
||||
# RetroPie reads advmame.rc at the build it installs, the pin: the
|
||||
# config_reads revision is the pin, and moves with it.
|
||||
pin = "a" * 40
|
||||
self.path.write_text(
|
||||
SAMPLE.replace('profiled_date: "2026-03-29"\n',
|
||||
f'profiled_date: "2026-03-29"\nsource_commit: "{pin}"\n', 1)
|
||||
+ "built_by: [retropie]\n"
|
||||
+ 'pin_follows: "RetroPie builds the branch tip"\n'
|
||||
+ "config_reads:\n"
|
||||
+ ' - file: "advmame.rc"\n'
|
||||
+ " platforms: [retropie]\n"
|
||||
+ f' revision: "{pin}"\n'
|
||||
+ ' source_ref: "a.c:10-12"\n'
|
||||
+ " - file: \"other.rc\"\n"
|
||||
+ " platforms: [emuelec]\n"
|
||||
+ f' revision: "{"b" * 40}"\n'
|
||||
+ ' source_ref: "a.c:10-12"\n',
|
||||
encoding="utf-8",
|
||||
)
|
||||
part = PartResult(
|
||||
RefPart("a.c", 10, 12, "a.c:10-12"), "ANCHORED", None, 10, 12, []
|
||||
)
|
||||
head = "c" * 40
|
||||
report = ProfileReport(
|
||||
name="p", repo="o/n", pin=pin, head=head,
|
||||
entries=[EntryReport("a.bin", "a.c:10-12", "ANCHORED", [part])],
|
||||
counts={"ANCHORED": 1},
|
||||
)
|
||||
self.assertTrue(bump_commit(self.path, report))
|
||||
document = yaml.safe_load(self.path.read_text(encoding="utf-8"))
|
||||
self.assertEqual(document["source_commit"], head)
|
||||
self.assertEqual([r["revision"] for r in document["config_reads"]], [head, "b" * 40])
|
||||
|
||||
def test_refused_when_no_ref_reads_the_pinned_repository(self):
|
||||
"""gam4980: every bare libretro.c ref anchored in upstream, and the
|
||||
bump wrote the fork's HEAD over refs that never described it."""
|
||||
|
||||
@@ -17,6 +17,8 @@ import unittest
|
||||
from pathlib import Path
|
||||
from unittest import mock
|
||||
|
||||
import yaml
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0, str(REPO_ROOT / "scripts"))
|
||||
|
||||
@@ -55,6 +57,15 @@ class Planning(unittest.TestCase):
|
||||
["scripts/verify.py", "--platform", "retrobat"]],
|
||||
)
|
||||
|
||||
def test_a_scraper_reading_its_pin_is_moved_by_rescrape_args(self):
|
||||
registry = dict(REGISTRY, retrobat={"scraper": "retrobat",
|
||||
"rescrape_args": ["--revision", "master"]})
|
||||
jobs, _, _ = rs.plan_jobs([finding("platforms", "retrobat")], registry, {})
|
||||
self.assertEqual(jobs[0].command[-2:], ["--revision", "master"])
|
||||
with (REPO_ROOT / "platforms" / "_registry.yml").open(encoding="utf-8") as fh:
|
||||
real = yaml.safe_load(fh)["platforms"]["retrobat"]
|
||||
self.assertEqual(real["rescrape_args"], ["--revision", "master"])
|
||||
|
||||
def test_a_child_waits_for_its_rescraped_parent(self):
|
||||
"""retropie inherits retroarch: run beside the parent's rescrape, its
|
||||
truth read the old parent and its export was refused as stale."""
|
||||
|
||||
+139
-4
@@ -313,13 +313,14 @@ class TheReleaseNotesNameTheSetupsWithoutAZip(unittest.TestCase):
|
||||
import release_notes
|
||||
|
||||
text = release_notes.render(self.RECORD, PLATFORMS, "### What changed\n\n- x\n")
|
||||
paragraph = next(line for line in text.splitlines() if line.startswith("No ZIP for "))
|
||||
paragraph = next(line for line in text.splitlines()
|
||||
if line.startswith("Only the most used setups have a pack"))
|
||||
for name in ("KNULLI", "Recalbox", "RetroPie", "Lakka"):
|
||||
self.assertIn(name, paragraph)
|
||||
for name in ("RetroArch", "Batocera", "RomM"):
|
||||
self.assertNotIn(f" {name},", paragraph)
|
||||
self.assertIn("The command above", paragraph)
|
||||
self.assertIn("--dry-run", paragraph)
|
||||
self.assertTrue(paragraph.endswith("use the command above."))
|
||||
self.assertLess(text.index("| Platform"), text.index(paragraph))
|
||||
self.assertLess(text.index(paragraph), text.index("### What changed"))
|
||||
|
||||
def test_the_rows_link_this_release_files(self):
|
||||
@@ -331,7 +332,141 @@ class TheReleaseNotesNameTheSetupsWithoutAZip(unittest.TestCase):
|
||||
self.assertIn(
|
||||
"[Download](https://github.com/Abdess/retrobios/releases/download/"
|
||||
"v2026.10.24/RomM_5_BIOS_Pack.zip)", text)
|
||||
self.assertNotIn(f"{SITE}get/", text)
|
||||
rows = [line for line in text.splitlines() if line.startswith("| ")]
|
||||
self.assertTrue(rows)
|
||||
for row in rows:
|
||||
self.assertNotIn(f"{SITE}get/", row)
|
||||
|
||||
def test_the_command_comes_before_the_packs(self):
|
||||
"""Most readers need a few files, not a pack of several GB (owner,
|
||||
2026-11-10): the command and the handheld app open the notes."""
|
||||
import release_notes
|
||||
|
||||
text = release_notes.render(self.RECORD, PLATFORMS, "### What changed\n\n- x\n")
|
||||
command = text.index("```sh")
|
||||
# The installer's handheld section, which opens on every download.
|
||||
handheld = text.index(f"{SITE}wiki/installer/#on-a-handheld-the-retrobios-port")
|
||||
packs = text.index("### Full packs")
|
||||
self.assertLess(text.index("### Get the BIOS files"), command)
|
||||
self.assertLess(command, handheld)
|
||||
self.assertLess(handheld, packs)
|
||||
self.assertLess(packs, text.index("| Platform"))
|
||||
self.assertLess(packs, text.index("### What changed"))
|
||||
self.assertNotIn("releases/download/", text[:packs])
|
||||
|
||||
|
||||
class TheReleaseNotesThankPeople(unittest.TestCase):
|
||||
"""The notes end with everyone who helped since the repository started
|
||||
and the full changelog, read from gh and git (owner, 2026-11-10).
|
||||
Fixtures stand in for both."""
|
||||
|
||||
TAGS = {"c4": "v2026.11.10", "c3": "v2026.10.10", "c2": "v2026.10.10",
|
||||
"c1": "v2026.10.10", "c0": "v2026.09.04"}
|
||||
# `gh api --paginate --jq` prints one login per line, none for a
|
||||
# commit GitHub links to no account.
|
||||
COMMIT_AUTHORS = "Abdess\nhabib256\nAbdess76\ndependabot[bot]\nzed\nhabib256\n"
|
||||
PULLS = [
|
||||
{"number": 84, "author": {"login": "dajiaohuang", "is_bot": False}},
|
||||
{"number": 86, "author": {"login": "habib256", "is_bot": False}},
|
||||
{"number": 80, "author": {"login": "app/dependabot", "is_bot": True}},
|
||||
{"number": 67, "author": {"login": "prakashmagat50-byte", "is_bot": False}},
|
||||
{"number": 70, "author": {"login": "closedwithoutmerge", "is_bot": False}},
|
||||
]
|
||||
ISSUES = [
|
||||
{"number": 87, "author": {"login": "paperweightorder", "is_bot": False}},
|
||||
{"number": 85, "author": {"login": "72374", "is_bot": False}},
|
||||
{"number": 83, "author": {"login": "72374", "is_bot": False}},
|
||||
{"number": 32, "author": {"login": "Bappo0", "is_bot": False}},
|
||||
{"number": 31, "author": {"login": "ghost", "is_bot": False}},
|
||||
{"number": 30, "author": {"login": "habib256", "is_bot": False}},
|
||||
{"number": 29, "author": {"login": "Abdess", "is_bot": False}},
|
||||
]
|
||||
ISSUE_COMMENTS = "Abdess\nhelper\n72374\ngithub-actions[bot]\nAlpha\n"
|
||||
REVIEW_COMMENTS = "reviewer\nhabib256\n"
|
||||
|
||||
def fake(self, argv):
|
||||
self.calls.append(argv)
|
||||
if argv[:2] == ["git", "log"]:
|
||||
return "\n".join(self.TAGS) + "\n"
|
||||
if argv[:2] == ["git", "show"]:
|
||||
return json.dumps({"tag": self.TAGS[argv[2].split(":")[0]]})
|
||||
if argv[:2] == ["gh", "api"]:
|
||||
path = argv[3]
|
||||
return {"repos/Abdess/retrobios/commits": self.COMMIT_AUTHORS,
|
||||
"repos/Abdess/retrobios/issues/comments": self.ISSUE_COMMENTS,
|
||||
"repos/Abdess/retrobios/pulls/comments": self.REVIEW_COMMENTS}[path]
|
||||
if argv[:3] == ["gh", "pr", "list"]:
|
||||
return json.dumps(self.PULLS)
|
||||
if argv[:3] == ["gh", "issue", "list"]:
|
||||
return json.dumps(self.ISSUES)
|
||||
raise AssertionError(argv)
|
||||
|
||||
def setUp(self):
|
||||
self.calls = []
|
||||
|
||||
def test_the_base_is_the_previous_release_record(self):
|
||||
import release_notes
|
||||
|
||||
self.assertEqual(release_notes.previous_record_commit("v2026.11.10", self.fake), "c1")
|
||||
|
||||
def test_everyone_since_the_start_is_thanked_once(self):
|
||||
import release_notes
|
||||
|
||||
lines = release_notes.gather_thanks(self.fake)
|
||||
self.assertEqual(lines, [
|
||||
"- **Code and data**: @closedwithoutmerge, @dajiaohuang, @habib256 and @zed.",
|
||||
"- **Reports**: @72374 and @paperweightorder.",
|
||||
"- **Help in issues**: @Alpha, @helper and @reviewer.",
|
||||
])
|
||||
text = "\n".join(lines)
|
||||
for left_out in ("Abdess", "bot", "dependabot", "ghost", "Bappo0", "prakashmagat50"):
|
||||
self.assertNotIn(left_out, text)
|
||||
# Every state: a pull request closed without merge still counts.
|
||||
pulls = next(argv for argv in self.calls if argv[:3] == ["gh", "pr", "list"])
|
||||
self.assertEqual(pulls[pulls.index("--state") + 1], "all")
|
||||
issues = next(argv for argv in self.calls if argv[:3] == ["gh", "issue", "list"])
|
||||
self.assertEqual(issues[issues.index("--state") + 1], "all")
|
||||
|
||||
def test_the_notes_end_with_thanks_then_the_changelog(self):
|
||||
import release_notes
|
||||
|
||||
closing = release_notes.closing_lines(
|
||||
["- **Code and data**: @habib256."],
|
||||
release_notes.changelog_url("55eb95344" + "0" * 31, "v2026.11.10"))
|
||||
text = release_notes.render(TheReleaseNotesNameTheSetupsWithoutAZip.RECORD, PLATFORMS,
|
||||
"### What changed\n\n- x\n", closing)
|
||||
self.assertLess(text.index("### What changed"), text.index("### Thanks"))
|
||||
self.assertIn("### Thanks\n\n<details>\n"
|
||||
"<summary>Everyone who helped since the start</summary>\n\n"
|
||||
"- **Code and data**: @habib256.\n\n</details>\n\n**Full changelog**",
|
||||
text)
|
||||
self.assertEqual(release_notes.refused_words(text), [])
|
||||
self.assertTrue(text.rstrip().endswith(
|
||||
"**Full changelog**: https://github.com/Abdess/retrobios/compare/"
|
||||
"55eb95344...v2026.11.10"))
|
||||
|
||||
def test_a_checked_list_replaces_the_one_gh_gives(self):
|
||||
import release_notes
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
tmp = Path(tmp)
|
||||
(tmp / "whats-new.md").write_text("### What changed\n\n- x\n", encoding="utf-8")
|
||||
(tmp / "thanks.md").write_text("- **Code and data**: @habib256.\n",
|
||||
encoding="utf-8")
|
||||
(tmp / "release.json").write_text(
|
||||
json.dumps(TheReleaseNotesNameTheSetupsWithoutAZip.RECORD), encoding="utf-8")
|
||||
argv = ["release_notes.py", "--record", str(tmp / "release.json"),
|
||||
"--whats-new", str(tmp / "whats-new.md"), "--thanks", str(tmp / "thanks.md"),
|
||||
"--platforms-dir", PLATFORMS, "--output", str(tmp / "notes.md")]
|
||||
with mock.patch.object(sys, "argv", argv), \
|
||||
mock.patch.object(release_notes, "_run", self.fake), \
|
||||
mock.patch.object(release_notes, "gather_thanks",
|
||||
side_effect=AssertionError("gh read")), \
|
||||
contextlib.redirect_stdout(io.StringIO()):
|
||||
self.assertEqual(release_notes.main(), 0)
|
||||
text = (tmp / "notes.md").read_text(encoding="utf-8")
|
||||
self.assertIn("- **Code and data**: @habib256.\n", text)
|
||||
self.assertIn("/compare/c4...v2026.10.24", text)
|
||||
|
||||
|
||||
class EveryPlatformHasAPermanentPage(unittest.TestCase):
|
||||
|
||||
@@ -133,6 +133,13 @@ class EsXmlFormat(unittest.TestCase):
|
||||
self.assertEqual(rows["psx"]["board_defaults"]["rk3326"]["core"], "duckstation")
|
||||
self.assertNotIn("board_defaults", rows["mame"])
|
||||
|
||||
def test_every_core_the_system_lists_is_offered(self) -> None:
|
||||
self.assertEqual(self.rows["psx"]["offers"], [
|
||||
{"emulator": "retroarch", "core": "pcsx_rearmed"},
|
||||
{"emulator": "retroarch", "core": "swanstation"}])
|
||||
# A default alone is no choice.
|
||||
self.assertNotIn("offers", self.rows["mame"])
|
||||
|
||||
def test_source_ref_points_at_the_name_line(self) -> None:
|
||||
self.assertEqual(self.rows["psx"]["source_ref"], "os es_systems.cfg:4")
|
||||
self.assertEqual(self.rows["advision"]["source_ref"], "os es_systems.cfg:20")
|
||||
@@ -173,6 +180,11 @@ class ElecConfFormat(unittest.TestCase):
|
||||
"DEVICE=RK3326": {"core": "pcsx_rearmed", "emulator": "retroarch",
|
||||
"source_ref": "os package.mk:11"}})
|
||||
|
||||
def test_a_core_under_every_branch_is_offered_unconditionally(self) -> None:
|
||||
self.assertEqual(self.rows["psx"]["offers"], [
|
||||
{"emulator": "retroarch", "core": "pcsx_rearmed", "source_ref": "os package.mk:11,16"},
|
||||
{"emulator": "retroarch", "core": "swanstation", "source_ref": "os package.mk:12,15"}])
|
||||
|
||||
def test_unconditional_default(self) -> None:
|
||||
self.assertEqual(self.rows["3do"]["core"], "opera")
|
||||
self.assertEqual(self.rows["3do"]["source_ref"],
|
||||
@@ -198,6 +210,34 @@ class EsdeFormat(unittest.TestCase):
|
||||
self.assertEqual(model2["core"], "model-2")
|
||||
self.assertIn("names no command", model2["note"])
|
||||
|
||||
def test_a_rom_search_path_names_the_folders_it_reads(self) -> None:
|
||||
# The Tano Dragon reads the Dragon 32 folder, the commented command
|
||||
# counts for nothing.
|
||||
(tano,) = self.rows["tanodragon"]["searched_by"]
|
||||
self.assertEqual(tano["reads"], ["dragon32"])
|
||||
self.assertEqual(tano["machines"], ["tanodr64"])
|
||||
self.assertNotIn("any_machine", tano)
|
||||
self.assertEqual(tano["source_ref"], "os es_systems.xml:20")
|
||||
|
||||
def test_the_game_itself_as_machine(self) -> None:
|
||||
libretro, standalone = self.rows["arcade"]["searched_by"]
|
||||
self.assertEqual(standalone["emulator"], "mame")
|
||||
self.assertNotIn("core", standalone)
|
||||
self.assertTrue(standalone["any_machine"])
|
||||
self.assertNotIn("machines", standalone)
|
||||
self.assertNotIn("searched_by", self.rows["psx"])
|
||||
# The libretro core reads the `-rompath` of the command line it is
|
||||
# handed as content (retro_init.cpp execute_game_cmd).
|
||||
self.assertEqual((libretro["emulator"], libretro["core"]), ("retroarch", "mame"))
|
||||
self.assertEqual(libretro["reads"], ["arcade"])
|
||||
self.assertTrue(libretro["any_machine"])
|
||||
self.assertEqual(libretro["source_ref"], "os es_systems.xml:27")
|
||||
|
||||
def test_each_command_offers_its_emulator(self) -> None:
|
||||
self.assertEqual(self.rows["arcade"]["offers"], [
|
||||
{"emulator": "retroarch", "core": "mame", "source_ref": "os es_systems.xml:27"},
|
||||
{"emulator": "mame", "core": "mame", "source_ref": "os es_systems.xml:28"}])
|
||||
|
||||
def test_first_command_without_alternative(self) -> None:
|
||||
rows = by_folder(scrape("esde", "esde", {"systems": {"source": "os", "path": "es_systems.xml"}}))
|
||||
self.assertEqual((rows["psx"]["core"], rows["psx"]["emulator"]), ("mednafen_psx", "retroarch"))
|
||||
|
||||
@@ -95,6 +95,24 @@ class SemanticManifestValidation(unittest.TestCase):
|
||||
self.assertEqual(len(errors), 1)
|
||||
self.assertIn("total_files does not equal len(files)", errors[0])
|
||||
|
||||
def test_an_emulator_folder_omission_is_keyed_by_its_cores(self):
|
||||
"""mame2015 and mame2016 read 3dobios.zip each in its own folder:
|
||||
two omissions, two places. The same core twice is one place."""
|
||||
path = REPO_ROOT / "install" / "synthetic.json"
|
||||
|
||||
def omission(core: str) -> dict:
|
||||
return {"dest": "3dobios.zip", "root": "emulator", "cores": [core]}
|
||||
|
||||
def errors(omitted: list[dict]) -> list[str]:
|
||||
manifest = {"files": [], "total_files": 0, "total_size": 0,
|
||||
"omitted_files": omitted, "total_omitted": len(omitted)}
|
||||
return [e for e in validate_schemas._semantic_install_checks(path, manifest)
|
||||
if "omitted destinations" in e]
|
||||
|
||||
self.assertEqual(errors([omission("mame2015"), omission("mame2016")]), [])
|
||||
self.assertEqual(len(errors([omission("mame2015"), omission("mame2015")])), 1)
|
||||
self.assertEqual(len(errors([{"dest": "a.bin"}, {"dest": "a.bin"}])), 1)
|
||||
|
||||
|
||||
try:
|
||||
import jsonschema
|
||||
|
||||
@@ -650,6 +650,15 @@ class UnreadableReleaseStopsTheScrape(unittest.TestCase):
|
||||
# Read at a release tag: the pin is the tag, not a branch commit.
|
||||
TAG_PINNED = {"amberelec", "batocera", "bizhawk", "emuelec", "knulli", "recalbox",
|
||||
"rocknix", "romm"}
|
||||
# Reread the commit the platform file pins, moved by the revision the
|
||||
# registry's rescrape_args names: checked with that revision.
|
||||
FILE_PINNED = {"retrobat"}
|
||||
|
||||
@classmethod
|
||||
def _construct(cls, module: object, scraper: str) -> object:
|
||||
if scraper in cls.FILE_PINNED:
|
||||
return module.Scraper(revision="master")
|
||||
return module.Scraper()
|
||||
|
||||
@staticmethod
|
||||
def _registry_scrapers() -> list[str]:
|
||||
@@ -671,7 +680,17 @@ class UnreadableReleaseStopsTheScrape(unittest.TestCase):
|
||||
with self.subTest(scraper=name), mock.patch(
|
||||
"urllib.request.urlopen", self._refuse
|
||||
), self.assertRaises(RuntimeError):
|
||||
module.Scraper()
|
||||
self._construct(module, scraper)
|
||||
|
||||
def test_a_file_pinned_scraper_reads_its_pin_offline(self):
|
||||
for scraper in sorted(self.FILE_PINNED):
|
||||
module = importlib.import_module(f"scraper.{scraper}_scraper")
|
||||
with self.subTest(scraper=scraper), mock.patch(
|
||||
"urllib.request.urlopen", self._refuse
|
||||
):
|
||||
self.assertEqual(
|
||||
module.launcher_revision(module.Scraper().url), module.pinned_revision()
|
||||
)
|
||||
|
||||
def test_a_branch_read_records_its_commit(self):
|
||||
"""System.dat, batocera-systems.json, checkBIOS.sh, the BiosDB and the
|
||||
@@ -695,7 +714,7 @@ class UnreadableReleaseStopsTheScrape(unittest.TestCase):
|
||||
name = f"scraper.{scraper}_scraper"
|
||||
module = importlib.import_module(name)
|
||||
with self.subTest(scraper=name), mock.patch("urllib.request.urlopen", answer):
|
||||
instance = module.Scraper()
|
||||
instance = self._construct(module, scraper)
|
||||
# RetroDECK reads a tree of manifests and keeps the commit apart.
|
||||
recorded = getattr(instance, "revision", "") or instance.url
|
||||
self.assertRegex(recorded, f"(^|/){sha}(/|$)")
|
||||
|
||||
@@ -328,7 +328,7 @@ class TitleLogoOnAPlate(unittest.TestCase):
|
||||
# written, the tile's and the title's.
|
||||
import sitemarkup # noqa: PLC0415
|
||||
|
||||
self.assertRegex(sitemarkup._tile_mark("MyMinUI", ""), r"<svg[^>]*>.*>MM</text></svg>")
|
||||
self.assertIn('data-initials="MM" aria-hidden="true"></span>', sitemarkup._tile_mark("MyMinUI", ""))
|
||||
component = _read(REPO_ROOT / "website" / "src" / "components" / "PageTitle.astro")
|
||||
self.assertIn("{initials(setup.name)}", component)
|
||||
|
||||
@@ -409,7 +409,7 @@ class WideTablesStackAndFiltersAreBuilt(unittest.TestCase):
|
||||
|
||||
def test_the_filter_box_is_in_the_html(self):
|
||||
html = _built("gaps-files-to-source")
|
||||
boxes = re.findall(r'<div class="rb-table-filter">(.*?)</div>\s*<table', html, re.S)
|
||||
boxes = re.findall(r'<div class="rb-table-filter"[^>]*>(.*?)</div>\s*<table', html, re.S)
|
||||
self.assertTrue(boxes)
|
||||
for box in boxes:
|
||||
self.assertRegex(box, r'<label for="rb-table-filter-\d+">Filter [^<]+</label>')
|
||||
|
||||
@@ -41,6 +41,8 @@ import unittest
|
||||
from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
|
||||
import yaml
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0, str(REPO_ROOT / "scripts"))
|
||||
sys.path.insert(0, str(REPO_ROOT))
|
||||
@@ -160,7 +162,7 @@ class SetupTiles(unittest.TestCase):
|
||||
def test_a_setup_without_a_logo_shows_its_initials(self):
|
||||
self.assertEqual(sitemarkup.initials("MyMinUI"), "MM")
|
||||
tile = "".join(sitemarkup.platform_tiles([("MyMinUI", "x.md", "", "Handhelds")]))
|
||||
self.assertIn(">MM</text>", tile)
|
||||
self.assertIn('data-initials="MM"', tile)
|
||||
tile = "".join(sitemarkup.platform_tiles([("RomM", "x.md", "logo.png", "A server")]))
|
||||
self.assertIn('<img class="rb-card-logo" src="logo.png"', tile)
|
||||
|
||||
@@ -983,9 +985,10 @@ class GetPagesSayWhatTheyHold(unittest.TestCase):
|
||||
display = _display(name)
|
||||
text = sitepages.page(f"get/{name}.md").read_text(encoding="utf-8")
|
||||
kind = "pack" if REGISTRY[name].get("release_pack") is True else "files"
|
||||
title = (f"BIOS {kind} for {display}"
|
||||
if (REPO_ROOT / "emulators" / f"{name}.yml").is_file()
|
||||
else f"{display} BIOS {kind}")
|
||||
# A profile that lists files titles its page "<name> BIOS files".
|
||||
profile = REPO_ROOT / "emulators" / f"{name}.yml"
|
||||
lists = profile.is_file() and (yaml.safe_load(profile.read_text(encoding="utf-8")) or {}).get("files")
|
||||
title = f"BIOS {kind} for {display}" if lists else f"{display} BIOS {kind}"
|
||||
with self.subTest(setup=name):
|
||||
self.assertEqual(generate_site.get_page_title(name, display), title)
|
||||
self.assertIn(f"title: {title}\n", text)
|
||||
|
||||
@@ -49,8 +49,9 @@ class TheEntryTable(unittest.TestCase):
|
||||
def test_a_long_table_has_its_filter_box_and_stacks(self):
|
||||
lines = siteentries.entry_table(self._rows(25), gs.ENTRY_HEADS, "rb-entry-filter-x", "Required")
|
||||
text = "\n".join(lines)
|
||||
self.assertRegex(text, r'<div class="rb-table-filter"><label for="rb-entry-filter-x">'
|
||||
r"Filter Required</label><input id=\"rb-entry-filter-x\" type=\"search\"")
|
||||
self.assertRegex(text, r'<div class="rb-table-filter" hidden data-pagefind-ignore>'
|
||||
r'<label for="rb-entry-filter-x">Filter Required</label> '
|
||||
r"<input id=\"rb-entry-filter-x\" type=\"search\"")
|
||||
self.assertIn('aria-live="polite">25 rows</span></div>\n<table class="rb-entries" '
|
||||
'data-rb-stack="true">', text)
|
||||
# The Status column is empty on every row: not written.
|
||||
@@ -210,7 +211,7 @@ class TheWantedListIsOneFilteredTable(unittest.TestCase):
|
||||
self.assertIn("| Nintendo - GameCube - BIOS Images | 16 |", self.page)
|
||||
|
||||
def test_every_dump_is_one_row_under_a_filter_box(self):
|
||||
box = re.search(r'<div class="rb-table-filter">.*?</div>\n<details[^>]*>\n'
|
||||
box = re.search(r'<div class="rb-table-filter"[^>]*>.*?</div>\n<details[^>]*>\n'
|
||||
r"<summary>All 31 wanted dumps</summary>\n<table class=\"rb-wanted\"",
|
||||
self.page, re.S)
|
||||
self.assertIsNotNone(box)
|
||||
|
||||
@@ -344,7 +344,7 @@ class APlatformPageSaysWhereEachFileGoes(unittest.TestCase):
|
||||
{"nintendo-gamecube": files}, {("nintendo-gamecube", "IPL.bin"): declared}, {})
|
||||
for region in regions:
|
||||
# The folder: the name is before it in the row.
|
||||
self.assertIn(f"<summary>IPL.bin<code>dolphin-emu/Sys/GC/{region}/</code>"
|
||||
self.assertIn(f"<summary>IPL.bin <code>dolphin-emu/Sys/GC/{region}/</code> "
|
||||
'<span class="rb-badge rb-badge-success">OK</span></summary>',
|
||||
"\n".join(lines))
|
||||
|
||||
|
||||
@@ -0,0 +1,168 @@
|
||||
"""The handheld launchers the site serves.
|
||||
|
||||
The four archives build_port.py writes carry install.py pinned by SHA-256,
|
||||
so they left the release (owner, 2026-11-10): the site builds them from its
|
||||
own commit, serves them under get/handheld/, and the get/ page of each
|
||||
system names the file, its size and hash, where it goes and which menu
|
||||
starts it.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
|
||||
|
||||
import contextlib
|
||||
import hashlib
|
||||
import re
|
||||
import shutil
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
from unittest import mock
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0, str(REPO_ROOT / "scripts"))
|
||||
|
||||
import build_port # noqa: E402
|
||||
import common # noqa: E402
|
||||
import sitehandheld # noqa: E402
|
||||
|
||||
PLATFORMS = str(REPO_ROOT / "platforms")
|
||||
|
||||
|
||||
def _pages() -> dict[str, str]:
|
||||
"""Every page that carries a launcher, by site path."""
|
||||
import generate_site # noqa: PLC0415
|
||||
|
||||
with contextlib.chdir(REPO_ROOT):
|
||||
pages = {f"get/{key}.md": generate_site.generate_get_page(key)
|
||||
for key in sorted(set(sitehandheld.PLATFORM_OF.values()))}
|
||||
pages[f"get/{sitehandheld.GROUP_PAGE}.md"] = sitehandheld.group_page(REPO_ROOT)
|
||||
return pages
|
||||
|
||||
|
||||
class TheSiteServesTheLaunchers(unittest.TestCase):
|
||||
def setUp(self):
|
||||
scratch = REPO_ROOT / "tmp"
|
||||
scratch.mkdir(exist_ok=True)
|
||||
self.tmp = Path(tempfile.mkdtemp(dir=scratch, prefix="site-handheld-"))
|
||||
self.addCleanup(shutil.rmtree, self.tmp, True)
|
||||
|
||||
def test_the_written_archives_are_the_ones_build_port_writes(self):
|
||||
written = sitehandheld.write_launchers(self.tmp / "public", REPO_ROOT)
|
||||
self.assertEqual([path.name for path in written], list(build_port.ARCHIVES))
|
||||
for path in written:
|
||||
with self.subTest(archive=path.name):
|
||||
self.assertEqual(path.parent, self.tmp / "public" / "get" / "handheld")
|
||||
built = build_port.build_archive(path.name, self.tmp / "built" / path.name)
|
||||
self.assertEqual(path.read_bytes(), built.read_bytes())
|
||||
|
||||
def test_an_unchanged_archive_is_not_rewritten(self):
|
||||
first = sitehandheld.write_launchers(self.tmp / "public", REPO_ROOT)
|
||||
stamps = {path: path.stat().st_mtime_ns for path in first}
|
||||
sitehandheld.write_launchers(self.tmp / "public", REPO_ROOT)
|
||||
self.assertEqual({path: path.stat().st_mtime_ns for path in first}, stamps)
|
||||
|
||||
def test_a_stale_pin_stops_the_build(self):
|
||||
"""build_port refuses an install.py the bootstraps do not pin: served,
|
||||
that launcher would refuse its own installer."""
|
||||
with mock.patch.dict(sitehandheld._built, clear=True), \
|
||||
mock.patch.object(build_port, "pinned_installer_sha256", return_value="0" * 64):
|
||||
with self.assertRaisesRegex(ValueError, "re-pin the bootstraps"):
|
||||
sitehandheld.write_launchers(self.tmp / "public", REPO_ROOT)
|
||||
self.assertFalse(list((self.tmp / "public").rglob("RetroBIOS*")))
|
||||
|
||||
def test_every_archive_is_on_a_page_with_its_link_and_hash(self):
|
||||
public = self.tmp / "public"
|
||||
written = {path.name: path for path in sitehandheld.write_launchers(public, REPO_ROOT)}
|
||||
pages = _pages()
|
||||
for name in build_port.ARCHIVES:
|
||||
with self.subTest(archive=name):
|
||||
data = written[name].read_bytes()
|
||||
digest = hashlib.sha256(data).hexdigest()
|
||||
holding = [page for page, text in pages.items()
|
||||
if f'href="handheld/{name}"' in text]
|
||||
self.assertTrue(holding, f"no page links {name}")
|
||||
for page in holding:
|
||||
text = pages[page]
|
||||
# The link resolves to the file written under public/.
|
||||
target = (Path(page).parent / "handheld" / name).as_posix()
|
||||
self.assertTrue((public / target).is_file(), target)
|
||||
block = text.split(f'href="handheld/{name}"', 1)[1].split("\n\n", 2)[1]
|
||||
self.assertIn(f"SHA-256: `{digest}`", block)
|
||||
self.assertIn(sitehandheld._size(len(data)), block)
|
||||
self.assertRegex(block, r"- (Copy it to|Unzip it into) .+\.")
|
||||
self.assertRegex(block, r"- Start it from .+\.")
|
||||
|
||||
|
||||
class WhereEachSystemFindsItsFile(unittest.TestCase):
|
||||
def test_each_platform_page_is_a_registered_platform(self):
|
||||
registered = set(common.list_registered_platforms(PLATFORMS))
|
||||
self.assertLessEqual(set(sitehandheld.PLATFORM_OF.values()), registered)
|
||||
self.assertNotIn(sitehandheld.GROUP_PAGE, registered)
|
||||
|
||||
def test_the_group_page_sits_with_the_handheld_guide(self):
|
||||
"""It shares the guide's name, so the sidebar files it with it, and
|
||||
the guide a muOS or ArkOS owner lands on links it."""
|
||||
import generate_site # noqa: PLC0415
|
||||
|
||||
guide = generate_site.HANDHELD_GUIDE
|
||||
self.assertEqual(sitehandheld.GROUP_PAGE, guide.page)
|
||||
with contextlib.chdir(REPO_ROOT):
|
||||
self.assertIn(f"(../get/{sitehandheld.GROUP_PAGE}.md)",
|
||||
generate_site.generate_handheld_guide(guide))
|
||||
self.assertIn(f"]({sitehandheld.GROUP_PAGE}.md)", generate_site.generate_get_index())
|
||||
|
||||
def test_every_system_has_its_launchers_on_its_page(self):
|
||||
pages = _pages()
|
||||
for system in sitehandheld.systems():
|
||||
page = sitehandheld.page_of(system)
|
||||
with self.subTest(system=system):
|
||||
self.assertIn(page, pages)
|
||||
for launcher in sitehandheld.launchers_for(system):
|
||||
self.assertIn(f'href="handheld/{launcher.archive}"', pages[page])
|
||||
self.assertIn(launcher.folder_for(system), pages[page])
|
||||
self.assertIn(launcher.start, pages[page])
|
||||
for system in sitehandheld.group_systems():
|
||||
self.assertIn(f"\n## {system}\n", pages[f"get/{sitehandheld.GROUP_PAGE}.md"])
|
||||
|
||||
def test_the_installer_table_is_written_from_the_same_rows(self):
|
||||
text = (REPO_ROOT / "wiki" / "installer.md").read_text(encoding="utf-8")
|
||||
block = re.search(r"<!-- generated: handheld -->\n(.*?)<!-- /generated: handheld -->",
|
||||
text, re.S)
|
||||
self.assertIsNotNone(block)
|
||||
self.assertEqual(block.group(1).strip(), "\n".join(sitehandheld.table_rows()))
|
||||
self.assertNotIn("releases/latest", text.split("## On a handheld", 1)[1].split("\n## ")[0])
|
||||
|
||||
def test_the_installer_section_opens_on_the_downloads(self):
|
||||
"""The section was long, with no link to click (owner, 2026-11-10):
|
||||
it opens on one row per system, each file a link to its copy on the
|
||||
site, before the detail."""
|
||||
text = (REPO_ROOT / "wiki" / "installer.md").read_text(encoding="utf-8")
|
||||
section = text.split("## On a handheld", 1)[1].split("\n## ")[0]
|
||||
block = re.search(r"<!-- generated: handheld-downloads -->\n(.*?)"
|
||||
r"<!-- /generated: handheld-downloads -->", section, re.S)
|
||||
self.assertIsNotNone(block)
|
||||
self.assertEqual(block.group(1).strip(), "\n".join(sitehandheld.download_rows()))
|
||||
self.assertLess(block.start(), section.index("### Where each file goes"))
|
||||
self.assertLess(len(section[:block.start()].split()), 40)
|
||||
for system in sitehandheld.systems():
|
||||
with self.subTest(system=system):
|
||||
row = next(line for line in block.group(1).splitlines()
|
||||
if line.startswith(f"| {system} |"))
|
||||
for launcher in sitehandheld.launchers_for(system):
|
||||
self.assertIn(f"](../{sitehandheld.SERVED_DIR}/{launcher.archive})", row)
|
||||
self.assertIn(f"](../{sitehandheld.page_of(system)}#", row)
|
||||
for name in build_port.ARCHIVES:
|
||||
self.assertIn(f"](../{sitehandheld.SERVED_DIR}/{name})", block.group(1))
|
||||
|
||||
def test_the_generator_writes_them(self):
|
||||
source = (REPO_ROOT / "scripts" / "generate_site.py").read_text(encoding="utf-8")
|
||||
self.assertIn("sitehandheld.write_launchers(public, _REPO_ROOT)", source)
|
||||
self.assertIn("sitehandheld.platform_block(platform_name, _REPO_ROOT)", source)
|
||||
self.assertIn("sitehandheld.group_page(_REPO_ROOT)", source)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -396,7 +396,7 @@ class _Page(HTMLParser):
|
||||
def handle_endtag(self, tag: str) -> None:
|
||||
if tag == "nav" and self._crumbs:
|
||||
self._crumbs = 0
|
||||
if tag == "div" and self._pagination and not self.pagination:
|
||||
if tag == "nav" and self._pagination and not self.pagination:
|
||||
self._pagination = False
|
||||
if self._text is not None and tag in ("a", "summary"):
|
||||
self.sidebar.append(" ".join("".join(self._text).split()))
|
||||
@@ -621,7 +621,7 @@ def _html(url: str) -> str:
|
||||
|
||||
|
||||
def _pagination(text: str) -> tuple[str | None, str | None]:
|
||||
start = text.find('<div class="pagination-links')
|
||||
start = text.find('<nav class="pagination-links')
|
||||
if start == -1:
|
||||
return None, None
|
||||
links = text[start:text.find("</footer>", start)]
|
||||
|
||||
@@ -0,0 +1,373 @@
|
||||
"""The text a page gives to whatever reads it without looking at it.
|
||||
|
||||
A crawler, a screen reader, an assistant, a text browser and a copy read
|
||||
the words of the HTML, not the layout. The Steam Deck steps of Get the
|
||||
files read three times there, once in the prose and once per drawn layout
|
||||
glued letter to letter ("Open Konsole3Click Copy,the button bythe line"),
|
||||
a filter box read "Filter Options41 rows" and the file picker an empty
|
||||
"Setup Choose a setup". These tests read representative pages the way such
|
||||
a reader does, skipping what is `hidden`, `aria-hidden`, scripts and
|
||||
styles, and hold the page to one reading of each thing it says.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
|
||||
|
||||
import json
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import unittest
|
||||
from html.parser import HTMLParser
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
sys.path.insert(0, str(ROOT / "scripts"))
|
||||
|
||||
import sitediagrams # noqa: E402
|
||||
import siteentries # noqa: E402
|
||||
import sitesteps # noqa: E402
|
||||
from siteguides import TERMINALS # noqa: E402
|
||||
|
||||
WEBSITE = ROOT / "website"
|
||||
DOCS = WEBSITE / "src" / "content" / "docs"
|
||||
DIST = WEBSITE / "dist"
|
||||
PLUGIN = WEBSITE / "src" / "plugins" / "rehype-stack-tables.mjs"
|
||||
SATTERI = WEBSITE / "node_modules" / "satteri" / "dist" / "index.js"
|
||||
|
||||
# The pages that hold each kind: the drawn steps and the picker, the
|
||||
# figures, a filter box written by the build, one by the generator above
|
||||
# a file list, one above an entry table, and the stats of a setup page.
|
||||
PAGES = ("which-pack", "wiki/first-install", "wiki/architecture", "wiki/what-are-bios-files",
|
||||
"wiki/installer", "platforms/retrodeck", "provenance-no-intro", "explore", "index")
|
||||
|
||||
BLOCKS = frozenset(
|
||||
"address article aside blockquote caption dd details dialog div dl dt fieldset figcaption "
|
||||
"figure footer form h1 h2 h3 h4 h5 h6 header hr li main nav ol option p pre section select "
|
||||
"summary table tbody td tfoot th thead tr ul".split())
|
||||
VOID = frozenset("area base br col embed hr img input link meta source track wbr".split())
|
||||
# What the stylesheet lays out as its own box beside the text before it:
|
||||
# the markup has to space it, a reader without the stylesheet sees no box.
|
||||
# A <br> breaks a line on screen only: a copy and textContent join across
|
||||
# it, so it separates nothing here. link-title is the page name of
|
||||
# Starlight's previous and next links.
|
||||
OWN_BOX = ("rb-tile-name", "rb-tile-runs", "rb-stat-label", "rb-badge", "rb-table-filter-count",
|
||||
"link-title")
|
||||
|
||||
|
||||
class PageText(HTMLParser):
|
||||
"""The text of a page, as a reader without the stylesheet gets it: a
|
||||
block starts a line, an inline element adds nothing between words.
|
||||
Skips script, style, template, `hidden` and `aria-hidden`. A tab panel,
|
||||
hidden until its tab is picked, is read: it is content, not chrome."""
|
||||
|
||||
def __init__(self, article_only: bool = False) -> None:
|
||||
super().__init__(convert_charrefs=True)
|
||||
self.parts: list[str] = []
|
||||
self.stack: list[tuple[str, bool]] = []
|
||||
self.skipping = 0
|
||||
self.inside = not article_only
|
||||
self.glued: list[str] = []
|
||||
# Filter boxes read: the build writes each one hidden until wired.
|
||||
self.filters_read = 0
|
||||
|
||||
def _text_so_far(self) -> str:
|
||||
return "".join(self.parts[-4:])
|
||||
|
||||
def handle_starttag(self, tag: str, attrs: list[tuple[str, str | None]]) -> None:
|
||||
attr = {key: value or "" for key, value in attrs}
|
||||
classes = attr.get("class", "").split()
|
||||
if not self.inside:
|
||||
self.inside = "sl-markdown-content" in classes
|
||||
return
|
||||
if self.skipping:
|
||||
if tag not in VOID:
|
||||
self.stack.append((tag, False))
|
||||
return
|
||||
if tag == "img":
|
||||
self.parts.append(attr.get("alt", ""))
|
||||
return
|
||||
if tag in BLOCKS:
|
||||
self.parts.append("\n")
|
||||
if "rb-table-filter" in classes and "hidden" not in attr:
|
||||
self.filters_read += 1
|
||||
if any(name in OWN_BOX for name in classes) or (tag == "code" and self.stack
|
||||
and self.stack[-1][0] == "summary"):
|
||||
before = self._text_so_far()
|
||||
if before and not before[-1].isspace():
|
||||
self.glued.append(f"{before[-20:]!r} <{tag} class={' '.join(classes)!r}>")
|
||||
if tag in VOID:
|
||||
return
|
||||
skip = (tag in ("script", "style", "template")
|
||||
or ("hidden" in attr and attr.get("role") != "tabpanel")
|
||||
or attr.get("aria-hidden") == "true")
|
||||
self.stack.append((tag, skip))
|
||||
self.skipping += skip
|
||||
|
||||
def handle_endtag(self, tag: str) -> None:
|
||||
if tag in VOID or not self.inside:
|
||||
return
|
||||
while self.stack:
|
||||
name, skip = self.stack.pop()
|
||||
self.skipping -= skip
|
||||
if name == tag:
|
||||
break
|
||||
if not self.skipping and tag in BLOCKS:
|
||||
self.parts.append("\n")
|
||||
|
||||
def handle_data(self, data: str) -> None:
|
||||
if self.inside and not self.skipping:
|
||||
self.parts.append(data)
|
||||
|
||||
@property
|
||||
def text(self) -> str:
|
||||
return re.sub(r"\n\s*", "\n", re.sub(r"[ \t]+", " ", "".join(self.parts))).strip()
|
||||
|
||||
|
||||
def read(html: str, article_only: bool = False) -> PageText:
|
||||
reader = PageText(article_only)
|
||||
reader.feed(html)
|
||||
reader.close()
|
||||
return reader
|
||||
|
||||
|
||||
def _letters(text: str) -> str:
|
||||
"""The text without any space: the letters an SVG wrapped across text
|
||||
nodes still spell, joined or not."""
|
||||
return re.sub(r"\s+", "", text.replace("**", ""))
|
||||
|
||||
|
||||
def _sources() -> dict[str, str]:
|
||||
found = {}
|
||||
for page in PAGES:
|
||||
for suffix in (".mdx", ".md"):
|
||||
path = DOCS / f"{page}{suffix}"
|
||||
if path.is_file():
|
||||
# MDX keeps a space between two tags only as an expression.
|
||||
found[page] = path.read_text(encoding="utf-8").replace('{" "}', " ")
|
||||
return found
|
||||
|
||||
|
||||
def _built() -> dict[str, str]:
|
||||
found = {}
|
||||
for page in PAGES:
|
||||
path = DIST / ("index.html" if page == "index" else f"{page}/index.html")
|
||||
if path.is_file():
|
||||
found[page] = path.read_text(encoding="utf-8")
|
||||
return found
|
||||
|
||||
|
||||
class PageReadsOnce:
|
||||
"""The assertions, on generated page sources (the HTML the generators
|
||||
write, Markdown left as text) and on built pages when there are any."""
|
||||
|
||||
pages: dict[str, PageText]
|
||||
|
||||
def test_the_drawn_steps_are_not_read_again(self):
|
||||
checked = 0
|
||||
for name, page in self.pages.items():
|
||||
text = _letters(page.text)
|
||||
for tab, (title, steps) in sitesteps.STEPS.items():
|
||||
prose = _letters(TERMINALS[tab][1])
|
||||
with self.subTest(page=name, tab=tab):
|
||||
self.assertLessEqual(text.count(prose), 1)
|
||||
self.assertNotIn(_letters(title), text)
|
||||
self.assertNotIn(_letters(sitesteps.description(tab)), text)
|
||||
# A drawn layout repeats every caption: a caption long
|
||||
# enough to be told apart is read at most once, by the
|
||||
# prose when it says it.
|
||||
for step in steps:
|
||||
caption = _letters(step.caption)
|
||||
if len(caption) >= 16:
|
||||
checked += 1
|
||||
self.assertLessEqual(text.count(caption), 1, step.caption)
|
||||
self.assertGreater(checked, 0)
|
||||
|
||||
def test_a_figure_says_its_words_once(self):
|
||||
for name, page in self.pages.items():
|
||||
text = _letters(page.text)
|
||||
for image_id in sitediagrams.IMAGE_IDS:
|
||||
figure = sitediagrams.figures()[image_id]
|
||||
with self.subTest(page=name, image=image_id):
|
||||
self.assertLessEqual(text.count(_letters(figure.desc)), 1)
|
||||
self.assertLessEqual(text.count(_letters(figure.caption)), 1)
|
||||
|
||||
def test_no_rows_counter_glued_to_a_label(self):
|
||||
for name, page in self.pages.items():
|
||||
with self.subTest(page=name):
|
||||
self.assertIsNone(re.search(r"[^\s\d,(][\d,]*\d rows\b", page.text))
|
||||
# A filter box read whole ("Filter Options41 rows"). A cell
|
||||
# may open on the word: installer.md's "Filter a long list".
|
||||
self.assertEqual(page.filters_read, 0)
|
||||
|
||||
def test_no_empty_picker(self):
|
||||
for name, page in self.pages.items():
|
||||
with self.subTest(page=name):
|
||||
self.assertNotIn("Choose a setup", page.text)
|
||||
|
||||
def test_what_sits_in_its_own_box_is_spaced(self):
|
||||
for name, page in self.pages.items():
|
||||
with self.subTest(page=name):
|
||||
self.assertEqual(page.glued, [])
|
||||
|
||||
|
||||
class GeneratedPagesReadOnce(PageReadsOnce, unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
sources = _sources()
|
||||
if "which-pack" not in sources:
|
||||
raise unittest.SkipTest("no generated pages: run scripts/generate_site.py")
|
||||
cls.pages = {name: read(text) for name, text in sources.items()}
|
||||
|
||||
def test_the_pages_hold_what_is_checked(self):
|
||||
sources = _sources()
|
||||
self.assertIn("rb-steps", sources["which-pack"])
|
||||
self.assertIn('class="rb-table-filter" hidden', sources["platforms/retrodeck"])
|
||||
self.assertIn('class="rb-table-filter" hidden', sources["provenance-no-intro"])
|
||||
self.assertIn('class="rb-figure"', sources["wiki/architecture"])
|
||||
|
||||
|
||||
class BuiltPagesReadOnce(PageReadsOnce, unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
built = _built()
|
||||
if "which-pack" not in built:
|
||||
raise unittest.SkipTest("no built site")
|
||||
cls.pages = {name: read(text, article_only=True) for name, text in built.items()}
|
||||
|
||||
def test_the_build_writes_the_filter_boxes_hidden(self):
|
||||
boxes = re.findall(r'<div class="rb-table-filter"[^>]*>', _built()["wiki/installer"])
|
||||
self.assertTrue(boxes)
|
||||
for box in boxes:
|
||||
self.assertIn(" hidden", box)
|
||||
|
||||
|
||||
class TheTwoFilterBoxesAreOne(unittest.TestCase):
|
||||
"""rehype-stack-tables.mjs writes the box above a Markdown table,
|
||||
siteentries.filter_box above an HTML one: the same markup, so site.ts,
|
||||
the stylesheet and every reader meet one box."""
|
||||
|
||||
def test_the_build_writes_what_the_generator_writes(self):
|
||||
node = shutil.which("node")
|
||||
if not node or not SATTERI.is_file():
|
||||
self.skipTest("no node or no website/node_modules")
|
||||
rows = "\n".join(f"| a{i} | b | c |" for i in range(22))
|
||||
script = (
|
||||
f"const {{ markdownToHtml }} = await import({json.dumps(SATTERI.as_uri())});\n"
|
||||
f"const {{ default: stackTables }} = await import({json.dumps(PLUGIN.as_uri())});\n"
|
||||
f"const md = {json.dumps(f'## Options{chr(10)}{chr(10)}| Flag | What | When |{chr(10)}|---|---|---|{chr(10)}{rows}{chr(10)}')};\n"
|
||||
"console.log(markdownToHtml(md, { hastPlugins: [stackTables()] }).html);\n"
|
||||
)
|
||||
built = subprocess.run([node, "--input-type=module", "-e", script], capture_output=True,
|
||||
text=True, check=True, timeout=60).stdout
|
||||
box = re.search(r'<div class="rb-table-filter".*?</div>', built, re.S)
|
||||
self.assertIsNotNone(box)
|
||||
self.assertEqual(box.group(0), siteentries.filter_box(
|
||||
"rb-table-filter-1", "Options", ["Flag", "What", "When"], 22))
|
||||
|
||||
def test_a_box_reads_nothing_until_wired(self):
|
||||
box = siteentries.filter_box("x", "files", ["File", "path"], 41)
|
||||
self.assertEqual(read(box).text, "")
|
||||
self.assertIn('aria-describedby="x-count"', box)
|
||||
self.assertIn('<span id="x-count"', box)
|
||||
self.assertIn("</label> <input", box)
|
||||
self.assertIn('"> <span', box)
|
||||
|
||||
def test_the_script_shows_the_boxes(self):
|
||||
source = (WEBSITE / "src" / "scripts" / "site.ts").read_text(encoding="utf-8")
|
||||
self.assertIn("querySelectorAll<HTMLElement>('.rb-table-filter[hidden]')) box.hidden = false",
|
||||
source)
|
||||
css = (WEBSITE / "src" / "styles" / "retrobios.css").read_text(encoding="utf-8")
|
||||
self.assertIn(".rb-table-filter[hidden] { visibility: hidden; }", css)
|
||||
|
||||
|
||||
class PreviousAndNextAreSpaced(unittest.TestCase):
|
||||
"""Starlight's previous and next links read "PreviousWhat the packs do
|
||||
not hold": the word and the title were split by a <br> only. The
|
||||
override (src/components/Pagination.astro) spaces them and names each
|
||||
link by its direction and its page."""
|
||||
|
||||
def test_the_override_is_registered(self):
|
||||
config = (WEBSITE / "astro.config.mjs").read_text(encoding="utf-8")
|
||||
self.assertIn("Pagination: './src/components/Pagination.astro',", config)
|
||||
|
||||
def test_word_and_title_are_spaced_and_named(self):
|
||||
source = (WEBSITE / "src" / "components" / "Pagination.astro").read_text(encoding="utf-8")
|
||||
for word, rel, page in (("previousWord", "prev", "prev"), ("nextWord", "next", "next")):
|
||||
with self.subTest(rel=rel):
|
||||
self.assertIn(f"{{{word}}}{{' '}}\n\t\t\t\t\t<br />", source)
|
||||
self.assertIn(f'rel="{rel}" aria-label={{`${{{word}}}: ${{{page}.label}}`}}', source)
|
||||
self.assertRegex(source, r'<nav class="pagination-links[^"]*" dir=\{dir\} aria-label=')
|
||||
|
||||
def test_a_rendered_pair_reads_spaced(self):
|
||||
html = ('<div class="sl-markdown-content"></div><nav class="pagination-links">'
|
||||
'<a href="/a/" rel="prev"><span>Previous <br><span class="link-title">A</span>'
|
||||
'</span></a> <a href="/b/" rel="next"><span>Next <br>'
|
||||
'<span class="link-title">B</span></span></a></nav>')
|
||||
page = read(html, article_only=True)
|
||||
self.assertEqual(page.glued, [])
|
||||
self.assertEqual(page.text, "Previous A Next B")
|
||||
self.assertTrue(read(html.replace("Previous <br>", "Previous<br>"), article_only=True).glued)
|
||||
|
||||
|
||||
class ThePickerWaitsForItsScript(unittest.TestCase):
|
||||
def test_hidden_until_the_setups_are_listed(self):
|
||||
source = (WEBSITE / "src" / "components" / "FilePicker.astro").read_text(encoding="utf-8")
|
||||
self.assertRegex(source, r'<div class="rb-picker" hidden ')
|
||||
listed = source.index("select.add(new Option(entry.name, entry.platform));")
|
||||
self.assertLess(listed, source.index("root.hidden = false;"))
|
||||
self.assertIn(".rb-picker[hidden] { display: block; visibility: hidden; }", source)
|
||||
|
||||
|
||||
class DiagramsAreImages(unittest.TestCase):
|
||||
"""One text source per drawing: the images are alt="", the figure says
|
||||
the words once. Each theme has its files, coloured as the page is."""
|
||||
|
||||
def test_no_inline_drawing_and_no_alt(self):
|
||||
for html in [*(sitediagrams.figure_html(i) for i in sitediagrams.IMAGE_IDS),
|
||||
*("".join(sitesteps.steps_figure(tab)) for tab in sitesteps.STEPS)]:
|
||||
with self.subTest(html=html[:60]):
|
||||
self.assertNotIn("<svg", html)
|
||||
self.assertEqual(set(re.findall(r'<img [^>]*alt="([^"]*)"', html)), {""})
|
||||
self.assertEqual(len(re.findall(r"<picture ", html)), len(sitediagrams.THEMES))
|
||||
|
||||
def test_every_image_has_its_file(self):
|
||||
files = {**sitediagrams.figure_files(), **sitesteps.steps_files()}
|
||||
pages = [*(sitediagrams.figure_html(i) for i in sitediagrams.IMAGE_IDS),
|
||||
*("".join(sitesteps.steps_figure(tab)) for tab in sitesteps.STEPS)]
|
||||
named = {url.rsplit("/", 1)[1] for html in pages
|
||||
for url in re.findall(r'(?:src|srcset)="([^"]+)"', html)}
|
||||
self.assertEqual(named, set(files))
|
||||
|
||||
def test_the_figure_says_its_desc_once(self):
|
||||
for image_id in sitediagrams.IMAGE_IDS:
|
||||
figure = sitediagrams.figures()[image_id]
|
||||
with self.subTest(image=image_id):
|
||||
text = read(sitediagrams.figure_html(image_id)).text
|
||||
self.assertEqual(text.count(figure.desc), 1)
|
||||
self.assertIn(figure.caption, text)
|
||||
|
||||
def test_the_theme_colours_are_the_stylesheet_tokens(self):
|
||||
css = (WEBSITE / "src" / "styles" / "retrobios.css").read_text(encoding="utf-8")
|
||||
light_at = css.index(":root[data-theme='light'] {")
|
||||
blocks = {"dark": css[css.index(":root {"):light_at], "light": css[light_at:]}
|
||||
tokens = {"fill": "--rb-diagram-fill", "stroke": "--rb-diagram-stroke",
|
||||
"accent": "--rb-diagram-accent", "muted": "--rb-text-secondary"}
|
||||
for theme, block in blocks.items():
|
||||
for key, token in tokens.items():
|
||||
with self.subTest(theme=theme, token=token):
|
||||
value = re.search(rf"{token}:\s*(#[0-9a-f]+);", block).group(1)
|
||||
self.assertEqual(sitediagrams.THEMES[theme][key], value)
|
||||
|
||||
def test_a_file_carries_its_theme(self):
|
||||
for name, text in sitesteps.steps_files().items():
|
||||
theme = name.rsplit("-", 1)[1].removesuffix(".svg")
|
||||
with self.subTest(file=name):
|
||||
self.assertIn(f".rb-d-box{{fill:{sitediagrams.THEMES[theme]['fill']}", text)
|
||||
self.assertTrue(text.startswith("<svg "))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -97,7 +97,7 @@ class ARowPerFile(unittest.TestCase):
|
||||
{"name": "bios_a.bin", "md5": md5, "sha1": sha1, "crc32": "0badf00d",
|
||||
"destination": "bios/bios_a.bin"})
|
||||
# The summary is the row: the name, its folder, the status.
|
||||
self.assertIn('<details class="rb-file"><summary>bios_a.bin<code>bios/</code>'
|
||||
self.assertIn('<details class="rb-file"><summary>bios_a.bin <code>bios/</code> '
|
||||
'<span class="rb-badge rb-badge-success">OK</span></summary>', row)
|
||||
# The hash the platform checks, short, on one button beside the
|
||||
# summary (a summary is a control: no button inside it).
|
||||
@@ -113,7 +113,7 @@ class ARowPerFile(unittest.TestCase):
|
||||
def test_a_file_at_the_root_prints_no_path(self):
|
||||
for destination in ("", "x.bin"):
|
||||
row = self._row({"name": "x.bin", "status": "ok"}, {"destination": destination})
|
||||
self.assertIn("<summary>x.bin<span", row)
|
||||
self.assertIn("<summary>x.bin <span", row)
|
||||
|
||||
def test_a_list_drops_the_path_column_when_no_row_has_one(self):
|
||||
files = [{"name": "a.bin", "status": "ok"}, {"name": "b.bin", "status": "ok"}]
|
||||
@@ -153,7 +153,8 @@ class ARowPerFile(unittest.TestCase):
|
||||
def test_a_long_list_gets_a_filter(self):
|
||||
rows = ["<details></details>"] * generate_site.FILTER_ROWS
|
||||
block = generate_site._platform_file_list(rows, False, "arcade")
|
||||
self.assertTrue(block[0].startswith('<div class="rb-table-filter"><label for="rb-files-filter-arcade">'))
|
||||
self.assertTrue(block[0].startswith('<div class="rb-table-filter" hidden data-pagefind-ignore>'
|
||||
'<label for="rb-files-filter-arcade">Filter files</label>'))
|
||||
self.assertNotIn("rb-table-filter", "".join(
|
||||
generate_site._platform_file_list(rows[1:], False, "arcade")))
|
||||
|
||||
@@ -234,8 +235,10 @@ class NothingIsLost(unittest.TestCase):
|
||||
# 2026-10-27. A ceiling is the measured value plus 5 %, never above the
|
||||
# value before the rows were tables (Batocera 2,433, AmberELEC 1,301, RomM
|
||||
# 1,607, RetroArch 2,207, the largest main page 2,459, the largest part
|
||||
# 19,127: RetroDECK's arcade list).
|
||||
PAGE_CEILINGS = {"batocera": 2433, "amberelec": 1301, "romm": 1607, "retroarch": 2192}
|
||||
# 19,127: RetroDECK's arcade list). AmberELEC rose to 1,304 on 2026-11-11:
|
||||
# MAME is named beside ProSystem, O2EM and FreeIntv, the cores its rom
|
||||
# folders offer, and the MSX section shows its file count.
|
||||
PAGE_CEILINGS = {"batocera": 2433, "amberelec": 1304, "romm": 1607, "retroarch": 2192}
|
||||
MAIN_PAGE_CEILING = 2459
|
||||
PART_PAGE_CEILING = 2219
|
||||
|
||||
@@ -270,11 +273,26 @@ BEFORE_WEIGHT = {
|
||||
# bytes more where its Amiberry build is named "Amiberry 8.0.0
|
||||
# (facaaeb, Batocera)" (twice). The search stopped reading the date
|
||||
# line and "Next steps" on 2026-11-10 (data-pagefind-ignore, about 68
|
||||
# bytes a page): 1,357,282 bytes on the built site of 25057ee3a.
|
||||
"batocera": (13, 18_854, 1_357_282),
|
||||
"amberelec": (1, 7_928, 473_388),
|
||||
# bytes a page): 1,357,282 bytes on the built site of 25057ee3a. The
|
||||
# blueMSX and fMSX machine ROMs cite each reader since 2026-11-10 (the
|
||||
# config.ini line, machineCreate, readMachine, romLoad, LoadROM): the
|
||||
# MSX part went from 57,600 to 91,769 bytes, and the filter boxes and
|
||||
# file summaries got their spaces and labels (about 190 bytes a page).
|
||||
# 1,394,379 bytes on the built site of 7c5ad8366. MAME is named among
|
||||
# the readers of seven systems its rom folders offer it for, and the
|
||||
# LRPS2 that Batocera builds reads "LRPS2 (416291a, Batocera)" since
|
||||
# 2026-11-11: 1,396,309 bytes on the built site of 964875572.
|
||||
"batocera": (13, 18_854, 1_396_309),
|
||||
# AmberELEC's MSX files cite the fMSX ROM loader since 2026-11-11 (fMSX
|
||||
# named 82 times instead of 28, the same 295 files): the section moved
|
||||
# to a part page of its own, 2 pages, 7,160 elements and 545,681 bytes
|
||||
# on the built site of 964875572.
|
||||
"amberelec": (2, 7_928, 545_681),
|
||||
"romm": (2, 9_561, 572_487),
|
||||
"retroarch": (14, 21_503, 1_430_802),
|
||||
# RetroArch's MSX files cite the fMSX ROM loader and its ScummVM files
|
||||
# the readers of each data file since 2026-11-11 (46,737 and 9,275 bytes
|
||||
# more): 1,433,702 bytes on the built site of 964875572.
|
||||
"retroarch": (14, 21_503, 1_433_702),
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
"""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.
|
||||
Each drawing file says in words what it shows, for one opened on its own:
|
||||
a title and a desc the SVG names. On the page the images are alt="" and the
|
||||
text above them is the one reading (tests/test_site_page_text.py). The
|
||||
drawing tells the same steps as that text, the keys included, so the picture
|
||||
and the words never disagree. And it draws in the theme's colours.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -19,6 +20,7 @@ from pathlib import Path
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
sys.path.insert(0, str(ROOT / "scripts"))
|
||||
|
||||
import sitediagrams # noqa: E402
|
||||
import sitesteps # noqa: E402
|
||||
from siteguides import TERMINALS # noqa: E402
|
||||
|
||||
@@ -84,10 +86,12 @@ class TheBuiltPageHoldsThem(unittest.TestCase):
|
||||
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)
|
||||
for layout in ("wide", "narrow"):
|
||||
for theme in sitediagrams.THEMES:
|
||||
name = f"{sitesteps.stem(tab)}-{layout}-{theme}.svg"
|
||||
with self.subTest(file=name):
|
||||
self.assertIn(f"/retrobios/{sitediagrams.DIAGRAM_DIR}/{name}", html)
|
||||
self.assertTrue((DIST / sitediagrams.DIAGRAM_DIR / name).is_file())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -39,12 +39,10 @@ UNLINKED: dict[str, str] = {
|
||||
"fpinball": "Other > future-pinball-fploader",
|
||||
"fruitmachine": "Other > mfme",
|
||||
"mysteries-of-the-sith": "Game Engines > OpenJKDF2",
|
||||
"namco-na1": "Arcade > FBNeo",
|
||||
"namco-nb1": "Arcade > FBNeo",
|
||||
"omicron": "Other > omicron",
|
||||
"rpgmaker": "RPG Maker > easyrpg",
|
||||
"sdlpal": "the SDLPAL section under its own top, named after the program",
|
||||
"sega-model1": "Arcade > Arcade and Arcade > MAME: the I/O board device sets",
|
||||
"sega-system16b": "Arcade > FBNeo, and isgsm.zip is also the ISG Selection Master's",
|
||||
"smbx": "Game Engines > TheXTech",
|
||||
"thomson-mo6": "Other > Clock Signal",
|
||||
|
||||
@@ -1191,7 +1191,16 @@ class EnginesGoByEngine(unittest.TestCase):
|
||||
self.skipTest("pages not generated")
|
||||
for old, target in gs.SYSTEM_PAGES_MOVED.items():
|
||||
new = target.partition("#")[0]
|
||||
self.assertFalse((CONTENT / old).exists() or (CONTENT / old).with_suffix(".mdx").exists(), old)
|
||||
written = [path for path in (CONTENT / old, (CONTENT / old).with_suffix(".mdx"))
|
||||
if path.exists()]
|
||||
# A maker's page split by console again (Sega past its budget)
|
||||
# writes the old address as one of its parts: the redirect then
|
||||
# stands aside, and the page names the one it moved to as parent.
|
||||
for path in written:
|
||||
parent = re.search(r"^parent:\n label: .*\n link: (\S+)$",
|
||||
path.read_text(encoding="utf-8"), re.M)
|
||||
self.assertIsNotNone(parent, old)
|
||||
self.assertEqual(parent.group(1), "/" + new.removesuffix(".md") + "/", old)
|
||||
# A page with tabs is written as MDX.
|
||||
self.assertTrue((CONTENT / new).exists() or (CONTENT / new).with_suffix(".mdx").exists(), new)
|
||||
redirects = CONTENT.parents[1] / "generated" / "redirects.json"
|
||||
|
||||
+22
-2
@@ -33,6 +33,7 @@ from __future__ import annotations
|
||||
|
||||
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
|
||||
|
||||
import fnmatch
|
||||
import json
|
||||
import re
|
||||
import sys
|
||||
@@ -48,6 +49,7 @@ sys.path.insert(0, str(REPO_ROOT))
|
||||
import sitediagrams # noqa: E402
|
||||
from siteguides import INSTALL_SH # noqa: E402
|
||||
from tests import sitepages # noqa: E402
|
||||
import build_port # noqa: E402
|
||||
from check_release import SUMS, Asset, compare_release # noqa: E402
|
||||
|
||||
|
||||
@@ -350,7 +352,7 @@ class DiagramText(unittest.TestCase):
|
||||
sitediagrams.MAX_BOX_LINES)
|
||||
|
||||
def test_a_path_is_mono_on_its_own_line(self):
|
||||
html = sitediagrams.figure_html("bios-chain")
|
||||
html = sitediagrams.svg(sitediagrams.figures()["bios-chain"], "wide")
|
||||
self.assertRegex(html, r'<text [^>]*style="font-family: var\(--sl-font-mono[^>]*>/userdata/bios/</text>')
|
||||
|
||||
def test_boxes_of_a_row_share_one_height(self):
|
||||
@@ -870,15 +872,33 @@ class PinnedInstaller(unittest.TestCase):
|
||||
kinds = {(f.kind, f.name) for f in compare_release(record, sums, assets, "v1")}
|
||||
self.assertEqual(kinds, {("unrecorded", "install.py"), ("unrecorded", "retroarch.json")})
|
||||
|
||||
def test_a_launcher_attached_to_the_release_is_refused(self):
|
||||
"""The handheld launchers carry install.py: the site serves them
|
||||
from its own commit, the release never does."""
|
||||
record = {"tag": "v1", "packs": {"P.zip": {"download_size": 5, "assets": ["P.zip"]}}}
|
||||
sums = _sums_with(["P.zip", *build_port.ARCHIVES])
|
||||
assets = {name: Asset(5, digest) for name, digest in sums.items()}
|
||||
assets[SUMS] = Asset(1, None)
|
||||
kinds = {(f.kind, f.name) for f in compare_release(record, sums, assets, "v1")}
|
||||
self.assertEqual(kinds, {("unrecorded", name) for name in build_port.ARCHIVES})
|
||||
|
||||
def test_the_release_steps_ship_none(self):
|
||||
text = _wiki("release-process.md")
|
||||
self.assertNotIn("cp install.py", text)
|
||||
sums = re.search(r"sha256sum [^>]+> SHA256SUMS.txt", text, re.S).group(0)
|
||||
upload = re.search(r"for f in dist/SHA256SUMS.txt.*?; do", text, re.S).group(0)
|
||||
for name in ("install.py", "install.sh", "install.ps1", ".json"):
|
||||
for name in ("install.py", "install.sh", "install.ps1", ".json", "RetroBIOS",
|
||||
".muxapp", "build_port", " *.zip", "/*.zip"):
|
||||
with self.subTest(name=name):
|
||||
self.assertNotIn(name, sums)
|
||||
self.assertNotIn(name, upload)
|
||||
# A launcher built into dist/ is never caught by the glob either.
|
||||
for archive in build_port.ARCHIVES:
|
||||
with self.subTest(archive=archive):
|
||||
self.assertFalse(fnmatch.fnmatch(archive, "*_BIOS_Pack*.zip"))
|
||||
self.assertIn("*_BIOS_Pack*.zip", sums)
|
||||
self.assertIn("*_BIOS_Pack*.zip", upload)
|
||||
self.assertNotIn("scripts/build_port.py", text)
|
||||
|
||||
def test_the_installer_page_pins_one_commit(self):
|
||||
# v2026.10.10 carries no install.py: until a release does, the
|
||||
|
||||
@@ -120,6 +120,21 @@ class Sweep(unittest.TestCase):
|
||||
self.assertTrue((self.docs / "emulators/kept.md").exists())
|
||||
self.assertTrue((self.docs / "emulators/nested/deep.md").exists())
|
||||
|
||||
def test_a_page_the_decoration_pass_made_mdx_is_kept(self):
|
||||
"""A body is written as .md, and the decoration pass, after the
|
||||
sweep, renames a page with components to .mdx. The .mdx of the run
|
||||
before was swept and written again on every run: 402 pages."""
|
||||
(self.docs / "platforms/kept.mdx").write_text("x")
|
||||
(self.docs / "platforms/gone.mdx").write_text("x")
|
||||
self._produce("platforms/kept.md")
|
||||
sitewrite._sweep_generated(self.docs, ["platforms"])
|
||||
(self.docs / "top.mdx").write_text("x")
|
||||
sitewrite._record(self.docs / "top.md")
|
||||
self.assertEqual(sitewrite._sweep_top_pages(self.docs), 0)
|
||||
self.assertTrue((self.docs / "platforms/kept.mdx").exists())
|
||||
self.assertTrue((self.docs / "top.mdx").exists())
|
||||
self.assertFalse((self.docs / "platforms/gone.mdx").exists())
|
||||
|
||||
def test_a_directory_outside_the_list_is_never_touched(self):
|
||||
self._produce("emulators/kept.md", "emulators/nested/deep.md",
|
||||
"emulators/stale.md")
|
||||
|
||||
@@ -278,7 +278,7 @@ class ReleaseProcessPublishesArchives(unittest.TestCase):
|
||||
def test_the_checksums_are_those_of_the_published_files(self):
|
||||
self.assertLess(
|
||||
self.text.index("scripts/split_pack.py"),
|
||||
self.text.index("sha256sum *.zip"),
|
||||
self.text.index("sha256sum *_BIOS_Pack*.zip"),
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ from common import ( # noqa: E402
|
||||
system_file_index,
|
||||
)
|
||||
from launchers import ( # noqa: E402
|
||||
SEARCHED_FILES,
|
||||
bound_path,
|
||||
handed_directories,
|
||||
normalize_handle,
|
||||
@@ -205,7 +206,38 @@ class SearchLists(unittest.TestCase):
|
||||
self.assertEqual(
|
||||
bind(config(passes("emu", "$roms_path/coco:$bios_path/xroar", "xroar.conf rompath")),
|
||||
[], {"rompath": ""}),
|
||||
{"": ("", "xroar")},
|
||||
{SEARCHED_FILES: ("", "xroar")},
|
||||
)
|
||||
|
||||
def test_a_semicolon_list_leaves_out_the_game_folder(self) -> None:
|
||||
# MAME splits its search paths on semicolons (src/emu/fileio.cpp:53-58).
|
||||
found = handed_directories(config(passes(
|
||||
"emu", "<romDirname>;/userdata/bios/mame;/userdata/bios", "command line -rompath",
|
||||
)))
|
||||
self.assertEqual([h.folder for h in found], ["mame", ""])
|
||||
found = handed_directories(config(passes(
|
||||
"emu", "bios;<rom directory>", "command line -rp bios;<rom directory>",
|
||||
)))
|
||||
self.assertEqual([(h.folder, "-rp" in h.handles) for h in found], [("", True)])
|
||||
|
||||
def test_a_list_holding_the_files_folder_keeps_them_there(self) -> None:
|
||||
# KNULLI lists bios/mame before bios: the sets at the root stay.
|
||||
cfg = config(passes(
|
||||
"emu", "<romDirname>;/userdata/bios/mame;/userdata/bios", "command line -rompath",
|
||||
))
|
||||
cfg["systems"] = {"x": {"files": [{"name": "a.rom", "destination": "mame/a.rom"}]}}
|
||||
self.assertEqual(bind(cfg, [], {"-rompath": ""}), {SEARCHED_FILES: ("", "")})
|
||||
# Without the root, the first folder of the BIOS tree.
|
||||
cfg = config(passes("emu", "$romdir/mame;$biosdir/mame", "rompath in mame.ini"))
|
||||
self.assertEqual(bind(cfg, [], {"rompath": ""}), {SEARCHED_FILES: ("", "mame")})
|
||||
|
||||
def test_a_whole_layout_list_holds_files_not_folders(self) -> None:
|
||||
found = {SEARCHED_FILES: ("", "mame")}
|
||||
self.assertEqual(bound_path("neogeo.zip", found), ("", "mame/neogeo.zip"))
|
||||
self.assertIsNone(bound_path("samples/bbc.zip", found))
|
||||
self.assertEqual(
|
||||
bound_path("samples/bbc.zip", {**found, "samples": ("", "mame-sa/samples")}),
|
||||
("", "mame-sa/samples/bbc.zip"),
|
||||
)
|
||||
|
||||
def test_a_drive_letter_is_one_directory(self) -> None:
|
||||
@@ -241,11 +273,11 @@ class PerSystem(unittest.TestCase):
|
||||
POOLS = {"-rompath": ""}
|
||||
|
||||
def test_the_system_record_wins_for_its_system(self) -> None:
|
||||
self.assertEqual(bind(self.CFG, [], self.POOLS, ("coco",)), {"": ("", "coco")})
|
||||
self.assertEqual(bind(self.CFG, [], self.POOLS, ("coco",)), {SEARCHED_FILES: ("", "coco")})
|
||||
|
||||
def test_another_system_keeps_the_generic_record(self) -> None:
|
||||
self.assertEqual(bind(self.CFG, [], self.POOLS, ("dragon32",)), {"": ("", "dragon")})
|
||||
self.assertEqual(bind(self.CFG, [], self.POOLS), {"": ("", "dragon")})
|
||||
self.assertEqual(bind(self.CFG, [], self.POOLS, ("dragon32",)), {SEARCHED_FILES: ("", "dragon")})
|
||||
self.assertEqual(bind(self.CFG, [], self.POOLS), {SEARCHED_FILES: ("", "dragon")})
|
||||
|
||||
def test_native_names_are_read_as_our_ids(self) -> None:
|
||||
cfg = {
|
||||
@@ -270,7 +302,7 @@ class PerSystem(unittest.TestCase):
|
||||
[("dragon", ["dragon64"]), ("trs80coco", ["coco"])],
|
||||
)
|
||||
self.assertEqual(bind(cfg, [], self.POOLS | {"-rompath": ""}, ("coco",)),
|
||||
{"": ("", "trs80coco")})
|
||||
{SEARCHED_FILES: ("", "trs80coco")})
|
||||
self.assertEqual(bind(cfg, [], {"-rompath": ""}, ("dragon32",)), {})
|
||||
|
||||
def test_an_entry_is_launched_for_the_system_that_declares_its_name(self) -> None:
|
||||
|
||||
Reference in new issue
Block a user