mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-12 21:13:49 -06:00
feat: pack readme names spellings left out
A pack folded for Windows and macOS keeps one spelling of each case twin. Extracted on a Steam Deck or Linux, the core asking for the other spelling finds nothing, and only the installer added it. Where the platform also runs on a filesystem that keeps case, the README now lists each spelling left out beside the one it holds: 12 for EmuDeck and 10 for RetroArch, the manifest's case_variants.
This commit is contained in:
1 parent
4efcb3da64
commit
55e2c8328e
4 files changed
+157
-3
No files matched your search
@@ -7,7 +7,12 @@ went red. The flag lived in retrobat.yml and vanished at the next scrape.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import contextlib
|
||||
import hashlib
|
||||
import io
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
@@ -29,5 +34,82 @@ class CaseInsensitiveWhereTheFilesystemIs(unittest.TestCase):
|
||||
self.assertTrue(config.get("case_insensitive_fs"))
|
||||
|
||||
|
||||
class ThePackReadmeNamesTheSpellingsItLeavesOut(unittest.TestCase):
|
||||
"""The EmuDeck pack is folded for Windows and extracted on a Steam Deck,
|
||||
where the core asking for bios.col finds only BIOS.col. Only the
|
||||
installer adds that spelling (case_variants), and the pack's README said
|
||||
nothing about it."""
|
||||
|
||||
def setUp(self):
|
||||
import common
|
||||
import generate_db
|
||||
import generate_pack
|
||||
|
||||
self.gp = generate_pack
|
||||
tmp = tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp")
|
||||
self.addCleanup(tmp.cleanup)
|
||||
previous = os.getcwd()
|
||||
os.chdir(tmp.name)
|
||||
self.addCleanup(os.chdir, previous)
|
||||
Path("bios/Coleco").mkdir(parents=True)
|
||||
payload = b"coleco bios"
|
||||
Path("bios/Coleco/BIOS.col").write_bytes(payload)
|
||||
sha1 = hashlib.sha1(payload).hexdigest()
|
||||
files = {sha1: {"path": "bios/Coleco/BIOS.col", "name": "BIOS.col",
|
||||
"size": len(payload), "sha1": sha1,
|
||||
"md5": hashlib.md5(payload).hexdigest(),
|
||||
"sha256": hashlib.sha256(payload).hexdigest(),
|
||||
"crc32": "00000001"}}
|
||||
self.db = {"files": files, "indexes": generate_db.build_indexes(files, {})}
|
||||
Path("platforms").mkdir()
|
||||
Path("emulators").mkdir()
|
||||
self.config = {
|
||||
"platform": "P", "verification_mode": "existence",
|
||||
"case_insensitive_fs": True, "cores": ["mesence"],
|
||||
"systems": {"coleco": {"files": [{"name": "BIOS.col"}]}},
|
||||
}
|
||||
Path("emulators/mesence.yml").write_text(yaml.dump({
|
||||
"emulator": "mesence", "type": "libretro", "systems": ["coleco"],
|
||||
"files": [{"name": "bios.col", "required": True}],
|
||||
}))
|
||||
common._platform_config_cache.clear()
|
||||
common._emulator_profiles_cache.clear()
|
||||
self.addCleanup(common._platform_config_cache.clear)
|
||||
self.addCleanup(common._emulator_profiles_cache.clear)
|
||||
|
||||
def _readme(self, systems: list[str]) -> str:
|
||||
import common
|
||||
|
||||
Path("platforms/p.yml").write_text(yaml.dump(self.config))
|
||||
Path("platforms/_registry.yml").write_text(yaml.dump({"platforms": {"p": {
|
||||
"status": "active",
|
||||
"install": {"detect": [{"os": os_name} for os_name in systems]},
|
||||
}}}))
|
||||
common._platform_config_cache.clear()
|
||||
texts: dict[str, str] = {}
|
||||
real = self.gp._write_generated_member
|
||||
|
||||
def capture(zf, arcname, text):
|
||||
texts[arcname] = text
|
||||
return real(zf, arcname, text)
|
||||
|
||||
self.gp._write_generated_member = capture
|
||||
self.addCleanup(setattr, self.gp, "_write_generated_member", real)
|
||||
with contextlib.redirect_stdout(io.StringIO()):
|
||||
self.gp.generate_pack(
|
||||
"p", "platforms", self.db, "bios", "", emulators_dir="emulators",
|
||||
offline=True, record=self.gp.PackRecord(),
|
||||
)
|
||||
return texts["README.txt"]
|
||||
|
||||
def test_a_platform_also_on_linux_names_them(self):
|
||||
readme = self._readme(["windows", "linux"])
|
||||
self.assertIn("NAMES THAT DIFFER ONLY BY CASE", readme)
|
||||
self.assertIn(" bios.col (the pack has BIOS.col)", readme)
|
||||
|
||||
def test_a_platform_only_on_windows_does_not(self):
|
||||
self.assertNotIn("DIFFER ONLY BY CASE", self._readme(["windows"]))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user