chore: one folder for fbalpha 2012 samples

This commit is contained in:
Abdessamad Derraz committed 2026-10-23 14:47:59 +02:00
commit 8b4cc0db41
16 files changed
+161 -122

No files matched your search

+41 -2
View File
@@ -4,11 +4,15 @@ A system section is named after the folder its files live in. Nintendo held
DS and Nintendo DS, 64DD and Nintendo 64DD, Sega held Mega CD and Mega-CD,
Sinclair ZX Spectrum and ZXSpectrum, VTech V.Smile and VSmile, Acorn BBC and
BBC Micro: each console had two sections that hid each other on the site.
Reads the git index, which is what a clone checks out.
Reads the git index, which is what a clone checks out, and the database,
which also lists the release assets the index never holds: FBAlpha 2012 had
three samples committed under "FBAlpha 2012" and four release assets under
"fba2012", the folder the core reads.
"""
from __future__ import annotations
import json
import re
import subprocess
import unittest
@@ -19,7 +23,9 @@ REPO_ROOT = Path(__file__).resolve().parents[1]
def console_key(name: str) -> str:
return re.sub(r"[\s.\-]", "", name).casefold()
"""Spaces, dashes, dots and case folded, and "Alpha" read as its "A"
abbreviation, so "FBAlpha 2012" and "fba2012" are one core."""
return re.sub(r"[\s.\-]", "", name).casefold().replace("alpha", "a")
def twin_consoles(paths: list[str]) -> list[list[str]]:
@@ -58,6 +64,39 @@ class OneFolderPerConsole(unittest.TestCase):
[["Sega/Mega CD", "Sega/Mega-CD"], ["VTech/V.Smile", "VTech/VSmile"]],
)
def test_database_paths_name_each_console_once(self) -> None:
db_path = REPO_ROOT / "database.json"
if not db_path.is_file():
self.skipTest("database.json not generated")
files = json.loads(db_path.read_text(encoding="utf-8"))["files"]
self.assertEqual(twin_consoles([f["path"] for f in files.values()]), [])
def test_alpha_abbreviation_is_the_same_core(self) -> None:
self.assertEqual(
twin_consoles([
"bios/Arcade/FBAlpha 2012/samples/dkong.zip",
"bios/Arcade/fba2012/samples/ghox.zip",
]),
[["Arcade/FBAlpha 2012", "Arcade/fba2012"]],
)
def test_fbalpha2012_samples_sit_where_the_profile_reads(self) -> None:
db_path = REPO_ROOT / "database.json"
if not db_path.is_file():
self.skipTest("database.json not generated")
files = json.loads(db_path.read_text(encoding="utf-8"))["files"]
samples = sorted(
f["path"] for f in files.values()
if f["path"].startswith("bios/Arcade/")
and "/samples/" in f["path"] and "fba" in f["path"].casefold()
)
self.assertEqual(
samples,
[f"bios/Arcade/fba2012/samples/{name}.zip" for name in (
"dkong", "dkongjr", "fireshrk", "galaga", "ghox", "tekipaki", "vimana",
)],
)
if __name__ == "__main__":
unittest.main()