mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-22 09:37:48 -06:00
chore: merge engine and tooling batch
This commit is contained in:
commit
51ae0eb6d0
80 files changed
+1536
-116
No files matched your search
@@ -83,6 +83,27 @@ class EveryWriterGoesThroughIt(unittest.TestCase):
|
||||
]
|
||||
self.assertEqual(offenders, [])
|
||||
|
||||
def test_generators_publish_whole_files(self):
|
||||
"""install/games/ (12 MB, read by install.py --for-games), the event
|
||||
schema, the launcher index and wiki/installer.md were truncated at
|
||||
their final name: an interrupted run left a committed-looking file
|
||||
holding part of a JSON document. The installer doc's sandbox writes
|
||||
throwaway fixtures under tmp/ and is not published."""
|
||||
import ast
|
||||
|
||||
sandbox = {"write_small_list", "Sandbox"}
|
||||
offenders = []
|
||||
for path in sorted((REPO_ROOT / "scripts").glob("generate_*.py")):
|
||||
tree = ast.parse(path.read_text(encoding="utf-8"))
|
||||
for top in tree.body:
|
||||
if path.name == "generate_installer_doc.py" and getattr(top, "name", "") in sandbox:
|
||||
continue
|
||||
for node in ast.walk(top):
|
||||
if (isinstance(node, ast.Call) and isinstance(node.func, ast.Attribute)
|
||||
and node.func.attr in ("write_text", "write_bytes")):
|
||||
offenders.append(f"{path.name}:{node.lineno}")
|
||||
self.assertEqual(offenders, [])
|
||||
|
||||
def test_the_text_is_utf8_whatever_the_locale(self):
|
||||
import tempfile
|
||||
|
||||
@@ -154,6 +175,38 @@ class ScratchFilesGetThePlainMode(unittest.TestCase):
|
||||
artifacts.write_text_atomic(str(self.dir / "a.json"), "{}")
|
||||
self.assertEqual(self._mode(self.dir / "a.json"), 0o664)
|
||||
|
||||
def test_threads_reading_the_mode_leave_the_umask_alone(self):
|
||||
"""mame_devices fetches on eight threads and every cache write reads
|
||||
the umask: unguarded, two readers interleaved and left it at 0."""
|
||||
import threading # noqa: PLC0415
|
||||
|
||||
interval = sys.getswitchinterval()
|
||||
sys.setswitchinterval(1e-6)
|
||||
self.addCleanup(sys.setswitchinterval, interval)
|
||||
modes: set[int] = set()
|
||||
|
||||
def read() -> None:
|
||||
seen = {artifacts.plain_file_mode() for _ in range(20000)}
|
||||
modes.update(seen)
|
||||
|
||||
threads = [threading.Thread(target=read) for _ in range(8)]
|
||||
for thread in threads:
|
||||
thread.start()
|
||||
for thread in threads:
|
||||
thread.join()
|
||||
current = os.umask(0o022)
|
||||
self.assertEqual(current, 0o022)
|
||||
self.assertEqual(modes, {0o644})
|
||||
|
||||
def test_no_script_reads_the_umask_unguarded(self):
|
||||
offenders = [
|
||||
f"{path.name}:{number}"
|
||||
for path in sorted((REPO_ROOT / "scripts").rglob("*.py"))
|
||||
for number, line in enumerate(path.read_text(encoding="utf-8").splitlines(), 1)
|
||||
if "os.umask(" in line and path.name != "artifacts.py"
|
||||
]
|
||||
self.assertEqual(offenders, [])
|
||||
|
||||
def test_packs_and_their_manifest(self):
|
||||
import zipfile # noqa: PLC0415
|
||||
|
||||
|
||||
@@ -2725,6 +2725,34 @@ class DeclaredDependenciesMatchTheDocumentedWorkflows(unittest.TestCase):
|
||||
)
|
||||
|
||||
|
||||
class TheProjectInstallsWithPip(unittest.TestCase):
|
||||
"""pyproject declared a dev extra that pip could not install: without a
|
||||
[build-system] and an explicit module list, setuptools' flat-layout
|
||||
discovery found scripts/ and tests/ and refused to build."""
|
||||
|
||||
def test_setuptools_discovers_nothing_to_package(self):
|
||||
import importlib.util # noqa: PLC0415
|
||||
|
||||
if importlib.util.find_spec("setuptools") is None:
|
||||
self.skipTest("setuptools is not installed")
|
||||
program = (
|
||||
"from setuptools.dist import Distribution\n"
|
||||
"from setuptools.config.pyprojecttoml import apply_configuration\n"
|
||||
"dist = apply_configuration(Distribution(), 'pyproject.toml')\n"
|
||||
"dist.set_defaults()\n"
|
||||
"print(sorted(dist.packages or []), sorted(dist.py_modules or []))\n"
|
||||
)
|
||||
done = subprocess.run([sys.executable, "-c", program], cwd=ROOT,
|
||||
capture_output=True, text=True, check=False)
|
||||
self.assertEqual(done.returncode, 0, done.stderr[-2000:])
|
||||
self.assertEqual(done.stdout.strip(), "[] []")
|
||||
import tomllib # noqa: PLC0415
|
||||
|
||||
with (ROOT / "pyproject.toml").open("rb") as handle:
|
||||
build = tomllib.load(handle)["build-system"]
|
||||
self.assertEqual(build["build-backend"], "setuptools.build_meta")
|
||||
|
||||
|
||||
class ACheckThatCannotAnswerDoesNotPass(unittest.TestCase):
|
||||
"""Exiting zero says the question was answered and the answer was yes.
|
||||
|
||||
@@ -4196,6 +4224,10 @@ class AutoFetchAsksVerifyWhatIsMissing(unittest.TestCase):
|
||||
"system": "diablo", "emulator": "DevilutionX"},
|
||||
{"name": "held.bin", "in_repo": True, "required": True},
|
||||
{"name": "extra.bin", "in_repo": False, "required": False},
|
||||
# zesarux installs 128s.rom with the emulator: not a target,
|
||||
# and a copy placed in bios/ fails pipeline step 4d.
|
||||
{"name": "128s.rom", "in_repo": False, "required": True,
|
||||
"bundled": True, "emulator": "ZEsarUX"},
|
||||
],
|
||||
}
|
||||
with mock.patch.object(verify_mod, "verify_platform", lambda c, d: result):
|
||||
@@ -5582,12 +5614,17 @@ class ANamedPackThatIsAbsentFails(unittest.TestCase):
|
||||
|
||||
|
||||
|
||||
class AnAliasNamesItsProfile(unittest.TestCase):
|
||||
""""flycast_gles2 is an alias of flycast -use --emulator flycast": the
|
||||
dash read as an option, and an alias without alias_of advised
|
||||
"--emulator ?"."""
|
||||
class AnAliasSelectsItsProfile(unittest.TestCase):
|
||||
"""`--emulator mednafen_psx` refused with "use --emulator beetle_psx",
|
||||
a step the tool could take itself: the name a user reads in RetroArch
|
||||
now selects the profile it is an alias of, and says so on stderr. An
|
||||
alias without alias_of is found through the profile whose cores: names
|
||||
it."""
|
||||
|
||||
def test_the_alias_selects_its_profile(self):
|
||||
import contextlib as _contextlib
|
||||
import io as _io
|
||||
|
||||
def test_the_message(self):
|
||||
from scripts.common import ProfileSelectionError, select_emulator_profiles
|
||||
|
||||
profiles = {
|
||||
@@ -5595,12 +5632,28 @@ class AnAliasNamesItsProfile(unittest.TestCase):
|
||||
"flycast_gles2": {"type": "alias", "alias_of": "flycast"},
|
||||
"orphan": {"type": "alias"},
|
||||
"core": {"type": "libretro", "cores": ["orphan"]},
|
||||
"lost": {"type": "alias"},
|
||||
}
|
||||
for name, expected in (("flycast_gles2", "alias of flycast: use --emulator flycast"),
|
||||
("orphan", "alias of core: use --emulator core")):
|
||||
with self.subTest(name=name), self.assertRaises(ProfileSelectionError) as caught:
|
||||
select_emulator_profiles([name], profiles)
|
||||
self.assertIn(expected, str(caught.exception))
|
||||
for name, expected in (("flycast_gles2", "flycast"), ("orphan", "core")):
|
||||
err = _io.StringIO()
|
||||
with self.subTest(name=name), _contextlib.redirect_stderr(err):
|
||||
selected = select_emulator_profiles([name], profiles)
|
||||
self.assertEqual([key for key, _ in selected], [expected])
|
||||
self.assertIn(f"{name} is {expected}", err.getvalue())
|
||||
with _contextlib.redirect_stderr(_io.StringIO()):
|
||||
both = select_emulator_profiles(["flycast", "flycast_gles2"], profiles)
|
||||
self.assertEqual([key for key, _ in both], ["flycast"])
|
||||
with self.assertRaises(ProfileSelectionError):
|
||||
select_emulator_profiles(["lost"], profiles)
|
||||
|
||||
def test_verify_runs_the_alias(self):
|
||||
result = subprocess.run(
|
||||
[sys.executable, "scripts/verify.py", "--emulator", "mednafen_psx"],
|
||||
cwd=ROOT, capture_output=True, text=True, timeout=300, check=False,
|
||||
)
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
self.assertIn("beetle_psx", result.stdout)
|
||||
self.assertIn("mednafen_psx is beetle_psx", result.stderr)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -955,6 +955,23 @@ class SubjectsFollowTheRepositoryRules(unittest.TestCase):
|
||||
self.assertTrue(ar.check_subject(subject))
|
||||
self.assertEqual(ar.check_subject("chore: tidy the cache"), [])
|
||||
|
||||
def test_review_numbers_are_refused(self):
|
||||
"""47 pushed subjects pointed at a numbered private review, which no
|
||||
clone can follow. The subject says what the change does."""
|
||||
import commit_rules # noqa: PLC0415
|
||||
|
||||
for subject in ("chore: audit 24 and 17 cases, host kept out",
|
||||
"fix: polish the screens audit 11 named",
|
||||
"chore: merge audit batch, resolver and profiles",
|
||||
"fix: settle the review 3 notes"):
|
||||
with self.subTest(subject=subject):
|
||||
self.assertTrue(commit_rules.problems(subject))
|
||||
for subject in ("fix: scroll long messages in the installer",
|
||||
"feat: read regions in region_audit.py",
|
||||
"chore: merge resolver and profile fixes"):
|
||||
with self.subTest(subject=subject):
|
||||
self.assertEqual(commit_rules.problems(subject), [])
|
||||
|
||||
def test_the_rules_run_as_a_hook(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
message = Path(tmp) / "MSG"
|
||||
|
||||
@@ -538,7 +538,7 @@ class ProfileFieldsRequired(unittest.TestCase):
|
||||
section = _section(_page("profiling.md"), "Profile fields")
|
||||
marked = {
|
||||
row[0].strip("`") for row in _table_rows(section)
|
||||
if row[1].startswith(("yes", "for `type"))
|
||||
if row[1].startswith(("yes", "for `type", "with `"))
|
||||
}
|
||||
self.assertEqual(marked, required)
|
||||
|
||||
|
||||
+9
-4
@@ -17,7 +17,9 @@ Covers:
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import contextlib
|
||||
import hashlib
|
||||
import io
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
@@ -1444,10 +1446,13 @@ class TestE2E(unittest.TestCase):
|
||||
with self.assertRaises(SystemExit):
|
||||
verify_emulator(["test_game"], self.emulators_dir, self.db, standalone=True)
|
||||
|
||||
def test_93_verify_emulator_alias_rejected(self):
|
||||
"""Alias profile produces error with redirect message."""
|
||||
with self.assertRaises(SystemExit):
|
||||
verify_emulator(["test_alias"], self.emulators_dir, self.db)
|
||||
def test_93_verify_emulator_alias_selects_its_profile(self):
|
||||
"""An alias verifies the profile it is an alias of."""
|
||||
with contextlib.redirect_stderr(io.StringIO()):
|
||||
via_alias = verify_emulator(["test_alias"], self.emulators_dir, self.db)
|
||||
direct = verify_emulator(["test_emu"], self.emulators_dir, self.db)
|
||||
self.assertEqual(via_alias["emulators"], direct["emulators"])
|
||||
self.assertEqual(via_alias["details"], direct["details"])
|
||||
|
||||
def test_94_verify_emulator_launcher_rejected(self):
|
||||
"""Launcher profile produces error."""
|
||||
|
||||
@@ -220,5 +220,49 @@ class IndexedProof(unittest.TestCase):
|
||||
self.assertEqual(index.proofs(entry, destination), expected)
|
||||
|
||||
|
||||
class AProfileIsIndexedOncePerKind(unittest.TestCase):
|
||||
"""_matching walked the reader's whole profile for each platform entry:
|
||||
2,135 scans of the MAME profile took 2 s of verify --all."""
|
||||
|
||||
FILES = [
|
||||
{"name": "zero.bin", "md5": "0" * 32, "source_ref": "a.c:1"},
|
||||
{"name": "one.bin", "md5": "1" * 32, "source_ref": "a.c:2"},
|
||||
{"name": "one.bin", "md5": "2" * 32, "source_ref": "a.c:3"},
|
||||
{"name": "two.bin", "aliases": ["TWO.ROM"], "source_ref": "a.c:4"},
|
||||
{"name": "data.pak", "category": "game_data", "source_ref": "a.c:5"},
|
||||
]
|
||||
|
||||
def setUp(self):
|
||||
profiles = {"core": {"emulator": "Core", "type": "libretro", "cores": ["core"],
|
||||
"systems": ["s"], "files": self.FILES}}
|
||||
self.cats = EntryCategories(_config(["core"], []), profiles)
|
||||
|
||||
def test_the_index_answers_as_the_scan_did(self):
|
||||
cases = [
|
||||
({"name": "one.bin", "md5": "2" * 32}, BIOS, [{"name": "one.bin", "source_ref": "a.c:3"}]),
|
||||
# A cut md5 (Batocera's 29 characters) matches by prefix.
|
||||
({"name": "x", "md5": "1" * 29}, BIOS, [{"name": "one.bin", "source_ref": "a.c:2"}]),
|
||||
({"name": "one.bin"}, BIOS, [
|
||||
{"name": "one.bin", "source_ref": "a.c:2", "by": "name"},
|
||||
{"name": "one.bin", "source_ref": "a.c:3", "by": "name"},
|
||||
]),
|
||||
({"name": "one.bin", "md5": "9" * 32}, BIOS, []),
|
||||
({"name": "two.rom"}, BIOS, [{"name": "two.bin", "source_ref": "a.c:4", "by": "name"}]),
|
||||
({"name": "data.pak"}, BIOS, []),
|
||||
({"name": "data.pak"}, GAME_DATA, [{"name": "data.pak", "source_ref": "a.c:5", "by": "name"}]),
|
||||
]
|
||||
for entry, kind, expected in cases:
|
||||
with self.subTest(entry=entry, kind=kind):
|
||||
self.assertEqual(self.cats._matching("core", kind, entry), expected)
|
||||
|
||||
def test_the_profile_is_walked_once_per_kind(self):
|
||||
from unittest import mock
|
||||
|
||||
with mock.patch.object(self.cats, "_accepted_by", wraps=self.cats._accepted_by) as hashed:
|
||||
for _ in range(50):
|
||||
self.cats._matching("core", BIOS, {"name": "zero.bin", "md5": "0" * 32})
|
||||
self.assertEqual(hashed.call_count, 4)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -1060,5 +1060,41 @@ class ARemovedSizeIsReported(unittest.TestCase):
|
||||
self.assertEqual(changes.unsized, ["SNK - NeoGeo CD/neocdz.zip"])
|
||||
|
||||
|
||||
class AnExtendedListIsReported(unittest.TestCase):
|
||||
"""The truth adds an accepted md5 the platform lacks without
|
||||
contradicting it: RetroDECK wrote [A, B] where the manifest had A and
|
||||
Recalbox md5="A,B" where es_bios.xml had A, and the report listed
|
||||
nothing. Only Batocera named the list it writes."""
|
||||
|
||||
def _records(self, exporter):
|
||||
from export_native import landed_changes # noqa: PLC0415
|
||||
|
||||
platform = {"name": "f.bin", "md5": A, "core": "libretro/mesen"}
|
||||
fe = NativeFile("f.bin", "f.bin", "s", platform=platform,
|
||||
truth={"md5": [A, B], "validation": ["md5"]})
|
||||
return landed_changes(exporter, {"s": NativeSystem("s", files=[fe])}).records, fe
|
||||
|
||||
def test_both_formats_report_the_list_they_write(self):
|
||||
for exporter in (RetroDeck(), Recalbox()):
|
||||
with self.subTest(exporter=exporter.platform_name()):
|
||||
records, fe = self._records(exporter)
|
||||
self.assertEqual(fe.hashes("md5"), [A, B])
|
||||
self.assertEqual(
|
||||
[(r["kind"], r["field"], r["old"], r["new"]) for r in records],
|
||||
[("hash_corrected", "md5", A, [A, B])],
|
||||
)
|
||||
|
||||
def test_an_unchanged_value_reports_nothing(self):
|
||||
from export_native import landed_changes # noqa: PLC0415
|
||||
|
||||
for exporter in (RetroDeck(), Recalbox()):
|
||||
fe = NativeFile("f.bin", "f.bin", "s",
|
||||
platform={"name": "f.bin", "md5": A, "core": "libretro/mesen"},
|
||||
truth={"md5": A})
|
||||
with self.subTest(exporter=exporter.platform_name()):
|
||||
changes = landed_changes(exporter, {"s": NativeSystem("s", files=[fe])})
|
||||
self.assertEqual(changes.records, [])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -176,6 +176,47 @@ class GamesIndexFixture(unittest.TestCase):
|
||||
self.assertTrue(any("catalog" in f for f in failures))
|
||||
|
||||
|
||||
class CheckSaysWhatDiffers(unittest.TestCase):
|
||||
"""--check printed STALE and a path after 120 lines of coverage: the
|
||||
reader had to diff single-line JSON of 550 KB by hand to find that a
|
||||
manifest had gained one file."""
|
||||
|
||||
def test_an_added_file_is_named(self) -> None:
|
||||
old = json.dumps({"files": [["a.bin", 1, "bios"]], "version": 1})
|
||||
new = json.dumps({"files": [["a.bin", 1, "bios"], ["ide12.rom", 16384, "bios"]],
|
||||
"version": 1})
|
||||
lines = gi.describe_change(old, new)
|
||||
self.assertEqual(len(lines), 1)
|
||||
self.assertIn("1 added", lines[0])
|
||||
self.assertIn("ide12.rom", lines[0])
|
||||
|
||||
def test_new_and_unreadable_documents(self) -> None:
|
||||
self.assertEqual(gi.describe_change(None, "{}"), ["not written yet"])
|
||||
self.assertIn("not valid JSON", gi.describe_change("{", "{}")[0])
|
||||
|
||||
def test_check_names_the_command_and_skips_coverage(self) -> None:
|
||||
import contextlib
|
||||
import io
|
||||
from unittest import mock
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
out = Path(tmp)
|
||||
target = out / "index.json"
|
||||
target.write_text(json.dumps({"files": []}), encoding="utf-8")
|
||||
files = {target: json.dumps({"files": [["x.rom", 2, "bios"]]})}
|
||||
coverage = {"setups": {}, "systems": {}, "arcade": []}
|
||||
stdout, stderr = io.StringIO(), io.StringIO()
|
||||
argv = ["generate_games_index.py", "--check", "--output-dir", tmp]
|
||||
with mock.patch.object(gi, "render", return_value=(files, coverage)), \
|
||||
mock.patch.object(sys, "argv", argv), \
|
||||
contextlib.redirect_stdout(stdout), contextlib.redirect_stderr(stderr):
|
||||
code = gi.main()
|
||||
self.assertEqual(code, 1)
|
||||
self.assertEqual(stdout.getvalue(), "")
|
||||
self.assertIn("files: 1 added", stderr.getvalue())
|
||||
self.assertIn("python scripts/generate_games_index.py", stderr.getvalue())
|
||||
|
||||
|
||||
class CommittedData(unittest.TestCase):
|
||||
"""The data the repository publishes."""
|
||||
|
||||
|
||||
@@ -10,6 +10,8 @@ it, and these tests make the agreement checkable instead of reviewable.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import contextlib
|
||||
import io
|
||||
import json
|
||||
import sys
|
||||
import unittest
|
||||
@@ -446,10 +448,12 @@ class OneProfileSelector(unittest.TestCase):
|
||||
self.assertIsNone(error)
|
||||
self.assertEqual([n for n, _p in selected], ["real"])
|
||||
|
||||
def test_an_alias_names_the_profile_to_ask_instead(self):
|
||||
_selected, error = self._select(["ghost"])
|
||||
self.assertIn("alias of real", error)
|
||||
self.assertIn("--emulator real", error)
|
||||
def test_an_alias_selects_the_profile_it_names(self):
|
||||
with contextlib.redirect_stderr(io.StringIO()) as err:
|
||||
selected, error = self._select(["ghost"])
|
||||
self.assertIsNone(error)
|
||||
self.assertEqual([n for n, _p in selected], ["real"])
|
||||
self.assertIn("ghost is real", err.getvalue())
|
||||
|
||||
def test_a_launcher_is_refused(self):
|
||||
_selected, error = self._select(["starter"])
|
||||
|
||||
@@ -189,6 +189,9 @@ class EveryEmulatorPackMatchesItsReport(unittest.TestCase):
|
||||
finally:
|
||||
os.chdir(previous)
|
||||
self.assertTrue(ok, out.getvalue())
|
||||
# Packs of several profiles too: a placement rule that only goes
|
||||
# wrong when two profiles share a path never meets in one profile.
|
||||
self.assertIn("system packs compared, all equal", out.getvalue())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -0,0 +1,138 @@
|
||||
"""Held pins name the build file that holds them.
|
||||
|
||||
pin_frozen was free prose and no tool read the build file it cites: a
|
||||
platform moving mame0278 to another commit would have left the profile
|
||||
holding a revision no platform builds, in silence. `pin_build` records the
|
||||
file, and check_freshness reads it again where the platform now stands.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
from unittest import mock
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0, str(REPO_ROOT / "scripts"))
|
||||
|
||||
import check_freshness as cf # noqa: E402
|
||||
|
||||
RECALBOX = "https://gitlab.com/recalbox/recalbox"
|
||||
|
||||
|
||||
class HeldPinsReadTheirBuildFileAgain(unittest.TestCase):
|
||||
REF = {"platform": "recalbox", "repo": RECALBOX,
|
||||
"revision": "10.1.1", "path": "package/libretro-mame0278/libretro-mame0278.mk",
|
||||
"variable": "LIBRETRO_MAME0278_VERSION", "value": "a" * 40}
|
||||
|
||||
def setUp(self):
|
||||
self._tmp = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(self._tmp.cleanup)
|
||||
self.platforms = Path(self._tmp.name)
|
||||
|
||||
def _platform(self, revision: str) -> None:
|
||||
(self.platforms / "recalbox.yml").write_text(
|
||||
f'source: "{RECALBOX}/-/raw/{revision}/board/es_bios.xml"\n'
|
||||
)
|
||||
|
||||
def _check(self, lines=None, offline=False):
|
||||
profiles = {"mame0278": {"pin_frozen": "Recalbox builds it.", "pin_build": [self.REF]},
|
||||
"raine": {"pin_frozen": "RetroBat installs this release."}}
|
||||
with mock.patch.object(cf.upstream, "fetch_file", return_value=lines) as fetched:
|
||||
findings = cf.check_pin_builds(profiles, self.platforms, "cache", offline)
|
||||
return {f.subject: f for f in findings}, fetched
|
||||
|
||||
def test_the_variable_forms_the_platforms_write(self):
|
||||
cases = [
|
||||
(["LIBRETRO_MAME0278_VERSION = fba5074"], "LIBRETRO_MAME0278_VERSION", "fba5074"),
|
||||
(['PKG_VERSION="37cddf2" #v0.6.3'], "PKG_VERSION", "37cddf2"),
|
||||
(['rp_module_repo="file $__archive_url/advancemame-1.4.tar.gz"'], "rp_module_repo",
|
||||
"file $__archive_url/advancemame-1.4.tar.gz"),
|
||||
(["function f() {", ' local version="20250829"', ' version="20250302"'],
|
||||
"version", "20250829"),
|
||||
(["OTHER_VERSION = 1"], "PKG_VERSION", None),
|
||||
]
|
||||
for lines, variable, expected in cases:
|
||||
with self.subTest(variable=variable):
|
||||
self.assertEqual(cf.build_variable(lines, variable), expected)
|
||||
|
||||
def test_the_platform_read_at_the_same_revision_needs_no_network(self):
|
||||
self._platform("10.1.1")
|
||||
found, fetched = self._check()
|
||||
fetched.assert_not_called()
|
||||
self.assertEqual(found["mame0278 (recalbox)"].status, cf.OK)
|
||||
|
||||
def test_a_new_revision_building_another_commit_is_stale(self):
|
||||
self._platform("10.2")
|
||||
found, fetched = self._check([f"LIBRETRO_MAME0278_VERSION = {'b' * 40}"])
|
||||
self.assertEqual(fetched.call_args.args[1:3],
|
||||
("10.2", "package/libretro-mame0278/libretro-mame0278.mk"))
|
||||
row = found["mame0278 (recalbox)"]
|
||||
self.assertEqual(row.status, cf.STALE)
|
||||
self.assertIn("now builds " + "b" * 40, row.detail)
|
||||
|
||||
def test_a_new_revision_building_the_same_commit_is_ok(self):
|
||||
self._platform("10.2")
|
||||
found, _ = self._check([f"LIBRETRO_MAME0278_VERSION = {'a' * 40}"])
|
||||
self.assertEqual(found["mame0278 (recalbox)"].status, cf.OK)
|
||||
|
||||
def test_a_build_file_gone_is_stale(self):
|
||||
self._platform("10.2")
|
||||
found, _ = self._check(None)
|
||||
self.assertEqual(found["mame0278 (recalbox)"].status, cf.STALE)
|
||||
self.assertIn("is gone", found["mame0278 (recalbox)"].detail)
|
||||
|
||||
def test_offline_and_uncached_is_skipped(self):
|
||||
self._platform("10.2")
|
||||
profiles = {"mame0278": {"pin_frozen": "x", "pin_build": [self.REF]}}
|
||||
cold = cf.upstream.NotCachedError("not cached")
|
||||
with mock.patch.object(cf.upstream, "fetch_file", side_effect=cold):
|
||||
(row,) = cf.check_pin_builds(profiles, self.platforms, "cache", True)
|
||||
self.assertEqual(row.status, cf.SKIPPED)
|
||||
|
||||
def test_a_hold_with_no_build_file_is_counted(self):
|
||||
self._platform("10.1.1")
|
||||
found, _ = self._check()
|
||||
row = found["pin_frozen without pin_build"]
|
||||
self.assertEqual(row.status, cf.SKIPPED)
|
||||
self.assertEqual(row.items, ["raine"])
|
||||
|
||||
|
||||
class EveryBuildReferenceNamesThePin(unittest.TestCase):
|
||||
"""Reads the repository: a pin_build value is what the platform builds,
|
||||
so it is the profile's source_commit or names its core_version, and the
|
||||
platform's own YAML was scraped from that repository."""
|
||||
|
||||
def test_the_values_agree(self):
|
||||
from common import load_emulator_profiles
|
||||
|
||||
disagree = []
|
||||
for name, profile in load_emulator_profiles(str(REPO_ROOT / "emulators")).items():
|
||||
references = profile.get("pin_build") or []
|
||||
if not references:
|
||||
continue
|
||||
pins = profile.get("source_commit")
|
||||
pins = set(pins.values()) if isinstance(pins, dict) else {pins}
|
||||
versions = profile.get("core_version")
|
||||
versions = (
|
||||
{str(v) for v in versions.values()} if isinstance(versions, dict)
|
||||
else {str(versions)} if versions else set()
|
||||
)
|
||||
|
||||
def names_it(value: str) -> bool:
|
||||
token = value.split()[-1].rsplit("/", 1)[-1].removesuffix(".tar.gz")
|
||||
return value in pins or any(token in v or v in value for v in versions)
|
||||
|
||||
if not any(names_it(str(r["value"])) for r in references):
|
||||
disagree.append(name)
|
||||
for reference in references:
|
||||
if not cf.pin_build_revision(reference, REPO_ROOT / "platforms"):
|
||||
disagree.append(f"{name}: {reference['platform']} is not read from "
|
||||
f"{reference['repo']}")
|
||||
self.assertEqual(disagree, [])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -2670,6 +2670,19 @@ class TestWriteDryRun(unittest.TestCase):
|
||||
counts={"SHIFTED": 1},
|
||||
)
|
||||
|
||||
def test_a_prose_read_that_fails_leaves_the_profile_as_it_was(self):
|
||||
"""The bumped profile was promoted before the prose under its new pin
|
||||
was read. Offline, an uncached cited file raised NotCachedError past
|
||||
the restore and the profile kept a pin the guard would refuse."""
|
||||
from unittest import mock # noqa: PLC0415
|
||||
|
||||
before = self.path.read_bytes()
|
||||
cold = profile_sync.upstream.NotCachedError("x.c not cached")
|
||||
with mock.patch.object(profile_sync, "realign_prose", side_effect=[[], cold]), \
|
||||
self.assertRaises(profile_sync.upstream.NotCachedError):
|
||||
self._run(self._args(rebase_refs=True, dry_run=False), self._shifted())
|
||||
self.assertEqual(self.path.read_bytes(), before)
|
||||
|
||||
def test_rebase_states_the_move_and_leaves_the_file(self):
|
||||
before = self.path.read_text()
|
||||
output = self._run(self._args(rebase_refs=True), self._shifted())
|
||||
@@ -3812,6 +3825,18 @@ class TestDriftScore(unittest.TestCase):
|
||||
report = ProfileReport(name="a", entries=[], counts={"ANCHORED": 5})
|
||||
self.assertEqual(drift_score(report, None, 0), 0)
|
||||
|
||||
def test_a_pin_to_set_again_outranks_a_gone_ref(self):
|
||||
"""pcem ranked last at 0 with "1 to review, 1 orphaned pin": its
|
||||
upstream_commit had left every branch of a force-pushed repository."""
|
||||
gone = ProfileReport(name="a", entries=[], counts={"GONE": 1})
|
||||
orphaned = ProfileReport(name="pcem", entries=[], counts={},
|
||||
orphaned=["upstream_commit 25b54e3f"])
|
||||
moved = ProfileReport(name="m", entries=[], counts={},
|
||||
moved_repos=["a/b answers as c/b"])
|
||||
for report in (orphaned, moved):
|
||||
with self.subTest(name=report.name):
|
||||
self.assertGreater(drift_score(report, None, 0), drift_score(gone, None, 0))
|
||||
|
||||
|
||||
class TestCollectCitations(unittest.TestCase):
|
||||
def test_files_refs_in_document_order(self):
|
||||
@@ -5303,6 +5328,24 @@ class TestEmulatorsDirStatus(unittest.TestCase):
|
||||
self.assertTrue(profile_sync.emulators_dir_is_dirty(root, ["a"]))
|
||||
self.assertFalse(profile_sync.emulators_dir_is_dirty(root, ["b"]))
|
||||
|
||||
def test_the_refusal_names_the_changed_profile(self):
|
||||
"""One profile changed by another session among ~375 refused the
|
||||
whole run without saying which."""
|
||||
with tempfile.TemporaryDirectory() as root:
|
||||
self._git("init", "-q", cwd=root)
|
||||
for name in "abc":
|
||||
Path(root, f"{name}.yml").write_text(f"emulator: {name}\n")
|
||||
self._git("add", "a.yml", "b.yml", "c.yml", cwd=root)
|
||||
self._git("-c", "user.name=t", "-c", "user.email=t@t", "commit", "-qm", "p", cwd=root)
|
||||
Path(root, "b.yml").write_text("emulator: b2\n")
|
||||
self.assertEqual(profile_sync.emulators_dir_is_dirty(root, ["a", "b", "c"]),
|
||||
["b.yml"])
|
||||
err = io.StringIO()
|
||||
with contextlib.redirect_stderr(err), self.assertRaises(SystemExit):
|
||||
profile_sync._refuse_dirty_tree(root, ["a", "b", "c"])
|
||||
self.assertIn("b.yml has uncommitted changes", err.getvalue())
|
||||
self.assertNotIn("a.yml", err.getvalue())
|
||||
|
||||
def test_a_tree_outside_any_repository_is_not_clean(self):
|
||||
with tempfile.TemporaryDirectory() as root, mock.patch.dict(
|
||||
os.environ, {"GIT_CEILING_DIRECTORIES": str(Path(root).parent)}
|
||||
@@ -5435,7 +5478,7 @@ class UpstreamForkedByThePort(unittest.TestCase):
|
||||
upstream with the fork. Compared to upstream's own HEAD, a bump moved it
|
||||
past anything the port carries."""
|
||||
|
||||
def _views(self, base):
|
||||
def _views(self, base, ancestry=None):
|
||||
from unittest import mock # noqa: PLC0415
|
||||
|
||||
fork = profile_sync.upstream.make_repo("github.com", "f", "port")
|
||||
@@ -5447,7 +5490,9 @@ class UpstreamForkedByThePort(unittest.TestCase):
|
||||
]
|
||||
with mock.patch.object(
|
||||
profile_sync.upstream, "fork_base", return_value=base
|
||||
) as asked:
|
||||
) as asked, mock.patch.object(
|
||||
profile_sync.upstream, "ancestry", return_value=ancestry
|
||||
):
|
||||
followed = profile_sync._follow_fork_base(views, "cache", True)
|
||||
return followed, asked
|
||||
|
||||
@@ -5462,6 +5507,17 @@ class UpstreamForkedByThePort(unittest.TestCase):
|
||||
views, _ = self._views(None)
|
||||
self.assertEqual(views[1].head, "up-tip")
|
||||
|
||||
def test_a_pin_newer_than_the_base_keeps_the_tip(self):
|
||||
"""melonds documents the Qt standalone from melonDS-emu/melonDS: its
|
||||
upstream_commit is 825 commits past the merge base with the libretro
|
||||
fork, and reading its refs at the 2021 base reported them CHANGED."""
|
||||
views, _ = self._views("old-merge", ancestry=(825, 0))
|
||||
self.assertEqual(views[1].head, "up-tip")
|
||||
|
||||
def test_a_pin_behind_the_base_follows_it(self):
|
||||
views, _ = self._views("new-base", ancestry=(0, 12))
|
||||
self.assertEqual(views[1].head, "new-base")
|
||||
|
||||
|
||||
class ACachedTipOlderThanThePin(TestBuildReport):
|
||||
"""scummvm-standalone was pinned on 6f7b060d while the cached tip was
|
||||
|
||||
@@ -623,6 +623,21 @@ class AMissingDumpNamesTheProfileItFills(unittest.TestCase):
|
||||
needs = provenance_report.profile_needs(self.PROFILES, db)
|
||||
self.assertNotIn("dicrom.rom", needs["by_name"])
|
||||
|
||||
def test_a_file_installed_with_the_emulator_is_not_a_need(self):
|
||||
"""43 of 50 needs were bundled entries (samcoupe.rom, zesarux's
|
||||
tk90x.rom), burying the six xm7 ROMs a maintainer has to find."""
|
||||
from scripts import provenance_report # noqa: PLC0415
|
||||
|
||||
profiles = {
|
||||
"samcoupe": {"files": [{"name": "samcoupe.rom", "required": True,
|
||||
"bundled": True, "sha1": "f" * 40}]},
|
||||
"hcl": {"files": [{"name": "kanji.rom", "required": True, "bundled": True,
|
||||
"not_bundled_on": ["batocera"], "sha1": "9" * 40}]},
|
||||
}
|
||||
needs = provenance_report.profile_needs(profiles, {"files": {}})
|
||||
self.assertNotIn(("sha1", "f" * 40), needs["by_hash"])
|
||||
self.assertIn(("sha1", "9" * 40), needs["by_hash"])
|
||||
|
||||
|
||||
class TheWantedPageAsksOnlyForWhatCannotBeMade(unittest.TestCase):
|
||||
"""The site's Wanted page asked the public for 79 dumps the collection
|
||||
|
||||
@@ -14,6 +14,8 @@ parts extracted into one folder are the pack.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import contextlib
|
||||
import io
|
||||
import os
|
||||
import stat
|
||||
import subprocess
|
||||
@@ -230,6 +232,26 @@ class PartsAreNotTakenForPacks(SplitFixture):
|
||||
[p.name for p in parts],
|
||||
)
|
||||
|
||||
def test_launcher_archives_are_not_packs(self):
|
||||
"""build_port.py writes RetroBIOS.zip, RetroBIOS-tools.zip and
|
||||
RetroBIOS-batocera.zip to dist/: verify_and_finalize_packs judged
|
||||
them as packs, failed them and injected a manifest into each."""
|
||||
for name in ("RetroBIOS.zip", "RetroBIOS-tools.zip", "RetroBIOS-batocera.zip"):
|
||||
self._build(self.dist / name, {"RetroBIOS.sh": b"#!/bin/sh\n"})
|
||||
before = {p.name: p.read_bytes() for p in self.dist.glob("RetroBIOS*.zip")}
|
||||
self.assertEqual(builder._pack_archives(str(self.dist)), [self.pack.name])
|
||||
# A --system platform pack carries its system after the suffix.
|
||||
system = self.dist / "Demo_1.0_BIOS_Pack_Playstation.zip"
|
||||
self._build(system, {"one.bin": b"1"})
|
||||
self.assertEqual(builder._pack_archives(str(self.dist)),
|
||||
sorted([self.pack.name, system.name]))
|
||||
system.unlink()
|
||||
with contextlib.redirect_stdout(io.StringIO()):
|
||||
builder.verify_and_finalize_packs(str(self.dist), {"files": {}, "indexes": {}},
|
||||
skip_conformance=True)
|
||||
self.assertEqual({p.name: p.read_bytes() for p in self.dist.glob("RetroBIOS*.zip")},
|
||||
before)
|
||||
|
||||
def test_the_directory_form_splits_only_what_is_too_large(self):
|
||||
small = self.dist / "Small_BIOS_Pack.zip"
|
||||
self._build(small, {"one.bin": b"1"})
|
||||
|
||||
@@ -424,6 +424,67 @@ class ASystemPackHoldsThatSystem(unittest.TestCase):
|
||||
self.assertEqual(report["total_files"], 2)
|
||||
|
||||
|
||||
class ATreeHoldsAPathForAnotherProfile(unittest.TestCase):
|
||||
"""--system colecovision --standalone: bluemsx keeps no file of the
|
||||
system but its Machines/ tree is packed, and holds msx-emu's coleco.rom
|
||||
path. verify skipped the tree of a profile left without files and
|
||||
credited msx-emu's copy the pack never wrote."""
|
||||
|
||||
def test_report_and_pack_agree(self):
|
||||
import hashlib
|
||||
import io
|
||||
import shutil
|
||||
from contextlib import redirect_stdout
|
||||
|
||||
import yaml
|
||||
from verify import verify_emulator
|
||||
|
||||
common._emulator_profiles_cache.clear()
|
||||
(REPO_ROOT / "tmp").mkdir(exist_ok=True)
|
||||
root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
self.addCleanup(shutil.rmtree, root, True)
|
||||
previous = os.getcwd()
|
||||
os.chdir(root)
|
||||
self.addCleanup(os.chdir, previous)
|
||||
data = b"coleco" * 4
|
||||
sha1 = hashlib.sha1(data).hexdigest()
|
||||
rel = "bios/Coleco/ColecoVision/coleco.rom"
|
||||
Path(rel).parent.mkdir(parents=True)
|
||||
Path(rel).write_bytes(data)
|
||||
tree = Path("data/tree/Machines/COL")
|
||||
tree.mkdir(parents=True)
|
||||
(tree / "coleco.rom").write_bytes(data)
|
||||
db = {"files": {sha1: {"path": rel, "name": "coleco.rom", "size": len(data),
|
||||
"md5": hashlib.md5(data).hexdigest(), "crc32": ""}},
|
||||
"indexes": {"by_md5": {}, "by_name": {"coleco.rom": [sha1]},
|
||||
"by_crc32": {}, "by_path_suffix": {}}}
|
||||
Path("platforms").mkdir()
|
||||
Path("platforms/_data_dirs.yml").write_text(yaml.safe_dump(
|
||||
{"data_directories": {"tree": {"local_cache": "data/tree"}}}))
|
||||
Path("emulators").mkdir()
|
||||
Path("emulators/atree.yml").write_text(yaml.safe_dump({
|
||||
"emulator": "ATree", "type": "libretro", "cores": ["atree"],
|
||||
"systems": ["colecovision", "msx"],
|
||||
"data_directories": [{"ref": "tree"}],
|
||||
"files": [{"name": "msx.rom", "system": "msx"}],
|
||||
}))
|
||||
Path("emulators/msxemu.yml").write_text(yaml.safe_dump({
|
||||
"emulator": "MsxEmu", "type": "libretro", "cores": ["msxemu"],
|
||||
"systems": ["colecovision"],
|
||||
"files": [{"name": "coleco.rom", "path": "Machines/COL/coleco.rom"}],
|
||||
}))
|
||||
names = ["atree", "msxemu"]
|
||||
report = verify_emulator(names, "emulators", db, platforms_dir="platforms",
|
||||
system_ids=["colecovision"])
|
||||
record = builder.PackRecord()
|
||||
with redirect_stdout(io.StringIO()):
|
||||
builder.generate_emulator_pack(
|
||||
names, "emulators", db, "bios", "", offline=True,
|
||||
platforms_dir="platforms", record=record, system_ids=["colecovision"],
|
||||
)
|
||||
self.assertEqual(sorted(report["pack_destinations"]), sorted(record.files))
|
||||
|
||||
|
||||
class ListingsKeepTheirColumns(unittest.TestCase):
|
||||
"""--list-systems and --list-emulators started their last column at a
|
||||
position that moved with the file count and the profile type."""
|
||||
|
||||
@@ -5,6 +5,7 @@ from __future__ import annotations
|
||||
import contextlib
|
||||
import io
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
@@ -84,6 +85,22 @@ class AMistypedTargetGetsTheClosestName(unittest.TestCase):
|
||||
|
||||
|
||||
|
||||
class AMistypedTargetAcrossAllPlatforms(unittest.TestCase):
|
||||
"""`verify --all --target swich` ended on "no platform has it" after 17
|
||||
INFO lines, two of which held the suggestion."""
|
||||
|
||||
def test_the_refusal_suggests_and_names_the_platforms(self):
|
||||
platforms = common.list_registered_platforms(str(REPO_ROOT / "platforms"))
|
||||
out = io.StringIO()
|
||||
with contextlib.redirect_stdout(out), self.assertRaises(ValueError) as caught:
|
||||
common.build_target_cores_cache(
|
||||
platforms, "swich", str(REPO_ROOT / "platforms"), is_all=True
|
||||
)
|
||||
self.assertIn("Did you mean: switch (", str(caught.exception))
|
||||
self.assertIn("retroarch", str(caught.exception))
|
||||
self.assertEqual(out.getvalue(), "")
|
||||
|
||||
|
||||
class AMistypedDataKeyGetsTheClosestName(unittest.TestCase):
|
||||
"""`--key dolphin-sis` printed all 27 keys on one line."""
|
||||
|
||||
@@ -635,5 +652,45 @@ class TheGitHubTokenComesFromGh(unittest.TestCase):
|
||||
run.assert_not_called()
|
||||
|
||||
|
||||
class CitedCommandsRunWhenPasted(unittest.TestCase):
|
||||
"""check_freshness wrote "run python scripts/generate_truth.py" on one
|
||||
line and "export_native.py --platform bizhawk writes it again" two lines
|
||||
below: pasted from the repository root, the second is command not found.
|
||||
A message that hands the reader a command spells the whole command."""
|
||||
|
||||
CITED = re.compile(r"(?:^|run |with |then |, )([a-z_]+\.py) --[a-z]")
|
||||
|
||||
def test_no_message_cites_a_bare_script(self):
|
||||
import ast # noqa: PLC0415
|
||||
|
||||
offenders = []
|
||||
for path in sorted((REPO_ROOT / "scripts").rglob("*.py")):
|
||||
tree = ast.parse(path.read_text(encoding="utf-8"))
|
||||
docs = {
|
||||
id(node.body[0].value)
|
||||
for node in ast.walk(tree)
|
||||
if isinstance(node, (ast.Module, ast.ClassDef, ast.FunctionDef,
|
||||
ast.AsyncFunctionDef))
|
||||
and node.body and isinstance(node.body[0], ast.Expr)
|
||||
}
|
||||
offenders += [
|
||||
f"{path.relative_to(REPO_ROOT)}:{node.lineno} {node.value.strip()[:60]}"
|
||||
for node in ast.walk(tree)
|
||||
if isinstance(node, ast.Constant) and isinstance(node.value, str)
|
||||
and id(node) not in docs and self.CITED.search(node.value)
|
||||
]
|
||||
self.assertEqual(offenders, [])
|
||||
|
||||
def test_the_target_hint_is_a_whole_command(self):
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
targets = Path(tmp) / "targets"
|
||||
targets.mkdir()
|
||||
(targets / "p.yml").write_text("targets:\n switch:\n cores: [a]\n")
|
||||
with self.assertRaises(ValueError) as caught:
|
||||
common.load_target_config("p", "swich", tmp)
|
||||
self.assertIn("python scripts/verify.py --platform p --list-targets",
|
||||
str(caught.exception))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -325,5 +325,55 @@ class AlternativesAreLookedUpBySlot(unittest.TestCase):
|
||||
self.assertEqual(built.call_count, 2)
|
||||
|
||||
|
||||
class AVersionTakenWithoutACheck(unittest.TestCase):
|
||||
"""The Batocera pack printed two DISCREPANCY lines for BLOOD.RFF that
|
||||
verify never showed: Raze lists three sized versions and a fourth,
|
||||
"Unknown Version", it takes without a check (the shareware RFF), and
|
||||
the message named one accepted size of the three."""
|
||||
|
||||
RAZE = {"files": [
|
||||
{"name": "BLOOD.RFF", "path": "BLOOD.RFF", "size": 8200353,
|
||||
"crc32": "b291418f", "validation": ["size", "crc32"]},
|
||||
{"name": "BLOOD.RFF", "path": "BLOOD.RFF", "size": 9570681,
|
||||
"crc32": "a8fdda84", "validation": ["size", "crc32"]},
|
||||
{"name": "BLOOD.RFF", "path": "BLOOD.RFF"},
|
||||
]}
|
||||
|
||||
def _file(self, tmp: str) -> str:
|
||||
path = Path(tmp) / "BLOOD.RFF"
|
||||
path.write_bytes(b"shareware")
|
||||
return str(path)
|
||||
|
||||
def test_the_unchecked_version_accepts_the_copy(self):
|
||||
from validation import check_file_validation # noqa: PLC0415
|
||||
|
||||
index = _build_validation_index({"raze": self.RAZE})
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
self.assertIsNone(check_file_validation(
|
||||
self._file(tmp), "BLOOD.RFF", index, emulators={"raze"}
|
||||
))
|
||||
|
||||
def test_the_pack_reads_it_as_an_alternative(self):
|
||||
import generate_pack # noqa: PLC0415
|
||||
|
||||
fe = {"name": "BLOOD.RFF", "source_profile": "raze", "source_path": "BLOOD.RFF"}
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
self.assertTrue(generate_pack._matches_an_alternative(
|
||||
fe, self._file(tmp), {"raze": self.RAZE}
|
||||
))
|
||||
|
||||
def test_a_refusal_names_every_accepted_size(self):
|
||||
from validation import check_file_validation # noqa: PLC0415
|
||||
|
||||
checked = {"files": self.RAZE["files"][:2]}
|
||||
index = _build_validation_index({"raze": checked})
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
reason, emulators = check_file_validation(
|
||||
self._file(tmp), "BLOOD.RFF", index, emulators={"raze"}
|
||||
)
|
||||
self.assertEqual(emulators, ["raze"])
|
||||
self.assertEqual(reason, "size mismatch: got 9, accepted [8200353,9570681]")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -200,5 +200,35 @@ class EveryGapCountedIsNamed(unittest.TestCase):
|
||||
self.assertIn("MISSING (game data): engine needs level.dat", verbose.getvalue())
|
||||
|
||||
|
||||
class CoreCopiesWithoutAGapEntryAreCounted(unittest.TestCase):
|
||||
"""verify --platform recalbox --system nec-pc-engine printed no Core
|
||||
files line while the pack held six geargrafx syscard copies: the gap
|
||||
report was empty, and the section returned before reading the pack's
|
||||
count."""
|
||||
|
||||
def test_the_packed_count_is_printed(self):
|
||||
import contextlib # noqa: PLC0415
|
||||
import io # noqa: PLC0415
|
||||
|
||||
sys.path.insert(0, str(REPO_ROOT / "scripts"))
|
||||
import verify # noqa: PLC0415
|
||||
|
||||
for packed, expected in (({"bios": 6, "game_data": 0}, "Core files: 6 in pack"),
|
||||
({"bios": 0, "game_data": 3}, "Game data: 3 in pack")):
|
||||
out = io.StringIO()
|
||||
with contextlib.redirect_stdout(out):
|
||||
verify._print_undeclared_section(
|
||||
{"undeclared_files": [], "packed_extras": packed}, verbose=False
|
||||
)
|
||||
with self.subTest(packed=packed):
|
||||
self.assertIn(expected, out.getvalue())
|
||||
out = io.StringIO()
|
||||
with contextlib.redirect_stdout(out):
|
||||
verify._print_undeclared_section(
|
||||
{"undeclared_files": [], "packed_extras": {"bios": 0, "game_data": 0}}, False
|
||||
)
|
||||
self.assertEqual(out.getvalue(), "")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user