mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-30 13:28:51 -06:00
refactor: split common.py into three packages
core: cli (run_cli, input errors, name hints), github (token), paths. model: sources, database, composition, registry, platforms, declarations, targets, systems, profiles, cliargs. resolve: content, ownership, datadirs, archives, localfile, directories, layout, contentlayout, standalone, grouping, cores. Definitions move verbatim; common.py and its re-exports are gone and every importer, patch target and code-in-string names the new home. A test that stubbed common.load_platform_config stubs each module that reads the loader by its own name.
This commit is contained in:
1 parent
c784aef883
commit
83cfa6fd0f
281 files changed
+7036
-6794
No files matched your search
@@ -19,7 +19,8 @@ import unittest
|
||||
import zlib
|
||||
from pathlib import Path
|
||||
|
||||
from common import adler32_of, resolve_local_file
|
||||
from resolve.content import adler32_of
|
||||
from resolve.localfile import resolve_local_file
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
@@ -117,7 +118,7 @@ class TheTwoRomsFormAPairTheCodeTakes(unittest.TestCase):
|
||||
|
||||
class DolphinGetsAPairItTakes(unittest.TestCase):
|
||||
def test_each_dolphin_dsp_rom_resolves_to_an_accepted_dump(self):
|
||||
from common import load_emulator_profiles
|
||||
from model.profiles import load_emulator_profiles
|
||||
|
||||
database = REPO_ROOT / "database.json"
|
||||
if not database.exists():
|
||||
@@ -137,7 +138,7 @@ class DolphinGetsAPairItTakes(unittest.TestCase):
|
||||
|
||||
|
||||
def test_every_paired_profile_resolves_a_pair_its_code_takes(self):
|
||||
from common import load_emulator_profiles
|
||||
from model.profiles import load_emulator_profiles
|
||||
|
||||
database = REPO_ROOT / "database.json"
|
||||
if not database.exists():
|
||||
|
||||
@@ -19,7 +19,8 @@ import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
import common
|
||||
from model.profiles import load_emulator_profiles, _emulator_profiles_cache
|
||||
from resolve.localfile import resolve_local_file
|
||||
import generate_pack as builder
|
||||
import packextras
|
||||
|
||||
@@ -87,15 +88,15 @@ class AgnosticScanStaysInItsTree(unittest.TestCase):
|
||||
"base_destination": "",
|
||||
"systems": {},
|
||||
}
|
||||
common._emulator_profiles_cache.clear()
|
||||
_emulator_profiles_cache.clear()
|
||||
|
||||
def tearDown(self):
|
||||
common._emulator_profiles_cache.clear()
|
||||
_emulator_profiles_cache.clear()
|
||||
self._tmp.cleanup()
|
||||
|
||||
def _write_profile(self, body: str):
|
||||
(self.root / "emulators" / "demo.yml").write_text(body)
|
||||
return common.load_emulator_profiles(str(self.root / "emulators"))
|
||||
return load_emulator_profiles(str(self.root / "emulators"))
|
||||
|
||||
def _scan(self, profiles):
|
||||
extras = builder._collect_emulator_extras(
|
||||
@@ -210,7 +211,7 @@ class AgnosticScanStaysInItsTree(unittest.TestCase):
|
||||
self.assertTrue(self._scan(profiles))
|
||||
for extra in self._scan(profiles):
|
||||
self.assertIn("sha1", extra, f"{extra['name']} carries no identity")
|
||||
path, status = common.resolve_local_file(extra, self.db)
|
||||
path, status = resolve_local_file(extra, self.db)
|
||||
self.assertEqual(status, "sha1_exact")
|
||||
self.assertTrue(path.endswith(extra["name"]))
|
||||
|
||||
@@ -254,7 +255,7 @@ class PathTailBeatsABareName(unittest.TestCase):
|
||||
|
||||
def test_the_tail_of_the_declared_path_decides(self):
|
||||
entry = {"name": "index.yaml", "path": "app/resources/index.yaml"}
|
||||
path, status = common.resolve_local_file(
|
||||
path, status = resolve_local_file(
|
||||
entry, self.db, dest_hint=entry["path"]
|
||||
)
|
||||
self.assertEqual(status, "path_exact")
|
||||
@@ -263,7 +264,7 @@ class PathTailBeatsABareName(unittest.TestCase):
|
||||
def test_a_bare_name_is_never_reached_through_the_tail(self):
|
||||
"""The tail stops above the filename: that is the weaker step."""
|
||||
entry = {"name": "index.yaml", "path": "nowhere/index.yaml"}
|
||||
_path, status = common.resolve_local_file(
|
||||
_path, status = resolve_local_file(
|
||||
entry, self.db, dest_hint=entry["path"]
|
||||
)
|
||||
self.assertEqual(status, "name_exact")
|
||||
|
||||
@@ -24,7 +24,9 @@ class ScanFollowsTheBuild(unittest.TestCase):
|
||||
previous = os.getcwd()
|
||||
os.chdir(REPO_ROOT)
|
||||
self.addCleanup(os.chdir, previous)
|
||||
from common import load_database, load_emulator_profiles, load_platform_config
|
||||
from model.database import load_database
|
||||
from model.profiles import load_emulator_profiles
|
||||
from model.platforms import load_platform_config
|
||||
from packextras import _collect_emulator_extras
|
||||
|
||||
profiles = load_emulator_profiles("emulators")
|
||||
|
||||
@@ -153,13 +153,11 @@ class BundledHashIsProof(unittest.TestCase):
|
||||
def test_no_bundled_entry_resolves_to_other_bytes(self):
|
||||
if not (REPO_ROOT / "database.json").is_file():
|
||||
self.skipTest("no database.json")
|
||||
from common import (
|
||||
build_zip_contents_index,
|
||||
load_data_dir_registry,
|
||||
load_database,
|
||||
load_emulator_profiles,
|
||||
resolve_local_file,
|
||||
)
|
||||
from core.ziptools import build_zip_contents_index
|
||||
from model.registry import load_data_dir_registry
|
||||
from model.database import load_database
|
||||
from model.profiles import load_emulator_profiles
|
||||
from resolve.localfile import resolve_local_file
|
||||
|
||||
previous = os.getcwd()
|
||||
os.chdir(REPO_ROOT)
|
||||
|
||||
@@ -157,7 +157,8 @@ class TheArchiveHoldingTheCoreMembers(unittest.TestCase):
|
||||
]
|
||||
|
||||
def test_the_copy_with_every_required_member_wins(self):
|
||||
from common import archive_entry, resolve_local_file
|
||||
from resolve.archives import archive_entry
|
||||
from resolve.localfile import resolve_local_file
|
||||
|
||||
path, status = resolve_local_file(
|
||||
archive_entry("neocdz.zip", self.profile_files), self.db
|
||||
@@ -166,7 +167,7 @@ class TheArchiveHoldingTheCoreMembers(unittest.TestCase):
|
||||
self.assertEqual(status, "name_exact")
|
||||
|
||||
def test_without_members_the_primary_stays(self):
|
||||
from common import resolve_local_file
|
||||
from resolve.localfile import resolve_local_file
|
||||
|
||||
path, _status = resolve_local_file({"name": "neocdz.zip"}, self.db)
|
||||
self.assertTrue(path.endswith("bios/neocdz.zip"))
|
||||
@@ -186,7 +187,9 @@ class TheArchiveHoldingTheCoreMembers(unittest.TestCase):
|
||||
MAME's 83b6f611 dump while the FBNeo dump sat loose in bios/."""
|
||||
import json
|
||||
|
||||
from common import archive_members, load_emulator_profiles, zip_member_crcs
|
||||
from resolve.archives import archive_members
|
||||
from model.profiles import load_emulator_profiles
|
||||
from core.ziptools import zip_member_crcs
|
||||
|
||||
database = REPO_ROOT / "database.json"
|
||||
if not database.exists():
|
||||
@@ -228,7 +231,7 @@ class EveryDeclaredLayoutIsHeld(unittest.TestCase):
|
||||
def setUp(self):
|
||||
import json
|
||||
|
||||
from common import get_mame_clone_map
|
||||
from model.database import get_mame_clone_map
|
||||
|
||||
database = REPO_ROOT / "database.json"
|
||||
if not (REPO_ROOT / "bios").is_dir() or not database.exists():
|
||||
@@ -240,7 +243,7 @@ class EveryDeclaredLayoutIsHeld(unittest.TestCase):
|
||||
self.addCleanup(os.chdir, previous)
|
||||
|
||||
def _declared_archives(self):
|
||||
from common import load_emulator_profiles
|
||||
from model.profiles import load_emulator_profiles
|
||||
|
||||
for emu, profile in load_emulator_profiles("emulators").items():
|
||||
for entry in profile.get("files") or []:
|
||||
@@ -273,7 +276,8 @@ class EveryDeclaredLayoutIsHeld(unittest.TestCase):
|
||||
self.assertEqual(absent, [])
|
||||
|
||||
def test_a_copy_holds_each_declared_layout_and_is_served(self):
|
||||
from common import resolve_local_file, zip_member_crcs
|
||||
from resolve.localfile import resolve_local_file
|
||||
from core.ziptools import zip_member_crcs
|
||||
|
||||
short, unserved = [], []
|
||||
for emu, entry in self._declared_archives():
|
||||
@@ -321,19 +325,19 @@ class AnArchiveHashedByItsMembers(unittest.TestCase):
|
||||
self.archive = str(archive)
|
||||
|
||||
def test_the_archive_answers_a_composite_frontend(self):
|
||||
from common import resolve_local_file
|
||||
from resolve.localfile import resolve_local_file
|
||||
|
||||
path, status = resolve_local_file({**self.entry, "zip_digest": "composite"}, self.db)
|
||||
self.assertEqual((path, status), (self.archive, "md5_composite_exact"))
|
||||
|
||||
def test_a_plain_digest_still_takes_the_md5_match(self):
|
||||
from common import resolve_local_file
|
||||
from resolve.localfile import resolve_local_file
|
||||
|
||||
path, _status = resolve_local_file(self.entry, self.db)
|
||||
self.assertTrue(path.endswith("neocd.bin"))
|
||||
|
||||
def test_the_registry_marks_recalbox_archives(self):
|
||||
from common import load_platform_config
|
||||
from model.platforms import load_platform_config
|
||||
|
||||
config = load_platform_config("recalbox", str(REPO_ROOT / "platforms"))
|
||||
marks = {
|
||||
@@ -369,7 +373,7 @@ class AnArchiveRankedByWhatItHolds(unittest.TestCase):
|
||||
"by_path_suffix": {}, "by_crc32": {}}}
|
||||
|
||||
def _resolve(self, entry: dict, db: dict) -> str:
|
||||
from common import resolve_local_file
|
||||
from resolve.localfile import resolve_local_file
|
||||
|
||||
path, _status = resolve_local_file(entry, db)
|
||||
return str(Path(path).relative_to(self.root))
|
||||
@@ -409,7 +413,7 @@ class AnArchiveRankedByWhatItHolds(unittest.TestCase):
|
||||
def test_a_copy_holding_no_declared_member_is_not_the_archive(self):
|
||||
"""galgames.zip held only an assembler listing and none of the six
|
||||
ROMs MAME declares: the name step served it as the BIOS set."""
|
||||
from common import resolve_local_file
|
||||
from resolve.localfile import resolve_local_file
|
||||
|
||||
db = self._db([("bios/MAME/hod2bios.zip", ["listing.lst"])])
|
||||
entry = {"name": "hod2bios.zip", "contents": [
|
||||
@@ -465,7 +469,7 @@ class ALooseEntryNamingItsArchive(unittest.TestCase):
|
||||
|
||||
import yaml
|
||||
|
||||
from common import _emulator_profiles_cache
|
||||
from model.profiles import _emulator_profiles_cache
|
||||
from generate_pack import generate_emulator_pack
|
||||
from verify import verify_emulator
|
||||
|
||||
@@ -546,7 +550,7 @@ class AnotherEmulatorsOwnSet(unittest.TestCase):
|
||||
return [{"name": n, "crc32": format(zlib.crc32(self.roms[n]), "08x")} for n in names]
|
||||
|
||||
def test_its_member_count_does_not_rank_for_another_emulator(self):
|
||||
from common import resolve_local_file
|
||||
from resolve.localfile import resolve_local_file
|
||||
|
||||
entry = {"name": "naomi.zip", "source_profile": "flycast",
|
||||
"contents": self._contents(list(self.roms))}
|
||||
@@ -554,13 +558,13 @@ class AnotherEmulatorsOwnSet(unittest.TestCase):
|
||||
self.assertEqual(path, "bios/MAME/naomi.zip")
|
||||
|
||||
def test_it_does_not_break_the_superset_of_an_unowned_entry(self):
|
||||
from common import resolve_local_file
|
||||
from resolve.localfile import resolve_local_file
|
||||
|
||||
path, _status = resolve_local_file({"name": "naomi.zip"}, self.db)
|
||||
self.assertEqual(path, "bios/MAME/naomi.zip")
|
||||
|
||||
def test_its_owner_still_gets_it(self):
|
||||
from common import resolve_local_file
|
||||
from resolve.localfile import resolve_local_file
|
||||
|
||||
entry = {"name": "naomi.zip", "source_profile": "demul",
|
||||
"contents": self._contents(list(self.roms))}
|
||||
@@ -595,7 +599,7 @@ class ArchiveMembersIndexOnce(unittest.TestCase):
|
||||
for f in list.__iter__(files) if f.get("archive") == archive and f.get("crc32")]
|
||||
|
||||
def test_a_profile_list_is_walked_once_and_answers_as_a_scan(self):
|
||||
from common import archive_members
|
||||
from resolve.archives import archive_members
|
||||
|
||||
files = self.entries()
|
||||
for archive in [f"set{n}.zip" for n in range(30)] + ["absent.zip", "", None]:
|
||||
@@ -604,7 +608,7 @@ class ArchiveMembersIndexOnce(unittest.TestCase):
|
||||
self.assertEqual(self.CountingList.walks, 1)
|
||||
|
||||
def test_a_list_that_grew_is_indexed_again(self):
|
||||
from common import archive_members
|
||||
from resolve.archives import archive_members
|
||||
|
||||
files = self.entries()
|
||||
archive_members("set1.zip", files)
|
||||
|
||||
@@ -84,7 +84,7 @@ def _hashes(values: object) -> set[str]:
|
||||
|
||||
|
||||
def _allowed_members() -> dict[str, set[str]]:
|
||||
from common import load_emulator_profiles
|
||||
from model.profiles import load_emulator_profiles
|
||||
from romset_recipes import load_dat_recipes
|
||||
|
||||
allowed: dict[str, set[str]] = defaultdict(set)
|
||||
@@ -111,7 +111,8 @@ def _allowed_members() -> dict[str, set[str]]:
|
||||
|
||||
|
||||
def _platform_pins() -> tuple[set[str], dict[str, set[tuple[str, str]]]]:
|
||||
from common import list_registered_platforms, load_platform_config
|
||||
from model.registry import list_registered_platforms
|
||||
from model.platforms import load_platform_config
|
||||
|
||||
pinned: set[str] = set()
|
||||
zipped: dict[str, set[tuple[str, str]]] = defaultdict(set)
|
||||
@@ -158,7 +159,7 @@ class HeldArchivesMatchTheirRecipes(unittest.TestCase):
|
||||
bios = REPO_ROOT / "bios"
|
||||
if not bios.is_dir() or not (REPO_ROOT / "recipes").is_dir():
|
||||
self.skipTest("bios/ or recipes/ is not present")
|
||||
from common import variant_base_name
|
||||
from resolve.localfile import variant_base_name
|
||||
from core.hashing import md5_composite_of
|
||||
|
||||
allowed = _allowed_members()
|
||||
|
||||
@@ -17,7 +17,7 @@ import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from common import (
|
||||
from core.artifacts import (
|
||||
ArtifactLockBusy,
|
||||
artifact_lock,
|
||||
hold_artifact_lock,
|
||||
@@ -66,7 +66,7 @@ class ArtifactLockTest(unittest.TestCase):
|
||||
"""A mistyped --output-dir given to --verify-packs or release_record
|
||||
was created holding a .lock, and the next run with the same typo no
|
||||
longer said the path did not exist."""
|
||||
from common import ArtifactDirectoryMissing
|
||||
from core.artifacts import ArtifactDirectoryMissing
|
||||
|
||||
missing = os.path.join(self.dir, "sub", "dsit")
|
||||
with self.assertRaises(ArtifactDirectoryMissing), artifact_lock(missing, exclusive=False):
|
||||
@@ -314,7 +314,7 @@ class StandaloneWritersHonourTheRepositoryHold(unittest.TestCase):
|
||||
def _child(self, target: str, env: dict) -> subprocess.CompletedProcess:
|
||||
code = (
|
||||
"import sys; sys.path.insert(0, 'scripts')\n"
|
||||
"from common import artifact_lock, repository_output_lock\n"
|
||||
"from core.artifacts import artifact_lock, repository_output_lock\n"
|
||||
f"with repository_output_lock({target!r}), artifact_lock({self.scratch!r}):\n"
|
||||
" pass\n"
|
||||
)
|
||||
@@ -349,7 +349,7 @@ class HeldLockTest(unittest.TestCase):
|
||||
def _child_locks(self, env: dict) -> subprocess.CompletedProcess:
|
||||
code = (
|
||||
"import sys; sys.path.insert(0, 'scripts')\n"
|
||||
"from common import artifact_lock\n"
|
||||
"from core.artifacts import artifact_lock\n"
|
||||
f"with artifact_lock({self.dir!r}):\n pass\n"
|
||||
)
|
||||
return subprocess.run(
|
||||
|
||||
@@ -309,7 +309,7 @@ class ATerminatedBuildLeavesNoScratch(unittest.TestCase):
|
||||
CHILD = (
|
||||
"import sys, time\n"
|
||||
"sys.path.insert(0, 'scripts')\n"
|
||||
"from common import run_cli\n"
|
||||
"from core.cli import run_cli\n"
|
||||
"from generate_pack import _writing_pack\n"
|
||||
"def main():\n"
|
||||
" with _writing_pack(sys.argv[1]) as zf:\n"
|
||||
|
||||
@@ -30,7 +30,8 @@ except ImportError:
|
||||
import install
|
||||
from scripts import pipeline, region_audit
|
||||
from scripts import region
|
||||
from scripts.common import resolve_local_file, safe_extract_zip
|
||||
from scripts.resolve.localfile import resolve_local_file
|
||||
from scripts.core.ziptools import safe_extract_zip
|
||||
from scripts.generate_pack import (
|
||||
_emulator_region_group,
|
||||
generate_target_manifests,
|
||||
@@ -600,7 +601,7 @@ class OnePlatformPerFlag(unittest.TestCase):
|
||||
self.assertNotIn("Traceback", completed.stderr)
|
||||
|
||||
def test_unknown_names_still_get_a_suggestion(self):
|
||||
from common import require_platform
|
||||
from model.cliargs import require_platform
|
||||
|
||||
with self.assertRaises(SystemExit) as caught:
|
||||
require_platform("batocra", str(ROOT / "platforms"))
|
||||
@@ -664,7 +665,8 @@ class EverySharedGroupServesAPlatform(unittest.TestCase):
|
||||
verify and no manifest, and nothing said so."""
|
||||
|
||||
def test_each_group_contributes_an_entry_somewhere(self):
|
||||
from common import list_registered_platforms, load_platform_config
|
||||
from model.registry import list_registered_platforms
|
||||
from model.platforms import load_platform_config
|
||||
|
||||
platforms_dir = str(ROOT / "platforms")
|
||||
with (ROOT / "platforms" / "_shared.yml").open(encoding="utf-8") as handle:
|
||||
@@ -1000,7 +1002,7 @@ class FaqRegressions(unittest.TestCase):
|
||||
# and FinalBurn Neo 1.0.0.2, versions no source at the pins states,
|
||||
# and the test holding them to the profiles kept the errors in step.
|
||||
import generate_site
|
||||
from common import load_emulator_profiles
|
||||
from model.profiles import load_emulator_profiles
|
||||
|
||||
profiles = load_emulator_profiles(str(ROOT / "emulators"), skip_aliases=False)
|
||||
page = (ROOT / "wiki" / "technical-faq.md").read_text(encoding="utf-8")
|
||||
@@ -1077,7 +1079,7 @@ class CatalogRatioRegressions(unittest.TestCase):
|
||||
)
|
||||
|
||||
def test_arcade_and_engine_data_stay_out_of_the_ratio(self):
|
||||
from scripts.common import compute_composition, count_catalog_matched
|
||||
from scripts.model.composition import compute_composition, count_catalog_matched
|
||||
|
||||
db = {
|
||||
"files": {
|
||||
@@ -1097,7 +1099,7 @@ class CatalogRatioRegressions(unittest.TestCase):
|
||||
"""Engine data collected under `Game Engines/` and under a game
|
||||
publisher counted as console and computer system files: 7 697 of
|
||||
them made the README announce 13 564 system files."""
|
||||
from scripts.common import composition_tier
|
||||
from scripts.model.composition import composition_tier
|
||||
|
||||
for path in (
|
||||
"bios/Game Engines/C-Dogs SDL/cdogs/data/guns.json",
|
||||
@@ -1110,7 +1112,8 @@ class CatalogRatioRegressions(unittest.TestCase):
|
||||
self.assertEqual(composition_tier("bios/Microsoft/MSX/MSX2.ROM"), "systems")
|
||||
|
||||
def test_readme_ratio_matches_the_database(self):
|
||||
from scripts.common import compute_composition, count_catalog_matched, load_database
|
||||
from scripts.model.composition import compute_composition, count_catalog_matched
|
||||
from scripts.model.database import load_database
|
||||
|
||||
database = ROOT / "database.json"
|
||||
if not database.exists():
|
||||
@@ -1466,7 +1469,7 @@ class OneBaselineVerdict(unittest.TestCase):
|
||||
digit."""
|
||||
import hashlib
|
||||
|
||||
from scripts.common import md5_composite
|
||||
from scripts.core.hashing import md5_composite
|
||||
from scripts.resolve.validation import baseline_verdict, digest_verdict
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
@@ -1496,7 +1499,7 @@ class OneBaselineVerdict(unittest.TestCase):
|
||||
neocd.bin shipped as neocdz.zip passed while Recalbox marks it red."""
|
||||
import hashlib
|
||||
|
||||
from scripts.common import md5_composite
|
||||
from scripts.core.hashing import md5_composite
|
||||
from scripts.resolve.validation import digest_verdict
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
@@ -2393,11 +2396,11 @@ class ManifestVersionIsThePlatformsOwn(unittest.TestCase):
|
||||
so each manifest states the version its own platform YAML records."""
|
||||
|
||||
def setUp(self):
|
||||
from scripts.common import _platform_config_cache
|
||||
from scripts.model.platforms import _platform_config_cache
|
||||
_platform_config_cache.clear()
|
||||
|
||||
def test_committed_manifests_state_their_platform_version(self):
|
||||
from scripts.common import load_platform_config
|
||||
from scripts.model.platforms import load_platform_config
|
||||
manifests = sorted((ROOT / "install").glob("*.json"))
|
||||
self.assertTrue(manifests)
|
||||
for path in manifests:
|
||||
@@ -2408,7 +2411,7 @@ class ManifestVersionIsThePlatformsOwn(unittest.TestCase):
|
||||
self.assertEqual(data["version"], str(config["version"]))
|
||||
|
||||
def test_no_child_shows_its_parents_version(self):
|
||||
from scripts.common import load_platform_config
|
||||
from scripts.model.platforms import load_platform_config
|
||||
platforms = ROOT / "platforms"
|
||||
children = {}
|
||||
for path in sorted(platforms.glob("*.yml")):
|
||||
@@ -2425,7 +2428,7 @@ class ManifestVersionIsThePlatformsOwn(unittest.TestCase):
|
||||
self.assertNotEqual(version, parent.get("version"))
|
||||
|
||||
def test_an_unversioned_child_has_no_version(self):
|
||||
from scripts.common import load_platform_config
|
||||
from scripts.model.platforms import load_platform_config
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as tmp:
|
||||
Path(tmp, "parent.yml").write_text("platform: P\nversion: '2.0'\nsystems: {}\n")
|
||||
Path(tmp, "child.yml").write_text("inherits: parent\nplatform: C\n")
|
||||
@@ -2907,7 +2910,7 @@ class FreshnessGuardMechanics(unittest.TestCase):
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
from common import write_if_changed
|
||||
from core.artifacts import write_if_changed
|
||||
|
||||
self.write_if_changed = write_if_changed
|
||||
self._tmp = tempfile.TemporaryDirectory()
|
||||
@@ -3217,10 +3220,13 @@ class ACheckThatCannotAnswerDoesNotPass(unittest.TestCase):
|
||||
self.assertEqual(stop.exception.code, 1)
|
||||
|
||||
def test_a_missing_profile_directory_says_so(self):
|
||||
from scripts import common as _common
|
||||
# Bare names, as the loader imports them: scripts.core.cli would be a
|
||||
# second copy of the module, with a second InputMissing.
|
||||
from core.cli import InputMissing
|
||||
from model.profiles import load_emulator_profiles
|
||||
|
||||
with self.assertRaisesRegex(_common.InputMissing, "no emulator profile directory"):
|
||||
_common.load_emulator_profiles(str(ROOT / "no-such-emulator-dir"))
|
||||
with self.assertRaisesRegex(InputMissing, "no emulator profile directory"):
|
||||
load_emulator_profiles(str(ROOT / "no-such-emulator-dir"))
|
||||
|
||||
|
||||
class TestEntryPointsRunEveryClass(unittest.TestCase):
|
||||
@@ -3260,7 +3266,7 @@ class ScriptsImportThreeWays(unittest.TestCase):
|
||||
|
||||
The three do not agree on what is on the path: only the first form adds
|
||||
the scripts directory. Adding the package marker without the bootstrap
|
||||
made `import scripts.common` fail on the first sibling import it reached.
|
||||
made `import scripts.common` (now scripts.core.cli) fail on the first sibling import it reached.
|
||||
"""
|
||||
|
||||
def _run(self, *args: str):
|
||||
@@ -3274,7 +3280,8 @@ class ScriptsImportThreeWays(unittest.TestCase):
|
||||
|
||||
def test_imported_as_a_package(self):
|
||||
result = self._run(
|
||||
"-c", "import scripts.common, scripts.verify, scripts.generate_pack"
|
||||
"-c", "import scripts.core.cli, scripts.model.platforms, scripts.resolve.localfile, "
|
||||
"scripts.verify, scripts.generate_pack"
|
||||
)
|
||||
self.assertEqual(result.returncode, 0, result.stderr[-400:])
|
||||
|
||||
@@ -3467,7 +3474,7 @@ class AnotherEmulatorsTreeProvesNothing(unittest.TestCase):
|
||||
return db
|
||||
|
||||
def test_neither_the_full_tail_nor_the_name_lands_in_a_foreign_tree(self):
|
||||
from scripts.common import resolve_local_file
|
||||
from scripts.resolve.localfile import resolve_local_file
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
root = Path(directory)
|
||||
@@ -3497,13 +3504,11 @@ class AnotherEmulatorsTreeProvesNothing(unittest.TestCase):
|
||||
|
||||
def test_no_desktop_retroarch_pack_serves_armsx2s_tree(self):
|
||||
from scripts import slots
|
||||
from scripts.common import (
|
||||
load_data_dir_registry,
|
||||
load_database,
|
||||
load_emulator_profiles,
|
||||
load_platform_config,
|
||||
load_target_config,
|
||||
)
|
||||
from scripts.model.registry import load_data_dir_registry
|
||||
from scripts.model.database import load_database
|
||||
from scripts.model.profiles import load_emulator_profiles
|
||||
from scripts.model.platforms import load_platform_config
|
||||
from scripts.model.targets import load_target_config
|
||||
|
||||
if not (ROOT / "database.json").exists():
|
||||
self.skipTest("database.json is not generated")
|
||||
@@ -3556,7 +3561,7 @@ class ANameWithItsDirectoryIsTheDestination(unittest.TestCase):
|
||||
def test_the_directory_in_the_name_picks_the_copy(self):
|
||||
import hashlib
|
||||
|
||||
from scripts.common import resolve_local_file
|
||||
from scripts.resolve.localfile import resolve_local_file
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
root = Path(directory)
|
||||
@@ -3760,7 +3765,7 @@ class KidVidTapesStayWithTheContent(unittest.TestCase):
|
||||
reaches: stella's tapes go there, never to the BIOS tree."""
|
||||
|
||||
def test_no_pack_places_them_in_the_system_directory(self):
|
||||
from scripts.common import load_emulator_profiles
|
||||
from scripts.model.profiles import load_emulator_profiles
|
||||
from scripts.resolve.validation import (
|
||||
outside_gap_scope,
|
||||
read_from_save_dir,
|
||||
@@ -3869,7 +3874,8 @@ class HashMergeBackupsAreNotSources(unittest.TestCase):
|
||||
offenders = [
|
||||
str(path.relative_to(ROOT))
|
||||
for path in sorted(ROOT.glob("scripts/**/*.py"))
|
||||
if path.name != "common.py" and '".old.yml"' in path.read_text()
|
||||
if path.relative_to(ROOT).as_posix() != "scripts/model/profiles.py"
|
||||
and '".old.yml"' in path.read_text()
|
||||
]
|
||||
self.assertEqual(offenders, [])
|
||||
|
||||
@@ -3880,7 +3886,7 @@ class AnUnreadableArchiveIsSaidOutLoud(unittest.TestCase):
|
||||
truncated archive read as a missing dump (not_found) or a wrong one."""
|
||||
|
||||
def test_the_resolver_names_the_archive(self):
|
||||
import common
|
||||
from resolve import localfile
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=ROOT / "tmp") as tmp:
|
||||
broken = Path(tmp) / "neogeo.zip"
|
||||
@@ -3893,7 +3899,7 @@ class AnUnreadableArchiveIsSaidOutLoud(unittest.TestCase):
|
||||
entry = {"name": "neogeo.zip", "md5": "1" * 32, "zipped_file": "sp-s2.sp1"}
|
||||
stderr = io.StringIO()
|
||||
with contextlib.redirect_stderr(stderr):
|
||||
common.resolve_local_file(entry, db)
|
||||
localfile.resolve_local_file(entry, db)
|
||||
self.assertIn(f"unreadable archive {broken}", stderr.getvalue())
|
||||
|
||||
|
||||
@@ -3903,19 +3909,20 @@ class GeneralUserGSReachesEveryCoreThatNamesIt(unittest.TestCase):
|
||||
shipped no General MIDI bank."""
|
||||
|
||||
def test_each_name_resolves_to_the_one_file(self):
|
||||
import common
|
||||
from model import profiles as model_profiles
|
||||
from resolve import localfile
|
||||
|
||||
if not (ROOT / "database.json").exists():
|
||||
self.skipTest("database.json is not generated")
|
||||
db = json.loads((ROOT / "database.json").read_text())
|
||||
profiles = common.load_emulator_profiles(str(ROOT / "emulators"))
|
||||
profiles = model_profiles.load_emulator_profiles(str(ROOT / "emulators"))
|
||||
held = "bios/Other/GeneralUser GS/GeneralUser-GS.sf2"
|
||||
for emulator, name in (("dosbox_pure", "DOSBOX.SF2"),
|
||||
("dosbox-staging", "GeneralUser-GS.sf2"),
|
||||
("dosbox-x", "GeneralUser_GS.sf2")):
|
||||
with self.subTest(emulator=emulator):
|
||||
entry = next(f for f in profiles[emulator]["files"] if f["name"] == name)
|
||||
path, _status = common.resolve_local_file(
|
||||
path, _status = localfile.resolve_local_file(
|
||||
{**entry, "source_profile": emulator}, db, dest_hint=entry.get("path", ""))
|
||||
self.assertEqual(path, held)
|
||||
|
||||
@@ -3927,19 +3934,20 @@ class APlatformPinDoesNotReplaceTheCoresRevision(unittest.TestCase):
|
||||
files to cores built against newer ones."""
|
||||
|
||||
def test_the_profile_revision_serves_the_core(self):
|
||||
import common
|
||||
from model import profiles as model_profiles
|
||||
from resolve import localfile
|
||||
|
||||
if not (ROOT / "database.json").exists():
|
||||
self.skipTest("database.json is not generated")
|
||||
db = json.loads((ROOT / "database.json").read_text())
|
||||
profiles = common.load_emulator_profiles(str(ROOT / "emulators"))
|
||||
profiles = model_profiles.load_emulator_profiles(str(ROOT / "emulators"))
|
||||
for emulator, name, pinned in (("scummvm", "kyra.dat", "21a57f79886e46f410cfb50186ed8d77"),
|
||||
("fbneo", "hiscore.dat", "37fc4e050b53a1ef2c2e7f3042553025")):
|
||||
with self.subTest(emulator=emulator):
|
||||
entry = next(f for f in profiles[emulator]["files"] if f["name"] == name)
|
||||
self.assertTrue(entry.get("sha1"), "the profile claims its revision")
|
||||
self.assertIn(pinned, db["indexes"]["by_md5"], "the platform's pin is held")
|
||||
path, status = common.resolve_local_file(
|
||||
path, status = localfile.resolve_local_file(
|
||||
{**entry, "source_profile": emulator}, db, dest_hint=entry["path"])
|
||||
self.assertEqual(status, "sha1_exact")
|
||||
self.assertEqual(db["files"][entry["sha1"]]["path"], path)
|
||||
@@ -3968,7 +3976,7 @@ class ADataDirectoryIsWalkedOnce(unittest.TestCase):
|
||||
resolution cost names x tree on every pack build."""
|
||||
|
||||
def test_two_lookups_share_one_walk_and_keep_its_order(self):
|
||||
import common
|
||||
from resolve.datadirs import forget_data_dir_index, _resolve_in_data_dirs
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=ROOT / "tmp") as tmp:
|
||||
cache = Path(tmp) / "cache"
|
||||
@@ -3978,7 +3986,7 @@ class ADataDirectoryIsWalkedOnce(unittest.TestCase):
|
||||
(cache / "b" / "font.bin").write_bytes(b"2")
|
||||
(cache / "b" / "other.bin").write_bytes(b"3")
|
||||
registry = {"x": {"local_cache": str(cache)}}
|
||||
common.forget_data_dir_index()
|
||||
forget_data_dir_index()
|
||||
walks = []
|
||||
real_walk = os.walk
|
||||
|
||||
@@ -3987,11 +3995,11 @@ class ADataDirectoryIsWalkedOnce(unittest.TestCase):
|
||||
return real_walk(top, *a, **k)
|
||||
|
||||
with mock.patch.object(os, "walk", counting_walk):
|
||||
first, _ = common._resolve_in_data_dirs(["font.bin"], registry,
|
||||
first, _ = _resolve_in_data_dirs(["font.bin"], registry,
|
||||
lambda _p: "name_exact")
|
||||
second, _ = common._resolve_in_data_dirs(["other.bin"], registry,
|
||||
second, _ = _resolve_in_data_dirs(["other.bin"], registry,
|
||||
lambda _p: "name_exact")
|
||||
common.forget_data_dir_index()
|
||||
forget_data_dir_index()
|
||||
self.assertEqual(len(walks), 1)
|
||||
expected = sorted(str(p) for p in (cache / "a" / "Font.bin", cache / "b" / "font.bin"))
|
||||
self.assertIn(first[0], expected)
|
||||
@@ -4271,12 +4279,9 @@ class OpenMsxRomsSitInItsSystemroms(unittest.TestCase):
|
||||
them there."""
|
||||
|
||||
def test_every_entry_is_under_share_systemroms(self):
|
||||
from scripts.common import (
|
||||
load_emulator_profiles,
|
||||
load_platform_config,
|
||||
platform_layouts,
|
||||
standalone_set,
|
||||
)
|
||||
from scripts.model.profiles import load_emulator_profiles
|
||||
from scripts.model.platforms import load_platform_config
|
||||
from scripts.resolve.standalone import platform_layouts, standalone_set
|
||||
|
||||
profile = load_emulator_profiles(str(ROOT / "emulators"))["openmsx"]
|
||||
retrobat = yaml.safe_load((ROOT / "platforms" / "retrobat.yml").read_text())
|
||||
@@ -4330,7 +4335,7 @@ class AnEmptyTargetIsNotEveryCore(unittest.TestCase):
|
||||
served gpsp's files only, the published list said null (every core)."""
|
||||
|
||||
def test_the_published_list_is_the_builder_reading(self):
|
||||
from scripts.common import load_target_config
|
||||
from scripts.model.targets import load_target_config
|
||||
from scripts.generate_pack import generate_target_manifests
|
||||
|
||||
tmp = Path(tempfile.mkdtemp(dir=TMP_ROOT))
|
||||
@@ -4364,16 +4369,16 @@ class ADataDirectoryIsHeldWhileRead(unittest.TestCase):
|
||||
self.addCleanup(lambda: __import__("shutil").rmtree(self.tmp, True))
|
||||
|
||||
def test_the_index_follows_a_swapped_tree(self):
|
||||
from scripts import common
|
||||
from scripts.resolve.datadirs import _data_dir_basenames
|
||||
|
||||
cache = self.tmp / "cache"
|
||||
cache.mkdir()
|
||||
(cache / "old.rom").write_bytes(b"old")
|
||||
self.assertIn("old.rom", common._data_dir_basenames(str(cache)))
|
||||
self.assertIn("old.rom", _data_dir_basenames(str(cache)))
|
||||
cache.rename(self.tmp / "gone")
|
||||
cache.mkdir()
|
||||
(cache / "new.rom").write_bytes(b"new")
|
||||
index = common._data_dir_basenames(str(cache))
|
||||
index = _data_dir_basenames(str(cache))
|
||||
self.assertIn("new.rom", index)
|
||||
self.assertNotIn("old.rom", index)
|
||||
|
||||
@@ -4756,7 +4761,8 @@ class TheIssueFormListsEveryPlatform(unittest.TestCase):
|
||||
"""The missing-BIOS form offered 7 of the 12 registered platforms."""
|
||||
|
||||
def test_every_registered_platform_is_an_option(self):
|
||||
from scripts.common import list_registered_platforms, load_platform_config
|
||||
from scripts.model.registry import list_registered_platforms
|
||||
from scripts.model.platforms import load_platform_config
|
||||
|
||||
form = yaml.safe_load(
|
||||
(ROOT / ".github" / "ISSUE_TEMPLATE" / "missing-bios.yml").read_text()
|
||||
@@ -5049,7 +5055,8 @@ class SignaturesCarryTheirTypes(unittest.TestCase):
|
||||
|
||||
# Lowered as modules are annotated, never raised.
|
||||
CEILING = 0
|
||||
COMPLETE = ("core/artifacts.py", "common.py", "resolve/validation.py", "generate_pack.py")
|
||||
COMPLETE = ("core/artifacts.py", "model/platforms.py", "model/profiles.py", "resolve/localfile.py",
|
||||
"resolve/validation.py", "generate_pack.py")
|
||||
|
||||
@staticmethod
|
||||
def _missing(path: Path) -> list[str]:
|
||||
@@ -5105,7 +5112,9 @@ class EmuDeckRunsItsEmulatorsStandalone(unittest.TestCase):
|
||||
lost their standalone-only files."""
|
||||
|
||||
def test_every_emuscripts_emulator_is_standalone(self):
|
||||
from scripts.common import load_platform_config, runs_standalone, load_emulator_profiles
|
||||
from scripts.model.platforms import load_platform_config
|
||||
from scripts.resolve.layout import runs_standalone
|
||||
from scripts.model.profiles import load_emulator_profiles
|
||||
|
||||
config = load_platform_config("emudeck", str(ROOT / "platforms"))
|
||||
self.assertEqual(
|
||||
@@ -5122,9 +5131,9 @@ class EmuDeckRunsItsEmulatorsStandalone(unittest.TestCase):
|
||||
"""The scraper dropped RetroArch's own script: np2kai, neocd and
|
||||
every core EmuDeck installs through RetroArch got no file that
|
||||
checkBIOS.sh does not name."""
|
||||
from scripts.common import (
|
||||
load_emulator_profiles, load_platform_config, resolve_platform_cores,
|
||||
)
|
||||
from scripts.model.profiles import load_emulator_profiles
|
||||
from scripts.model.platforms import load_platform_config
|
||||
from scripts.resolve.cores import resolve_platform_cores
|
||||
|
||||
config = load_platform_config("emudeck", str(ROOT / "platforms"))
|
||||
self.assertIn("retroarch", config["cores"])
|
||||
@@ -5419,7 +5428,8 @@ class BundledFilesAreNotToSource(unittest.TestCase):
|
||||
self.assertTrue(installed_with_emulator(hcl))
|
||||
|
||||
def test_every_platform_named_is_registered(self):
|
||||
from common import list_registered_platforms, load_emulator_profiles
|
||||
from model.registry import list_registered_platforms
|
||||
from model.profiles import load_emulator_profiles
|
||||
|
||||
known = set(list_registered_platforms(str(ROOT / "platforms")))
|
||||
unknown = sorted({
|
||||
@@ -5440,14 +5450,14 @@ class BundledFilesAreNotToSource(unittest.TestCase):
|
||||
|
||||
import yaml as _yaml
|
||||
|
||||
import common
|
||||
from model.profiles import installed_data_refs
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as tmp:
|
||||
Path(tmp, "dolphin.yml").write_text(_yaml.safe_dump({
|
||||
"emulator": "Dolphin", "type": "libretro", "files": [],
|
||||
"data_directories": [{"ref": "dolphin-sys", "installed_on": ["lakka"]}]}))
|
||||
self.assertEqual(common.installed_data_refs("lakka", tmp), frozenset({"dolphin-sys"}))
|
||||
self.assertEqual(common.installed_data_refs("retroarch", tmp), frozenset())
|
||||
self.assertEqual(installed_data_refs("lakka", tmp), frozenset({"dolphin-sys"}))
|
||||
self.assertEqual(installed_data_refs("retroarch", tmp), frozenset())
|
||||
source = (ROOT / "scripts" / "generate_pack.py").read_text(encoding="utf-8")
|
||||
self.assertIn("if ref_key in installed_data_refs(platform_name):", source)
|
||||
|
||||
@@ -5522,7 +5532,7 @@ class GapsPageCountsOneWay(unittest.TestCase):
|
||||
|
||||
def test_the_destination_is_the_list_entrys(self):
|
||||
from scripts.generate_site import _declared_destination
|
||||
from common import load_platform_config
|
||||
from model.platforms import load_platform_config
|
||||
|
||||
config = load_platform_config("amberelec", str(ROOT / "platforms"))
|
||||
detail = {"name": "N88_KNJ1.ROM", "system": "nec-pc-88"}
|
||||
@@ -5980,7 +5990,7 @@ const _EJS_NIGHTLY_CORES_MAP: Record<string, string[]> = {
|
||||
parse_player_cores(source)
|
||||
|
||||
def test_the_platform_file_carries_the_nightly_cores(self):
|
||||
from common import load_platform_config
|
||||
from model.platforms import load_platform_config
|
||||
|
||||
cores = set(load_platform_config("romm", str(ROOT / "platforms"))["cores"])
|
||||
self.assertTrue({"azahar", "bsnes", "genesis_plus_gx_wide"} <= cores)
|
||||
@@ -6092,7 +6102,7 @@ class TheReadmeCountsSystemsAsListSystemsDoes(unittest.TestCase):
|
||||
import re
|
||||
from contextlib import redirect_stdout
|
||||
|
||||
from scripts.common import list_system_ids
|
||||
from scripts.model.cliargs import list_system_ids
|
||||
|
||||
out = io.StringIO()
|
||||
with redirect_stdout(out):
|
||||
@@ -6163,7 +6173,7 @@ class AnAliasSelectsItsProfile(unittest.TestCase):
|
||||
import contextlib as _contextlib
|
||||
import io as _io
|
||||
|
||||
from scripts.common import ProfileSelectionError, select_emulator_profiles
|
||||
from scripts.model.profiles import ProfileSelectionError, select_emulator_profiles
|
||||
|
||||
profiles = {
|
||||
"flycast": {"type": "libretro", "cores": ["flycast", "flycast_gles2"]},
|
||||
@@ -6277,7 +6287,7 @@ class TheRepairCommandWritesTheFileNamed(unittest.TestCase):
|
||||
command wrote another file and the next run failed the same way."""
|
||||
|
||||
def test_the_command_names_the_path(self):
|
||||
from scripts.common import DatabaseUnreadable, load_database
|
||||
from scripts.model.database import DatabaseUnreadable, load_database
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
target = str(Path(directory) / "nosuch.json")
|
||||
@@ -6292,7 +6302,7 @@ class TheRepairCommandWritesTheFileNamed(unittest.TestCase):
|
||||
def test_a_typo_beside_the_database_names_the_database(self):
|
||||
"""--db databse.json beside database.json was told to rescan the whole
|
||||
collection into a second file named after the typo."""
|
||||
from scripts.common import DatabaseUnreadable, load_database
|
||||
from scripts.model.database import DatabaseUnreadable, load_database
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
(Path(directory) / "database.json").write_text("{}")
|
||||
@@ -6338,7 +6348,8 @@ class AHashScanningCoreContradictsNoPlatform(unittest.TestCase):
|
||||
import json
|
||||
|
||||
from scripts import slots
|
||||
from scripts.common import list_registered_platforms, load_emulator_profiles
|
||||
from scripts.model.registry import list_registered_platforms
|
||||
from scripts.model.profiles import load_emulator_profiles
|
||||
|
||||
root = ROOT
|
||||
if not (root / "database.json").exists():
|
||||
@@ -6469,7 +6480,7 @@ class AHashScanLabelNamesNoOtherDump(unittest.TestCase):
|
||||
def test_labels_are_not_other_dumps_names(self):
|
||||
import json
|
||||
|
||||
from scripts.common import load_emulator_profiles
|
||||
from scripts.model.profiles import load_emulator_profiles
|
||||
|
||||
if not (ROOT / "database.json").exists():
|
||||
self.skipTest("database.json is not built")
|
||||
@@ -6628,7 +6639,7 @@ class ABrokenRegistryIsNotAnEmptyOne(unittest.TestCase):
|
||||
and every --all build passed having checked nothing."""
|
||||
|
||||
def test_both_raise(self):
|
||||
from scripts.common import list_registered_platforms
|
||||
from scripts.model.registry import list_registered_platforms
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as tmp:
|
||||
with self.assertRaises(FileNotFoundError):
|
||||
@@ -6801,7 +6812,8 @@ class AnUnknownTargetIsRefusedUnderAll(unittest.TestCase):
|
||||
BizHawk and MiSTer unfiltered: a green run about no Switch at all."""
|
||||
|
||||
def test_a_typo_is_refused_and_targetless_platforms_are_left_out(self):
|
||||
from scripts.common import build_target_cores_cache, list_registered_platforms
|
||||
from scripts.model.targets import build_target_cores_cache
|
||||
from scripts.model.registry import list_registered_platforms
|
||||
|
||||
platforms = list_registered_platforms(str(ROOT / "platforms"))
|
||||
with contextlib.redirect_stdout(io.StringIO()):
|
||||
@@ -7028,7 +7040,8 @@ class WhatOnlyAnInstallProvidesIsListed(unittest.TestCase):
|
||||
"""The pull request checks run this suite, not the pipeline: without
|
||||
this, a copy only a bundled entry reaches merges green."""
|
||||
import bundled_only
|
||||
from common import load_database, load_emulator_profiles
|
||||
from model.database import load_database
|
||||
from model.profiles import load_emulator_profiles
|
||||
|
||||
rows = bundled_only.bundled_only(
|
||||
load_database(str(ROOT / "database.json")),
|
||||
|
||||
@@ -82,7 +82,8 @@ class AnEmulatorLaunchedBothWaysGetsBothLayouts(unittest.TestCase):
|
||||
self.assertEqual(standalone & es_systems_libretro(text), {"dolphin"})
|
||||
|
||||
def test_the_layouts_are_both(self):
|
||||
from common import DUAL_MODE_PREFIX, platform_layouts
|
||||
from resolve.layout import DUAL_MODE_PREFIX
|
||||
from resolve.standalone import platform_layouts
|
||||
|
||||
profile = {"type": "standalone + libretro", "cores": ["dolphin"], "files": []}
|
||||
both = platform_layouts("dolphin", profile, {"dolphin", DUAL_MODE_PREFIX + "dolphin"})
|
||||
@@ -127,7 +128,7 @@ class DualModeNameReachesTheLibretroBuild(unittest.TestCase):
|
||||
left out of the platform."""
|
||||
|
||||
def test_both_builds_of_a_dual_mode_name_resolve(self):
|
||||
from common import resolve_platform_cores
|
||||
from resolve.cores import resolve_platform_cores
|
||||
|
||||
profiles = {
|
||||
"pcsx2": {"type": "standalone", "cores": ["pcsx2"]},
|
||||
@@ -145,7 +146,7 @@ class APlatformsOwnBuildWinsItsName(unittest.TestCase):
|
||||
the standalone uae4all2: one name, two programs."""
|
||||
|
||||
def test_built_by_beats_the_key_match_for_that_platform_only(self):
|
||||
from common import resolve_platform_cores
|
||||
from resolve.cores import resolve_platform_cores
|
||||
|
||||
profiles = {
|
||||
"uae4all": {"type": "standalone", "cores": ["uae4all"]},
|
||||
@@ -164,7 +165,7 @@ class APatchedLibretroBuildTakesItsNameOnly(unittest.TestCase):
|
||||
the same name, stays."""
|
||||
|
||||
def test_own_libretro_build_keeps_the_standalone_of_a_dual_name(self):
|
||||
from common import resolve_platform_cores
|
||||
from resolve.cores import resolve_platform_cores
|
||||
|
||||
profiles = {
|
||||
"pcsx2": {"type": "standalone", "source": "s", "cores": ["pcsx2"]},
|
||||
@@ -179,7 +180,9 @@ class APatchedLibretroBuildTakesItsNameOnly(unittest.TestCase):
|
||||
self.assertEqual(resolve_platform_cores(config, profiles), {"lrps2-own"})
|
||||
|
||||
def test_the_registry_resolves_each_platform_build(self):
|
||||
from common import load_emulator_profiles, load_platform_config, resolve_platform_cores
|
||||
from model.profiles import load_emulator_profiles
|
||||
from model.platforms import load_platform_config
|
||||
from resolve.cores import resolve_platform_cores
|
||||
|
||||
profiles = load_emulator_profiles(str(REPO_ROOT / "emulators"))
|
||||
platforms = str(REPO_ROOT / "platforms")
|
||||
|
||||
@@ -17,7 +17,7 @@ import unittest
|
||||
import zipfile
|
||||
from pathlib import Path
|
||||
|
||||
from common import resolve_local_file
|
||||
from resolve.localfile import resolve_local_file
|
||||
from exporter import discover_exporters
|
||||
from export_native import landed_changes
|
||||
from resolve.reconcile import NativeFile, build_native_model
|
||||
|
||||
@@ -21,7 +21,8 @@ from pathlib import Path
|
||||
|
||||
import yaml
|
||||
|
||||
from common import load_database, resolve_local_file
|
||||
from model.database import load_database
|
||||
from resolve.localfile import resolve_local_file
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||
|
||||
|
||||
@@ -21,13 +21,10 @@ REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
class DeclaredFilesResolveWithoutDataCaches(unittest.TestCase):
|
||||
def test_no_platform_entry_rests_on_a_data_directory_cache(self):
|
||||
from common import (
|
||||
build_zip_contents_index,
|
||||
list_registered_platforms,
|
||||
load_data_dir_registry,
|
||||
load_database,
|
||||
load_platform_config,
|
||||
)
|
||||
from core.ziptools import build_zip_contents_index
|
||||
from model.registry import list_registered_platforms, load_data_dir_registry
|
||||
from model.database import load_database
|
||||
from model.platforms import load_platform_config
|
||||
from packresolve import resolve_declaration
|
||||
|
||||
platforms_dir = REPO_ROOT / "platforms"
|
||||
|
||||
@@ -19,7 +19,7 @@ from pathlib import Path
|
||||
|
||||
import yaml
|
||||
|
||||
from common import load_platform_config
|
||||
from model.platforms import load_platform_config
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
@@ -42,7 +42,8 @@ class ThePackReadmeNamesTheSpellingsItLeavesOut(unittest.TestCase):
|
||||
nothing about it."""
|
||||
|
||||
def setUp(self):
|
||||
import common
|
||||
from model.platforms import _platform_config_cache
|
||||
from model.profiles import _emulator_profiles_cache
|
||||
import generate_db
|
||||
import generate_pack
|
||||
|
||||
@@ -73,19 +74,19 @@ class ThePackReadmeNamesTheSpellingsItLeavesOut(unittest.TestCase):
|
||||
"emulator": "mesence", "type": "libretro", "systems": ["coleco"],
|
||||
"files": [{"name": "bios.col", "required": True}],
|
||||
}))
|
||||
common._platform_config_cache.clear()
|
||||
common._emulator_profiles_cache.clear()
|
||||
self.addCleanup(common._platform_config_cache.clear)
|
||||
self.addCleanup(common._emulator_profiles_cache.clear)
|
||||
_platform_config_cache.clear()
|
||||
_emulator_profiles_cache.clear()
|
||||
self.addCleanup(_platform_config_cache.clear)
|
||||
self.addCleanup(_emulator_profiles_cache.clear)
|
||||
|
||||
def _readme(self, systems: list[str]) -> str:
|
||||
import common
|
||||
from model.platforms import _platform_config_cache
|
||||
|
||||
Path("platforms/p.yml").write_text(yaml.dump(self.config))
|
||||
Path("platforms/_registry.yml").write_text(yaml.dump({"platforms": {"p": {
|
||||
"install": {"detect": [{"os": os_name} for os_name in systems]},
|
||||
}}}))
|
||||
common._platform_config_cache.clear()
|
||||
_platform_config_cache.clear()
|
||||
texts: dict[str, str] = {}
|
||||
real = self.gp._write_generated_member
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import tests
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from common import _casefold_name_index
|
||||
from resolve.localfile import _casefold_name_index
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
@@ -54,7 +54,7 @@ class APrimaryUnderAnotherCasing(unittest.TestCase):
|
||||
self.by_name.setdefault(name, []).append(sha1)
|
||||
|
||||
def _resolve(self, name: str) -> str:
|
||||
from common import _casefold_index_cache, resolve_local_file
|
||||
from resolve.localfile import _casefold_index_cache, resolve_local_file
|
||||
|
||||
_casefold_index_cache.clear()
|
||||
db = {"files": self.files, "indexes": {"by_name": self.by_name, "by_md5": {},
|
||||
|
||||
@@ -19,7 +19,7 @@ from unittest import mock
|
||||
from pathlib import Path
|
||||
|
||||
import check_freshness as cf
|
||||
from common import yaml_load
|
||||
from model.safeparse import yaml_load
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
|
||||
@@ -19,7 +19,9 @@ import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
import common
|
||||
from model.profiles import _emulator_profiles_cache, load_emulator_profiles
|
||||
from resolve.content import content_fits, size_fits, _masked_sha1_verdict
|
||||
from resolve.localfile import resolve_local_file
|
||||
import generate_pack as builder
|
||||
import packextras
|
||||
from core.romdir import romdir_accepts, walk
|
||||
@@ -191,21 +193,21 @@ class OtherContentTests(unittest.TestCase):
|
||||
config[0x20] ^= 0xFF
|
||||
reconfigured = Path(tmp, "reconfigured.rom")
|
||||
reconfigured.write_bytes(bytes(config))
|
||||
self.assertTrue(common.content_fits(entry_, str(good)))
|
||||
self.assertTrue(common.content_fits(entry_, str(reconfigured)))
|
||||
self.assertTrue(common.content_fits(entry_, str(other))) # past 0x1c000
|
||||
self.assertFalse(common.content_fits(entry_, str(short)))
|
||||
self.assertTrue(content_fits(entry_, str(good)))
|
||||
self.assertTrue(content_fits(entry_, str(reconfigured)))
|
||||
self.assertTrue(content_fits(entry_, str(other))) # past 0x1c000
|
||||
self.assertFalse(content_fits(entry_, str(short)))
|
||||
payload[0x100] ^= 1
|
||||
good.write_bytes(bytes(payload))
|
||||
common._masked_sha1_verdict.cache_clear()
|
||||
self.assertFalse(common.content_fits(entry_, str(good)))
|
||||
_masked_sha1_verdict.cache_clear()
|
||||
self.assertFalse(content_fits(entry_, str(good)))
|
||||
|
||||
def test_size_multiple(self):
|
||||
flash = {"min_size": 65536, "size_multiple": 65536, "validation": ["size"]}
|
||||
self.assertTrue(common.size_fits(flash, 262144))
|
||||
self.assertTrue(common.size_fits(flash, 65536 * 3))
|
||||
self.assertFalse(common.size_fits(flash, 65536 + 1))
|
||||
self.assertFalse(common.size_fits(flash, 0))
|
||||
self.assertTrue(size_fits(flash, 262144))
|
||||
self.assertTrue(size_fits(flash, 65536 * 3))
|
||||
self.assertFalse(size_fits(flash, 65536 + 1))
|
||||
self.assertFalse(size_fits(flash, 0))
|
||||
|
||||
|
||||
class ScannerVerifyManifestAgree(unittest.TestCase):
|
||||
@@ -255,13 +257,13 @@ class ScannerVerifyManifestAgree(unittest.TestCase):
|
||||
" - name: \"<bios>.nvm\"\n path: \"ps2/<bios>.nvm\"\n size: 1024\n"
|
||||
" - name: \"<bios>.mec\"\n path: \"ps2/<bios>.mec\"\n size: 4\n"
|
||||
)
|
||||
common._emulator_profiles_cache.clear()
|
||||
self.profiles = common.load_emulator_profiles(str(self.root / "emulators"))
|
||||
_emulator_profiles_cache.clear()
|
||||
self.profiles = load_emulator_profiles(str(self.root / "emulators"))
|
||||
self.config = {"platform": "Demo", "verification_mode": "existence",
|
||||
"cores": ["demo", "anchor"], "base_destination": "", "systems": {}}
|
||||
|
||||
def tearDown(self):
|
||||
common._emulator_profiles_cache.clear()
|
||||
_emulator_profiles_cache.clear()
|
||||
self._tmp.cleanup()
|
||||
|
||||
def accepted(self) -> set[str]:
|
||||
@@ -269,7 +271,7 @@ class ScannerVerifyManifestAgree(unittest.TestCase):
|
||||
beside an accepted image of its stem."""
|
||||
seed = self.profiles["demo"]["files"][0]
|
||||
images = {n for n in self.IMAGES
|
||||
if common.content_fits(seed, str(self.root / "bios" / "PS2" / n))}
|
||||
if content_fits(seed, str(self.root / "bios" / "PS2" / n))}
|
||||
stems = {n.rsplit(".", 1)[0] for n in images}
|
||||
return images | {n for n in self.COMPANIONS if n.rsplit(".", 1)[0] in stems}
|
||||
|
||||
@@ -300,7 +302,7 @@ class ScannerVerifyManifestAgree(unittest.TestCase):
|
||||
path = str(self.root / "bios" / "PS2" / name)
|
||||
entry_ = {"name": name, "found_by": "content", "validation": ["romdir"],
|
||||
"romdir": MODERN, "source_profile": "labels"}
|
||||
resolved, status = common.resolve_local_file(entry_, self.db)
|
||||
resolved, status = resolve_local_file(entry_, self.db)
|
||||
failure = check_file_validation(path, name, index)
|
||||
with self.subTest(name=name):
|
||||
accepted = name in self.accepted()
|
||||
|
||||
@@ -12,7 +12,7 @@ import tests
|
||||
|
||||
import unittest
|
||||
|
||||
from common import platform_declared_contents
|
||||
from model.declarations import platform_declared_contents
|
||||
from resolve.validation import declaration_settles
|
||||
|
||||
SHA1 = "70cdf57469a208528f78a14275837352e90e20f1"
|
||||
|
||||
@@ -184,7 +184,7 @@ class OneFileThroughTheBrowser(unittest.TestCase):
|
||||
with tempfile.TemporaryDirectory(dir=scratch) as directory:
|
||||
(Path(directory) / "bios").mkdir()
|
||||
(Path(directory) / "bios" / "boot.rom").write_bytes(b"boot")
|
||||
from common import compute_hashes
|
||||
from core.hashing import compute_hashes
|
||||
|
||||
sha1 = compute_hashes(str(Path(directory) / "bios" / "boot.rom"))["sha1"]
|
||||
hashes = {"sha1": {sha1}, "folders": {sha1: {"bios/Maker/Console/"}}}
|
||||
|
||||
@@ -16,7 +16,12 @@ import os
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
import common
|
||||
from model.database import load_database
|
||||
from model.platforms import load_platform_config
|
||||
from model.profiles import load_emulator_profiles, installed_data_refs
|
||||
from model.registry import load_data_dir_registry, list_registered_platforms
|
||||
from resolve.cores import resolve_platform_cores
|
||||
from resolve.standalone import platform_layouts, standalone_set
|
||||
import generate_pack as builder
|
||||
from resolve.validation import deliverable, read_from_system_dir
|
||||
|
||||
@@ -123,19 +128,19 @@ class EveryReaderHasTheTreeOrAReason(unittest.TestCase):
|
||||
|
||||
def test_for_platforms_leaves_no_reader_without_a_reason(self) -> None:
|
||||
platforms_dir = str(REPO_ROOT / "platforms")
|
||||
registry = common.load_data_dir_registry(platforms_dir)
|
||||
profiles = common.load_emulator_profiles(str(REPO_ROOT / "emulators"))
|
||||
registry = load_data_dir_registry(platforms_dir)
|
||||
profiles = load_emulator_profiles(str(REPO_ROOT / "emulators"))
|
||||
unexplained = []
|
||||
for platform in common.list_registered_platforms(platforms_dir):
|
||||
config = common.load_platform_config(platform, platforms_dir)
|
||||
handed = common.standalone_set(config)
|
||||
for core in sorted(common.resolve_platform_cores(config, profiles)):
|
||||
for platform in list_registered_platforms(platforms_dir):
|
||||
config = load_platform_config(platform, platforms_dir)
|
||||
handed = standalone_set(config)
|
||||
for core in sorted(resolve_platform_cores(config, profiles)):
|
||||
profile = profiles[core]
|
||||
if all(standalone for _view, standalone
|
||||
in common.platform_layouts(core, profile, handed)):
|
||||
in platform_layouts(core, profile, handed)):
|
||||
continue
|
||||
trees = [t for t in profile.get("data_directories") or [] if isinstance(t, dict)]
|
||||
installed = common.installed_data_refs(platform)
|
||||
installed = installed_data_refs(platform)
|
||||
for tree in deliverable(trees, False, platform):
|
||||
allowed = registry.get(tree.get("ref"), {}).get("for_platforms")
|
||||
if tree.get("ref") in installed or not read_from_system_dir(tree):
|
||||
@@ -162,9 +167,9 @@ class AmberelecCarriesTheMachines(unittest.TestCase):
|
||||
cwd = os.getcwd()
|
||||
os.chdir(REPO_ROOT)
|
||||
try:
|
||||
config = common.load_platform_config("amberelec", platforms_dir)
|
||||
registry = common.load_data_dir_registry(platforms_dir)
|
||||
profiles = common.load_emulator_profiles(str(REPO_ROOT / "emulators"))
|
||||
config = load_platform_config("amberelec", platforms_dir)
|
||||
registry = load_data_dir_registry(platforms_dir)
|
||||
profiles = load_emulator_profiles(str(REPO_ROOT / "emulators"))
|
||||
trees = builder.core_data_trees(config, profiles, "amberelec", registry)
|
||||
refs: dict = {}
|
||||
members = dict(
|
||||
@@ -194,13 +199,13 @@ class TheCountLineKeepsTreesOutOfTheBaseline(unittest.TestCase):
|
||||
previous = os.getcwd()
|
||||
os.chdir(REPO_ROOT)
|
||||
self.addCleanup(os.chdir, previous)
|
||||
db = common.load_database("database.json")
|
||||
db = load_database("database.json")
|
||||
record = builder.PackRecord()
|
||||
out = io.StringIO()
|
||||
with contextlib.redirect_stdout(out):
|
||||
builder.generate_pack(
|
||||
"myminui", "platforms", db, "bios", "tmp", offline=True, record=record,
|
||||
data_registry=common.load_data_dir_registry("platforms"),
|
||||
data_registry=load_data_dir_registry("platforms"),
|
||||
)
|
||||
line = next(entry for entry in out.getvalue().splitlines() if "files packed" in entry)
|
||||
self.assertIn("(0 baseline + ", line)
|
||||
|
||||
@@ -23,7 +23,8 @@ from unittest import mock
|
||||
|
||||
import yaml
|
||||
|
||||
from common import _emulator_profiles_cache, load_platform_config
|
||||
from model.profiles import _emulator_profiles_cache
|
||||
from model.platforms import load_platform_config
|
||||
from generate_pack import generate_pack
|
||||
from verify import verify_platform
|
||||
|
||||
|
||||
@@ -21,7 +21,8 @@ from pathlib import Path
|
||||
|
||||
import yaml
|
||||
|
||||
import common
|
||||
from model.platforms import _platform_config_cache
|
||||
from model.profiles import load_emulator_profiles, _emulator_profiles_cache
|
||||
import generate_db
|
||||
import generate_pack as builder
|
||||
from resolve.validation import core_size_refusal
|
||||
@@ -86,13 +87,13 @@ class _Collection(unittest.TestCase):
|
||||
)
|
||||
Path("emulators/sized.yml").write_text(SIZED)
|
||||
Path("emulators/unsized.yml").write_text(UNSIZED)
|
||||
common._platform_config_cache.clear()
|
||||
common._emulator_profiles_cache.clear()
|
||||
self.profiles = common.load_emulator_profiles("emulators")
|
||||
_platform_config_cache.clear()
|
||||
_emulator_profiles_cache.clear()
|
||||
self.profiles = load_emulator_profiles("emulators")
|
||||
|
||||
def tearDown(self):
|
||||
common._platform_config_cache.clear()
|
||||
common._emulator_profiles_cache.clear()
|
||||
_platform_config_cache.clear()
|
||||
_emulator_profiles_cache.clear()
|
||||
os.chdir(self._cwd)
|
||||
self._tmp.cleanup()
|
||||
|
||||
@@ -156,8 +157,8 @@ class SizeTheCoreRefuses(_Collection):
|
||||
Path("emulators/sized.yml").write_text(
|
||||
SIZED + " - name: ROM\n path: ROM\n size: 8\n validation: [size]\n"
|
||||
)
|
||||
common._emulator_profiles_cache.clear()
|
||||
self.profiles = common.load_emulator_profiles("emulators")
|
||||
_emulator_profiles_cache.clear()
|
||||
self.profiles = load_emulator_profiles("emulators")
|
||||
self.assertTrue(self._report("sized")["in_repo"])
|
||||
self.assertIn("ROM", self._pack_members())
|
||||
self.assertIn("ROM", {f["dest"] for f in self._manifest()["files"]})
|
||||
|
||||
@@ -313,14 +313,14 @@ class TestPackDeterminism(unittest.TestCase):
|
||||
" system: test-sys\n"
|
||||
" required: true\n"
|
||||
)
|
||||
import common
|
||||
from model.profiles import _emulator_profiles_cache
|
||||
|
||||
common._emulator_profiles_cache.clear()
|
||||
_emulator_profiles_cache.clear()
|
||||
path = generate_emulator_pack(
|
||||
["detcore"], str(self.tmp / "emulators"), self.db, str(self.bios),
|
||||
str(out), offline=True,
|
||||
)
|
||||
common._emulator_profiles_cache.clear()
|
||||
_emulator_profiles_cache.clear()
|
||||
self.assertIsNotNone(path)
|
||||
return Path(path)
|
||||
|
||||
|
||||
@@ -25,7 +25,8 @@ try:
|
||||
import jsonschema
|
||||
except ImportError:
|
||||
jsonschema = None
|
||||
import common
|
||||
from model.profiles import load_emulator_profiles, _emulator_profiles_cache
|
||||
from resolve.directories import directory_members
|
||||
import generate_db
|
||||
import generate_pack as builder
|
||||
import verify
|
||||
@@ -87,10 +88,10 @@ class DirectoryFixture(unittest.TestCase):
|
||||
(self.platforms / "_registry.yml").write_text(
|
||||
yaml.dump({"platforms": {"demo": {"config": "demo.yml"}}})
|
||||
)
|
||||
common._emulator_profiles_cache.clear()
|
||||
_emulator_profiles_cache.clear()
|
||||
|
||||
def tearDown(self):
|
||||
common._emulator_profiles_cache.clear()
|
||||
_emulator_profiles_cache.clear()
|
||||
self._tmp.cleanup()
|
||||
|
||||
def _add(self, relative: str, payload: bytes) -> None:
|
||||
@@ -120,14 +121,14 @@ class DirectoryFixture(unittest.TestCase):
|
||||
|
||||
def _profiles(self, body: str = PROFILE) -> dict:
|
||||
(self.emulators / "demo.yml").write_text(body)
|
||||
common._emulator_profiles_cache.clear()
|
||||
return common.load_emulator_profiles(str(self.emulators))
|
||||
_emulator_profiles_cache.clear()
|
||||
return load_emulator_profiles(str(self.emulators))
|
||||
|
||||
|
||||
class DirectoryMembers(DirectoryFixture):
|
||||
def test_every_file_under_the_tail_is_a_member(self):
|
||||
self.assertEqual(
|
||||
common.directory_members(self._db(), "rtp/2000/"),
|
||||
directory_members(self._db(), "rtp/2000/"),
|
||||
{
|
||||
"rtp/2000/Backdrop/a.png": self.sha1[
|
||||
"Engine/demo/rtp/2000/Backdrop/a.png"
|
||||
@@ -137,19 +138,19 @@ class DirectoryMembers(DirectoryFixture):
|
||||
)
|
||||
|
||||
def test_a_directory_nobody_collected_has_no_member(self):
|
||||
self.assertEqual(common.directory_members(self._db(), "demo/Fonts/"), {})
|
||||
self.assertEqual(directory_members(self._db(), "demo/Fonts/"), {})
|
||||
|
||||
def test_two_trees_answering_one_tail_prove_nothing(self):
|
||||
"""`voice/` under two unrelated parents is two directories, and merging
|
||||
them would hand one emulator the other's files."""
|
||||
self._add("Console/voice/E480.WAV", b"speech")
|
||||
self._add("Other/app/voice/hello.wav", b"another program")
|
||||
self.assertEqual(common.directory_members(self._db(), "voice/"), {})
|
||||
self.assertEqual(directory_members(self._db(), "voice/"), {})
|
||||
|
||||
def test_one_tree_under_a_generic_name_is_enough(self):
|
||||
self._add("Console/voice/E480.WAV", b"speech")
|
||||
self.assertEqual(
|
||||
common.directory_members(self._db(), "voice/"),
|
||||
directory_members(self._db(), "voice/"),
|
||||
{"voice/E480.WAV": self.sha1["Console/voice/E480.WAV"]},
|
||||
)
|
||||
|
||||
|
||||
+18
-17
@@ -238,9 +238,9 @@ class OneResolutionChain(unittest.TestCase):
|
||||
ORDER = ("SHA1", "SHA256", "CRC32", "MD5", "Path suffix")
|
||||
|
||||
def test_the_table_follows_the_code(self):
|
||||
import common
|
||||
from resolve.localfile import resolve_local_file
|
||||
|
||||
source = inspect.getsource(common.resolve_local_file)
|
||||
source = inspect.getsource(resolve_local_file)
|
||||
steps = re.findall(r"# \d+[a-z]?\. (SHA1|SHA256|CRC32|MD5|Path suffix)", source)
|
||||
self.assertEqual(tuple(dict.fromkeys(steps)), self.ORDER)
|
||||
table = _table_rows(_section(_page("verification-modes.md"), "File resolution chain"))
|
||||
@@ -460,13 +460,13 @@ class Md5CompositeDefinition(unittest.TestCase):
|
||||
def test_composite_only_is_read_by_both_checks(self):
|
||||
"""The page said the direct MD5 is tried before the composite, which
|
||||
Recalbox never does for a .zip, and the pack check did the same."""
|
||||
import common
|
||||
from resolve.localfile import resolve_local_file
|
||||
from resolve import validation
|
||||
|
||||
section = _section(_page("verification-modes.md"), "md5_composite (Recalbox ZIP verification)")
|
||||
self.assertIn("zip_digest: composite", section)
|
||||
self.assertNotIn("is tried before reporting a mismatch", section)
|
||||
for function in (common.resolve_local_file, validation.digest_verdict):
|
||||
for function in (resolve_local_file, validation.digest_verdict):
|
||||
self.assertIn('get("zip_digest") == "composite"', inspect.getsource(function))
|
||||
|
||||
|
||||
@@ -493,16 +493,16 @@ class CoreResolutionWrittenOnce(unittest.TestCase):
|
||||
def test_one_statement_matching_the_platforms_and_the_code(self):
|
||||
import yaml
|
||||
|
||||
import common
|
||||
from resolve.cores import resolve_platform_cores, _platform_profiles
|
||||
|
||||
self.assertNotIn("cores: [list]", _page("architecture.md"))
|
||||
# resolve_platform_cores narrows by target, _platform_profiles holds
|
||||
# the strategies.
|
||||
source = inspect.getsource(common._platform_profiles)
|
||||
source = inspect.getsource(_platform_profiles)
|
||||
self.assertIn('not p.get("built_by")', source)
|
||||
self.assertIn('"retroarch" in core_set', source)
|
||||
self.assertIn('config.get("installable_cores")', source)
|
||||
self.assertIn("downloadable_on", inspect.getsource(common.resolve_platform_cores))
|
||||
self.assertIn("downloadable_on", inspect.getsource(resolve_platform_cores))
|
||||
naming = set()
|
||||
for path in (ROOT / "platforms").glob("*.yml"):
|
||||
config = yaml.safe_load(path.read_text(encoding="utf-8")) or {}
|
||||
@@ -667,12 +667,12 @@ class ShortMd5Handling(unittest.TestCase):
|
||||
self.assertEqual(offenders, [])
|
||||
|
||||
def test_the_page_names_what_the_code_does(self):
|
||||
import common
|
||||
from resolve.localfile import resolve_local_file
|
||||
from scraper import batocera_scraper
|
||||
|
||||
scraper = inspect.getsource(batocera_scraper)
|
||||
self.assertIn("_resolve_truncated_md5(value, md5_index) for value in values", scraper)
|
||||
resolver = inspect.getsource(common.resolve_local_file)
|
||||
resolver = inspect.getsource(resolve_local_file)
|
||||
self.assertIn("cut_md5_owner(cut, by_md5)", resolver)
|
||||
self.assertIn("_md5_name_ok(path)", resolver)
|
||||
section = _section(_page("verification-modes.md"), "MD5 shorter than 32 characters (Batocera)")
|
||||
@@ -695,9 +695,9 @@ class RegistryKeysDocumented(unittest.TestCase):
|
||||
self.assertEqual(sorted(k for k in keys if not re.search(rf"\b{k}\b", page)), [])
|
||||
|
||||
def test_the_page_says_the_registry_reaches_the_config(self):
|
||||
import common
|
||||
from model import platforms
|
||||
|
||||
source = inspect.getsource(common.load_platform_config)
|
||||
source = inspect.getsource(platforms.load_platform_config)
|
||||
self.assertIn("config[key] = val", source)
|
||||
section = _section(_page("adding-a-platform.md"), "Step 2: Register the platform")
|
||||
self.assertIn("copies every registry key", section)
|
||||
@@ -710,9 +710,9 @@ class ResolutionSkipsNamesForUnheldFiles(unittest.TestCase):
|
||||
disk, skips every step that answers by name and returns not_found."""
|
||||
|
||||
def test_the_page_names_both_cases_the_code_guards(self):
|
||||
import common
|
||||
from resolve.localfile import resolve_local_file
|
||||
|
||||
source = inspect.getsource(common.resolve_local_file)
|
||||
source = inspect.getsource(resolve_local_file)
|
||||
self.assertIn('unsourceable = bool(file_entry.get("unsourceable")) or own_file_absent', source)
|
||||
for guard in (
|
||||
"if not has_strong_hash and not unsourceable:",
|
||||
@@ -1114,9 +1114,9 @@ class PlatformListsFollowTheRegistry(unittest.TestCase):
|
||||
return names
|
||||
|
||||
def _modes(self) -> dict[str, str]:
|
||||
import common
|
||||
from model import platforms
|
||||
|
||||
return {key: common.load_platform_config(key, str(ROOT / "platforms")).get("verification_mode")
|
||||
return {key: platforms.load_platform_config(key, str(ROOT / "platforms")).get("verification_mode")
|
||||
for key in _registry()}
|
||||
|
||||
def _split(self, text: str) -> set[str]:
|
||||
@@ -2027,8 +2027,9 @@ class RegionFreeRuleNamesWhereItDoesNotHold(unittest.TestCase):
|
||||
where it is the only PlayStation core the filter drops it."""
|
||||
|
||||
def test_every_platform_that_drops_a_named_file_is_named(self):
|
||||
from common import (list_registered_platforms, load_emulator_profiles,
|
||||
load_platform_config)
|
||||
from model.registry import list_registered_platforms
|
||||
from model.profiles import load_emulator_profiles
|
||||
from model.platforms import load_platform_config
|
||||
from region import WORLD, platform_region_index
|
||||
|
||||
section = _section(_page("advanced-usage.md"), "Region filtering")
|
||||
|
||||
@@ -85,7 +85,7 @@ class TheDownloadTablesFollowTheRegistry(unittest.TestCase):
|
||||
def test_every_detected_system_lists_the_platform(self):
|
||||
import yaml
|
||||
|
||||
from common import load_platform_config
|
||||
from model.platforms import load_platform_config
|
||||
|
||||
registry = yaml.safe_load(_read("platforms/_registry.yml"))
|
||||
page = _which_pack()
|
||||
@@ -186,7 +186,7 @@ class DownloadLinksKeepTheirAddress(unittest.TestCase):
|
||||
def test_the_generated_readme_links_every_get_page(self):
|
||||
if not RECORD.get("packs"):
|
||||
self.skipTest("release.json is not written")
|
||||
from common import list_registered_platforms, list_release_pack_platforms
|
||||
from model.registry import list_registered_platforms, list_release_pack_platforms
|
||||
|
||||
readme = _read("README.md")
|
||||
table = _section(readme, "## Or download a ZIP")
|
||||
@@ -212,7 +212,8 @@ class DownloadLinksKeepTheirAddress(unittest.TestCase):
|
||||
"""KNULLI, AmberELEC and EmuELEC were registered after the recorded
|
||||
release, and the platforms without release_pack never get a ZIP: a
|
||||
row for them offers the command."""
|
||||
from common import list_registered_platforms, load_platform_config
|
||||
from model.registry import list_registered_platforms
|
||||
from model.platforms import load_platform_config
|
||||
import generate_site
|
||||
|
||||
record = release_record.load_advertised()
|
||||
@@ -445,7 +446,9 @@ class CoreCountsReadFromTheData(unittest.TestCase):
|
||||
|
||||
def test_the_run_count_is_what_the_platforms_resolve(self):
|
||||
import yaml
|
||||
from common import load_emulator_profiles, load_platform_config, resolve_platform_cores
|
||||
from model.profiles import load_emulator_profiles
|
||||
from model.platforms import load_platform_config
|
||||
from resolve.cores import resolve_platform_cores
|
||||
|
||||
from tests import sitepages
|
||||
|
||||
|
||||
+48
-52
@@ -33,20 +33,14 @@ from unittest import mock
|
||||
|
||||
from model import largefiles
|
||||
import yaml
|
||||
from common import (
|
||||
build_zip_contents_index,
|
||||
check_inside_zip,
|
||||
compute_hashes,
|
||||
expand_platform_declared_names,
|
||||
group_identical_platforms,
|
||||
load_emulator_profiles,
|
||||
load_platform_config,
|
||||
md5_composite,
|
||||
parse_md5_list,
|
||||
resolve_local_file,
|
||||
resolve_platform_cores,
|
||||
safe_extract_zip,
|
||||
)
|
||||
from core.ziptools import build_zip_contents_index, check_inside_zip, safe_extract_zip
|
||||
from core.hashing import compute_hashes, md5_composite, parse_md5_list
|
||||
from model.declarations import expand_platform_declared_names
|
||||
from resolve.grouping import group_identical_platforms
|
||||
from model.profiles import load_emulator_profiles
|
||||
from model.platforms import load_platform_config
|
||||
from resolve.localfile import resolve_local_file
|
||||
from resolve.cores import resolve_platform_cores
|
||||
from resolve.truth import diff_platform_truth, generate_platform_truth
|
||||
from resolve.validation import _build_validation_index, check_file_validation, filter_files_by_mode
|
||||
from verify import (
|
||||
@@ -85,7 +79,7 @@ class TestE2E(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
# Clear emulator profile cache to avoid stale data between tests
|
||||
from common import _emulator_profiles_cache
|
||||
from model.profiles import _emulator_profiles_cache
|
||||
|
||||
_emulator_profiles_cache.clear()
|
||||
|
||||
@@ -917,7 +911,7 @@ class TestE2E(unittest.TestCase):
|
||||
|
||||
def test_24b_a_held_group_member_makes_the_others_optional(self):
|
||||
"""RetroBat's group: one file held is enough (batocera-systems/Program.cs)."""
|
||||
from common import _platform_config_cache
|
||||
from model.platforms import _platform_config_cache
|
||||
|
||||
with open(os.path.join(self.platforms_dir, "test_md5.yml")) as fh:
|
||||
config = yaml.safe_load(fh)
|
||||
@@ -1893,21 +1887,21 @@ class TestE2E(unittest.TestCase):
|
||||
|
||||
def test_load_target_config(self):
|
||||
self._write_target_fixtures()
|
||||
from common import load_target_config
|
||||
from model.targets import load_target_config
|
||||
|
||||
cores = load_target_config("testplatform", "target-minimal", self.platforms_dir)
|
||||
self.assertEqual(cores, {"core_a"})
|
||||
|
||||
def test_target_alias_resolution(self):
|
||||
self._write_target_fixtures()
|
||||
from common import load_target_config
|
||||
from model.targets import load_target_config
|
||||
|
||||
cores = load_target_config("testplatform", "full", self.platforms_dir)
|
||||
self.assertEqual(cores, {"core_a", "core_b", "core_d"})
|
||||
|
||||
def test_target_unknown_error(self):
|
||||
self._write_target_fixtures()
|
||||
from common import load_target_config
|
||||
from model.targets import load_target_config
|
||||
|
||||
with self.assertRaises(ValueError) as ctx:
|
||||
load_target_config("testplatform", "nonexistent", self.platforms_dir)
|
||||
@@ -1916,7 +1910,7 @@ class TestE2E(unittest.TestCase):
|
||||
|
||||
def test_target_override_add_remove(self):
|
||||
self._write_target_fixtures()
|
||||
from common import load_target_config
|
||||
from model.targets import load_target_config
|
||||
|
||||
cores = load_target_config("testplatform", "full", self.platforms_dir)
|
||||
self.assertIn("core_d", cores)
|
||||
@@ -1927,7 +1921,7 @@ class TestE2E(unittest.TestCase):
|
||||
def test_target_default_override_reaches_every_target(self):
|
||||
"""`_default` drops a name on every target, then the target adds its own."""
|
||||
self._write_target_fixtures()
|
||||
from common import load_target_config
|
||||
from model.targets import load_target_config
|
||||
|
||||
targets_dir = os.path.join(self.platforms_dir, "targets")
|
||||
overrides = {
|
||||
@@ -1953,7 +1947,7 @@ class TestE2E(unittest.TestCase):
|
||||
|
||||
def test_target_single_target_noop(self):
|
||||
self._write_target_fixtures()
|
||||
from common import load_target_config
|
||||
from model.targets import load_target_config
|
||||
|
||||
cores = load_target_config("singleplatform", "only-target", self.platforms_dir)
|
||||
self.assertEqual(cores, {"core_a", "core_b"})
|
||||
@@ -1974,7 +1968,7 @@ class TestE2E(unittest.TestCase):
|
||||
}
|
||||
with open(os.path.join(targets_dir, "childplatform.yml"), "w") as f:
|
||||
yaml.dump(child_config, f)
|
||||
from common import load_target_config
|
||||
from model.targets import load_target_config
|
||||
|
||||
parent = load_target_config(
|
||||
"testplatform", "target-minimal", self.platforms_dir
|
||||
@@ -2441,7 +2435,7 @@ class TestE2E(unittest.TestCase):
|
||||
|
||||
def test_133_platform_system_filter_normalized(self):
|
||||
"""_norm_system_id normalization matches with manufacturer prefix."""
|
||||
from common import _norm_system_id
|
||||
from model.systems import _norm_system_id
|
||||
|
||||
self.assertEqual(
|
||||
_norm_system_id("sony-playstation"),
|
||||
@@ -2452,7 +2446,7 @@ class TestE2E(unittest.TestCase):
|
||||
"""list_platform_system_ids lists systems from a platform YAML."""
|
||||
import io
|
||||
|
||||
from common import list_platform_system_ids
|
||||
from model.cliargs import list_platform_system_ids
|
||||
|
||||
config = {
|
||||
"platform": "ListSysTest",
|
||||
@@ -2507,7 +2501,7 @@ class TestE2E(unittest.TestCase):
|
||||
with open(file_b, "wb") as f:
|
||||
f.write(b"system_b")
|
||||
|
||||
from common import compute_hashes
|
||||
from core.hashing import compute_hashes
|
||||
|
||||
ha = compute_hashes(file_a)
|
||||
hb = compute_hashes(file_b)
|
||||
@@ -2557,7 +2551,8 @@ class TestE2E(unittest.TestCase):
|
||||
with open(os.path.join(plat_dir, "splitplat.yml"), "w") as f:
|
||||
yaml.dump(plat_cfg, f)
|
||||
|
||||
from common import build_zip_contents_index, load_emulator_profiles
|
||||
from core.ziptools import build_zip_contents_index
|
||||
from model.profiles import load_emulator_profiles
|
||||
from generate_pack import generate_split_packs
|
||||
|
||||
zip_contents = build_zip_contents_index(db)
|
||||
@@ -2594,7 +2589,7 @@ class TestE2E(unittest.TestCase):
|
||||
|
||||
def test_136_derive_manufacturer(self):
|
||||
"""derive_manufacturer extracts manufacturer correctly."""
|
||||
from common import derive_manufacturer
|
||||
from model.systems import derive_manufacturer
|
||||
|
||||
# From system ID prefix
|
||||
self.assertEqual(derive_manufacturer("sony-playstation", {}), "Sony")
|
||||
@@ -2738,7 +2733,7 @@ class TestE2E(unittest.TestCase):
|
||||
bios_file = os.path.join(bios_dir, "scph5501.bin")
|
||||
with open(bios_file, "wb") as f:
|
||||
f.write(b"ps1_bios_content")
|
||||
from common import compute_hashes
|
||||
from core.hashing import compute_hashes
|
||||
|
||||
h = compute_hashes(bios_file)
|
||||
|
||||
@@ -2783,7 +2778,7 @@ class TestE2E(unittest.TestCase):
|
||||
with open(os.path.join(plat_dir, "testplat.yml"), "w") as f:
|
||||
yaml.dump(plat_cfg, f)
|
||||
|
||||
from common import build_zip_contents_index
|
||||
from core.ziptools import build_zip_contents_index
|
||||
from generate_pack import generate_md5_pack
|
||||
|
||||
zip_contents = build_zip_contents_index(db)
|
||||
@@ -3404,7 +3399,7 @@ class TestE2E(unittest.TestCase):
|
||||
_yaml.dump(profile, f)
|
||||
|
||||
# Clear profile cache so fresh load picks up our file
|
||||
from common import _emulator_profiles_cache
|
||||
from model.profiles import _emulator_profiles_cache
|
||||
|
||||
_emulator_profiles_cache.clear()
|
||||
|
||||
@@ -3434,7 +3429,7 @@ class TestE2E(unittest.TestCase):
|
||||
def test_169_generate_truth_mode_filtering(self):
|
||||
"""generate_platform_truth excludes standalone-only files for all_libretro."""
|
||||
import yaml as _yaml
|
||||
from common import _emulator_profiles_cache
|
||||
from model.profiles import _emulator_profiles_cache
|
||||
|
||||
profile = {
|
||||
"emulator": "DualMode",
|
||||
@@ -3484,7 +3479,7 @@ class TestE2E(unittest.TestCase):
|
||||
def test_170_generate_truth_standalone_cores(self):
|
||||
"""generate_platform_truth uses standalone mode for standalone_cores."""
|
||||
import yaml as _yaml
|
||||
from common import _emulator_profiles_cache
|
||||
from model.profiles import _emulator_profiles_cache
|
||||
|
||||
profile = {
|
||||
"emulator": "DualCore",
|
||||
@@ -3527,7 +3522,7 @@ class TestE2E(unittest.TestCase):
|
||||
def test_171_generate_truth_dedup_required_wins(self):
|
||||
"""Dedup merges cores and required=True wins over required=False."""
|
||||
import yaml as _yaml
|
||||
from common import _emulator_profiles_cache
|
||||
from model.profiles import _emulator_profiles_cache
|
||||
|
||||
core_a = {
|
||||
"emulator": "CoreA",
|
||||
@@ -3582,7 +3577,7 @@ class TestE2E(unittest.TestCase):
|
||||
def test_172_generate_truth_coverage_metadata(self):
|
||||
"""Coverage tracks profiled vs unprofiled cores."""
|
||||
import yaml as _yaml
|
||||
from common import _emulator_profiles_cache
|
||||
from model.profiles import _emulator_profiles_cache
|
||||
|
||||
profile = {
|
||||
"emulator": "ProfiledCore",
|
||||
@@ -3747,7 +3742,7 @@ class TestE2E(unittest.TestCase):
|
||||
A YAML without one, an inheriting child included, is refused rather
|
||||
than written with a stand-in or its parent's version.
|
||||
"""
|
||||
from common import _platform_config_cache
|
||||
from model.platforms import _platform_config_cache
|
||||
from generate_pack import generate_manifest
|
||||
|
||||
registry_path = os.path.join(self.platforms_dir, "_test_registry_version.yml")
|
||||
@@ -3803,7 +3798,7 @@ class TestE2E(unittest.TestCase):
|
||||
entry["sha1"] = "0" * 40 # upstream hash, absent from the repo
|
||||
with open(config_path, "w") as fh:
|
||||
yaml.dump(config, fh)
|
||||
from common import _platform_config_cache
|
||||
from model.platforms import _platform_config_cache
|
||||
|
||||
_platform_config_cache.clear()
|
||||
|
||||
@@ -4405,7 +4400,7 @@ class TestE2E(unittest.TestCase):
|
||||
|
||||
# No profile for core_b (unprofiled)
|
||||
# Clear cache so the new profile is picked up
|
||||
from common import _emulator_profiles_cache
|
||||
from model.profiles import _emulator_profiles_cache
|
||||
|
||||
_emulator_profiles_cache.clear()
|
||||
profiles = load_emulator_profiles(self.emulators_dir)
|
||||
@@ -4509,7 +4504,7 @@ class TestE2E(unittest.TestCase):
|
||||
|
||||
def test_175_registry_merge_cores(self):
|
||||
"""load_platform_config merges cores from _registry.yml."""
|
||||
from common import _platform_config_cache
|
||||
from model.platforms import _platform_config_cache
|
||||
|
||||
# Platform YAML with 1 core
|
||||
config = {
|
||||
@@ -4540,7 +4535,8 @@ class TestE2E(unittest.TestCase):
|
||||
|
||||
def test_176_all_libretro_in_list(self):
|
||||
"""resolve_platform_cores expands all_libretro/retroarch in a list."""
|
||||
from common import load_emulator_profiles, resolve_platform_cores
|
||||
from model.profiles import load_emulator_profiles
|
||||
from resolve.cores import resolve_platform_cores
|
||||
|
||||
# Create a libretro profile and a standalone profile
|
||||
for name, ptype in [("lr_core", "libretro"), ("sa_core", "standalone")]:
|
||||
@@ -5253,7 +5249,7 @@ struct BurnDriver BurnDrvneogeo = {
|
||||
with zipfile.ZipFile(zip_src, "w", zipfile.ZIP_DEFLATED) as zf:
|
||||
info = zipfile.ZipInfo("rom.bin", date_time=(2020, 6, 15, 12, 0, 0))
|
||||
zf.writestr(info, b"rom_content_bytes")
|
||||
from common import compute_hashes
|
||||
from core.hashing import compute_hashes
|
||||
|
||||
h = compute_hashes(zip_src)
|
||||
|
||||
@@ -5427,7 +5423,7 @@ struct BurnDriver BurnDrvneogeo = {
|
||||
"""resolve_local_file matches files by declared sha256."""
|
||||
import tempfile
|
||||
|
||||
from common import resolve_local_file
|
||||
from resolve.localfile import resolve_local_file
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
path = os.path.join(tmpdir, "SNES_dsp1.rom")
|
||||
@@ -5472,7 +5468,7 @@ struct BurnDriver BurnDrvneogeo = {
|
||||
import tempfile
|
||||
import urllib.error
|
||||
|
||||
import common
|
||||
from model.largefiles import fetch_large_file
|
||||
|
||||
attempts = []
|
||||
|
||||
@@ -5503,7 +5499,7 @@ struct BurnDriver BurnDrvneogeo = {
|
||||
with tempfile.TemporaryDirectory() as tmpdir, mock.patch.dict(
|
||||
os.environ, {"RETROBIOS_OFFLINE": ""}
|
||||
):
|
||||
path = common.fetch_large_file(
|
||||
path = fetch_large_file(
|
||||
"MAME 0.174 Arcade XML.dat", dest_dir=tmpdir
|
||||
)
|
||||
self.assertIsNotNone(path)
|
||||
@@ -5534,7 +5530,7 @@ struct BurnDriver BurnDrvneogeo = {
|
||||
import tempfile
|
||||
import zlib
|
||||
|
||||
from common import resolve_local_file
|
||||
from resolve.localfile import resolve_local_file
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
data = b"exos rom bytes" * 100
|
||||
@@ -5574,7 +5570,7 @@ struct BurnDriver BurnDrvneogeo = {
|
||||
"""Name resolution falls back to a case-insensitive match."""
|
||||
import tempfile
|
||||
|
||||
from common import resolve_local_file
|
||||
from resolve.localfile import resolve_local_file
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
path = os.path.join(tmpdir, "VEC_Minestorm.vec")
|
||||
@@ -5605,7 +5601,7 @@ struct BurnDriver BurnDrvneogeo = {
|
||||
import hashlib as hl
|
||||
import tempfile
|
||||
|
||||
from common import resolve_local_file
|
||||
from resolve.localfile import resolve_local_file
|
||||
|
||||
rom = b"inner rom bytes"
|
||||
rom_md5 = hl.md5(rom).hexdigest()
|
||||
@@ -6075,7 +6071,7 @@ struct BurnDriver BurnDrvneogeo = {
|
||||
self.assertNotIn("rgn_jp.bin", names)
|
||||
|
||||
def test_verify_platform_region_matches_the_pack(self):
|
||||
from common import load_platform_config
|
||||
from model.platforms import load_platform_config
|
||||
from verify import verify_platform
|
||||
|
||||
self._create_region_fixtures()
|
||||
@@ -6773,7 +6769,7 @@ class StandaloneModeRequiresAStandaloneBuild(unittest.TestCase):
|
||||
profile loses every ``path:`` and drops its files at the root."""
|
||||
|
||||
def test_libretro_only_profile_keeps_its_layout(self):
|
||||
from common import runs_standalone
|
||||
from resolve.layout import runs_standalone
|
||||
|
||||
libretro_only = {"type": "libretro", "cores": ["scummvm"]}
|
||||
dual = {"type": "standalone + libretro", "cores": ["dolphin"]}
|
||||
@@ -6800,7 +6796,7 @@ class OneOfASearchList(unittest.TestCase):
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
from common import _emulator_profiles_cache
|
||||
from model.profiles import _emulator_profiles_cache
|
||||
|
||||
_emulator_profiles_cache.clear()
|
||||
repo = Path(__file__).resolve().parent.parent
|
||||
@@ -6985,7 +6981,7 @@ class OneOfASearchList(unittest.TestCase):
|
||||
def test_an_archive_needs_one_member_of_a_set(self):
|
||||
import zlib
|
||||
|
||||
from common import holds_required_members
|
||||
from resolve.archives import holds_required_members
|
||||
|
||||
path = self.root / "set.zip"
|
||||
with zipfile.ZipFile(path, "w") as zf:
|
||||
@@ -7066,7 +7062,7 @@ class AnArchiveIsAMemberOfASet(unittest.TestCase):
|
||||
def _fixture(self, held: bool) -> dict:
|
||||
import zlib
|
||||
|
||||
from common import _emulator_profiles_cache
|
||||
from model.profiles import _emulator_profiles_cache
|
||||
|
||||
_emulator_profiles_cache.clear()
|
||||
repo = Path(__file__).resolve().parent.parent
|
||||
|
||||
@@ -240,7 +240,7 @@ class CoreFilesGoUnderTheStatedFolder(unittest.TestCase):
|
||||
/storage/roms itself, where no core reads them."""
|
||||
|
||||
def test_core_destination_wins_over_the_guess(self):
|
||||
from common import declared_root
|
||||
from model.declarations import declared_root
|
||||
|
||||
files = [{"destination": f"bios/f{i}"} for i in range(3)]
|
||||
files.append({"destination": "ports/diablo/diabdat.mpq"})
|
||||
|
||||
@@ -80,7 +80,7 @@ class APlaceholderIsAnsweredByEvidence(unittest.TestCase):
|
||||
|
||||
import yaml
|
||||
|
||||
from common import _emulator_profiles_cache
|
||||
from model.profiles import _emulator_profiles_cache
|
||||
from generate_pack import generate_emulator_pack
|
||||
from verify import verify_emulator
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
import common
|
||||
from model.platforms import load_platform_config, _shared_yml_cache, _platform_config_cache
|
||||
from export_native import load_inputs
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||
@@ -24,10 +24,10 @@ REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||
|
||||
class TheNativeLayerIsThePlatformsOwn(unittest.TestCase):
|
||||
def setUp(self):
|
||||
common._platform_config_cache.clear()
|
||||
common._shared_yml_cache.clear()
|
||||
self.addCleanup(common._platform_config_cache.clear)
|
||||
self.addCleanup(common._shared_yml_cache.clear)
|
||||
_platform_config_cache.clear()
|
||||
_shared_yml_cache.clear()
|
||||
self.addCleanup(_platform_config_cache.clear)
|
||||
self.addCleanup(_shared_yml_cache.clear)
|
||||
|
||||
def test_shared_and_mirrored_entries_are_left_out(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
@@ -48,7 +48,7 @@ class TheNativeLayerIsThePlatformsOwn(unittest.TestCase):
|
||||
" - name: dsp_rom.bin\n destination: dolphin-emu/Sys/GC/dsp_rom.bin\n"
|
||||
" curated: true\n"
|
||||
)
|
||||
pack_view = common.load_platform_config("demo", str(platforms))
|
||||
pack_view = load_platform_config("demo", str(platforms))
|
||||
_truth, native = load_inputs("demo", platforms / "truth", str(platforms))
|
||||
|
||||
self.assertEqual(
|
||||
|
||||
@@ -296,7 +296,7 @@ def _parse_dat(text: str) -> dict[tuple[str, str], dict[str, str]]:
|
||||
|
||||
def _parse_es_bios(text: str) -> dict[tuple[str, str], dict[str, str]]:
|
||||
"""Each bios element of an es_bios.xml, keyed by system and path."""
|
||||
from common import parse_untrusted_xml
|
||||
from model.safeparse import parse_untrusted_xml
|
||||
|
||||
root = parse_untrusted_xml(text)
|
||||
elements: dict[tuple[str, str], dict[str, str]] = {}
|
||||
@@ -315,7 +315,7 @@ class ReportedChangesAreTheDiff(unittest.TestCase):
|
||||
entry, or a maintainer checks the diff against a list that differs."""
|
||||
|
||||
def _run(self, platform: str, filename: str) -> tuple[list[dict], str, str, dict]:
|
||||
from common import load_platform_config, native_layer
|
||||
from model.platforms import load_platform_config, native_layer
|
||||
from exporter import discover_exporters
|
||||
from resolve.reconcile import build_native_model
|
||||
|
||||
@@ -392,7 +392,7 @@ class ReportedChangesAreTheDiff(unittest.TestCase):
|
||||
def test_retropie(self):
|
||||
"""Each addition is a name a help sentence gains, and no other: the
|
||||
report counted every file a profiled core reads as added."""
|
||||
from common import load_platform_config, native_layer
|
||||
from model.platforms import load_platform_config, native_layer
|
||||
from exporter import discover_exporters
|
||||
from resolve.reconcile import build_native_model
|
||||
|
||||
@@ -550,7 +550,7 @@ class RemovalCandidatesNeedAReadingNoCoreAnswers(unittest.TestCase):
|
||||
self.assertIn("corea", found[0]["reason"])
|
||||
|
||||
def test_unresolved_names_skip_the_all_libretro_markers(self):
|
||||
from common import unresolved_platform_cores
|
||||
from resolve.cores import unresolved_platform_cores
|
||||
|
||||
config = {"cores": ["retroarch", "all_libretro", "corea", "nope"]}
|
||||
self.assertEqual(unresolved_platform_cores(config, self.PROFILES), {"nope"})
|
||||
|
||||
@@ -30,12 +30,9 @@ import zipfile
|
||||
from collections import OrderedDict
|
||||
from pathlib import Path
|
||||
|
||||
from common import (
|
||||
list_registered_platforms,
|
||||
load_platform_config,
|
||||
native_layer,
|
||||
parse_untrusted_xml,
|
||||
)
|
||||
from model.registry import list_registered_platforms
|
||||
from model.platforms import load_platform_config, native_layer
|
||||
from model.safeparse import parse_untrusted_xml
|
||||
from exporter import discover_exporters
|
||||
from exporter.base_exporter import BaseExporter
|
||||
from export_native import (
|
||||
|
||||
@@ -13,7 +13,7 @@ import tests
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from common import PROFILE_IDENTITY_FIELDS
|
||||
from model.profiles import PROFILE_IDENTITY_FIELDS
|
||||
from packextras import _collect_emulator_extras
|
||||
from verify import find_undeclared_files
|
||||
|
||||
|
||||
@@ -14,7 +14,8 @@ import tests
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from common import load_platform_config, load_platform_registry
|
||||
from model.platforms import load_platform_config
|
||||
from model.registry import load_platform_registry
|
||||
from generate_readme import extract_notes, extract_targets
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||
|
||||
@@ -153,7 +153,7 @@ class ReadersFollowTheDataTrees(unittest.TestCase):
|
||||
def tearDown(self):
|
||||
import os
|
||||
|
||||
from common import forget_data_dir_index
|
||||
from resolve.datadirs import forget_data_dir_index
|
||||
|
||||
os.chdir(self._previous)
|
||||
forget_data_dir_index()
|
||||
@@ -206,7 +206,7 @@ class TheDestinationBasenameComesLast(unittest.TestCase):
|
||||
self._tree.cleanup()
|
||||
|
||||
def test_the_resolver_keeps_the_entry_name(self):
|
||||
from common import resolve_local_file
|
||||
from resolve.localfile import resolve_local_file
|
||||
|
||||
path, status = resolve_local_file(
|
||||
{**self.entry, "source_profile": "melonds-nightly"}, self.db,
|
||||
@@ -222,7 +222,7 @@ class TheDestinationBasenameComesLast(unittest.TestCase):
|
||||
|
||||
def test_a_descriptive_name_still_reaches_the_basename(self):
|
||||
"""name: "MDA font ROM", path: "mda.rom" is the case the basename step serves."""
|
||||
from common import resolve_local_file
|
||||
from resolve.localfile import resolve_local_file
|
||||
|
||||
path, _ = resolve_local_file(
|
||||
{"name": "Wii NAND image", "path": "nand.bin"}, self.db, dest_hint="nand.bin",
|
||||
@@ -242,10 +242,10 @@ class EveryReaderIsTheEmulatorPackFile(unittest.TestCase):
|
||||
import json
|
||||
import os
|
||||
|
||||
from common import (
|
||||
build_zip_contents_index, load_data_dir_registry,
|
||||
load_emulator_profiles, resolve_local_file,
|
||||
)
|
||||
from core.ziptools import build_zip_contents_index
|
||||
from model.registry import load_data_dir_registry
|
||||
from model.profiles import load_emulator_profiles
|
||||
from resolve.localfile import resolve_local_file
|
||||
|
||||
db_path = REPO_ROOT / "database.json"
|
||||
if not db_path.exists():
|
||||
|
||||
@@ -18,7 +18,7 @@ import unittest
|
||||
from pathlib import Path
|
||||
|
||||
import generate_db
|
||||
from common import resolve_local_file
|
||||
from resolve.localfile import resolve_local_file
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||
|
||||
@@ -107,7 +107,7 @@ class AReleaseNamedAfterTheTree(unittest.TestCase):
|
||||
|
||||
def test_only_whole_leading_words_name_the_tree(self):
|
||||
"""dolphin-mmjr2 is not a release of dolphin-mmjr: mmjr2 is one word."""
|
||||
from common import _owner_tokens
|
||||
from resolve.ownership import _owner_tokens
|
||||
|
||||
self.assertNotIn("dolphinmmjr", _owner_tokens({"source_profile": "dolphin-mmjr2"}))
|
||||
self.assertIn("cxbxreloaded", _owner_tokens({"source_profile": "cxbx-reloaded-2023"}))
|
||||
@@ -121,7 +121,7 @@ class AnotherMachinesRomIsNotServed(unittest.TestCase):
|
||||
def test_np2pi_does_not_receive_the_apple_ii_rom(self):
|
||||
import yaml
|
||||
|
||||
from common import load_database
|
||||
from model.database import load_database
|
||||
|
||||
if not (REPO_ROOT / "database.json").is_file():
|
||||
self.skipTest("database.json is absent")
|
||||
|
||||
@@ -18,7 +18,7 @@ import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from common import resolve_local_file
|
||||
from resolve.localfile import resolve_local_file
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
@@ -160,7 +160,7 @@ class RetailDashboardTree(unittest.TestCase):
|
||||
def test_partition_c_resolves_by_path_for_both_importers(self):
|
||||
import yaml
|
||||
|
||||
from common import load_database
|
||||
from model.database import load_database
|
||||
|
||||
db_path = REPO_ROOT / "database.json"
|
||||
if not db_path.exists():
|
||||
|
||||
@@ -19,7 +19,7 @@ from pathlib import Path
|
||||
|
||||
import yaml
|
||||
|
||||
from common import load_platform_config
|
||||
from model.platforms import load_platform_config
|
||||
from generate_pack import generate_manifest, generate_pack
|
||||
from verify import verify_platform
|
||||
|
||||
|
||||
@@ -20,14 +20,11 @@ import re
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from common import (
|
||||
build_zip_contents_index,
|
||||
load_data_dir_registry,
|
||||
load_database,
|
||||
load_emulator_profiles,
|
||||
resolution_is_hash_exact,
|
||||
resolve_local_file,
|
||||
)
|
||||
from core.ziptools import build_zip_contents_index
|
||||
from model.registry import load_data_dir_registry
|
||||
from model.database import load_database
|
||||
from model.profiles import load_emulator_profiles
|
||||
from resolve.localfile import resolution_is_hash_exact, resolve_local_file
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
@@ -201,7 +198,7 @@ class APlatformEntryTakesNoOtherEmulatorsTree(unittest.TestCase):
|
||||
|
||||
def test_the_emuelec_entry_is_not_served_xrick(self):
|
||||
os.chdir(self._cwd)
|
||||
from common import load_platform_config
|
||||
from model.platforms import load_platform_config
|
||||
|
||||
config = load_platform_config("emuelec", str(REPO_ROOT / "platforms"))
|
||||
entry = config["systems"]["vvvvvv"]["files"][0]
|
||||
@@ -330,7 +327,7 @@ class ForeignCopyYieldsToADataDirectory(unittest.TestCase):
|
||||
def test_the_data_directory_answers_before_another_emulators_copy(self):
|
||||
import tempfile
|
||||
|
||||
from common import resolve_local_file
|
||||
from resolve.localfile import resolve_local_file
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
previous = os.getcwd()
|
||||
@@ -371,7 +368,7 @@ class NameStepPrefersTheOwnersCopy(unittest.TestCase):
|
||||
def test_the_copy_stored_with_the_profile_wins(self):
|
||||
import tempfile
|
||||
|
||||
from common import resolve_local_file
|
||||
from resolve.localfile import resolve_local_file
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
previous = os.getcwd()
|
||||
|
||||
@@ -11,7 +11,7 @@ from pathlib import Path
|
||||
|
||||
import yaml
|
||||
|
||||
from common import load_emulator_profiles
|
||||
from model.profiles import load_emulator_profiles
|
||||
from region import REGIONS
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
|
||||
@@ -16,7 +16,7 @@ import unittest
|
||||
from pathlib import Path
|
||||
|
||||
import game_rules
|
||||
from common import load_emulator_profiles
|
||||
from model.profiles import load_emulator_profiles
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
|
||||
@@ -236,7 +236,7 @@ class CommittedData(unittest.TestCase):
|
||||
setups = load_setups(ROOT / "platforms" / "romfolders")
|
||||
if not setups:
|
||||
self.skipTest("no setup scraped")
|
||||
from common import load_emulator_profiles
|
||||
from model.profiles import load_emulator_profiles
|
||||
from romfolders import ProfileResolver
|
||||
|
||||
resolver = SystemResolver.from_repo(str(ROOT / "emulators"), str(ROOT / "platforms"))
|
||||
@@ -257,7 +257,7 @@ class CommittedData(unittest.TestCase):
|
||||
unrecognised GBA game got none of the nintendo-gba files. A CD
|
||||
folder run by mednafen_pce_fast, which lists nec-pc-engine, got no
|
||||
System Card."""
|
||||
from common import load_emulator_profiles
|
||||
from model.profiles import load_emulator_profiles
|
||||
from romfolders import ProfileResolver, folder_names
|
||||
|
||||
setups = load_setups(ROOT / "platforms" / "romfolders")
|
||||
@@ -301,7 +301,7 @@ class CommittedData(unittest.TestCase):
|
||||
self.assertIn("gba_bios.bin", dests)
|
||||
|
||||
def test_a_folder_of_a_several_machine_core_holds_its_machines(self) -> None:
|
||||
from common import load_emulator_profiles
|
||||
from model.profiles import load_emulator_profiles
|
||||
|
||||
resolver = SystemResolver.from_repo(str(ROOT / "emulators"), str(ROOT / "platforms"))
|
||||
profiles = gi.Profiles(load_emulator_profiles(str(ROOT / "emulators")), resolver)
|
||||
@@ -344,7 +344,7 @@ KNOWN_UNRESOLVED = {
|
||||
|
||||
class EveryCoreResolvesOrIsExplained(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
from common import load_emulator_profiles
|
||||
from model.profiles import load_emulator_profiles
|
||||
from romfolders import ProfileResolver
|
||||
|
||||
self.resolver = SystemResolver.from_repo(str(ROOT / "emulators"), str(ROOT / "platforms"))
|
||||
|
||||
@@ -86,9 +86,10 @@ class TheReportSaysSo(unittest.TestCase):
|
||||
previous = os.getcwd()
|
||||
os.chdir(REPO_ROOT)
|
||||
try:
|
||||
from common import load_database, load_emulator_profiles
|
||||
from model.database import load_database
|
||||
from model.profiles import load_emulator_profiles
|
||||
from verify import verify_platform
|
||||
from common import load_platform_config
|
||||
from model.platforms import load_platform_config
|
||||
|
||||
db = load_database("database.json")
|
||||
profiles = load_emulator_profiles("emulators")
|
||||
@@ -152,7 +153,9 @@ class TheGapReportIsComputedOnce(unittest.TestCase):
|
||||
os.chdir(REPO_ROOT)
|
||||
try:
|
||||
import verify
|
||||
from common import load_database, load_emulator_profiles, load_platform_config
|
||||
from model.database import load_database
|
||||
from model.profiles import load_emulator_profiles
|
||||
from model.platforms import load_platform_config
|
||||
|
||||
db = load_database("database.json")
|
||||
profiles = load_emulator_profiles("emulators")
|
||||
|
||||
@@ -1828,7 +1828,7 @@ class TargetFlagIsAppliedOrRefused(unittest.TestCase):
|
||||
self.assertEqual(targets[alias], targets["nintendo-switch"])
|
||||
|
||||
def test_every_alias_resolves_to_its_canonical_core_list(self):
|
||||
from common import load_target_config
|
||||
from model.targets import load_target_config
|
||||
|
||||
for name in ("install/targets/retroarch.json",):
|
||||
path = REPO_ROOT / name
|
||||
@@ -1861,7 +1861,7 @@ class TargetFlagIsAppliedOrRefused(unittest.TestCase):
|
||||
"unknown target" on one side only, and a published null left behind
|
||||
once the builder filters a target makes the installer serve every core.
|
||||
"""
|
||||
from common import list_available_targets, load_target_config
|
||||
from model.targets import list_available_targets, load_target_config
|
||||
|
||||
platforms = str(REPO_ROOT / "platforms")
|
||||
sources = sorted(
|
||||
@@ -2486,7 +2486,7 @@ class TestAvailablePlatforms(unittest.TestCase):
|
||||
|
||||
def test_every_registered_platform_is_installable(self):
|
||||
"""The installer serves every registered platform from its manifest."""
|
||||
from common import list_registered_platforms
|
||||
from model.registry import list_registered_platforms
|
||||
|
||||
registered = set(
|
||||
list_registered_platforms(
|
||||
@@ -3407,7 +3407,7 @@ class CaseVariants(unittest.TestCase):
|
||||
folded = {e["dest"] for e in manifest["files"]}
|
||||
# A case-keeping RetroArch install is the Lakka list, less what
|
||||
# Lakka's own core packages install (installed_on: lakka).
|
||||
from common import load_emulator_profiles
|
||||
from model.profiles import load_emulator_profiles
|
||||
|
||||
installed = {
|
||||
entry.get("path") or entry.get("name")
|
||||
|
||||
@@ -266,7 +266,7 @@ class TheBuildersOrder(unittest.TestCase):
|
||||
if not db_path.exists():
|
||||
self.skipTest("database.json is not built")
|
||||
import generate_pack as gp
|
||||
from common import load_emulator_profiles
|
||||
from model.profiles import load_emulator_profiles
|
||||
|
||||
db = json.loads(db_path.read_text(encoding="utf-8"))
|
||||
profiles = load_emulator_profiles(str(REPO_ROOT / "emulators"))
|
||||
|
||||
@@ -49,8 +49,10 @@ class RealListParity(unittest.TestCase):
|
||||
# The builder's floor: install.py alone keeps 3.8.
|
||||
raise unittest.SkipTest("generate_pack.py needs Python 3.9 or newer")
|
||||
import generate_pack as gp
|
||||
from common import (build_zip_contents_index, list_registered_platforms,
|
||||
load_emulator_profiles, load_platform_config)
|
||||
from core.ziptools import build_zip_contents_index
|
||||
from model.registry import list_registered_platforms
|
||||
from model.profiles import load_emulator_profiles
|
||||
from model.platforms import load_platform_config
|
||||
|
||||
cls.gp = gp
|
||||
cls.config = staticmethod(
|
||||
@@ -134,7 +136,7 @@ class RealListParity(unittest.TestCase):
|
||||
self.assertGreater(dropped, 0)
|
||||
|
||||
def test_one_per_slot_on_a_board(self):
|
||||
from common import load_target_config
|
||||
from model.targets import load_target_config
|
||||
|
||||
for plat, target in TARGETS:
|
||||
with self.subTest(platform=plat, target=target):
|
||||
@@ -150,7 +152,7 @@ class RealListParity(unittest.TestCase):
|
||||
"""--installed-cores ranks a slot by the cores found, as a pack built
|
||||
for exactly those cores (generate_pack target_cores) ranks it: the
|
||||
run passes the found cores as its reach (slot_reach)."""
|
||||
from common import load_target_config
|
||||
from model.targets import load_target_config
|
||||
|
||||
for plat, target in (("retroarch", "switch"), ("retroarch", "playstation-psp")):
|
||||
with self.subTest(platform=plat, cores=target):
|
||||
|
||||
@@ -813,7 +813,7 @@ class InstallMatchesThePack(unittest.TestCase):
|
||||
if not db_path.exists():
|
||||
raise unittest.SkipTest("database.json is not built")
|
||||
import generate_pack as gp
|
||||
from common import load_emulator_profiles
|
||||
from model.profiles import load_emulator_profiles
|
||||
|
||||
cls.gp = gp
|
||||
cls.db = json.loads(db_path.read_text(encoding="utf-8"))
|
||||
@@ -866,7 +866,8 @@ class InstallMatchesASystemPack(unittest.TestCase):
|
||||
if not db_path.exists():
|
||||
raise unittest.SkipTest("database.json is not built")
|
||||
import generate_pack as gp
|
||||
from common import load_emulator_profiles, load_platform_config
|
||||
from model.profiles import load_emulator_profiles
|
||||
from model.platforms import load_platform_config
|
||||
|
||||
cls.gp = gp
|
||||
cls.db = json.loads(db_path.read_text(encoding="utf-8"))
|
||||
@@ -921,7 +922,7 @@ class DataTreesFollowTheSystemsTheyServe(InstallMatchesASystemPack):
|
||||
def _packed(self, systems, regions) -> set[str]:
|
||||
import zipfile
|
||||
|
||||
from common import load_data_dir_registry
|
||||
from model.registry import load_data_dir_registry
|
||||
|
||||
# The trees come from the registry the manifest reads by itself.
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as out:
|
||||
@@ -997,7 +998,8 @@ class InstallMatchesATargetManifest(unittest.TestCase):
|
||||
if not db_path.exists():
|
||||
raise unittest.SkipTest("database.json is not built")
|
||||
import generate_pack as gp
|
||||
from common import load_emulator_profiles, load_target_config
|
||||
from model.profiles import load_emulator_profiles
|
||||
from model.targets import load_target_config
|
||||
|
||||
cls.gp = gp
|
||||
cls.load_target_config = staticmethod(load_target_config)
|
||||
@@ -1023,7 +1025,7 @@ class InstallMatchesATargetManifest(unittest.TestCase):
|
||||
files, omitted = install.narrow_to_cores(full, cores, target=target)
|
||||
# A case-insensitive platform reads one file under both
|
||||
# spellings (BlastEm's 32X_M_BIOS.bin, PicoDrive's .BIN).
|
||||
from common import load_platform_config
|
||||
from model.platforms import load_platform_config
|
||||
|
||||
config = load_platform_config(platform, str(REPO_ROOT / "platforms"))
|
||||
fold = str.lower if config.get("case_insensitive_fs") else str
|
||||
@@ -1049,7 +1051,9 @@ class AHeldFileTheInstallerCannotFetch(unittest.TestCase):
|
||||
pack drops."""
|
||||
|
||||
def setUp(self):
|
||||
import common
|
||||
from model import profiles
|
||||
from model.platforms import _platform_config_cache
|
||||
from model.profiles import _emulator_profiles_cache
|
||||
import generate_db
|
||||
import generate_pack
|
||||
|
||||
@@ -1094,11 +1098,11 @@ class AHeldFileTheInstallerCannotFetch(unittest.TestCase):
|
||||
{"name": "us.bin", "system": "sys", "region": ["north-america"],
|
||||
"required": True},
|
||||
]}))
|
||||
common._platform_config_cache.clear()
|
||||
common._emulator_profiles_cache.clear()
|
||||
self.addCleanup(common._platform_config_cache.clear)
|
||||
self.addCleanup(common._emulator_profiles_cache.clear)
|
||||
self.profiles = common.load_emulator_profiles("emulators")
|
||||
_platform_config_cache.clear()
|
||||
_emulator_profiles_cache.clear()
|
||||
self.addCleanup(_platform_config_cache.clear)
|
||||
self.addCleanup(_emulator_profiles_cache.clear)
|
||||
self.profiles = profiles.load_emulator_profiles("emulators")
|
||||
|
||||
def _manifest(self, regions):
|
||||
return self.gp.generate_manifest(
|
||||
@@ -1131,7 +1135,9 @@ class AStandaloneLayoutBelowTheBiosFolder(unittest.TestCase):
|
||||
the pack kept the European BIOS the installer drops."""
|
||||
|
||||
def setUp(self):
|
||||
import common
|
||||
from model import profiles
|
||||
from model.platforms import _platform_config_cache
|
||||
from model.profiles import _emulator_profiles_cache
|
||||
import generate_db
|
||||
import generate_pack
|
||||
|
||||
@@ -1178,11 +1184,11 @@ class AStandaloneLayoutBelowTheBiosFolder(unittest.TestCase):
|
||||
{"name": name, "system": "sys", "required": False}
|
||||
for name in ("eu.bin", "jp.bin")
|
||||
]}))
|
||||
common._platform_config_cache.clear()
|
||||
common._emulator_profiles_cache.clear()
|
||||
self.addCleanup(common._platform_config_cache.clear)
|
||||
self.addCleanup(common._emulator_profiles_cache.clear)
|
||||
self.profiles = common.load_emulator_profiles("emulators")
|
||||
_platform_config_cache.clear()
|
||||
_emulator_profiles_cache.clear()
|
||||
self.addCleanup(_platform_config_cache.clear)
|
||||
self.addCleanup(_emulator_profiles_cache.clear)
|
||||
self.profiles = profiles.load_emulator_profiles("emulators")
|
||||
|
||||
def _manifest(self, regions):
|
||||
return self.gp.generate_manifest(
|
||||
@@ -1215,7 +1221,9 @@ class AnExtraBesideItsDeclarationBelowTheBiosFolder(unittest.TestCase):
|
||||
which records the path once, dropped it."""
|
||||
|
||||
def setUp(self):
|
||||
import common
|
||||
from model import profiles
|
||||
from model.platforms import _platform_config_cache
|
||||
from model.profiles import _emulator_profiles_cache
|
||||
import generate_db
|
||||
import generate_pack
|
||||
|
||||
@@ -1268,11 +1276,11 @@ class AnExtraBesideItsDeclarationBelowTheBiosFolder(unittest.TestCase):
|
||||
"emulator": "other", "type": "libretro", "systems": ["sys"], "files": [
|
||||
{"name": "us.bin", "path": "alt/us.bin", "system": "sys", "required": False},
|
||||
]}))
|
||||
common._platform_config_cache.clear()
|
||||
common._emulator_profiles_cache.clear()
|
||||
self.addCleanup(common._platform_config_cache.clear)
|
||||
self.addCleanup(common._emulator_profiles_cache.clear)
|
||||
self.profiles = common.load_emulator_profiles("emulators")
|
||||
_platform_config_cache.clear()
|
||||
_emulator_profiles_cache.clear()
|
||||
self.addCleanup(_platform_config_cache.clear)
|
||||
self.addCleanup(_emulator_profiles_cache.clear)
|
||||
self.profiles = profiles.load_emulator_profiles("emulators")
|
||||
|
||||
def _manifest(self, regions):
|
||||
return self.gp.generate_manifest(
|
||||
@@ -1355,8 +1363,8 @@ class ThePlatformsOwnSystemNamesAreAccepted(unittest.TestCase):
|
||||
file records psx as the native_system of sony-playstation."""
|
||||
|
||||
def test_the_names_come_from_the_platform_file(self):
|
||||
from common import load_platform_config
|
||||
from common import platform_system_names
|
||||
from model.platforms import load_platform_config
|
||||
from model.systems import platform_system_names
|
||||
|
||||
config = load_platform_config("batocera", str(REPO_ROOT / "platforms"))
|
||||
names = platform_system_names(config, list(config["systems"]))
|
||||
@@ -1425,7 +1433,7 @@ class ANativeNameSelectsOneSetEverywhere(unittest.TestCase):
|
||||
import generate_pack as gp
|
||||
import pipeline
|
||||
import verify
|
||||
from common import load_emulator_profiles
|
||||
from model.profiles import load_emulator_profiles
|
||||
|
||||
cls.gp, cls.pipeline, cls.verify = gp, pipeline, verify
|
||||
cls.db = json.loads(db_path.read_text(encoding="utf-8"))
|
||||
@@ -1449,7 +1457,8 @@ class ANativeNameSelectsOneSetEverywhere(unittest.TestCase):
|
||||
return {i.filename: i.file_size for i in infos}
|
||||
|
||||
def test_pack_verify_and_installer_agree(self):
|
||||
from common import load_platform_config, resolve_system_arg
|
||||
from model.platforms import load_platform_config
|
||||
from model.systems import resolve_system_arg
|
||||
|
||||
for platform, native, system_id in self.CASES:
|
||||
with self.subTest(platform=platform, name=native):
|
||||
@@ -1514,7 +1523,7 @@ class SystemNamesResolveOneWay(unittest.TestCase):
|
||||
}}
|
||||
|
||||
def _resolve(self, value, config=CONFIG):
|
||||
from common import resolve_system_arg
|
||||
from model.systems import resolve_system_arg
|
||||
|
||||
return resolve_system_arg(value, list(self.CONFIG["systems"]), config)
|
||||
|
||||
|
||||
@@ -16165,7 +16165,7 @@ class EmulatorChoiceMatchesTheEmulatorPack(unittest.TestCase):
|
||||
# The builder's floor: install.py alone keeps 3.8.
|
||||
raise unittest.SkipTest("generate_pack.py needs Python 3.9 or newer")
|
||||
import generate_pack as gp
|
||||
from common import build_zip_contents_index
|
||||
from core.ziptools import build_zip_contents_index
|
||||
|
||||
cls.gp = gp
|
||||
cls.db = json.loads(db_path.read_text(encoding="utf-8"))
|
||||
|
||||
@@ -22,7 +22,8 @@ import urllib.error
|
||||
from pathlib import Path
|
||||
from unittest import mock
|
||||
|
||||
import common
|
||||
from model.composition import GAME_DATA_TOPS, composition_tier
|
||||
from model.profiles import load_emulator_profiles
|
||||
from model import largefiles
|
||||
import check_release_assets
|
||||
|
||||
@@ -110,7 +111,7 @@ class LargeFileCacheTest(unittest.TestCase):
|
||||
results: list[str | None] = [None, None]
|
||||
|
||||
def worker(slot: int):
|
||||
results[slot] = common.fetch_large_file("asset.bin", dest_dir=self.dir)
|
||||
results[slot] = largefiles.fetch_large_file("asset.bin", dest_dir=self.dir)
|
||||
|
||||
threads = [threading.Thread(target=worker, args=(i,)) for i in range(2)]
|
||||
for t in threads:
|
||||
@@ -129,7 +130,7 @@ class LargeFileCacheTest(unittest.TestCase):
|
||||
largefiles.urllib.request.urlopen = lambda req, timeout=None: _SlowResponse(
|
||||
PAYLOAD_A
|
||||
)
|
||||
common.fetch_large_file("asset.bin", dest_dir=self.dir)
|
||||
largefiles.fetch_large_file("asset.bin", dest_dir=self.dir)
|
||||
leftovers = [f for f in os.listdir(self.dir) if f.endswith(".tmp")]
|
||||
self.assertEqual(leftovers, [])
|
||||
|
||||
@@ -138,7 +139,7 @@ class LargeFileCacheTest(unittest.TestCase):
|
||||
raise urllib.error.URLError("offline")
|
||||
|
||||
largefiles.urllib.request.urlopen = fail
|
||||
self.assertIsNone(common.fetch_large_file("asset.bin", dest_dir=self.dir))
|
||||
self.assertIsNone(largefiles.fetch_large_file("asset.bin", dest_dir=self.dir))
|
||||
self.assertEqual(os.listdir(self.dir), [])
|
||||
|
||||
def test_a_spaced_name_served_dotted_reports_nothing(self):
|
||||
@@ -154,7 +155,7 @@ class LargeFileCacheTest(unittest.TestCase):
|
||||
|
||||
largefiles.urllib.request.urlopen = urlopen
|
||||
with mock.patch("sys.stderr", new_callable=io.StringIO) as err:
|
||||
result = common.fetch_large_file("spaced asset.bin", dest_dir=self.dir)
|
||||
result = largefiles.fetch_large_file("spaced asset.bin", dest_dir=self.dir)
|
||||
self.assertIsNotNone(result)
|
||||
self.assertEqual(len(asked), 2)
|
||||
self.assertEqual(err.getvalue(), "")
|
||||
@@ -165,7 +166,7 @@ class LargeFileCacheTest(unittest.TestCase):
|
||||
|
||||
largefiles.urllib.request.urlopen = fail
|
||||
with mock.patch("sys.stderr", new_callable=io.StringIO) as err:
|
||||
self.assertIsNone(common.fetch_large_file("spaced asset.bin", dest_dir=self.dir))
|
||||
self.assertIsNone(largefiles.fetch_large_file("spaced asset.bin", dest_dir=self.dir))
|
||||
self.assertIn("spaced asset.bin", err.getvalue())
|
||||
self.assertIn("spaced.asset.bin", err.getvalue())
|
||||
|
||||
@@ -173,7 +174,7 @@ class LargeFileCacheTest(unittest.TestCase):
|
||||
largefiles.urllib.request.urlopen = lambda req, timeout=None: _SlowResponse(
|
||||
PAYLOAD_A
|
||||
)
|
||||
result = common.fetch_large_file(
|
||||
result = largefiles.fetch_large_file(
|
||||
"asset.bin", dest_dir=self.dir, expected_sha1="00" * 20
|
||||
)
|
||||
self.assertIsNone(result)
|
||||
@@ -188,7 +189,7 @@ class LargeFileCacheTest(unittest.TestCase):
|
||||
|
||||
largefiles.urllib.request.urlopen = fail
|
||||
self.assertTrue(os.path.samefile(
|
||||
common.fetch_large_file("asset.bin", dest_dir=self.dir), cached
|
||||
largefiles.fetch_large_file("asset.bin", dest_dir=self.dir), cached
|
||||
))
|
||||
|
||||
def test_offline_cache_miss_never_opens_the_network(self):
|
||||
@@ -197,7 +198,7 @@ class LargeFileCacheTest(unittest.TestCase):
|
||||
|
||||
largefiles.urllib.request.urlopen = fail
|
||||
self.assertIsNone(
|
||||
common.fetch_large_file(
|
||||
largefiles.fetch_large_file(
|
||||
"asset.bin", dest_dir=self.dir, offline=True
|
||||
)
|
||||
)
|
||||
@@ -212,7 +213,7 @@ class LargeFileCacheTest(unittest.TestCase):
|
||||
|
||||
largefiles.urllib.request.urlopen = fail
|
||||
self.assertTrue(os.path.samefile(
|
||||
common.fetch_large_file(
|
||||
largefiles.fetch_large_file(
|
||||
"asset.bin",
|
||||
dest_dir=self.dir,
|
||||
expected_sha1=hashlib.sha1(PAYLOAD_A).hexdigest(),
|
||||
@@ -247,7 +248,7 @@ class LargeFileCacheTest(unittest.TestCase):
|
||||
rebuilt = b"C" * 1000
|
||||
gets: list = []
|
||||
self._serve(rebuilt, gets)
|
||||
result = common.fetch_large_file(
|
||||
result = largefiles.fetch_large_file(
|
||||
"asset.bin", dest_dir=self.dir,
|
||||
expected_sha1=hashlib.sha1(rebuilt).hexdigest(),
|
||||
)
|
||||
@@ -261,11 +262,11 @@ class LargeFileCacheTest(unittest.TestCase):
|
||||
the prune of that same download removed it."""
|
||||
self._serve(PAYLOAD_A, [])
|
||||
sha1 = hashlib.sha1(PAYLOAD_A).hexdigest()
|
||||
first = common.fetch_large_file("asset.bin", dest_dir=self.dir, expected_sha1=sha1)
|
||||
first = largefiles.fetch_large_file("asset.bin", dest_dir=self.dir, expected_sha1=sha1)
|
||||
self.assertTrue(first and os.path.isfile(first))
|
||||
os.unlink(Path(self.dir) / "asset.bin")
|
||||
with mock.patch.object(largefiles, "ORPHAN_GRACE", -1):
|
||||
second = common.fetch_large_file(
|
||||
second = largefiles.fetch_large_file(
|
||||
"asset.bin", dest_dir=self.dir, expected_sha1=sha1
|
||||
)
|
||||
self.assertTrue(second and os.path.isfile(second))
|
||||
@@ -276,11 +277,11 @@ class LargeFileCacheTest(unittest.TestCase):
|
||||
handed out the old link, which a prune elsewhere would remove."""
|
||||
self._serve(PAYLOAD_A, [])
|
||||
sha1 = hashlib.sha1(PAYLOAD_A).hexdigest()
|
||||
common.fetch_large_file("asset.bin", dest_dir=self.dir, expected_sha1=sha1)
|
||||
largefiles.fetch_large_file("asset.bin", dest_dir=self.dir, expected_sha1=sha1)
|
||||
cached = Path(self.dir) / "asset.bin"
|
||||
os.unlink(cached)
|
||||
cached.write_bytes(PAYLOAD_A)
|
||||
hit = common.fetch_large_file(
|
||||
hit = largefiles.fetch_large_file(
|
||||
"asset.bin", dest_dir=self.dir, expected_sha1=sha1, offline=True
|
||||
)
|
||||
self.assertTrue(os.path.samefile(hit, cached))
|
||||
@@ -290,7 +291,7 @@ class LargeFileCacheTest(unittest.TestCase):
|
||||
cached.write_bytes(PAYLOAD_A)
|
||||
gets: list = []
|
||||
self._serve(PAYLOAD_A, gets)
|
||||
result = common.fetch_large_file(
|
||||
result = largefiles.fetch_large_file(
|
||||
"asset.bin", dest_dir=self.dir, expected_sha1="00" * 20
|
||||
)
|
||||
self.assertIsNone(result)
|
||||
@@ -302,7 +303,7 @@ class LargeFileCacheTest(unittest.TestCase):
|
||||
cached.write_bytes(PAYLOAD_A)
|
||||
gets: list = []
|
||||
self._serve(b"D" * 10, gets)
|
||||
result = common.fetch_large_file(
|
||||
result = largefiles.fetch_large_file(
|
||||
"asset.bin", dest_dir=self.dir, expected_sha1="00" * 20
|
||||
)
|
||||
self.assertIsNone(result)
|
||||
@@ -410,12 +411,12 @@ class PreservedLargeFileEntries(unittest.TestCase):
|
||||
self._cwd = os.getcwd()
|
||||
os.chdir(self.tmp)
|
||||
(self.tmp / ".gitignore").write_text("bios/Sony/PS3/FW.PUP\n")
|
||||
self._real_fetch = common.fetch_large_file
|
||||
self._real_fetch = largefiles.fetch_large_file
|
||||
generate_db.__dict__.pop("fetch_large_file", None)
|
||||
|
||||
def tearDown(self):
|
||||
os.chdir(self._cwd)
|
||||
common.fetch_large_file = self._real_fetch
|
||||
largefiles.fetch_large_file = self._real_fetch
|
||||
self._tmp.cleanup()
|
||||
|
||||
def _write_db(self, entries: dict) -> str:
|
||||
@@ -424,7 +425,7 @@ class PreservedLargeFileEntries(unittest.TestCase):
|
||||
return path
|
||||
|
||||
def test_stale_entry_for_a_rescanned_path_is_dropped(self):
|
||||
common.fetch_large_file = lambda *_a, **_k: None
|
||||
largefiles.fetch_large_file = lambda *_a, **_k: None
|
||||
db_path = self._write_db(
|
||||
{
|
||||
"a" * 40: {"name": "FW.PUP", "path": "bios/Sony/PS3/FW.PUP"},
|
||||
@@ -438,7 +439,7 @@ class PreservedLargeFileEntries(unittest.TestCase):
|
||||
self.assertEqual(list(files), ["a" * 40])
|
||||
|
||||
def test_absent_large_file_is_still_preserved(self):
|
||||
common.fetch_large_file = lambda *_a, **_k: None
|
||||
largefiles.fetch_large_file = lambda *_a, **_k: None
|
||||
db_path = self._write_db(
|
||||
{"b" * 40: {"name": "FW.PUP", "path": "bios/Sony/PS3/FW.PUP"}}
|
||||
)
|
||||
@@ -451,7 +452,7 @@ class PreservedLargeFileEntries(unittest.TestCase):
|
||||
cache = self.tmp / "cache" / "FW.PUP"
|
||||
cache.parent.mkdir()
|
||||
cache.write_bytes(b"firmware")
|
||||
common.fetch_large_file = lambda *_a, **_k: str(cache)
|
||||
largefiles.fetch_large_file = lambda *_a, **_k: str(cache)
|
||||
db_path = self._write_db(
|
||||
{"b" * 40: {"name": "FW.PUP", "path": "bios/Sony/PS3/FW.PUP"}}
|
||||
)
|
||||
@@ -465,7 +466,7 @@ class PreservedLargeFileEntries(unittest.TestCase):
|
||||
cache = self.tmp / "cache" / "FW.PUP"
|
||||
cache.parent.mkdir()
|
||||
cache.write_bytes(b"firmware")
|
||||
common.fetch_large_file = lambda *_a, **_k: str(cache)
|
||||
largefiles.fetch_large_file = lambda *_a, **_k: str(cache)
|
||||
db_path = self._write_db(
|
||||
{"b" * 40: {"name": "FW.PUP", "path": "bios/Sony/PS3/FW.PUP"}}
|
||||
)
|
||||
@@ -481,7 +482,7 @@ class PreservedLargeFileEntries(unittest.TestCase):
|
||||
self.assertEqual(list(directory.iterdir()), [])
|
||||
|
||||
def test_a_file_sharing_only_the_name_is_not_preserved(self):
|
||||
common.fetch_large_file = lambda *_a, **_k: "/cache/large/FW.PUP"
|
||||
largefiles.fetch_large_file = lambda *_a, **_k: "/cache/large/FW.PUP"
|
||||
db_path = self._write_db(
|
||||
{"c" * 40: {"name": "FW.PUP", "path": "bios/Sony/PSP/FW.PUP"}}
|
||||
)
|
||||
@@ -492,7 +493,7 @@ class PreservedLargeFileEntries(unittest.TestCase):
|
||||
self.assertEqual(files, {})
|
||||
|
||||
def test_a_second_revision_under_a_rescanned_path_is_dropped(self):
|
||||
common.fetch_large_file = lambda *_a, **_k: "/cache/large/FW.PUP"
|
||||
largefiles.fetch_large_file = lambda *_a, **_k: "/cache/large/FW.PUP"
|
||||
db_path = self._write_db(
|
||||
{"b" * 40: {"name": "FW.PUP", "path": "bios/Sony/PS3/FW.PUP"}}
|
||||
)
|
||||
@@ -737,7 +738,7 @@ class GameDataHasOneDefinition(unittest.TestCase):
|
||||
"bios/Toys for Bob/The Ur-Quan Masters/uqm-0.8.0-voice.uqm",
|
||||
):
|
||||
with self.subTest(path=path):
|
||||
self.assertEqual(common.composition_tier(path), "game_data")
|
||||
self.assertEqual(composition_tier(path), "game_data")
|
||||
self.assertEqual(
|
||||
check_release_assets._section_for(path), "Game engine data"
|
||||
)
|
||||
@@ -747,7 +748,7 @@ class GameDataHasOneDefinition(unittest.TestCase):
|
||||
if not db_path.exists():
|
||||
self.skipTest("database.json not generated")
|
||||
db = json.loads(db_path.read_text(encoding="utf-8"))
|
||||
profiles = common.load_emulator_profiles(str(REPO_ROOT / "emulators"))
|
||||
profiles = load_emulator_profiles(str(REPO_ROOT / "emulators"))
|
||||
names: dict[str, set[str]] = {}
|
||||
for profile in profiles.values():
|
||||
for entry in profile.get("files") or []:
|
||||
@@ -766,7 +767,7 @@ class GameDataHasOneDefinition(unittest.TestCase):
|
||||
top for top, categories in trees.items() if categories == {"game_data"}
|
||||
)
|
||||
self.assertEqual(
|
||||
[top for top in only_game_data if top not in common.GAME_DATA_TOPS], []
|
||||
[top for top in only_game_data if top not in GAME_DATA_TOPS], []
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ from pathlib import Path
|
||||
|
||||
import yaml
|
||||
|
||||
from common import load_platform_config
|
||||
from model.platforms import load_platform_config
|
||||
from resolve.launchers import (
|
||||
bound_launchers,
|
||||
config_evidence,
|
||||
|
||||
@@ -28,7 +28,8 @@ from unittest import mock
|
||||
import yaml
|
||||
|
||||
import verify
|
||||
from common import _emulator_profiles_cache, load_emulator_profiles, load_platform_config
|
||||
from model.profiles import _emulator_profiles_cache, load_emulator_profiles
|
||||
from model.platforms import load_platform_config
|
||||
from cross_reference import (
|
||||
LAUNCHER_READS_KEY,
|
||||
LAUNCHER_UNPROVEN_KEY,
|
||||
|
||||
@@ -20,7 +20,8 @@ import zipfile
|
||||
|
||||
import yaml
|
||||
|
||||
from common import _emulator_profiles_cache, load_emulator_profiles, load_platform_config
|
||||
from model.profiles import _emulator_profiles_cache, load_emulator_profiles
|
||||
from model.platforms import load_platform_config
|
||||
from resolve.launchers import LauncherLayer, launcher_places, suffixed_stem
|
||||
from verify import find_undeclared_files, verify_platform
|
||||
|
||||
|
||||
@@ -324,8 +324,10 @@ class AUserFolderInTheConfigsFolder(unittest.TestCase):
|
||||
of the configs root its batoceraPaths builds (../system/configs)."""
|
||||
|
||||
def test_the_sys_modules_go_below_the_configs_root(self):
|
||||
from common import load_emulator_profiles, load_platform_config, platform_layouts
|
||||
from common import standalone_set
|
||||
from model.profiles import load_emulator_profiles
|
||||
from model.platforms import load_platform_config
|
||||
from resolve.standalone import platform_layouts
|
||||
from resolve.standalone import standalone_set
|
||||
|
||||
profile = load_emulator_profiles(str(REPO_ROOT / "emulators"))["shadps4"]
|
||||
# KNULLI's generator does the same, but no KNULLI board builds shadps4.
|
||||
|
||||
@@ -23,13 +23,9 @@ from pathlib import Path
|
||||
|
||||
import yaml
|
||||
|
||||
from common import (
|
||||
_emulator_profiles_cache,
|
||||
load_emulator_profiles,
|
||||
load_platform_config,
|
||||
platform_layouts,
|
||||
standalone_set,
|
||||
)
|
||||
from model.profiles import _emulator_profiles_cache, load_emulator_profiles
|
||||
from model.platforms import load_platform_config
|
||||
from resolve.standalone import platform_layouts, standalone_set
|
||||
from generate_pack import generate_manifest, generate_pack
|
||||
from verify import verify_platform
|
||||
|
||||
@@ -241,7 +237,7 @@ class FsUaeOnRetroPie(unittest.TestCase):
|
||||
def test_the_launcher_name_is_filled_without_another_core(self) -> None:
|
||||
import json
|
||||
|
||||
from common import load_target_config
|
||||
from model.targets import load_target_config
|
||||
|
||||
db_path = REPO_ROOT / "database.json"
|
||||
if not db_path.exists():
|
||||
@@ -528,7 +524,8 @@ class EachProgramItsOwnProfile(unittest.TestCase):
|
||||
"""PICO-8 and Voxatron are two programs: a platform running one gets its files only."""
|
||||
|
||||
def test_only_the_platforms_that_run_voxatron_get_it(self) -> None:
|
||||
from common import list_registered_platforms, resolve_platform_cores
|
||||
from model.registry import list_registered_platforms
|
||||
from resolve.cores import resolve_platform_cores
|
||||
|
||||
profiles = load_emulator_profiles(str(REPO_ROOT / "emulators"))
|
||||
runs = {
|
||||
@@ -544,7 +541,7 @@ class EachProgramItsOwnProfile(unittest.TestCase):
|
||||
"batocera", "knulli", "rocknix", "retrodeck", "retrobat", "recalbox")))
|
||||
|
||||
def test_a_standalone_emulator_is_run(self) -> None:
|
||||
from common import resolve_platform_cores
|
||||
from resolve.cores import resolve_platform_cores
|
||||
|
||||
profiles = {"emu": {"emulator": "Emu", "type": "standalone", "cores": ["emu"],
|
||||
"systems": ["sys"], "files": []}}
|
||||
@@ -895,7 +892,8 @@ class MameSearchPaths(unittest.TestCase):
|
||||
self.assertEqual(bbc["standalone_path"], "mame/samples/bbc.zip")
|
||||
|
||||
def test_a_moved_tree_is_found_by_its_layout_path(self) -> None:
|
||||
from common import expand_directory_entries, load_database
|
||||
from resolve.directories import expand_directory_entries
|
||||
from model.database import load_database
|
||||
|
||||
db = load_database(str(REPO_ROOT / "database.json"))
|
||||
view = standalone_view("mame", "retrodeck")
|
||||
@@ -996,7 +994,7 @@ class AdvanceMameOnEmuELEC(unittest.TestCase):
|
||||
def test_both_copies_are_one_file(self) -> None:
|
||||
# Outside the BIOS tree the folder is no proof of content: each copy
|
||||
# resolves by its layout path, so both folders hold the same file.
|
||||
from common import load_database
|
||||
from model.database import load_database
|
||||
|
||||
db = load_database(str(REPO_ROOT / "database.json"))
|
||||
with redirect_stdout(io.StringIO()):
|
||||
@@ -1022,7 +1020,8 @@ class AdvanceMameOnEmuELEC(unittest.TestCase):
|
||||
|
||||
def test_the_roms_folder_is_no_proof_of_content(self) -> None:
|
||||
# bios/Arcade/MAME/konamigv.zip is MAME 0.289's set, not AdvanceMAME's.
|
||||
from common import load_database, resolve_local_file
|
||||
from model.database import load_database
|
||||
from resolve.localfile import resolve_local_file
|
||||
|
||||
db = load_database(str(REPO_ROOT / "database.json"))
|
||||
view = standalone_view("advancemame", "emuelec")
|
||||
@@ -1094,7 +1093,7 @@ class SetsReadBesideTheGame(unittest.TestCase):
|
||||
self.assertTrue(all("load_from" not in e and "root" not in e for e in sets))
|
||||
|
||||
def test_the_manifest_drops_the_root_copy_no_core_reads(self) -> None:
|
||||
from common import load_database
|
||||
from model.database import load_database
|
||||
|
||||
db = load_database(str(REPO_ROOT / "database.json"))
|
||||
with redirect_stdout(io.StringIO()):
|
||||
@@ -1125,7 +1124,7 @@ class MameOnRetroDeckRomPaths(unittest.TestCase):
|
||||
self.assertTrue(found["neogeo"]["any_machine"])
|
||||
|
||||
def test_a_machine_reads_its_own_set_and_its_devices(self) -> None:
|
||||
from common import rom_search_sets
|
||||
from resolve.contentlayout import rom_search_sets
|
||||
|
||||
self.assertIn("adam", rom_search_sets("mame", "adam", ["adam"], False))
|
||||
neogeo = rom_search_sets("mame", "neogeo", [], True)
|
||||
@@ -1212,7 +1211,7 @@ class CloneReadsItsParent(unittest.TestCase):
|
||||
finds o2bios.rom in the parent's videopac.zip (src/emu/driver.cpp:31-38)."""
|
||||
|
||||
def test_the_parent_set_goes_to_the_clone_folder(self) -> None:
|
||||
from common import rom_search_sets
|
||||
from resolve.contentlayout import rom_search_sets
|
||||
|
||||
self.assertIn("videopac", rom_search_sets("mame", "odyssey2", ["odyssey2"], False))
|
||||
for platform, dest in (("emudeck", "odyssey2/videopac.zip"),
|
||||
@@ -1264,7 +1263,7 @@ class CoreOfferedOnSomeBoards(unittest.TestCase):
|
||||
return {**base, "_rom_folders": [self.ROW], **extra}
|
||||
|
||||
def test_a_branch_names_the_boards(self) -> None:
|
||||
from common import when_admits
|
||||
from resolve.contentlayout import when_admits
|
||||
|
||||
self.assertTrue(when_admits("DEVICE H700|RK3326", "rk3326"))
|
||||
self.assertFalse(when_admits("DEVICE H700|RK3326", "s922x"))
|
||||
@@ -1272,7 +1271,7 @@ class CoreOfferedOnSomeBoards(unittest.TestCase):
|
||||
self.assertTrue(when_admits('if [ "${PREFER_GLES}" = "yes" ]; then', "h700"))
|
||||
|
||||
def test_an_offer_carries_the_boards_its_branch_names(self) -> None:
|
||||
from common import offer_boards
|
||||
from resolve.contentlayout import offer_boards
|
||||
|
||||
boards = offer_boards(self.config())
|
||||
self.assertEqual(boards[("uae4arm", "amiga")], frozenset({"h700", "rk3326"}))
|
||||
@@ -1280,7 +1279,8 @@ class CoreOfferedOnSomeBoards(unittest.TestCase):
|
||||
self.assertIsNone(boards[("puae2021", "amiga")])
|
||||
|
||||
def test_a_board_pack_places_the_core_where_the_board_offers_it(self) -> None:
|
||||
from common import CONTENT_FOLDER_PREFIX, TARGET_KEY, content_folder_tags
|
||||
from resolve.layout import CONTENT_FOLDER_PREFIX
|
||||
from resolve.contentlayout import TARGET_KEY, content_folder_tags
|
||||
|
||||
def placed(config: dict) -> dict:
|
||||
rows = [json.loads(t[len(CONTENT_FOLDER_PREFIX):]) for t in content_folder_tags(config)
|
||||
@@ -1296,7 +1296,7 @@ class CoreOfferedOnSomeBoards(unittest.TestCase):
|
||||
|
||||
|
||||
def platform_manifest(platform: str) -> dict:
|
||||
from common import load_database
|
||||
from model.database import load_database
|
||||
|
||||
db = load_database(str(REPO_ROOT / "database.json"))
|
||||
with redirect_stdout(io.StringIO()):
|
||||
|
||||
@@ -60,7 +60,9 @@ class RetroArchCarriesDolphinWhereItReads(unittest.TestCase):
|
||||
previous = os.getcwd()
|
||||
os.chdir(REPO_ROOT)
|
||||
self.addCleanup(os.chdir, previous)
|
||||
from common import load_database, load_emulator_profiles, load_platform_config
|
||||
from model.database import load_database
|
||||
from model.profiles import load_emulator_profiles
|
||||
from model.platforms import load_platform_config
|
||||
from packextras import _collect_emulator_extras
|
||||
|
||||
config = load_platform_config("retroarch")
|
||||
|
||||
@@ -34,7 +34,7 @@ class ScrapedSystemIdsAreSlugs(unittest.TestCase):
|
||||
The quasi88 group supplies N88EXT0-3.ROM, which the core reads first
|
||||
(src/LIBRETRO/libretro.c:109-112) and which match that main ROM.
|
||||
"""
|
||||
from common import load_platform_config
|
||||
from model.platforms import load_platform_config
|
||||
|
||||
config = load_platform_config("retroarch", str(REPO_ROOT / "platforms"))
|
||||
names = {
|
||||
|
||||
@@ -25,7 +25,14 @@ from pathlib import Path
|
||||
|
||||
import yaml
|
||||
|
||||
import common
|
||||
from model import cliargs, platforms
|
||||
from resolve import cores, grouping, localfile
|
||||
from model.database import load_database
|
||||
from model.platforms import _platform_config_cache
|
||||
from model.profiles import _emulator_profiles_cache, load_emulator_profiles
|
||||
from model.registry import list_registered_platforms, load_data_dir_registry
|
||||
from resolve.localfile import resolve_local_file
|
||||
from resolve.ownership import BUCKET_FOLDERS, names_manufacturer
|
||||
import generate_db
|
||||
import generate_pack as builder
|
||||
import generate_site
|
||||
@@ -95,15 +102,15 @@ class _Collection(unittest.TestCase):
|
||||
"--bios-dir", "bios", "--output", "database.json"],
|
||||
check=True, capture_output=True,
|
||||
)
|
||||
self.db = common.load_database("database.json")
|
||||
common._platform_config_cache.clear()
|
||||
common._emulator_profiles_cache.clear()
|
||||
self.config = common.load_platform_config("handheld", "platforms")
|
||||
self.profiles = common.load_emulator_profiles("emulators")
|
||||
self.db = load_database("database.json")
|
||||
_platform_config_cache.clear()
|
||||
_emulator_profiles_cache.clear()
|
||||
self.config = platforms.load_platform_config("handheld", "platforms")
|
||||
self.profiles = load_emulator_profiles("emulators")
|
||||
|
||||
def tearDown(self):
|
||||
common._platform_config_cache.clear()
|
||||
common._emulator_profiles_cache.clear()
|
||||
_platform_config_cache.clear()
|
||||
_emulator_profiles_cache.clear()
|
||||
os.chdir(self._cwd)
|
||||
self._tmp.cleanup()
|
||||
|
||||
@@ -138,33 +145,33 @@ class DiskRomGoesToThePc88File(_Collection):
|
||||
|
||||
def test_resolution(self):
|
||||
entry = self._entry("nec-pc-88")
|
||||
path, status = common.resolve_local_file(
|
||||
path, status = resolve_local_file(
|
||||
entry, self.db, dest_hint=entry["destination"]
|
||||
)
|
||||
self.assertEqual((path, status), ("bios/NEC/PC-88/n88sub.rom", "name_exact"))
|
||||
|
||||
def test_the_msx_system_keeps_the_msx_file(self):
|
||||
entry = self._entry("microsoft-msx")
|
||||
path, _status = common.resolve_local_file(
|
||||
path, _status = resolve_local_file(
|
||||
entry, self.db, dest_hint=entry["destination"]
|
||||
)
|
||||
self.assertEqual(path, "bios/Microsoft/MSX/DISK.ROM")
|
||||
|
||||
def test_a_declared_hash_still_decides(self):
|
||||
entry = {**self._entry("nec-pc-88"), "md5": hashlib.md5(MSX_DISK).hexdigest()}
|
||||
path, status = common.resolve_local_file(entry, self.db)
|
||||
path, status = resolve_local_file(entry, self.db)
|
||||
self.assertEqual((path, status), ("bios/Microsoft/MSX/DISK.ROM", "md5_exact"))
|
||||
|
||||
def test_an_emulator_entry_is_not_narrowed(self):
|
||||
entry = {**self._entry("nec-pc-88"), "source_profile": "msx-emu"}
|
||||
path, _status = common.resolve_local_file(entry, self.db)
|
||||
path, _status = resolve_local_file(entry, self.db)
|
||||
self.assertEqual(path, "bios/Microsoft/MSX/DISK.ROM")
|
||||
|
||||
def test_no_pc88_copy_leaves_it_missing_not_mismatched(self):
|
||||
Path("bios/NEC/PC-88/n88sub.rom").unlink()
|
||||
entry = self._entry("nec-pc-88")
|
||||
self.assertEqual(
|
||||
common.resolve_local_file(entry, self.db, dest_hint=entry["destination"]),
|
||||
resolve_local_file(entry, self.db, dest_hint=entry["destination"]),
|
||||
(None, "not_found"),
|
||||
)
|
||||
|
||||
@@ -189,7 +196,9 @@ class DiskRomGoesToThePc88File(_Collection):
|
||||
|
||||
def test_the_manifest_changes_only_that_row(self):
|
||||
manifest = self._manifest()
|
||||
original = (common.load_platform_config, common.system_makers)
|
||||
original = (platforms.load_platform_config, localfile.system_makers)
|
||||
# Every module that reads the loader by its own name sees the stub.
|
||||
readers = (builder, platforms, cliargs, cores, grouping)
|
||||
|
||||
def untagged(*args, **kwargs):
|
||||
config = original[0](*args, **kwargs)
|
||||
@@ -198,15 +207,17 @@ class DiskRomGoesToThePc88File(_Collection):
|
||||
f.pop("platform_system", None)
|
||||
return config
|
||||
|
||||
common._platform_config_cache.clear()
|
||||
builder.load_platform_config = common.load_platform_config = untagged
|
||||
common.system_makers = lambda *args: frozenset()
|
||||
_platform_config_cache.clear()
|
||||
for module in readers:
|
||||
module.load_platform_config = untagged
|
||||
localfile.system_makers = lambda *args: frozenset()
|
||||
try:
|
||||
before = self._manifest()
|
||||
finally:
|
||||
builder.load_platform_config = common.load_platform_config = original[0]
|
||||
common.system_makers = original[1]
|
||||
common._platform_config_cache.clear()
|
||||
for module in readers:
|
||||
module.load_platform_config = original[0]
|
||||
localfile.system_makers = original[1]
|
||||
_platform_config_cache.clear()
|
||||
rows = {f["dest"]: f for f in manifest["files"]}
|
||||
old_rows = {f["dest"]: f for f in before["files"]}
|
||||
self.assertEqual(rows["bios/quasi88/DISK.ROM"]["size"], len(PC88_DISK))
|
||||
@@ -225,8 +236,8 @@ class DiskRomGoesToThePc88File(_Collection):
|
||||
|
||||
class SiteSharesTheMakerTest(unittest.TestCase):
|
||||
def test_one_copy(self):
|
||||
self.assertIs(generate_site.names_manufacturer, common.names_manufacturer)
|
||||
self.assertIs(generate_site.BUCKET_FOLDERS, common.BUCKET_FOLDERS)
|
||||
self.assertIs(generate_site.names_manufacturer, names_manufacturer)
|
||||
self.assertIs(generate_site.BUCKET_FOLDERS, BUCKET_FOLDERS)
|
||||
|
||||
|
||||
class NoHashlessNameMatchCrossesMakers(unittest.TestCase):
|
||||
@@ -238,24 +249,24 @@ class NoHashlessNameMatchCrossesMakers(unittest.TestCase):
|
||||
db_path = REPO_ROOT / "database.json"
|
||||
if not db_path.exists():
|
||||
self.skipTest("database.json not built")
|
||||
db = common.load_database(str(db_path))
|
||||
registry = common.load_data_dir_registry("platforms")
|
||||
db = load_database(str(db_path))
|
||||
registry = load_data_dir_registry("platforms")
|
||||
folders = {
|
||||
parts[1]
|
||||
for entry in db["files"].values()
|
||||
if len(parts := entry["path"].split("/")) >= 3 and parts[0] == "bios"
|
||||
} - common.BUCKET_FOLDERS
|
||||
} - BUCKET_FOLDERS
|
||||
crossings = []
|
||||
for platform in common.list_registered_platforms("platforms"):
|
||||
config = common.load_platform_config(platform, "platforms")
|
||||
for platform in list_registered_platforms("platforms"):
|
||||
config = platforms.load_platform_config(platform, "platforms")
|
||||
for sys_id, system in config.get("systems", {}).items():
|
||||
makers = {f for f in folders if common.names_manufacturer(sys_id, f)}
|
||||
makers = {f for f in folders if names_manufacturer(sys_id, f)}
|
||||
if not makers:
|
||||
continue
|
||||
for entry in system.get("files") or []:
|
||||
if any(entry.get(k) for k in ("sha1", "md5", "sha256", "crc32")):
|
||||
continue
|
||||
path, status = common.resolve_local_file(
|
||||
path, status = resolve_local_file(
|
||||
entry, db, dest_hint=entry.get("destination", ""),
|
||||
data_dir_registry=registry,
|
||||
)
|
||||
@@ -264,7 +275,7 @@ class NoHashlessNameMatchCrossesMakers(unittest.TestCase):
|
||||
status.startswith("name")
|
||||
and len(parts) >= 3
|
||||
and parts[0] == "bios"
|
||||
and parts[1] not in common.BUCKET_FOLDERS
|
||||
and parts[1] not in BUCKET_FOLDERS
|
||||
and parts[1] not in makers
|
||||
):
|
||||
crossings.append(f"{platform} {sys_id} {entry.get('name')}: {path}")
|
||||
|
||||
@@ -17,7 +17,7 @@ import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from scripts.common import yaml_load
|
||||
from scripts.model.safeparse import yaml_load
|
||||
from scripts.scraper._hash_merge import (
|
||||
DEVICE_SECTION,
|
||||
SOFTLIST_SECTION,
|
||||
@@ -607,7 +607,7 @@ class APickReadsTheEntrySystems(unittest.TestCase):
|
||||
SYSTEMS = ["apple2gs", "coco", "snk-neogeo-mvs"]
|
||||
|
||||
def test_entry_system_ids(self):
|
||||
from scripts.common import entry_system_ids
|
||||
from scripts.model.profiles import entry_system_ids
|
||||
|
||||
profile = {"systems": self.SYSTEMS}
|
||||
self.assertEqual(entry_system_ids({"system": "coco"}, profile), ["coco"])
|
||||
@@ -617,7 +617,7 @@ class APickReadsTheEntrySystems(unittest.TestCase):
|
||||
self.assertEqual(entry_system_ids({}, profile), self.SYSTEMS)
|
||||
|
||||
def test_entry_serves_systems(self):
|
||||
from scripts.common import entry_serves_systems
|
||||
from scripts.model.profiles import entry_serves_systems
|
||||
|
||||
profile = {"systems": self.SYSTEMS}
|
||||
entry = {"systems": ["apple2gs", "coco"]}
|
||||
@@ -966,7 +966,8 @@ class TheSupportMergeWritesListsAndSamples(unittest.TestCase):
|
||||
self.assertEqual(profile_seeds(text), {"neogeo": "acorn-bbc-micro"})
|
||||
|
||||
def test_a_pick_takes_its_lists_and_leaves_the_others(self):
|
||||
from scripts.common import entry_serves_systems, expand_directory_entries
|
||||
from scripts.model.profiles import entry_serves_systems
|
||||
from scripts.resolve.directories import expand_directory_entries
|
||||
|
||||
self._merge()
|
||||
profile = yaml_load(self.path.read_text(encoding="utf-8"))
|
||||
|
||||
@@ -75,7 +75,7 @@ class SystemAndEmulatorPacksKeepTheirNames(unittest.TestCase):
|
||||
|
||||
import yaml
|
||||
|
||||
import common
|
||||
from model.profiles import _emulator_profiles_cache
|
||||
import generate_db
|
||||
import generate_pack as gp
|
||||
|
||||
@@ -99,7 +99,7 @@ class SystemAndEmulatorPacksKeepTheirNames(unittest.TestCase):
|
||||
"systems": ["sega-triforce"],
|
||||
"files": [{"name": "segaboot.gcm", "required": True}],
|
||||
}))
|
||||
common._emulator_profiles_cache.clear()
|
||||
_emulator_profiles_cache.clear()
|
||||
try:
|
||||
emulator_pack = gp.generate_emulator_pack(
|
||||
["triforce"], str(root / "emulators"), db, str(root / "bios"),
|
||||
@@ -110,7 +110,7 @@ class SystemAndEmulatorPacksKeepTheirNames(unittest.TestCase):
|
||||
str(root / "bios"), str(out), offline=True,
|
||||
)
|
||||
finally:
|
||||
common._emulator_profiles_cache.clear()
|
||||
_emulator_profiles_cache.clear()
|
||||
self.assertNotEqual(Path(emulator_pack).name, Path(system_pack).name)
|
||||
self.assertTrue(Path(emulator_pack).exists())
|
||||
self.assertTrue(Path(system_pack).exists())
|
||||
|
||||
@@ -27,7 +27,8 @@ from pathlib import Path
|
||||
|
||||
import yaml
|
||||
|
||||
from common import load_emulator_profiles, load_platform_config
|
||||
from model.profiles import load_emulator_profiles
|
||||
from model.platforms import load_platform_config
|
||||
from scraper import minui_scraper
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||
@@ -167,7 +168,7 @@ class PackPlacesCoreFilesUnderTheTag(unittest.TestCase):
|
||||
folder the platform hands it, and nowhere else."""
|
||||
|
||||
def setUp(self):
|
||||
from common import _emulator_profiles_cache
|
||||
from model.profiles import _emulator_profiles_cache
|
||||
|
||||
_emulator_profiles_cache.clear()
|
||||
self.root = tempfile.mkdtemp(dir=REPO_ROOT / "tmp" / "tests")
|
||||
@@ -300,7 +301,7 @@ class PackPlacesCoreFilesUnderTheTag(unittest.TestCase):
|
||||
self.assertEqual(outside, [])
|
||||
|
||||
def test_the_same_cores_in_other_folders_make_another_pack(self):
|
||||
from common import group_identical_platforms
|
||||
from resolve.grouping import group_identical_platforms
|
||||
|
||||
twin = yaml.safe_load(Path(self.platforms, "test_minui.yml").read_text())
|
||||
twin["core_system_dirs"]["Bios/GB"]["cores"] = ["arcade_lib"]
|
||||
@@ -335,7 +336,7 @@ class PublishedPlatformsHoldTheRule(unittest.TestCase):
|
||||
repository the platform's recipe names: a library renamed from
|
||||
another project (dosbox-pure as dosbox) would hand the wrong
|
||||
profile's files to the folder."""
|
||||
from common import resolve_platform_cores
|
||||
from resolve.cores import resolve_platform_cores
|
||||
|
||||
profiles = load_emulator_profiles(str(REPO_ROOT / "emulators"))
|
||||
|
||||
@@ -421,7 +422,8 @@ class TheSitePageOfACardPlatform(unittest.TestCase):
|
||||
|
||||
def test_folders_replace_the_empty_coverage(self):
|
||||
import generate_site
|
||||
from common import load_database, load_platform_registry
|
||||
from model.database import load_database
|
||||
from model.registry import load_platform_registry
|
||||
from generate_readme import compute_coverage
|
||||
|
||||
if not (REPO_ROOT / "database.json").is_file():
|
||||
@@ -445,7 +447,7 @@ class TheWholeTreeKeepsCoresMinUILeavesOut(unittest.TestCase):
|
||||
and the global report lost 238 profiles."""
|
||||
|
||||
def test_a_core_minui_does_not_list_keeps_its_files(self):
|
||||
from common import merged_standalone_set, platform_layouts
|
||||
from resolve.standalone import merged_standalone_set, platform_layouts
|
||||
|
||||
minui = {"core_system_dirs": {"Bios/FC": {"cores": ["fceumm"]}}}
|
||||
retroarch = {}
|
||||
|
||||
@@ -13,7 +13,7 @@ import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from common import _by_affinity
|
||||
from resolve.localfile import _by_affinity
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
@@ -36,7 +36,7 @@ class DeclaredSizeOrders(unittest.TestCase):
|
||||
class OwnerOutranksSharedTree(unittest.TestCase):
|
||||
def test_the_owners_copy_beats_two_matching_segments(self):
|
||||
"""armsx2's fxaa.fx lost to NetherSX2's under shaders/common/."""
|
||||
from common import _by_affinity
|
||||
from resolve.localfile import _by_affinity
|
||||
|
||||
paths = [
|
||||
"bios/Other/nethersx2/assets/shaders/common/fxaa.fx",
|
||||
|
||||
@@ -219,13 +219,13 @@ class GapAnalysisAgreesWithTheBuilder(unittest.TestCase):
|
||||
return tmp, root, db
|
||||
|
||||
def _in_repo(self, mode: str) -> bool:
|
||||
import common
|
||||
from model.profiles import _emulator_profiles_cache, load_emulator_profiles
|
||||
from verify import find_undeclared_files
|
||||
|
||||
tmp, root, db = self._fixture()
|
||||
try:
|
||||
common._emulator_profiles_cache.clear()
|
||||
profiles = common.load_emulator_profiles(str(root / "emulators"))
|
||||
_emulator_profiles_cache.clear()
|
||||
profiles = load_emulator_profiles(str(root / "emulators"))
|
||||
config = {
|
||||
"platform": "Demo",
|
||||
"verification_mode": mode,
|
||||
@@ -238,7 +238,7 @@ class GapAnalysisAgreesWithTheBuilder(unittest.TestCase):
|
||||
entry = next(e for e in found if e["name"] == "collide.rom")
|
||||
return bool(entry["in_repo"])
|
||||
finally:
|
||||
common._emulator_profiles_cache.clear()
|
||||
_emulator_profiles_cache.clear()
|
||||
tmp.cleanup()
|
||||
|
||||
def test_a_digest_mode_does_not_call_a_contradicted_copy_available(self):
|
||||
@@ -365,7 +365,7 @@ class SkippingIsNotSettling(unittest.TestCase):
|
||||
import hashlib
|
||||
import tempfile
|
||||
|
||||
import common
|
||||
from model.profiles import _emulator_profiles_cache, load_emulator_profiles
|
||||
from verify import find_undeclared_files
|
||||
|
||||
tmp = tempfile.TemporaryDirectory()
|
||||
@@ -396,8 +396,8 @@ class SkippingIsNotSettling(unittest.TestCase):
|
||||
"files:\n" + entry
|
||||
)
|
||||
try:
|
||||
common._emulator_profiles_cache.clear()
|
||||
profiles = common.load_emulator_profiles(str(root / "emulators"))
|
||||
_emulator_profiles_cache.clear()
|
||||
profiles = load_emulator_profiles(str(root / "emulators"))
|
||||
config = {
|
||||
"platform": "Demo", "verification_mode": "existence",
|
||||
"cores": ["a_standalone_only", "b_libretro"], "systems": {},
|
||||
@@ -407,7 +407,7 @@ class SkippingIsNotSettling(unittest.TestCase):
|
||||
)
|
||||
return {(u["emulator"], u["name"]) for u in found}
|
||||
finally:
|
||||
common._emulator_profiles_cache.clear()
|
||||
_emulator_profiles_cache.clear()
|
||||
tmp.cleanup()
|
||||
|
||||
def test_the_profile_that_needs_the_file_still_reports_it(self):
|
||||
@@ -438,7 +438,7 @@ class OneProfileSelector(unittest.TestCase):
|
||||
}
|
||||
|
||||
def _select(self, names, standalone=False):
|
||||
from common import ProfileSelectionError, select_emulator_profiles
|
||||
from model.profiles import ProfileSelectionError, select_emulator_profiles
|
||||
|
||||
try:
|
||||
return select_emulator_profiles(names, self.PROFILES, standalone), None
|
||||
|
||||
@@ -25,7 +25,7 @@ class PC88FilesStayInPC88(unittest.TestCase):
|
||||
folder = REPO_ROOT / "bios" / "NEC" / "PC-98"
|
||||
if not folder.is_dir():
|
||||
self.skipTest("bios/NEC/PC-98 is absent")
|
||||
from common import load_emulator_profiles
|
||||
from model.profiles import load_emulator_profiles
|
||||
|
||||
readers: dict[str, set[str]] = {}
|
||||
for profile in load_emulator_profiles(str(REPO_ROOT / "emulators")).values():
|
||||
|
||||
@@ -74,11 +74,9 @@ class SharedGroupsAddNoSecondSpelling(unittest.TestCase):
|
||||
and verify counted one more required file."""
|
||||
|
||||
def test_no_group_entry_respells_a_declared_destination(self) -> None:
|
||||
from common import (
|
||||
list_registered_platforms,
|
||||
load_emulator_profiles,
|
||||
load_platform_config,
|
||||
)
|
||||
from model.registry import list_registered_platforms
|
||||
from model.profiles import load_emulator_profiles
|
||||
from model.platforms import load_platform_config
|
||||
|
||||
# A spelling some code opens as its own file stands: NP2kai's rhythm
|
||||
# engine reads 2608_bd.wav, its fmgen engine 2608_BD.WAV, and a
|
||||
@@ -117,7 +115,7 @@ class Np2kaiRhythmSamplesAreTwoSets(unittest.TestCase):
|
||||
from the profile shipped one spelling and reported both OK."""
|
||||
|
||||
def test_each_spelling_is_its_own_entry(self):
|
||||
from common import load_emulator_profiles
|
||||
from model.profiles import load_emulator_profiles
|
||||
|
||||
files = load_emulator_profiles(str(REPO_ROOT / "emulators"))["np2kai"]["files"]
|
||||
paths = {entry.get("path") for entry in files}
|
||||
|
||||
@@ -28,7 +28,8 @@ from pathlib import Path
|
||||
|
||||
import yaml
|
||||
|
||||
import common
|
||||
from model.platforms import load_platform_config, _platform_config_cache
|
||||
from model.profiles import _emulator_profiles_cache
|
||||
import generate_db
|
||||
import generate_pack as builder
|
||||
import install
|
||||
@@ -103,14 +104,14 @@ class _Fixture(unittest.TestCase):
|
||||
(self.platforms / "_registry.yml").write_text(
|
||||
yaml.dump({"platforms": {"handheld": {"config": "handheld.yml"}}})
|
||||
)
|
||||
common._platform_config_cache.clear()
|
||||
common._emulator_profiles_cache.clear()
|
||||
_platform_config_cache.clear()
|
||||
_emulator_profiles_cache.clear()
|
||||
self.out = self.root / "dist"
|
||||
self.out.mkdir()
|
||||
|
||||
def tearDown(self):
|
||||
common._platform_config_cache.clear()
|
||||
common._emulator_profiles_cache.clear()
|
||||
_platform_config_cache.clear()
|
||||
_emulator_profiles_cache.clear()
|
||||
self._tmp.cleanup()
|
||||
|
||||
def pack(self, no_game_data: bool) -> tuple[str, set[str], str]:
|
||||
@@ -182,7 +183,7 @@ class PackNarrowing(_Fixture):
|
||||
|
||||
def test_verify_reports_the_pack_the_builder_wrote(self):
|
||||
zip_path, members, _ = self.pack(no_game_data=True)
|
||||
config = common.load_platform_config("handheld", str(self.platforms))
|
||||
config = load_platform_config("handheld", str(self.platforms))
|
||||
result = verify.verify_platform(
|
||||
config, self.db, str(self.emulators), PROFILES, no_game_data=True,
|
||||
)
|
||||
@@ -202,7 +203,7 @@ class PackNarrowing(_Fixture):
|
||||
self.assertFalse(full[0])
|
||||
|
||||
def test_the_full_report_is_unchanged(self):
|
||||
config = common.load_platform_config("handheld", str(self.platforms))
|
||||
config = load_platform_config("handheld", str(self.platforms))
|
||||
result = verify.verify_platform(config, self.db, str(self.emulators), PROFILES)
|
||||
self.assertNotIn("left_out", result)
|
||||
self.assertEqual(set(result["pack_destinations"]), FIRMWARE | GAME)
|
||||
|
||||
@@ -20,7 +20,7 @@ from pathlib import Path
|
||||
|
||||
import yaml
|
||||
|
||||
from common import resolve_local_file
|
||||
from resolve.localfile import resolve_local_file
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
|
||||
@@ -158,7 +158,8 @@ class ScriptsNeedOnlyPyyaml(unittest.TestCase):
|
||||
|
||||
class TheDownloaderRunsWithoutPyyaml(unittest.TestCase):
|
||||
"""download.py is the documented Windows downloader, "stdlib only". It
|
||||
stays so only because common.py imports yaml optionally: made a plain
|
||||
stays so only because the core modules it imports use the standard
|
||||
library alone (tests/test_layers.py): had one imported yaml as a plain
|
||||
import, every CI job (which installs pyyaml) would stay green."""
|
||||
|
||||
def test_help_runs_with_yaml_unimportable(self):
|
||||
|
||||
@@ -19,11 +19,9 @@ from pathlib import Path
|
||||
|
||||
import cross_reference
|
||||
import slots
|
||||
from common import (
|
||||
build_zip_contents_index,
|
||||
load_database,
|
||||
load_emulator_profiles,
|
||||
)
|
||||
from core.ziptools import build_zip_contents_index
|
||||
from model.database import load_database
|
||||
from model.profiles import load_emulator_profiles
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||
|
||||
|
||||
@@ -147,7 +147,8 @@ class NarrowedPacksAgainstTheirOwnList(unittest.TestCase):
|
||||
now held to the platform list narrowed the way it was built."""
|
||||
|
||||
def setUp(self):
|
||||
import common
|
||||
from model.platforms import _platform_config_cache
|
||||
from model.profiles import load_emulator_profiles, _emulator_profiles_cache
|
||||
import generate_db
|
||||
import generate_pack
|
||||
|
||||
@@ -184,11 +185,11 @@ class NarrowedPacksAgainstTheirOwnList(unittest.TestCase):
|
||||
{"name": "core.bin", "path": "core.bin", "required": True},
|
||||
{"name": "extra.bin", "path": "extra.bin", "required": False},
|
||||
]}), encoding="utf-8")
|
||||
common._platform_config_cache.clear()
|
||||
common._emulator_profiles_cache.clear()
|
||||
self.addCleanup(common._platform_config_cache.clear)
|
||||
self.addCleanup(common._emulator_profiles_cache.clear)
|
||||
self.profiles = common.load_emulator_profiles("emulators")
|
||||
_platform_config_cache.clear()
|
||||
_emulator_profiles_cache.clear()
|
||||
self.addCleanup(_platform_config_cache.clear)
|
||||
self.addCleanup(_emulator_profiles_cache.clear)
|
||||
self.profiles = load_emulator_profiles("emulators")
|
||||
|
||||
def _build(self, source: str, required: bool) -> tuple[str, set[str]]:
|
||||
zip_path = self.gp.generate_pack(
|
||||
|
||||
+13
-11
@@ -28,7 +28,9 @@ try:
|
||||
import jsonschema
|
||||
except ImportError:
|
||||
jsonschema = None
|
||||
import common
|
||||
from core.artifacts import ArtifactLockBusy, artifact_lock
|
||||
from model.platforms import _platform_config_cache
|
||||
from model.profiles import _emulator_profiles_cache, load_emulator_profiles
|
||||
import generate_db
|
||||
import generate_pack as builder
|
||||
import generate_readme
|
||||
@@ -104,11 +106,11 @@ class PackCountFixture(unittest.TestCase):
|
||||
yaml.dump({"platforms": {"demo": {"config": "demo.yml"}}})
|
||||
)
|
||||
(self.emulators / "demo.yml").write_text(PROFILE)
|
||||
common._emulator_profiles_cache.clear()
|
||||
self.profiles = common.load_emulator_profiles(str(self.emulators))
|
||||
_emulator_profiles_cache.clear()
|
||||
self.profiles = load_emulator_profiles(str(self.emulators))
|
||||
|
||||
def tearDown(self):
|
||||
common._emulator_profiles_cache.clear()
|
||||
_emulator_profiles_cache.clear()
|
||||
self._tmp.cleanup()
|
||||
|
||||
def _manifest(self) -> dict:
|
||||
@@ -157,8 +159,8 @@ class ManifestStatesWhatThePackHolds(PackCountFixture):
|
||||
],
|
||||
}}}
|
||||
(self.platforms / "demo.yml").write_text(yaml.dump(platform))
|
||||
common._platform_config_cache.clear()
|
||||
self.addCleanup(common._platform_config_cache.clear)
|
||||
_platform_config_cache.clear()
|
||||
self.addCleanup(_platform_config_cache.clear)
|
||||
out = self.root / "dist"
|
||||
out.mkdir()
|
||||
zip_path = builder.generate_pack(
|
||||
@@ -491,8 +493,8 @@ class ReleaseRecord(unittest.TestCase):
|
||||
self.assertNotIn(narrowed, owners)
|
||||
|
||||
def test_a_directory_being_written_is_not_read(self):
|
||||
with common.artifact_lock(str(self.dist)), \
|
||||
self.assertRaises(common.ArtifactLockBusy):
|
||||
with artifact_lock(str(self.dist)), \
|
||||
self.assertRaises(ArtifactLockBusy):
|
||||
release_record.build_record(self.dist, "v1", owners=self.OWNERS)
|
||||
|
||||
|
||||
@@ -527,7 +529,7 @@ class RefusedFilesAreNotPresent(unittest.TestCase):
|
||||
def test_the_coverage_subtracts_a_refused_file(self):
|
||||
import os
|
||||
|
||||
import common
|
||||
from model.platforms import _platform_config_cache
|
||||
import generate_db
|
||||
import generate_readme
|
||||
|
||||
@@ -560,8 +562,8 @@ class RefusedFilesAreNotPresent(unittest.TestCase):
|
||||
Path("platforms/_registry.yml").write_text(
|
||||
yaml.dump({"platforms": {"hashy": {"config": "hashy.yml"}}})
|
||||
)
|
||||
common._platform_config_cache.clear()
|
||||
self.addCleanup(common._platform_config_cache.clear)
|
||||
_platform_config_cache.clear()
|
||||
self.addCleanup(_platform_config_cache.clear)
|
||||
coverage = generate_readme.compute_coverage(
|
||||
"hashy", "platforms", db, emulators_dir="emulators"
|
||||
)
|
||||
|
||||
@@ -29,7 +29,7 @@ REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
class _Fixture(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
from common import _emulator_profiles_cache
|
||||
from model.profiles import _emulator_profiles_cache
|
||||
|
||||
_emulator_profiles_cache.clear()
|
||||
(REPO_ROOT / "tmp").mkdir(exist_ok=True)
|
||||
@@ -61,7 +61,8 @@ class _Fixture(unittest.TestCase):
|
||||
return config
|
||||
|
||||
def _both(self) -> tuple[dict, set[str]]:
|
||||
from common import load_emulator_profiles, load_platform_config
|
||||
from model.profiles import load_emulator_profiles
|
||||
from model.platforms import load_platform_config
|
||||
from generate_pack import generate_pack
|
||||
from verify import verify_platform
|
||||
|
||||
@@ -126,7 +127,8 @@ class ARequiredOnlyPack(_Fixture):
|
||||
"""verify had no --required-only: nothing compared the pack to a report."""
|
||||
|
||||
def test_verify_credits_what_the_pack_writes(self):
|
||||
from common import load_emulator_profiles, load_platform_config
|
||||
from model.profiles import load_emulator_profiles
|
||||
from model.platforms import load_platform_config
|
||||
from generate_pack import PackRecord, generate_pack
|
||||
from verify import verify_platform
|
||||
|
||||
@@ -206,7 +208,8 @@ class EveryNarrowingIsCompared(unittest.TestCase):
|
||||
|
||||
def test_the_variants_reach_every_compared_dimension(self):
|
||||
import pipeline
|
||||
from common import load_emulator_profiles, load_platform_config
|
||||
from model.profiles import load_emulator_profiles
|
||||
from model.platforms import load_platform_config
|
||||
|
||||
platforms = str(REPO_ROOT / "platforms")
|
||||
config = load_platform_config("retroarch", platforms)
|
||||
|
||||
@@ -22,7 +22,9 @@ class SlotPassReadsTheRegionGrouping(unittest.TestCase):
|
||||
if not (REPO_ROOT / "database.json").is_file():
|
||||
self.skipTest("database.json not built")
|
||||
import generate_pack as gp
|
||||
from common import load_database, load_emulator_profiles, load_platform_config
|
||||
from model.database import load_database
|
||||
from model.profiles import load_emulator_profiles
|
||||
from model.platforms import load_platform_config
|
||||
|
||||
previous = os.getcwd()
|
||||
os.chdir(REPO_ROOT)
|
||||
@@ -56,7 +58,9 @@ class VariantGroupSpansSystems(unittest.TestCase):
|
||||
self.skipTest("database.json not built")
|
||||
import generate_pack as gp
|
||||
import region as region_mod
|
||||
from common import load_database, load_emulator_profiles, load_platform_config
|
||||
from model.database import load_database
|
||||
from model.profiles import load_emulator_profiles
|
||||
from model.platforms import load_platform_config
|
||||
|
||||
previous = os.getcwd()
|
||||
os.chdir(REPO_ROOT)
|
||||
@@ -86,7 +90,8 @@ class AFrontendCheckSeparatesPacks(unittest.TestCase):
|
||||
|
||||
import yaml
|
||||
|
||||
import common
|
||||
from model.platforms import _platform_config_cache
|
||||
from resolve.grouping import group_identical_platforms
|
||||
|
||||
files = [{"name": "a.bin", "destination": "a.bin", "md5": "0" * 32}]
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
@@ -98,9 +103,9 @@ class AFrontendCheckSeparatesPacks(unittest.TestCase):
|
||||
"systems": {"s": {"files": [entry]}},
|
||||
}))
|
||||
Path(tmp, "_registry.yml").write_text(yaml.dump({"platforms": {}}))
|
||||
common._platform_config_cache.clear()
|
||||
self.addCleanup(common._platform_config_cache.clear)
|
||||
groups = common.group_identical_platforms(["one", "two", "three"], tmp)
|
||||
_platform_config_cache.clear()
|
||||
self.addCleanup(_platform_config_cache.clear)
|
||||
groups = group_identical_platforms(["one", "two", "three"], tmp)
|
||||
self.assertEqual(sorted(g for g, _ in groups), [["one"], ["three"], ["two"]])
|
||||
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ def _pack_path(platform_name: str) -> str | None:
|
||||
|
||||
|
||||
def _registered_platforms() -> list[str]:
|
||||
from common import list_registered_platforms
|
||||
from model.registry import list_registered_platforms
|
||||
|
||||
return list_registered_platforms(PLATFORMS_DIR)
|
||||
|
||||
@@ -55,7 +55,9 @@ def _profiles_newer_than(path: str, platform_name: str) -> list[str]:
|
||||
comment edited in any of 500 profiles used to disarm the integrity
|
||||
check of every pack on disk.
|
||||
"""
|
||||
from common import load_emulator_profiles, load_platform_config, resolve_platform_cores
|
||||
from model.profiles import load_emulator_profiles
|
||||
from model.platforms import load_platform_config
|
||||
from resolve.cores import resolve_platform_cores
|
||||
|
||||
built = os.path.getmtime(path)
|
||||
config = load_platform_config(platform_name, PLATFORMS_DIR)
|
||||
|
||||
@@ -20,7 +20,8 @@ from pathlib import Path
|
||||
|
||||
import yaml
|
||||
|
||||
import common
|
||||
from model.platforms import load_platform_config, _platform_config_cache
|
||||
from model.profiles import _emulator_profiles_cache
|
||||
import generate_db
|
||||
import generate_pack as builder
|
||||
from verify import verify_platform
|
||||
@@ -66,11 +67,11 @@ class ConflictingDeclarations(unittest.TestCase):
|
||||
(self.platforms / "_registry.yml").write_text(
|
||||
yaml.dump({"platforms": {"conflict": {"config": "conflict.yml"}}})
|
||||
)
|
||||
common._platform_config_cache.clear()
|
||||
common._emulator_profiles_cache.clear()
|
||||
_platform_config_cache.clear()
|
||||
_emulator_profiles_cache.clear()
|
||||
|
||||
def tearDown(self):
|
||||
common._platform_config_cache.clear()
|
||||
_platform_config_cache.clear()
|
||||
self._tmp.cleanup()
|
||||
|
||||
def test_the_pack_and_verify_count_alike(self):
|
||||
@@ -86,7 +87,7 @@ class ConflictingDeclarations(unittest.TestCase):
|
||||
packed = re.search(r"(\d+)/(\d+) files OK", report.getvalue())
|
||||
self.assertIsNotNone(packed, report.getvalue())
|
||||
|
||||
config = common.load_platform_config("conflict", str(self.platforms))
|
||||
config = load_platform_config("conflict", str(self.platforms))
|
||||
verified = verify_platform(config, self.db, str(self.emulators))
|
||||
counts = verified["status_counts"]
|
||||
self.assertEqual(counts.get("missing"), 1)
|
||||
@@ -142,12 +143,12 @@ class AnExtraDoesNotPassAHashCheck(unittest.TestCase):
|
||||
"required": True}],
|
||||
}
|
||||
(self.emulators / "fxcore.yml").write_text(yaml.dump(profile))
|
||||
common._platform_config_cache.clear()
|
||||
common._emulator_profiles_cache.clear()
|
||||
_platform_config_cache.clear()
|
||||
_emulator_profiles_cache.clear()
|
||||
|
||||
def tearDown(self):
|
||||
common._platform_config_cache.clear()
|
||||
common._emulator_profiles_cache.clear()
|
||||
_platform_config_cache.clear()
|
||||
_emulator_profiles_cache.clear()
|
||||
self._tmp.cleanup()
|
||||
|
||||
def test_the_declaration_stays_failed(self):
|
||||
@@ -161,7 +162,7 @@ class AnExtraDoesNotPassAHashCheck(unittest.TestCase):
|
||||
)
|
||||
packed = re.search(r"(\d+)/(\d+) files OK", report.getvalue())
|
||||
self.assertIsNotNone(packed, report.getvalue())
|
||||
config = common.load_platform_config("hashed", str(self.platforms))
|
||||
config = load_platform_config("hashed", str(self.platforms))
|
||||
verified = verify_platform(config, self.db, str(self.emulators))
|
||||
self.assertEqual(verified["status_counts"].get("ok", 0), 0)
|
||||
self.assertEqual(int(packed.group(1)), 0, report.getvalue())
|
||||
@@ -196,10 +197,10 @@ class TheEmulatorPackShipsWhatTheCoreAccepts(unittest.TestCase):
|
||||
"max_size": 1048576, "validation": ["size"]}],
|
||||
}
|
||||
(self.emulators / "mac.yml").write_text(yaml.dump(profile))
|
||||
common._emulator_profiles_cache.clear()
|
||||
_emulator_profiles_cache.clear()
|
||||
|
||||
def tearDown(self):
|
||||
common._emulator_profiles_cache.clear()
|
||||
_emulator_profiles_cache.clear()
|
||||
self._tmp.cleanup()
|
||||
|
||||
def test_the_refused_rom_is_named_not_shipped(self):
|
||||
@@ -253,10 +254,10 @@ class AlternativesAgreeWithThePack(unittest.TestCase):
|
||||
],
|
||||
}
|
||||
(self.emulators / "eng.yml").write_text(yaml.dump(profile))
|
||||
common._emulator_profiles_cache.clear()
|
||||
_emulator_profiles_cache.clear()
|
||||
|
||||
def tearDown(self):
|
||||
common._emulator_profiles_cache.clear()
|
||||
_emulator_profiles_cache.clear()
|
||||
self._tmp.cleanup()
|
||||
|
||||
def test_verify_counts_what_the_pack_ships(self):
|
||||
@@ -315,10 +316,10 @@ class AMaskedArchiveIsMissing(unittest.TestCase):
|
||||
"files": [{"name": "y.bin", "archive": "pack.zip", "required": True,
|
||||
"crc32": f"{__import__('zlib').crc32(b'y'):08x}"}],
|
||||
}))
|
||||
common._emulator_profiles_cache.clear()
|
||||
_emulator_profiles_cache.clear()
|
||||
|
||||
def tearDown(self):
|
||||
common._emulator_profiles_cache.clear()
|
||||
_emulator_profiles_cache.clear()
|
||||
self._tmp.cleanup()
|
||||
|
||||
def test_both_report_the_archive_missing(self):
|
||||
|
||||
@@ -24,7 +24,9 @@ class NoPathNoCopy(unittest.TestCase):
|
||||
previous = os.getcwd()
|
||||
os.chdir(REPO_ROOT)
|
||||
self.addCleanup(os.chdir, previous)
|
||||
from common import load_database, load_emulator_profiles, load_platform_config
|
||||
from model.database import load_database
|
||||
from model.profiles import load_emulator_profiles
|
||||
from model.platforms import load_platform_config
|
||||
from packextras import _collect_emulator_extras
|
||||
|
||||
profiles = load_emulator_profiles("emulators")
|
||||
|
||||
@@ -10,7 +10,7 @@ import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from common import resolve_local_file
|
||||
from resolve.localfile import resolve_local_file
|
||||
from generate_db import _path_suffixes
|
||||
|
||||
|
||||
|
||||
@@ -137,7 +137,7 @@ class EveryBuildReferenceNamesThePin(unittest.TestCase):
|
||||
platform's own YAML was scraped from that repository."""
|
||||
|
||||
def test_the_values_agree(self):
|
||||
from common import load_emulator_profiles
|
||||
from model.profiles import load_emulator_profiles
|
||||
|
||||
disagree = []
|
||||
for name, profile in load_emulator_profiles(str(REPO_ROOT / "emulators")).items():
|
||||
|
||||
@@ -17,7 +17,8 @@ from pathlib import Path
|
||||
|
||||
import yaml
|
||||
|
||||
import common
|
||||
from model.platforms import load_platform_config, _platform_config_cache, _shared_yml_cache
|
||||
from resolve.grouping import group_identical_platforms
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
@@ -26,8 +27,8 @@ class AChildLeavesItsParentAlone(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.dir = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
self.addCleanup(shutil.rmtree, self.dir, True)
|
||||
self.addCleanup(common._platform_config_cache.clear)
|
||||
self.addCleanup(common._shared_yml_cache.clear)
|
||||
self.addCleanup(_platform_config_cache.clear)
|
||||
self.addCleanup(_shared_yml_cache.clear)
|
||||
files = {
|
||||
"parent.yml": {"platform": "Parent", "verification_mode": "existence",
|
||||
"systems": {"sys-a": {"files": [{"name": "a.bin"}]}}},
|
||||
@@ -44,7 +45,7 @@ class AChildLeavesItsParentAlone(unittest.TestCase):
|
||||
(self.dir / name).write_text(yaml.safe_dump(data))
|
||||
|
||||
def load(self, name):
|
||||
return common.load_platform_config(name, str(self.dir))
|
||||
return load_platform_config(name, str(self.dir))
|
||||
|
||||
def test_the_parent_keeps_its_systems(self):
|
||||
self.load("parent")
|
||||
@@ -75,15 +76,15 @@ class ALinuxPlatformKeepsBothCases(unittest.TestCase):
|
||||
exact case, and only System.dat's 2608_BD.WAV and BIOS.col shipped."""
|
||||
|
||||
def setUp(self):
|
||||
self.addCleanup(common._platform_config_cache.clear)
|
||||
common._platform_config_cache.clear()
|
||||
self.addCleanup(_platform_config_cache.clear)
|
||||
_platform_config_cache.clear()
|
||||
|
||||
def test_the_linux_platforms_do_not_fold(self):
|
||||
platforms = str(REPO_ROOT / "platforms")
|
||||
self.assertTrue(common.load_platform_config("retroarch", platforms)["case_insensitive_fs"])
|
||||
self.assertTrue(load_platform_config("retroarch", platforms)["case_insensitive_fs"])
|
||||
for name in ("lakka", "retropie"):
|
||||
with self.subTest(platform=name):
|
||||
config = common.load_platform_config(name, platforms)
|
||||
config = load_platform_config(name, platforms)
|
||||
self.assertFalse(config["case_insensitive_fs"])
|
||||
dests = {
|
||||
f.get("destination", f.get("name"))
|
||||
@@ -92,7 +93,7 @@ class ALinuxPlatformKeepsBothCases(unittest.TestCase):
|
||||
self.assertTrue({"np2kai/2608_BD.WAV", "np2kai/2608_bd.wav"} <= dests)
|
||||
|
||||
def test_lakka_does_not_share_retroarchs_pack(self):
|
||||
groups = common.group_identical_platforms(
|
||||
groups = group_identical_platforms(
|
||||
["retroarch", "lakka"], str(REPO_ROOT / "platforms")
|
||||
)
|
||||
self.assertEqual(sorted(g for g, _rep in groups), [["lakka"], ["retroarch"]])
|
||||
|
||||
@@ -31,7 +31,7 @@ class ZippedFileKey(unittest.TestCase):
|
||||
self.assertIsNone(pattern.search(path.read_text(encoding="utf-8")))
|
||||
|
||||
def test_member_md5_declares_no_loose_name(self):
|
||||
from common import expand_platform_declared_names
|
||||
from model.declarations import expand_platform_declared_names
|
||||
|
||||
config = {"systems": {"s": {"files": [
|
||||
{"name": "casloopy.zip", "md5": "m1", "zipped_file": "hd6437021.lsi302"},
|
||||
|
||||
@@ -12,7 +12,7 @@ import tests
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from common import load_emulator_profiles
|
||||
from model.profiles import load_emulator_profiles
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||
|
||||
|
||||
@@ -3039,7 +3039,7 @@ class TestDeliberatelyFrozenPin(TestBuildReport):
|
||||
# reicast is the commit Recalbox's reicast.mk builds, 789 commits
|
||||
# behind master. Compared to HEAD it showed eight refs to review that
|
||||
# nobody could act on.
|
||||
from common import load_emulator_profiles
|
||||
from model.profiles import load_emulator_profiles
|
||||
|
||||
root = Path(__file__).resolve().parents[1] / "emulators"
|
||||
profiles = load_emulator_profiles(str(root))
|
||||
@@ -3059,7 +3059,7 @@ class TestDeliberatelyFrozenPin(TestBuildReport):
|
||||
# RetroPie builds ppsspp-1.5.4 as PPSSPPSDL alone: the frozen build
|
||||
# is the standalone half of a project that also ships a core.
|
||||
builds_differ = {("duckstation-legacy", "duckstation"), ("ppsspp-1.5.4", "ppsspp")}
|
||||
from common import load_emulator_profiles
|
||||
from model.profiles import load_emulator_profiles
|
||||
|
||||
root = Path(__file__).resolve().parents[1] / "emulators"
|
||||
profiles = load_emulator_profiles(str(root))
|
||||
@@ -5125,7 +5125,7 @@ class AWriteRefreshesTheSourcePaths(unittest.TestCase):
|
||||
with mock.patch.object(sitesources, "build_source_paths", return_value=({}, [])) as built, \
|
||||
mock.patch.dict(os.environ, {"RETROBIOS_OFFLINE": ""}), \
|
||||
mock.patch.object(profile_sync, "load_emulator_profiles", return_value={}), \
|
||||
mock.patch("common.write_if_changed") as written, \
|
||||
mock.patch("core.artifacts.write_if_changed") as written, \
|
||||
contextlib.redirect_stderr(io.StringIO()):
|
||||
profile_sync._WRITTEN.clear()
|
||||
profile_sync._refresh_source_paths(self._args())
|
||||
@@ -5143,19 +5143,20 @@ class AWriteRefreshesTheSourcePaths(unittest.TestCase):
|
||||
# before writing them: the record kept the pins it had replaced.
|
||||
from unittest import mock
|
||||
|
||||
import common
|
||||
from model import profiles as model_profiles
|
||||
from model.profiles import _emulator_profiles_cache
|
||||
import sitesources
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
profile = Path(tmp) / "p.yml"
|
||||
profile.write_text('emulator: P\nsource_commit: "old"\n', encoding="utf-8")
|
||||
common._emulator_profiles_cache.clear()
|
||||
self.addCleanup(common._emulator_profiles_cache.clear)
|
||||
common.load_emulator_profiles(tmp, skip_aliases=False)
|
||||
_emulator_profiles_cache.clear()
|
||||
self.addCleanup(_emulator_profiles_cache.clear)
|
||||
model_profiles.load_emulator_profiles(tmp, skip_aliases=False)
|
||||
profile.write_text('emulator: P\nsource_commit: "new"\n', encoding="utf-8")
|
||||
with mock.patch.object(sitesources, "build_source_paths", return_value=({}, [])) as built, \
|
||||
mock.patch.dict(os.environ, {"RETROBIOS_OFFLINE": ""}), \
|
||||
mock.patch("common.write_if_changed"), \
|
||||
mock.patch("core.artifacts.write_if_changed"), \
|
||||
contextlib.redirect_stderr(io.StringIO()), \
|
||||
contextlib.redirect_stdout(io.StringIO()):
|
||||
profile_sync._WRITTEN.add("p")
|
||||
|
||||
@@ -22,7 +22,7 @@ import zlib
|
||||
from pathlib import Path
|
||||
|
||||
import generate_db
|
||||
from common import resolve_local_file
|
||||
from resolve.localfile import resolve_local_file
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import unittest
|
||||
import zipfile
|
||||
from pathlib import Path
|
||||
|
||||
from scripts.common import (
|
||||
from scripts.model.dumpcatalog import (
|
||||
annotate_provenance,
|
||||
build_provenance_index,
|
||||
load_provenance_snapshots,
|
||||
|
||||
+33
-29
@@ -11,7 +11,8 @@ import sys
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
import common
|
||||
from model import profiles as model_profiles
|
||||
from model.profiles import _emulator_profiles_cache
|
||||
import region
|
||||
from packextras import emulator_region_drops
|
||||
|
||||
@@ -491,7 +492,7 @@ class OneCodeOneRegionAnswer(unittest.TestCase):
|
||||
PROFILES = os.path.join(os.path.dirname(__file__), "..", "emulators")
|
||||
|
||||
def test_the_mednafen_saturn_profiles_agree(self):
|
||||
profiles = common.load_emulator_profiles(self.PROFILES)
|
||||
profiles = model_profiles.load_emulator_profiles(self.PROFILES)
|
||||
seen: dict[str, dict[str, frozenset]] = {}
|
||||
for name in ("mednafen", "beetle_saturn", "saturn-emu", "mednafen_stv"):
|
||||
for entry in profiles[name]["files"]:
|
||||
@@ -505,7 +506,7 @@ class OneCodeOneRegionAnswer(unittest.TestCase):
|
||||
self.assertIn("oceania", next(iter(tags.values())))
|
||||
|
||||
def test_export_cartridges_and_allowed_regions(self):
|
||||
profiles = common.load_emulator_profiles(self.PROFILES)
|
||||
profiles = model_profiles.load_emulator_profiles(self.PROFILES)
|
||||
bios_sms = next(e for e in profiles["clk"]["files"] if e["name"] == "bios.sms")
|
||||
self.assertIn("oceania", bios_sms["region"])
|
||||
# A Mexican export cartridge is analysed as Europe or USA and boots the
|
||||
@@ -526,7 +527,7 @@ class AustraliaReadsThePalIpl(unittest.TestCase):
|
||||
alone, `--region australia` dropped it and kept the American one."""
|
||||
|
||||
def test_the_pal_ipl_answers_oceania(self):
|
||||
profiles = common.load_emulator_profiles(
|
||||
profiles = model_profiles.load_emulator_profiles(
|
||||
os.path.join(os.path.dirname(__file__), "..", "emulators")
|
||||
)
|
||||
for name in ("dolphin", "primehack", "ishiiruka", "triforce"):
|
||||
@@ -694,14 +695,15 @@ class TestReportAndBuilderNarrowTogether(unittest.TestCase):
|
||||
return tmp, root, db, config
|
||||
|
||||
def test_the_report_withdraws_what_the_builder_withdraws(self):
|
||||
import common
|
||||
from model import profiles as model_profiles
|
||||
from model.profiles import _emulator_profiles_cache
|
||||
import generate_pack as builder
|
||||
import verify as reporter
|
||||
|
||||
tmp, root, db, config = self._fixture()
|
||||
try:
|
||||
common._emulator_profiles_cache.clear()
|
||||
profiles = common.load_emulator_profiles(str(root / "emulators"))
|
||||
_emulator_profiles_cache.clear()
|
||||
profiles = model_profiles.load_emulator_profiles(str(root / "emulators"))
|
||||
groups, extra_dests = builder.platform_region_groups(
|
||||
config, config["systems"], str(root / "emulators"),
|
||||
db, "", profiles,
|
||||
@@ -730,14 +732,15 @@ class TestReportAndBuilderNarrowTogether(unittest.TestCase):
|
||||
"the report must withdraw exactly the builder's drop set",
|
||||
)
|
||||
finally:
|
||||
common._emulator_profiles_cache.clear()
|
||||
_emulator_profiles_cache.clear()
|
||||
tmp.cleanup()
|
||||
|
||||
def test_a_missing_regional_core_file_is_withdrawn_too(self):
|
||||
"""A missing platform file is grouped and withdrawn under --region, but a
|
||||
missing core file was never grouped and stayed "required missing"
|
||||
for a region the request excludes."""
|
||||
import common
|
||||
from model import profiles as model_profiles
|
||||
from model.profiles import _emulator_profiles_cache
|
||||
import verify as reporter
|
||||
|
||||
tmp, root, db, config = self._fixture()
|
||||
@@ -745,8 +748,8 @@ class TestReportAndBuilderNarrowTogether(unittest.TestCase):
|
||||
jp = next(k for k, v in db["files"].items() if v["name"] == "jp.bin")
|
||||
del db["files"][jp]
|
||||
del db["indexes"]["by_name"]["jp.bin"]
|
||||
common._emulator_profiles_cache.clear()
|
||||
profiles = common.load_emulator_profiles(str(root / "emulators"))
|
||||
_emulator_profiles_cache.clear()
|
||||
profiles = model_profiles.load_emulator_profiles(str(root / "emulators"))
|
||||
plain = reporter.verify_platform(
|
||||
config, db, str(root / "emulators"), profiles,
|
||||
)
|
||||
@@ -760,19 +763,20 @@ class TestReportAndBuilderNarrowTogether(unittest.TestCase):
|
||||
{u["name"] for u in narrowed["undeclared_files"]}, {"us.bin"}
|
||||
)
|
||||
finally:
|
||||
common._emulator_profiles_cache.clear()
|
||||
_emulator_profiles_cache.clear()
|
||||
tmp.cleanup()
|
||||
|
||||
def test_the_report_names_the_fallback_groups(self):
|
||||
"""The pack README lists the systems kept whole because nothing
|
||||
answers the request. verify said all OK and named none."""
|
||||
import common
|
||||
from model import profiles as model_profiles
|
||||
from model.profiles import _emulator_profiles_cache
|
||||
import verify as reporter
|
||||
|
||||
tmp, root, db, config = self._fixture()
|
||||
try:
|
||||
common._emulator_profiles_cache.clear()
|
||||
profiles = common.load_emulator_profiles(str(root / "emulators"))
|
||||
_emulator_profiles_cache.clear()
|
||||
profiles = model_profiles.load_emulator_profiles(str(root / "emulators"))
|
||||
result = reporter.verify_platform(
|
||||
config, db, str(root / "emulators"), profiles,
|
||||
regions=["brazil"],
|
||||
@@ -783,7 +787,7 @@ class TestReportAndBuilderNarrowTogether(unittest.TestCase):
|
||||
reporter.print_platform_result(result, ["Demo"])
|
||||
self.assertIn("all kept (1): demo-system", out.getvalue())
|
||||
finally:
|
||||
common._emulator_profiles_cache.clear()
|
||||
_emulator_profiles_cache.clear()
|
||||
tmp.cleanup()
|
||||
|
||||
def test_one_grouping_pass_serves_both_sides(self):
|
||||
@@ -820,7 +824,7 @@ class TestReportAndBuilderNarrowTogether(unittest.TestCase):
|
||||
if not (repo / "emulators" / "o2em.yml").is_file():
|
||||
self.skipTest("no o2em profile")
|
||||
from verify import verify_emulator
|
||||
from common import load_database
|
||||
from model.database import load_database
|
||||
|
||||
db = load_database(str(repo / "database.json"))
|
||||
full = verify_emulator(["o2em"], str(repo / "emulators"), db)
|
||||
@@ -934,7 +938,7 @@ class RegionalRequestsKeepWhatTheCodeLoads(unittest.TestCase):
|
||||
)
|
||||
|
||||
def test_each_request_keeps_its_file(self):
|
||||
profiles = common.load_emulator_profiles(
|
||||
profiles = model_profiles.load_emulator_profiles(
|
||||
os.path.join(os.path.dirname(__file__), "..", "emulators")
|
||||
)
|
||||
for name, regions, kept in self.CASES:
|
||||
@@ -960,7 +964,7 @@ class DsiNandFollowsTheHeaderRegion(unittest.TestCase):
|
||||
}
|
||||
|
||||
def _profile(self) -> dict:
|
||||
return common.load_emulator_profiles(
|
||||
return model_profiles.load_emulator_profiles(
|
||||
os.path.join(os.path.dirname(__file__), "..", "emulators")
|
||||
)["bizhawk"]
|
||||
|
||||
@@ -984,7 +988,7 @@ class FontRomsCarryNoTerritory(unittest.TestCase):
|
||||
from the generic MSX2+ machine whose config.ini loads both."""
|
||||
|
||||
def test_no_kanji_or_hangul_font_declares_a_region(self):
|
||||
profiles = common.load_emulator_profiles(
|
||||
profiles = model_profiles.load_emulator_profiles(
|
||||
os.path.join(os.path.dirname(__file__), "..", "emulators")
|
||||
)
|
||||
tagged = [
|
||||
@@ -1083,7 +1087,7 @@ class GenesisPlusGxUsBiosServesEurope(unittest.TestCase):
|
||||
def test_eu_jp_keeps_bios_u(self):
|
||||
from pathlib import Path
|
||||
|
||||
from common import load_emulator_profiles
|
||||
from model.profiles import load_emulator_profiles
|
||||
from region import build_region_index, parse_requested, resolve_region_drops
|
||||
|
||||
root = Path(__file__).resolve().parents[1]
|
||||
@@ -1104,7 +1108,7 @@ class GenesisPlusGxUsBiosServesEurope(unittest.TestCase):
|
||||
def _real_drops(profile: str, members: list[str], requested: str) -> set[str]:
|
||||
from pathlib import Path
|
||||
|
||||
from common import load_emulator_profiles
|
||||
from model.profiles import load_emulator_profiles
|
||||
from region import build_region_index, parse_requested, resolve_region_drops
|
||||
|
||||
root = Path(__file__).resolve().parents[1]
|
||||
@@ -1139,7 +1143,7 @@ class KoreanGameCubeDiscsReadTheJapaneseIpl(unittest.TestCase):
|
||||
for profile in ("dolphin", "dolphin-mmjr", "dolphin-mmjr2", "ishiiruka",
|
||||
"primehack", "triforce"):
|
||||
with self.subTest(profile=profile):
|
||||
from common import load_emulator_profiles
|
||||
from model.profiles import load_emulator_profiles
|
||||
|
||||
entries = [
|
||||
f for f in load_emulator_profiles("emulators")[profile]["files"]
|
||||
@@ -1157,7 +1161,7 @@ class ANameNoCodeOpensCarriesNoRegion(unittest.TestCase):
|
||||
exist."""
|
||||
|
||||
def test_scph5903_is_unregioned(self):
|
||||
from common import load_emulator_profiles
|
||||
from model.profiles import load_emulator_profiles
|
||||
|
||||
entry = next(
|
||||
f for f in load_emulator_profiles("emulators")["beetle_psx"]["files"]
|
||||
@@ -1216,7 +1220,7 @@ class PcsxRearmedUsSlotIsTheDefault(unittest.TestCase):
|
||||
other market boots the US slot."""
|
||||
|
||||
def test_every_us_slot_bios_includes_latin_america(self):
|
||||
from common import load_emulator_profiles
|
||||
from model.profiles import load_emulator_profiles
|
||||
|
||||
tagged = [
|
||||
f for f in load_emulator_profiles("emulators")["pcsx_rearmed"]["files"]
|
||||
@@ -1241,7 +1245,7 @@ class PlayStationUsImageAnswersTheAmericaLicence(unittest.TestCase):
|
||||
"rustation": 6, "duckstation": 28}
|
||||
|
||||
def test_every_us_image_includes_latin_america(self):
|
||||
from common import load_emulator_profiles
|
||||
from model.profiles import load_emulator_profiles
|
||||
|
||||
profiles = load_emulator_profiles("emulators")
|
||||
for name, count in self.COUNTS.items():
|
||||
@@ -1263,7 +1267,7 @@ class FusionSmsExportBiosFollowsTheSetting(unittest.TestCase):
|
||||
list. Neither export BIOS is chosen for a territory the cart names."""
|
||||
|
||||
def test_the_export_bioses_are_unregioned(self):
|
||||
from common import load_emulator_profiles
|
||||
from model.profiles import load_emulator_profiles
|
||||
|
||||
files = {f["name"]: f for f in load_emulator_profiles("emulators")["kega-fusion"]["files"]}
|
||||
for name in ("bios_U.sms", "bios_E.sms"):
|
||||
@@ -1307,7 +1311,7 @@ class ARefusedRegionalFileHoldsNoSlot(unittest.TestCase):
|
||||
from generate_pack import generate_emulator_pack
|
||||
from verify import verify_emulator
|
||||
|
||||
common._emulator_profiles_cache.clear()
|
||||
_emulator_profiles_cache.clear()
|
||||
repo = Path(__file__).resolve().parents[1]
|
||||
(repo / "tmp").mkdir(exist_ok=True)
|
||||
root = Path(tempfile.mkdtemp(dir=repo / "tmp"))
|
||||
@@ -1394,7 +1398,7 @@ class MachineModelRomsCarryNoTerritory(unittest.TestCase):
|
||||
}
|
||||
|
||||
def test_model_roms_are_unregioned(self):
|
||||
profiles = common.load_emulator_profiles(
|
||||
profiles = model_profiles.load_emulator_profiles(
|
||||
os.path.join(os.path.dirname(__file__), "..", "emulators")
|
||||
)
|
||||
for profile, names in self.CASES.items():
|
||||
|
||||
@@ -26,7 +26,9 @@ class ScanCopiesStay(unittest.TestCase):
|
||||
os.chdir(REPO_ROOT)
|
||||
self.addCleanup(os.chdir, previous)
|
||||
import region as region_mod
|
||||
from common import load_database, load_emulator_profiles, load_platform_config
|
||||
from model.database import load_database
|
||||
from model.profiles import load_emulator_profiles
|
||||
from model.platforms import load_platform_config
|
||||
from packextras import platform_region_groups
|
||||
|
||||
db = load_database("database.json")
|
||||
|
||||
@@ -180,7 +180,7 @@ class ContentList(unittest.TestCase):
|
||||
def test_every_region_system_has_a_game_per_region_or_says_why(self) -> None:
|
||||
"""A system whose BIOS a profile ties to JP, US and EU has a game for
|
||||
each of the three, or the content list says why it has none."""
|
||||
from common import load_emulator_profiles
|
||||
from model.profiles import load_emulator_profiles
|
||||
|
||||
import yaml
|
||||
|
||||
|
||||
@@ -47,7 +47,9 @@ class TheEnterpriseKeepsItsRom(unittest.TestCase):
|
||||
if not (REPO_ROOT / "database.json").exists():
|
||||
self.skipTest("database.json is not built")
|
||||
import region
|
||||
from common import load_database, load_emulator_profiles, load_platform_config
|
||||
from model.database import load_database
|
||||
from model.profiles import load_emulator_profiles
|
||||
from model.platforms import load_platform_config
|
||||
from packextras import platform_region_groups
|
||||
|
||||
db = load_database(str(REPO_ROOT / "database.json"))
|
||||
@@ -65,7 +67,7 @@ class TheEnterpriseKeepsItsRom(unittest.TestCase):
|
||||
def test_brd_rom_is_chosen_by_the_content_not_a_territory(self):
|
||||
# core.hpp:221-226: "[req brd-rom]" in the content name selects it,
|
||||
# whatever the user's country, as "[req zrom]" selects hun.rom.
|
||||
from common import load_emulator_profiles
|
||||
from model.profiles import load_emulator_profiles
|
||||
|
||||
profiles = load_emulator_profiles(str(REPO_ROOT / "emulators"))
|
||||
entry = next(
|
||||
@@ -107,8 +109,10 @@ class ALosingClaimIsKeyedLikeTheWinner(unittest.TestCase):
|
||||
def test_a_losing_claim_carries_the_declared_root(self):
|
||||
import os
|
||||
|
||||
from common import declared_root, load_database, load_emulator_profiles
|
||||
from common import load_platform_config
|
||||
from model.declarations import declared_root
|
||||
from model.database import load_database
|
||||
from model.profiles import load_emulator_profiles
|
||||
from model.platforms import load_platform_config
|
||||
from packextras import platform_region_groups
|
||||
|
||||
previous = os.getcwd()
|
||||
|
||||
@@ -66,8 +66,10 @@ class ADataDirectoryCopyIsHeld(unittest.TestCase):
|
||||
previous = os.getcwd()
|
||||
os.chdir(REPO_ROOT)
|
||||
try:
|
||||
from common import load_data_dir_registry, load_database
|
||||
from common import load_emulator_profiles, load_platform_config
|
||||
from model.registry import load_data_dir_registry
|
||||
from model.database import load_database
|
||||
from model.profiles import load_emulator_profiles
|
||||
from model.platforms import load_platform_config
|
||||
cls.db = load_database("database.json")
|
||||
cls.registry = load_data_dir_registry("platforms")
|
||||
cls.profiles = load_emulator_profiles("emulators")
|
||||
|
||||
@@ -26,7 +26,7 @@ from unittest import mock
|
||||
|
||||
import yaml
|
||||
|
||||
import common
|
||||
from model.registry import list_registered_platforms, list_release_pack_platforms
|
||||
import release_record
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||
@@ -62,7 +62,7 @@ def _which_pack() -> str:
|
||||
class TheFieldIsTheList(unittest.TestCase):
|
||||
def test_the_registry_marks_the_most_downloaded_setups(self):
|
||||
self.assertEqual(
|
||||
set(common.list_release_pack_platforms(PLATFORMS)), RELEASED
|
||||
set(list_release_pack_platforms(PLATFORMS)), RELEASED
|
||||
)
|
||||
|
||||
def test_only_marked_platforms_are_listed(self):
|
||||
@@ -72,9 +72,9 @@ class TheFieldIsTheList(unittest.TestCase):
|
||||
"small": {},
|
||||
"off": {"release_pack": False},
|
||||
})
|
||||
self.assertEqual(common.list_release_pack_platforms(platforms_dir), ["big"])
|
||||
self.assertEqual(list_release_pack_platforms(platforms_dir), ["big"])
|
||||
self.assertEqual(
|
||||
common.list_registered_platforms(platforms_dir), ["big", "off", "small"]
|
||||
list_registered_platforms(platforms_dir), ["big", "off", "small"]
|
||||
)
|
||||
|
||||
def test_the_schema_holds_the_field(self):
|
||||
@@ -145,7 +145,7 @@ class TheBuildReadsTheField(unittest.TestCase):
|
||||
def test_manifests_cover_every_platform(self):
|
||||
self.assertEqual(
|
||||
set(self._groups("--all", "--manifest", "--offline")),
|
||||
set(common.list_registered_platforms(PLATFORMS)),
|
||||
set(list_registered_platforms(PLATFORMS)),
|
||||
)
|
||||
|
||||
def test_the_release_owners_are_the_marked_platforms(self):
|
||||
@@ -475,7 +475,7 @@ class EveryPlatformHasAPermanentPage(unittest.TestCase):
|
||||
|
||||
record = release_record.load_advertised()
|
||||
with contextlib.chdir(REPO_ROOT):
|
||||
for name in common.list_registered_platforms(PLATFORMS):
|
||||
for name in list_registered_platforms(PLATFORMS):
|
||||
page = generate_site.generate_get_page(name)
|
||||
pack = release_record.pack_for(name, record)
|
||||
with self.subTest(platform=name):
|
||||
@@ -501,7 +501,7 @@ class EveryPlatformHasAPermanentPage(unittest.TestCase):
|
||||
docs = REPO_ROOT / "website" / "src" / "content" / "docs" / release_record.GET_DIR
|
||||
if not docs.is_dir():
|
||||
self.skipTest("the site is not generated")
|
||||
for name in common.list_registered_platforms(PLATFORMS):
|
||||
for name in list_registered_platforms(PLATFORMS):
|
||||
with self.subTest(platform=name):
|
||||
self.assertTrue(any(docs.glob(f"{name}.md*")))
|
||||
|
||||
@@ -529,7 +529,7 @@ class TheSiteCheckResolvesEveryGetPage(unittest.TestCase):
|
||||
record_path.write_text(json.dumps(record), encoding="utf-8")
|
||||
pages = {
|
||||
f"get/{name}/index.html": "install.sh"
|
||||
for name in common.list_registered_platforms(PLATFORMS)
|
||||
for name in list_registered_platforms(PLATFORMS)
|
||||
}
|
||||
pages["get/romm/index.html"] = f'<a href="{download}v1/RomM_BIOS_Pack.zip">x</a>'
|
||||
pages["get/knulli/index.html"] = f'<a href="{download}v1/K_BIOS_Pack.zip">x</a>'
|
||||
|
||||
@@ -21,7 +21,8 @@ from pathlib import Path
|
||||
|
||||
import yaml
|
||||
|
||||
import common
|
||||
from model.platforms import _platform_config_cache
|
||||
from model.profiles import _emulator_profiles_cache
|
||||
import generate_db
|
||||
import generate_pack as builder
|
||||
|
||||
@@ -69,11 +70,11 @@ class RequiredTwins(unittest.TestCase):
|
||||
(self.platforms / "_registry.yml").write_text(
|
||||
yaml.dump({"platforms": {"twins": {"config": "twins.yml"}}})
|
||||
)
|
||||
common._platform_config_cache.clear()
|
||||
common._emulator_profiles_cache.clear()
|
||||
_platform_config_cache.clear()
|
||||
_emulator_profiles_cache.clear()
|
||||
|
||||
def tearDown(self):
|
||||
common._platform_config_cache.clear()
|
||||
_platform_config_cache.clear()
|
||||
self._tmp.cleanup()
|
||||
|
||||
def test_the_required_only_pack_carries_the_required_file(self):
|
||||
|
||||
@@ -19,7 +19,8 @@ import zipfile
|
||||
import zlib
|
||||
from pathlib import Path
|
||||
|
||||
import common
|
||||
from resolve.content import declared_hash_verdict
|
||||
from resolve.localfile import resolve_local_file, _resolve_agnostic
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||
|
||||
@@ -55,7 +56,7 @@ class DeclaredHashVerdict(unittest.TestCase):
|
||||
md5_list=[], crc_candidates=set(), zipped_file=None, declared_size=None,
|
||||
)
|
||||
base.update(declared)
|
||||
return common.declared_hash_verdict(str(path), **base)
|
||||
return declared_hash_verdict(str(path), **base)
|
||||
|
||||
def test_no_declared_hash_means_the_name_is_all_there_is(self):
|
||||
self.assertEqual(
|
||||
@@ -173,13 +174,13 @@ class AgnosticFallback(unittest.TestCase):
|
||||
"size": 64,
|
||||
}
|
||||
self.assertEqual(
|
||||
common._resolve_agnostic(entry, self.files_db, False),
|
||||
_resolve_agnostic(entry, self.files_db, False),
|
||||
(str(self.match), "agnostic_fallback"),
|
||||
)
|
||||
|
||||
def test_a_declared_hash_outranks_the_shape(self):
|
||||
entry = {"agnostic": True, "agnostic_path_prefix": str(self.root), "size": 64}
|
||||
self.assertIsNone(common._resolve_agnostic(entry, self.files_db, True))
|
||||
self.assertIsNone(_resolve_agnostic(entry, self.files_db, True))
|
||||
|
||||
def test_the_wrong_size_is_not_a_candidate(self):
|
||||
entry = {
|
||||
@@ -187,7 +188,7 @@ class AgnosticFallback(unittest.TestCase):
|
||||
"agnostic_path_prefix": str(self.root),
|
||||
"size": 65,
|
||||
}
|
||||
self.assertIsNone(common._resolve_agnostic(entry, self.files_db, False))
|
||||
self.assertIsNone(_resolve_agnostic(entry, self.files_db, False))
|
||||
|
||||
def test_a_size_range_is_honoured(self):
|
||||
entry = {
|
||||
@@ -196,7 +197,7 @@ class AgnosticFallback(unittest.TestCase):
|
||||
"min_size": 32,
|
||||
"max_size": 128,
|
||||
}
|
||||
self.assertIsNotNone(common._resolve_agnostic(entry, self.files_db, False))
|
||||
self.assertIsNotNone(_resolve_agnostic(entry, self.files_db, False))
|
||||
|
||||
def test_a_list_of_accepted_sizes_is_honoured(self):
|
||||
entry = {
|
||||
@@ -205,19 +206,19 @@ class AgnosticFallback(unittest.TestCase):
|
||||
"size": [32, 64],
|
||||
}
|
||||
self.assertEqual(
|
||||
common._resolve_agnostic(entry, self.files_db, False),
|
||||
_resolve_agnostic(entry, self.files_db, False),
|
||||
(str(self.match), "agnostic_fallback"),
|
||||
)
|
||||
entry["size"] = [32, 65]
|
||||
self.assertIsNone(common._resolve_agnostic(entry, self.files_db, False))
|
||||
self.assertIsNone(_resolve_agnostic(entry, self.files_db, False))
|
||||
|
||||
def test_without_a_prefix_nothing_is_scanned(self):
|
||||
entry = {"agnostic": True, "size": 64}
|
||||
self.assertIsNone(common._resolve_agnostic(entry, self.files_db, False))
|
||||
self.assertIsNone(_resolve_agnostic(entry, self.files_db, False))
|
||||
|
||||
def test_an_entry_that_is_not_agnostic_is_left_alone(self):
|
||||
entry = {"agnostic_path_prefix": str(self.root), "size": 64}
|
||||
self.assertIsNone(common._resolve_agnostic(entry, self.files_db, False))
|
||||
self.assertIsNone(_resolve_agnostic(entry, self.files_db, False))
|
||||
|
||||
|
||||
class OneSpellingForAcceptedSizes(unittest.TestCase):
|
||||
@@ -271,7 +272,7 @@ class SeveralAcceptedCrc32(unittest.TestCase):
|
||||
hack_first = sorted([crc[variant], crc[primary]])
|
||||
entry = {"name": "syscard3.pce", "crc32": hack_first}
|
||||
self.assertEqual(
|
||||
common.resolve_local_file(entry, db), (str(primary), "crc32_exact")
|
||||
resolve_local_file(entry, db), (str(primary), "crc32_exact")
|
||||
)
|
||||
|
||||
|
||||
@@ -296,7 +297,7 @@ class TheMatchingArchiveForAMember(unittest.TestCase):
|
||||
"by_md5": {}, "by_crc32": {}, "by_path_suffix": {}}}
|
||||
entry = {"name": "neogeo.zip", "zipped_file": "sfix.sfix",
|
||||
"md5": hashlib.md5(b"second").hexdigest()}
|
||||
self.assertEqual(common.resolve_local_file(entry, db), (str(paths[1]), "zip_exact"))
|
||||
self.assertEqual(resolve_local_file(entry, db), (str(paths[1]), "zip_exact"))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -663,7 +663,8 @@ class RepositoryRun(unittest.TestCase):
|
||||
if not database.is_file() or not bios.is_dir():
|
||||
self.skipTest("collection not present in this checkout")
|
||||
|
||||
from common import load_database, load_emulator_profiles
|
||||
from model.database import load_database
|
||||
from model.profiles import load_emulator_profiles
|
||||
|
||||
db = load_database(str(database))
|
||||
recipes = collect_recipes(
|
||||
|
||||
@@ -119,7 +119,7 @@ class ThePlatformNamesItsSaveDirectory(unittest.TestCase):
|
||||
)
|
||||
|
||||
def test_retroarch_and_lakka_have_one_retropie_none(self):
|
||||
from common import load_platform_config
|
||||
from model.platforms import load_platform_config
|
||||
|
||||
platforms = str(REPO_ROOT / "platforms")
|
||||
self.assertEqual(save_layout(load_platform_config("retroarch", platforms)),
|
||||
@@ -132,7 +132,7 @@ class ThePlatformNamesItsSaveDirectory(unittest.TestCase):
|
||||
def test_each_platform_running_these_cores_says_where(self):
|
||||
"""The layout read from each platform's launch code, or none where
|
||||
saves sit beside each game or in a browser."""
|
||||
from common import load_platform_config
|
||||
from model.platforms import load_platform_config
|
||||
|
||||
platforms = str(REPO_ROOT / "platforms")
|
||||
expected = {
|
||||
@@ -211,7 +211,8 @@ class _Fixture(unittest.TestCase):
|
||||
OTHER_KEYS = b"PLATFORM KEYS"
|
||||
|
||||
def setUp(self) -> None:
|
||||
from common import _emulator_profiles_cache, _platform_config_cache
|
||||
from model.profiles import _emulator_profiles_cache
|
||||
from model.platforms import _platform_config_cache
|
||||
|
||||
_emulator_profiles_cache.clear()
|
||||
_platform_config_cache.clear()
|
||||
@@ -265,12 +266,12 @@ class _Fixture(unittest.TestCase):
|
||||
}))
|
||||
|
||||
def config(self, name: str) -> dict:
|
||||
from common import load_platform_config
|
||||
from model.platforms import load_platform_config
|
||||
|
||||
return load_platform_config(name, str(self.platforms))
|
||||
|
||||
def profiles(self) -> dict:
|
||||
from common import load_emulator_profiles
|
||||
from model.profiles import load_emulator_profiles
|
||||
|
||||
return load_emulator_profiles(str(self.emulators))
|
||||
|
||||
|
||||
@@ -611,7 +611,7 @@ class EveryTargetCoreReachesAProfile(unittest.TestCase):
|
||||
import yaml
|
||||
|
||||
import check_freshness
|
||||
from common import load_emulator_profiles
|
||||
from model.profiles import load_emulator_profiles
|
||||
|
||||
root = Path(__file__).resolve().parents[1]
|
||||
index = check_freshness.profile_name_index(
|
||||
@@ -932,7 +932,7 @@ class OneNativeIdOneSystem(unittest.TestCase):
|
||||
FOLDS = {"fbneo", "pcenginecd"}
|
||||
|
||||
def test_scrapers_agree_on_every_shared_native_id(self):
|
||||
from common import _norm_system_id
|
||||
from model.systems import _norm_system_id
|
||||
|
||||
seen: dict[str, dict[str, str]] = {}
|
||||
for path in sorted((REPO_ROOT / "scripts" / "scraper").glob("*_scraper.py")):
|
||||
@@ -977,11 +977,9 @@ class OneNativeIdOneSystem(unittest.TestCase):
|
||||
def test_every_platform_system_meets_a_profile_system(self):
|
||||
import yaml
|
||||
|
||||
from common import (
|
||||
_norm_system_id,
|
||||
load_emulator_profiles,
|
||||
load_platform_config,
|
||||
)
|
||||
from model.systems import _norm_system_id
|
||||
from model.profiles import load_emulator_profiles
|
||||
from model.platforms import load_platform_config
|
||||
|
||||
known = set()
|
||||
for profile in load_emulator_profiles(str(REPO_ROOT / "emulators")).values():
|
||||
@@ -1000,7 +998,7 @@ class OneNativeIdOneSystem(unittest.TestCase):
|
||||
def test_xroar_machines_reach_the_platforms_that_run_it(self):
|
||||
import yaml
|
||||
|
||||
from common import _norm_system_id
|
||||
from model.systems import _norm_system_id
|
||||
|
||||
xroar = yaml.safe_load((REPO_ROOT / "emulators" / "xroar.yml").read_text())
|
||||
machines = {_norm_system_id(s) for s in xroar["systems"]}
|
||||
|
||||
@@ -22,7 +22,7 @@ class SegaFilesStayUnderSega(unittest.TestCase):
|
||||
folder = REPO_ROOT / "bios" / "Microsoft" / "MSX"
|
||||
if not folder.is_dir():
|
||||
self.skipTest("bios/Microsoft/MSX is absent")
|
||||
from common import load_emulator_profiles
|
||||
from model.profiles import load_emulator_profiles
|
||||
|
||||
systems: dict[str, set[str]] = {}
|
||||
for profile in load_emulator_profiles(str(REPO_ROOT / "emulators")).values():
|
||||
|
||||
@@ -14,7 +14,7 @@ import tests
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from common import load_emulator_profiles
|
||||
from model.profiles import load_emulator_profiles
|
||||
from model.safeparse import yaml_load
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
@@ -26,7 +26,12 @@ import unittest
|
||||
import zipfile
|
||||
from pathlib import Path
|
||||
|
||||
import common
|
||||
from core.hashing import md5_composite
|
||||
from core.paths import sanitize_pack_path
|
||||
from model.database import load_database
|
||||
from model.platforms import load_platform_config
|
||||
from model.profiles import load_emulator_profiles
|
||||
from resolve.localfile import resolve_local_file
|
||||
from resolve.nativemode import reads_file_contents
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
@@ -71,7 +76,7 @@ class ShippedFilesSatisfyTheirDeclaration(unittest.TestCase):
|
||||
for manifest_path in sorted(self.install.glob("*.json")):
|
||||
platform = manifest_path.stem
|
||||
try:
|
||||
config = common.load_platform_config(platform, str(ROOT / "platforms"))
|
||||
config = load_platform_config(platform, str(ROOT / "platforms"))
|
||||
except (FileNotFoundError, KeyError):
|
||||
continue
|
||||
if not reads_file_contents(config.get("verification_mode")):
|
||||
@@ -85,13 +90,13 @@ class ShippedFilesSatisfyTheirDeclaration(unittest.TestCase):
|
||||
dest = entry.get("destination") or entry.get("name", "")
|
||||
if dest:
|
||||
declared.setdefault(
|
||||
common.sanitize_pack_path(dest), []
|
||||
sanitize_pack_path(dest), []
|
||||
).append(entry)
|
||||
|
||||
manifest = json.loads(manifest_path.read_text())
|
||||
for shipped in manifest.get("files", []):
|
||||
entries = declared.get(
|
||||
common.sanitize_pack_path(shipped.get("dest", "")), []
|
||||
sanitize_pack_path(shipped.get("dest", "")), []
|
||||
)
|
||||
entries = [e for e in entries if not e.get("zipped_file")]
|
||||
candidates = [(e, _declared_digests(e)) for e in entries]
|
||||
@@ -116,7 +121,7 @@ class ShippedFilesSatisfyTheirDeclaration(unittest.TestCase):
|
||||
# A variant carries its hash after the extension
|
||||
# (cdimono1.zip.e6714b3d), so the name is not the test.
|
||||
with contextlib.suppress(zipfile.BadZipFile, OSError):
|
||||
digests["md5"].append(common.md5_composite(str(blob_path)))
|
||||
digests["md5"].append(md5_composite(str(blob_path)))
|
||||
# A declared MD5 can be shorter than 32 characters: compare by prefix.
|
||||
satisfied = any(
|
||||
all(
|
||||
@@ -165,8 +170,8 @@ class ProfileContradictionsAreKnown(unittest.TestCase):
|
||||
database = ROOT / "database.json"
|
||||
if not database.is_file():
|
||||
self.skipTest("database.json not built")
|
||||
db = common.load_database(str(database))
|
||||
profiles = common.load_emulator_profiles(str(ROOT / "emulators"))
|
||||
db = load_database(str(database))
|
||||
profiles = load_emulator_profiles(str(ROOT / "emulators"))
|
||||
unsatisfied = []
|
||||
for name, profile in sorted(profiles.items()):
|
||||
if profile.get("type") in ("alias", "launcher"):
|
||||
@@ -180,7 +185,7 @@ class ProfileContradictionsAreKnown(unittest.TestCase):
|
||||
continue
|
||||
if not _declared_digests(entry):
|
||||
continue
|
||||
path, status = common.resolve_local_file(
|
||||
path, status = resolve_local_file(
|
||||
entry, db, dest_hint=entry.get("path", "")
|
||||
)
|
||||
if path and status == "hash_mismatch":
|
||||
@@ -220,7 +225,7 @@ class ArchiveNamesDesignateArchives(unittest.TestCase):
|
||||
database = ROOT / "database.json"
|
||||
if not database.is_file():
|
||||
self.skipTest("database.json not built")
|
||||
db = common.load_database(str(database))
|
||||
db = load_database(str(database))
|
||||
loose = []
|
||||
for name, ids in db["indexes"]["by_name"].items():
|
||||
if not name.lower().endswith(".zip"):
|
||||
|
||||
@@ -15,7 +15,7 @@ from pathlib import Path
|
||||
|
||||
import yaml
|
||||
|
||||
from common import load_database
|
||||
from model.database import load_database
|
||||
from generate_site import _availability_check, _file_badges
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||
|
||||
@@ -192,7 +192,7 @@ class EveryBuiltPage(unittest.TestCase):
|
||||
class TheIntegrationItems(unittest.TestCase):
|
||||
|
||||
def test_a_platform_page_draws_its_logo_beside_the_title(self):
|
||||
from common import load_platform_registry
|
||||
from model.registry import load_platform_registry
|
||||
|
||||
registry = load_platform_registry(str(REPO_ROOT / "platforms"))
|
||||
with_logo = [key for key, entry in registry.items() if entry.get("logo")]
|
||||
|
||||
@@ -32,7 +32,7 @@ import zlib
|
||||
import html
|
||||
import sys
|
||||
|
||||
from common import list_release_pack_platforms
|
||||
from model.registry import list_release_pack_platforms
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
|
||||
Loaded 100 of 281 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user