feat: install the fewest files for a card's games

--for-games --required-only on a dArkOS card from a computer kept every
file of the list: --dest skipped the card's detection, so its rom
folders were never found. The games part beside the BIOS folder now
names them. The manifest marks a data tree every core runs without
(optional), and --required-only leaves it out: one GBA and one SNES game
took FBNeo's cheats and samples, 3,472 files no game opened.
This commit is contained in:
Abdessamad Derraz committed 2026-11-06 19:58:41 +01:00
1 parent adce8dd0d4
commit 072380c268
24 files changed
+184 -78

No files matched your search

+5 -3
View File
@@ -6923,9 +6923,11 @@ class RequiredOnlyReachesDataDirectories(unittest.TestCase):
def test_every_tree_walk_reads_the_flag(self):
source = (ROOT / "scripts" / "generate_pack.py").read_text(encoding="utf-8")
self.assertEqual(
source.count('if required_only and dd.get("required") is False:'), 2
)
# The pack's walk and the manifest's, which records the flag for
# install.py --required-only.
self.assertEqual(source.count('if required_only and dd.get("required") is False:'), 1)
self.assertIn('needed = dd.get("required") is not False\n if required_only and not needed:',
source)
self.assertIn("seen_parents, required_only=required_only,", source)
self.assertIn("data_refs, required_only=required_only,", source)
+14
View File
@@ -3880,6 +3880,20 @@ class DataDirectoriesAreInstalled(unittest.TestCase):
},
}
def test_required_only_leaves_out_an_optional_tree(self):
"""A GBA and a SNES game with --for-games --required-only took
FBNeo's cheats and samples, 3,472 files no game opened."""
cheats = {**self._entry(), "ref": "fbneo-cheats", "systems": ["snes"], "optional": True}
sys_tree = {**self._entry(), "systems": ["snes"]}
manifest = {"data_directories": [cheats, sys_tree]}
files = [{"dest": "a.rom", "systems": ["snes"]}]
self.assertEqual(install.select_data_directories(manifest, files, True), [cheats, sys_tree])
self.assertEqual(install.select_data_directories(manifest, files, True, True), [sys_tree])
self.assertEqual(install.select_data_directories(manifest, files, False, True), [sys_tree])
install._check_data_directory(cheats, "data_directories[0]")
with self.assertRaises(ValueError):
install._check_data_directory({**cheats, "optional": False}, "data_directories[0]")
def test_the_archive_is_drawn_and_counted(self):
"""82 MB of archives came with no progress line, and the run ended
on "310.5 KB downloaded", the BIOS files alone."""
+12
View File
@@ -12912,6 +12912,18 @@ class DriveIsACardByItsFiles(unittest.TestCase):
self.assertEqual([install.card_system(mount) for mount in mounts],
[None, None, None])
def test_a_dest_on_a_games_part_reads_its_rom_folders(self):
"""--dest EASYROMS/bios --for-games from a computer: detection never
ran on the card, the generic RetroArch folders were tried, and the
run kept every file of the list."""
arkos = games_part(self.root / "media" / "EASYROMS")
index = {"setups": {"arkos": {}, "retroarch": {}}}
with mock.patch.object(install, "_mount_points", return_value=frozenset()), \
mock.patch.object(install, "_drive_not_removable", return_value=False):
self.assertEqual(install.games_setups(index, "retroarch", arkos / "bios"), ["arkos"])
self.assertEqual(install.games_setups(index, "retroarch", self.root / "bios"),
["retroarch"])
def test_a_card_beside_a_data_drive_comes_first(self):
"""The ArkOS card and the data drive mounted,
the data drive sorted first and took Enter. The card comes first in