From fbad34adbd0a17f0ea6ab7e85940a508d6a8f99e Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Thu, 5 Nov 2026 11:59:32 +0100 Subject: [PATCH] fix: badge only the platforms that read a file --- scripts/generate_site.py | 21 ++++++++++++++++++++- tests/test_site_render.py | 20 ++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/scripts/generate_site.py b/scripts/generate_site.py index 731dee433..f6fff2aae 100644 --- a/scripts/generate_site.py +++ b/scripts/generate_site.py @@ -10296,6 +10296,22 @@ def _upload_folder(profile: dict) -> str: return "" +def reading_platforms(emu_name: str, profile: dict, name: str, + configs: dict[str, dict]) -> set[str]: + """Of the platforms running an emulator (name -> config), those whose + build of it reads the entry: BlastEm's cdbios.bin is read by the + standalone build only, and RetroBat hands that build other names.""" + from common import platform_layouts, standalone_set # noqa: PLC0415 + from validation import filter_files_by_mode, unread_on # noqa: PLC0415 + + return { + platform for platform, config in configs.items() + if any(f.get("name") == name and not unread_on(f, platform) + for view, standalone in platform_layouts(emu_name, profile, standalone_set(config)) + for f in filter_files_by_mode(view.get("files") or [], standalone)) + } + + def generate_gap_analysis( profiles: dict, coverages: dict, @@ -10627,6 +10643,7 @@ def generate_gap_analysis( for emu_name in matched: emu_to_platforms.setdefault(emu_name, set()).add(pname) + # One row per file to find: a name two emulators share is one file # only when both declare the same hash. Keyed by name alone, Fallout # 2's master.dat vanished behind Fallout 1's, and the three Sonic @@ -10685,7 +10702,9 @@ def generate_gap_analysis( key=lambda x: (not x["required"], x["name"]), ): plats = sorted(set().union( - *(emu_to_platforms.get(key, set()) for key in m["emu_keys"]) + *(reading_platforms(key, profiles[key], m["name"], { + p: coverages[p]["config"] for p in emu_to_platforms.get(key, set()) + }) for key in m["emu_keys"]) )) plat_badges = ( " ".join( diff --git a/tests/test_site_render.py b/tests/test_site_render.py index 2abaf0809..347d75cc4 100644 --- a/tests/test_site_render.py +++ b/tests/test_site_render.py @@ -8,6 +8,8 @@ import unittest from pathlib import Path from unittest import mock +import yaml + REPO_ROOT = Path(__file__).resolve().parents[1] sys.path.insert(0, str(REPO_ROOT / "scripts")) @@ -100,6 +102,24 @@ class BundledFilesAreNotToSource(unittest.TestCase): self.assertIn("| [ZQuest Classic](emulators/zq.md) | 4 | 1 | 0 | 0 | 2 | " '1 |', page) + def test_a_row_names_only_the_platforms_that_read_it(self): + """cdbios.bin, read by standalone BlastEm only and never on RetroBat, + was badged retroarch, lakka and retrobat.""" + import generate_site + from common import load_platform_config, resolve_platform_cores + + root = Path(__file__).resolve().parents[1] + profile = yaml.safe_load((root / "emulators" / "blastem.yml").read_text(encoding="utf-8")) + configs = {} + for name in ("retroarch", "lakka", "retrobat", "batocera"): + config = load_platform_config(name, str(root / "platforms")) + if "blastem" in resolve_platform_cores(config, {"blastem": profile}): + configs[name] = config + self.assertIn("retroarch", configs) + self.assertIn("retrobat", configs) + found = generate_site.reading_platforms("blastem", profile, "cdbios.bin", configs) + self.assertFalse(found & {"retroarch", "lakka", "retrobat"}, found) + class StructuredBlocks(unittest.TestCase): PIN = "1e0de94dc7e669c0925a22c0fccf6cdc837af0a0"