mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-16 16:33:27 -05:00
refactor: split the extras collector into its passes
_collect_emulator_extras ran three passes in one body: the undeclared files a platform's cores need, a second copy of an archive under the subdirectory some cores read, and the scan a filename-agnostic core allows. The last two are named now, complexity 98 to 54. The archive-prefix pass had no test, and extracting it surfaced why that mattered: it read an index from the enclosing scope, so on its own it would have raised. Three tests cover it, including the case it exists to prevent - claiming a prefixed path for an archive the collection does not hold.
This commit is contained in:
1 parent
53fc5b7005
commit
6aa5685fc7
2 files changed
+251
-151
No files matched your search
@@ -23,6 +23,7 @@ sys.path.insert(0, str(REPO_ROOT / "scripts"))
|
||||
|
||||
import common # noqa: E402
|
||||
import generate_pack as builder # noqa: E402
|
||||
import packextras # noqa: E402
|
||||
|
||||
SIZE = 1024
|
||||
|
||||
@@ -253,3 +254,52 @@ class PathTailBeatsABareName(unittest.TestCase):
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
|
||||
class ArchivePrefixCopies(unittest.TestCase):
|
||||
"""A core that reads its romset from a subdirectory of its own.
|
||||
|
||||
FBNeo looks for system/fbneo/neogeo.zip while the platform declares
|
||||
neogeo.zip at the root, so the pack carries both paths. The pass had no
|
||||
test: extracting it surfaced a name it read from the enclosing scope and
|
||||
would have raised on, for any platform reaching it.
|
||||
"""
|
||||
|
||||
def _extras(self, by_name):
|
||||
profiles = {
|
||||
"fbneo": {
|
||||
"emulator": "FBNeo",
|
||||
"type": "libretro",
|
||||
"systems": ["arcade"],
|
||||
"archive_prefix": "fbneo",
|
||||
"files": [
|
||||
{"name": "rom.bin", "archive": "neogeo.zip", "system": "arcade"},
|
||||
],
|
||||
}
|
||||
}
|
||||
return packextras._archive_prefix_extras(
|
||||
profiles, {"fbneo"}, {"neogeo.zip"}, set(), "", by_name
|
||||
)
|
||||
|
||||
def test_a_covered_archive_gets_a_prefixed_copy(self):
|
||||
extras = self._extras({"neogeo.zip": ["abc"]})
|
||||
self.assertEqual([e["destination"] for e in extras], ["fbneo/neogeo.zip"])
|
||||
|
||||
def test_an_archive_the_collection_lacks_is_not_copied(self):
|
||||
"""The prefixed path would name bytes nothing can supply."""
|
||||
self.assertEqual(self._extras({}), [])
|
||||
|
||||
def test_a_destination_already_taken_is_not_claimed_twice(self):
|
||||
profiles = {
|
||||
"fbneo": {
|
||||
"emulator": "FBNeo", "type": "libretro", "systems": ["arcade"],
|
||||
"archive_prefix": "fbneo",
|
||||
"files": [{"name": "rom.bin", "archive": "neogeo.zip",
|
||||
"system": "arcade"}],
|
||||
}
|
||||
}
|
||||
extras = packextras._archive_prefix_extras(
|
||||
profiles, {"fbneo"}, {"neogeo.zip"}, {"fbneo/neogeo.zip"}, "",
|
||||
{"neogeo.zip": ["abc"]},
|
||||
)
|
||||
self.assertEqual(extras, [])
|
||||
Reference in new issue
Block a user