mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-12-02 06:18:51 -06:00
refactor: split native model and review hashes
This commit is contained in:
1 parent
753e873472
commit
571a22d2b6
33 files changed
+658
-617
No files matched your search
@@ -20,7 +20,8 @@ from pathlib import Path
|
||||
from resolve.localfile import resolve_local_file
|
||||
from exporter import discover_exporters
|
||||
from exporter.landed import landed_changes
|
||||
from resolve.reconcile import NativeFile, build_native_model
|
||||
from resolve.nativemodel import NativeFile
|
||||
from resolve.reconcile import build_native_model
|
||||
from exporter.batocera_exporter import md5_list_support
|
||||
from scraper import rocknix_scraper
|
||||
from scraper.base_scraper import md5_field, requirement_entry
|
||||
|
||||
@@ -271,7 +271,7 @@ class TheExportKeepsTheirShape(unittest.TestCase):
|
||||
|
||||
def test_paths_start_where_the_list_starts(self):
|
||||
from exporter.amberelec_exporter import Exporter as Amber
|
||||
from resolve.reconcile import NativeFile
|
||||
from resolve.nativemodel import NativeFile
|
||||
from exporter.knulli_exporter import Exporter as Knulli
|
||||
|
||||
fe = NativeFile("neogeo.zip", "neogeo/neogeo.zip", "neogeo")
|
||||
|
||||
@@ -16,7 +16,8 @@ import unittest
|
||||
from collections import OrderedDict
|
||||
from pathlib import Path
|
||||
|
||||
from resolve.reconcile import NativeFile, NativeSystem, Report, build_native_model
|
||||
from resolve.nativemodel import NativeFile, NativeSystem, Report
|
||||
from resolve.reconcile import build_native_model
|
||||
from exporter.bizhawk_exporter import Exporter as BizHawk
|
||||
from exporter.misterfpga_exporter import Exporter as Mister
|
||||
from exporter.romm_exporter import Exporter as Romm
|
||||
@@ -191,7 +192,7 @@ class RetroBatKeepsWhatWeDoNotModel(unittest.TestCase):
|
||||
]},
|
||||
"newsys": {"name": "New", "biosFiles": [{"md5": B, "file": "bios/new.bin"}]},
|
||||
}
|
||||
from resolve.reconcile import Report
|
||||
from resolve.nativemodel import Report
|
||||
|
||||
produced = json.loads(RetroBat().render(
|
||||
systems, Report(), {"batocera-systems.json": json.dumps(original)},
|
||||
@@ -251,7 +252,7 @@ class PureDataExportsKeepWhatWeDoNotModel(unittest.TestCase):
|
||||
filled=[])
|
||||
|
||||
def test_recalbox(self):
|
||||
from resolve.reconcile import Report
|
||||
from resolve.nativemodel import Report
|
||||
from exporter.recalbox_exporter import Exporter as Recalbox
|
||||
|
||||
fe = self._file("a.bin", "nes", destination="nes/a.bin", core="libretro:fceumm")
|
||||
@@ -277,7 +278,7 @@ class PureDataExportsKeepWhatWeDoNotModel(unittest.TestCase):
|
||||
self.assertIn('mandatory="false"', produced)
|
||||
|
||||
def test_system_dat(self):
|
||||
from resolve.reconcile import Report
|
||||
from resolve.nativemodel import Report
|
||||
|
||||
fe = self._file("a.bin", "Nintendo - NES")
|
||||
systems = {"Nintendo - NES": NativeSystem("Nintendo - NES", files=[fe])}
|
||||
@@ -301,7 +302,7 @@ class PureDataExportsKeepWhatWeDoNotModel(unittest.TestCase):
|
||||
def test_two_additions_differing_by_directory_are_two_lines(self):
|
||||
"""PCSX2's vulkan and opengl convert.glsl were both written under the
|
||||
bare name, so the second was dropped and still counted as added."""
|
||||
from resolve.reconcile import Report
|
||||
from resolve.nativemodel import Report
|
||||
|
||||
shaders = [
|
||||
NativeFile("convert.glsl", f"pcsx2/resources/shaders/{api}/convert.glsl",
|
||||
@@ -989,7 +990,7 @@ class TheSummaryCountsWhatTheFileCarries(unittest.TestCase):
|
||||
|
||||
def test_romm_drops_the_hashes_it_counts_cleared(self):
|
||||
from exporter.landed import landed_changes
|
||||
from resolve.reconcile import Report
|
||||
from resolve.nativemodel import Report
|
||||
|
||||
fe = self._contradicted()
|
||||
systems = {"psx": NativeSystem("psx", files=[fe])}
|
||||
|
||||
@@ -38,7 +38,8 @@ from exporter import discover_exporters
|
||||
from exporter.base_exporter import BaseExporter
|
||||
from exporter.originals import SOURCES_INDEX, collect_originals, fetch, pinned_base, source_key
|
||||
from exporter.landed import landed_changes
|
||||
from resolve.reconcile import NativeFile, NativeSystem, Report, build_native_model
|
||||
from resolve.nativemodel import NativeFile, NativeSystem, Report
|
||||
from resolve.reconcile import build_native_model
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||
|
||||
@@ -760,7 +761,7 @@ class SearchOrder(unittest.TestCase):
|
||||
"""PicoDrive loads the first file of each region's list. RetroPie
|
||||
names one per region, but the export appended three more, which the
|
||||
sentence reads as three more required files."""
|
||||
from resolve.reconcile import NativeSystem
|
||||
from resolve.nativemodel import NativeSystem
|
||||
|
||||
def cd(name, region, rank):
|
||||
return NativeFile(name=name, destination=name, native_system="segacd", truth={
|
||||
@@ -795,7 +796,7 @@ class SearchOrder(unittest.TestCase):
|
||||
"""flycast's help names the Dreamcast BIOS, then the Naomi/Atomiswave
|
||||
ones. naomi2.zip, an arcade archive, went into the Dreamcast list:
|
||||
only the first BIOS clause was read."""
|
||||
from resolve.reconcile import NativeSystem
|
||||
from resolve.nativemodel import NativeSystem
|
||||
|
||||
def entry(name, system):
|
||||
return NativeFile(name=name, destination=f"dc/{name}", native_system=system,
|
||||
@@ -2871,7 +2872,7 @@ class ARecordDescribesOneDump(unittest.TestCase):
|
||||
export wrote v2.0's crc beside v2.1's md5 and sha1."""
|
||||
|
||||
def test_the_platform_record_stays_whole_when_the_truth_accepts_it(self):
|
||||
from resolve.reconcile import NativeFile
|
||||
from resolve.nativemodel import NativeFile
|
||||
|
||||
fe = NativeFile(
|
||||
name="syscard2.pce", destination="syscard2.pce", native_system="pce",
|
||||
@@ -2884,7 +2885,7 @@ class ARecordDescribesOneDump(unittest.TestCase):
|
||||
self.assertEqual(fe.record_hash("md5"), "3cdd6614" + "0" * 24)
|
||||
|
||||
def test_a_field_only_the_truth_names_is_written_when_unambiguous(self):
|
||||
from resolve.reconcile import NativeFile
|
||||
from resolve.nativemodel import NativeFile
|
||||
|
||||
one = NativeFile(name="a", destination="a", native_system="s",
|
||||
platform={"crc32": "11111111"},
|
||||
|
||||
@@ -28,7 +28,7 @@ from pathlib import Path
|
||||
from sitegen import gaps
|
||||
from sitegen import lookup
|
||||
from sitegen import wanted as sitewanted
|
||||
from resolve import review, sendable
|
||||
from resolve import review, reviewhashes, sendable
|
||||
import yaml
|
||||
from model.database import load_database
|
||||
from tests.test_site_pronouns import pronouns
|
||||
@@ -159,7 +159,7 @@ class _World(unittest.TestCase):
|
||||
]}]
|
||||
self.platform_hashes = {"sha1": set(), "md5": set(), "names": set(), "folders": {},
|
||||
"named": {}}
|
||||
self.profile_hashes = review.load_profile_hashes(str(emulators), self.db)
|
||||
self.profile_hashes = reviewhashes.load_profile_hashes(str(emulators), self.db)
|
||||
self.placer = sitewanted.Placer(self.db, self.platform_hashes, self.profile_hashes)
|
||||
self.data = sitewanted.build_wanted(
|
||||
self.profiles, self.coverages, self.gap_report, self.db, self.placer,
|
||||
@@ -606,8 +606,8 @@ class AFolderComesFromTheSystem(unittest.TestCase):
|
||||
if not (REPO_ROOT / "database.json").is_file():
|
||||
raise unittest.SkipTest("no database")
|
||||
cls.db = load_database(str(REPO_ROOT / "database.json"))
|
||||
cls.platform_hashes = review.load_platform_hashes(str(REPO_ROOT / "platforms"), cls.db)
|
||||
cls.profile_hashes = review.load_profile_hashes(str(REPO_ROOT / "emulators"), cls.db)
|
||||
cls.platform_hashes = reviewhashes.load_platform_hashes(str(REPO_ROOT / "platforms"), cls.db)
|
||||
cls.profile_hashes = reviewhashes.load_profile_hashes(str(REPO_ROOT / "emulators"), cls.db)
|
||||
|
||||
def place(self, systems: list[str], directory: str) -> review.Placement:
|
||||
return review.placement([], "config.ini", self.db, self.platform_hashes,
|
||||
@@ -655,8 +655,8 @@ class ThePublishedList(unittest.TestCase):
|
||||
|
||||
def test_every_folder_is_the_reviews(self):
|
||||
placer = sitewanted.Placer(
|
||||
self.db, review.load_platform_hashes(str(REPO_ROOT / "platforms"), self.db),
|
||||
review.load_profile_hashes(str(REPO_ROOT / "emulators"), self.db))
|
||||
self.db, reviewhashes.load_platform_hashes(str(REPO_ROOT / "platforms"), self.db),
|
||||
reviewhashes.load_profile_hashes(str(REPO_ROOT / "emulators"), self.db))
|
||||
# An entry placed by its hashes. The others take their folder from
|
||||
# their system and directory, which the list does not carry: the
|
||||
# synthetic world above holds them to the rule.
|
||||
|
||||
@@ -18,7 +18,7 @@ import unittest
|
||||
import unittest.mock
|
||||
from pathlib import Path
|
||||
|
||||
from resolve.reconcile import checked_hashes
|
||||
from resolve.nativemodel import checked_hashes
|
||||
from resolve.truth import generate_platform_truth
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||
|
||||
@@ -18,6 +18,7 @@ from pathlib import Path
|
||||
|
||||
from devtools import reviewfiles, reviewreport
|
||||
from resolve import review
|
||||
from resolve.reviewhashes import load_profile_hashes, load_platform_hashes
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||
|
||||
@@ -132,7 +133,7 @@ class AFileOnlyACoreReadsIsKnown(_Fixture):
|
||||
"emulator: Engine\ntype: standalone\nsystems: [x]\nfiles:\n"
|
||||
f" - name: \"data.bin\"\n sha1: \"{hashlib.sha1(data).hexdigest()}\"\n"
|
||||
)
|
||||
known = review.load_profile_hashes(str(emulators))
|
||||
known = load_profile_hashes(str(emulators))
|
||||
result = review.validate_file(
|
||||
self._bios_file("bios/Maker/Engine/data.bin", data), None, EMPTY_HASHES, known,
|
||||
)
|
||||
@@ -155,7 +156,7 @@ class AFileOnlyACoreReadsIsKnown(_Fixture):
|
||||
)
|
||||
db = {"files": {hashlib.sha1(held).hexdigest(): {"path": "bios/Maker/Console/a.bin"}},
|
||||
"indexes": {"by_md5": {}, "by_sha256": {}}}
|
||||
known = review.load_profile_hashes(str(emulators), db)
|
||||
known = load_profile_hashes(str(emulators), db)
|
||||
result = review.validate_file(
|
||||
self._bios_file("Downloads/b.bin", missing), db, EMPTY_HASHES, known,
|
||||
)
|
||||
@@ -203,7 +204,7 @@ class ADeclaredFileBesideItsHeldNameIsAVariant(_Fixture):
|
||||
)
|
||||
db = {"files": {"a" * 40: {"path": "bios/Maker/Console/v.bin"}},
|
||||
"indexes": {"by_md5": {}, "by_sha256": {}, "by_name": {"v.bin": ["a" * 40]}}}
|
||||
known = review.load_profile_hashes(str(emulators), db)
|
||||
known = load_profile_hashes(str(emulators), db)
|
||||
result = review.validate_file(
|
||||
self._bios_file("card/v.bin", data), db, EMPTY_HASHES, known)
|
||||
slot = f"bios/Maker/Console/.variants/v.bin.{result.sha1[:8]}"
|
||||
@@ -434,7 +435,7 @@ class PlacementBySystem(_Fixture):
|
||||
db = {"files": {"aaaa": {"path": "bios/Arcade/MAME/a.zip"},
|
||||
"bbbb": {"path": "bios/Apple/Apple II/b.zip"}},
|
||||
"indexes": {"by_md5": {}}}
|
||||
known = review.load_platform_hashes(str(platforms), db)
|
||||
known = load_platform_hashes(str(platforms), db)
|
||||
self.assertEqual(known["folders"], {})
|
||||
|
||||
|
||||
@@ -498,7 +499,7 @@ class Reporting(_Fixture):
|
||||
|
||||
class PlatformHashLoading(_Fixture):
|
||||
def test_missing_directory_yields_empty_sets(self):
|
||||
known = review.load_platform_hashes(str(self.tmp / "absent"))
|
||||
known = load_platform_hashes(str(self.tmp / "absent"))
|
||||
self.assertEqual(known, {"sha1": set(), "md5": set(), "sha256": set(), "crc32": set(),
|
||||
"names": set(), "folders": {}, "sizes": {}, "entries": {},
|
||||
"named": {}, "name_systems": {}, "system_dirs": {},
|
||||
@@ -519,7 +520,7 @@ class PlatformHashLoading(_Fixture):
|
||||
f" sha1: {'a' * 40}\n"
|
||||
f" md5: {'b' * 32}\n"
|
||||
)
|
||||
known = review.load_platform_hashes(str(platforms))
|
||||
known = load_platform_hashes(str(platforms))
|
||||
self.assertIn("a" * 40, known["sha1"])
|
||||
self.assertIn("b" * 32, known["md5"])
|
||||
self.assertIn("boot.bin", known["names"])
|
||||
@@ -539,7 +540,7 @@ class ThePlatformsOwnCheckDecides(_Fixture):
|
||||
encoding="utf-8")
|
||||
(platforms / "p.yml").write_text(f"platform: P\nsystems:\n s:\n files:\n{systems}",
|
||||
encoding="utf-8")
|
||||
return review.load_platform_hashes(str(platforms))
|
||||
return load_platform_hashes(str(platforms))
|
||||
|
||||
def _zip(self) -> str:
|
||||
import zipfile
|
||||
@@ -682,7 +683,7 @@ class ProfileHashesReadAsTheResolverDoes(unittest.TestCase):
|
||||
" - name: bsx.bin\n sha256: \"aa,bb\"\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
known = review.load_profile_hashes(tmp)
|
||||
known = load_profile_hashes(tmp)
|
||||
self.assertEqual(known["crc32"][("bf63fb1f", 16384)], {"core"})
|
||||
self.assertIn("bb", known["sha256"])
|
||||
|
||||
|
||||
@@ -20,9 +20,9 @@ REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
class EveryAcceptedRevisionIsKnown(unittest.TestCase):
|
||||
def test_multi_hash_members_are_known(self):
|
||||
from resolve import review
|
||||
from resolve.reviewhashes import load_platform_hashes
|
||||
|
||||
known = review.load_platform_hashes(str(REPO_ROOT / "platforms"))
|
||||
known = load_platform_hashes(str(REPO_ROOT / "platforms"))
|
||||
raw = yaml.safe_load((REPO_ROOT / "platforms" / "recalbox.yml").read_text())
|
||||
listed = [
|
||||
value.strip().lower()
|
||||
|
||||
Reference in new issue
Block a user