diff --git a/scripts/packextras.py b/scripts/packextras.py index eeb534a2..a8223fc1 100644 --- a/scripts/packextras.py +++ b/scripts/packextras.py @@ -686,6 +686,10 @@ def _collect_emulator_extras( # file; the archive itself is placed by the passes above. if f.get("archive"): continue + # No path: the core reads it from nowhere a pack reaches + # (Dolphin's codehandler.bin ships in its Sys tree). + if "path" in f and f["path"] is None: + continue file_mode = f.get("mode") if file_mode == "standalone" and not is_standalone: continue diff --git a/tests/test_path_null_copies.py b/tests/test_path_null_copies.py new file mode 100644 index 00000000..eb2a405e --- /dev/null +++ b/tests/test_path_null_copies.py @@ -0,0 +1,49 @@ +"""An entry with `path: null` is never copied to the root of a pack. + +The pass that copies a file covered elsewhere to each destination a core +reads skipped neither: Dolphin's codehandler.bin, which ships in its Sys +tree, landed at system/codehandler.bin in RetroArch, Lakka and RetroPie. +Reads the repository: skips when the database is absent. +""" + +from __future__ import annotations + +import os +import sys +import unittest +from pathlib import Path + +REPO_ROOT = Path(__file__).resolve().parents[1] +sys.path.insert(0, str(REPO_ROOT / "scripts")) + + +class NoPathNoCopy(unittest.TestCase): + def test_codehandler_stays_out(self): + if not (REPO_ROOT / "database.json").exists(): + self.skipTest("database.json is not built") + previous = os.getcwd() + os.chdir(REPO_ROOT) + self.addCleanup(os.chdir, previous) + from common import load_database, load_emulator_profiles, load_platform_config + from packextras import _collect_emulator_extras + + profiles = load_emulator_profiles("emulators") + nameless = { + (p.get("emulator", n), f["name"]) + for n, p in profiles.items() for f in p.get("files", []) + if isinstance(f, dict) and "path" in f and f["path"] is None + } + config = load_platform_config("retroarch") + extras = _collect_emulator_extras( + config, "emulators", load_database("database.json"), set(), + config.get("base_destination", ""), profiles, + ) + self.assertEqual( + [e["destination"] for e in extras + if (e.get("source_emulator"), e["name"]) in nameless], + [], + ) + + +if __name__ == "__main__": + unittest.main()