fix: report core files as the builder declares

This commit is contained in:
Abdessamad Derraz committed 2026-10-17 19:19:05 +02:00
1 parent 02ab1556cf
commit d600a54a6e
2 files changed
+52

No files matched your search

+5
View File
@@ -1089,6 +1089,10 @@ def verify_platform(
from cross_reference import _build_supplemental_index
supplemental_names = _build_supplemental_index()
# The builder's declarations, not the enriched ones: a core file the
# platform also declares under another name is packed at the core's own
# path, and a report reading the enriched set never counted it (21 such
# files in the RetroArch pack).
undeclared = find_undeclared_files(
config,
emulators_dir,
@@ -1096,6 +1100,7 @@ def verify_platform(
emu_profiles,
target_cores=target_cores,
data_names=supplemental_names,
declared_names=platform_declarations(config, db, enrich=False),
)
if region_drops:
undeclared = [
+47
View File
@@ -95,3 +95,50 @@ class ACoreFileFillsAFreeDeclaration(unittest.TestCase):
if __name__ == "__main__":
unittest.main()
class AFileDeclaredUnderAnotherName(unittest.TestCase):
"""The platform declares ROM1 with the md5 of the core's ROM. The
builder packs ROM at the core's path; verify read the enriched
declarations, took ROM as declared and never counted it."""
def test_the_report_lists_what_the_builder_packs(self):
_emulator_profiles_cache.clear()
root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
self.addCleanup(shutil.rmtree, root, True)
bios = root / "bios" / "Apple" / "IIgs"
bios.mkdir(parents=True)
data = b"IIGS ROM BYTES"
(bios / "ROM").write_bytes(data)
sha1, md5 = hashlib.sha1(data).hexdigest(), hashlib.md5(data).hexdigest()
db = {
"files": {sha1: {"path": str(bios / "ROM"), "name": "ROM", "md5": md5,
"crc32": "", "size": len(data)}},
"indexes": {"by_md5": {md5: sha1}, "by_name": {"ROM": [sha1]},
"by_crc32": {}, "by_path_suffix": {}},
}
(root / "platforms").mkdir()
(root / "emulators").mkdir()
(root / "platforms" / "fakeplat.yml").write_text(yaml.safe_dump({
"platform": "FakePlat", "verification_mode": "existence",
"base_destination": "system", "cores": ["gs"],
"systems": {"apple-iigs": {"files": [
{"name": "ROM1", "destination": "ROM1", "md5": md5},
]}},
}))
(root / "emulators" / "gs.yml").write_text(yaml.safe_dump({
"emulator": "GS", "type": "libretro", "cores": ["gs"],
"systems": ["apple-iigs"],
"files": [{"name": "ROM", "path": "gs/ROM", "md5": md5, "required": True}],
}))
config = load_platform_config("fakeplat", str(root / "platforms"))
result = verify_platform(config, db, str(root / "emulators"), supplemental_names=set())
with redirect_stdout(io.StringIO()):
zip_path = generate_pack(
"fakeplat", str(root / "platforms"), db, str(root / "bios"),
str(root / "out"), emulators_dir=str(root / "emulators"), offline=True,
)
with zipfile.ZipFile(zip_path) as zf:
self.assertIn("gs/ROM", zf.namelist())
reported = [(u["name"], u["in_repo"]) for u in result["undeclared_files"]]
self.assertIn(("ROM", True), reported)