refactor: put scripts/ on the test path once

tests/__init__ now puts the repository root and scripts/ on sys.path,
so no test module inserts them and every import sits in the import
block. ruff accepts the bare `import tests` the modules keep for its
side effects. The last suppressions go: helper test modules import as
tests.<name>, files open in with blocks, lambdas become functions.
This commit is contained in:
Abdessamad Derraz committed 2026-11-17 16:11:23 +01:00
1 parent 8f1b88bb7e
commit 5f18caec31
281 files changed
+1036 -1659

No files matched your search

+4
View File
@@ -89,6 +89,10 @@ ignore = [
"RET504", "RET505", "RET506", "RET508",
]
[tool.ruff.lint.pyflakes]
# Each test module imports the tests package first for its isolation (offline, scratch under tmp/).
allowed-unused-imports = ["tests"]
[tool.ruff.lint.mccabe]
max-complexity = 15
+7
View File
@@ -13,10 +13,17 @@ temporary directory instead of naming the missing parent.
from __future__ import annotations
import os
import sys
import tempfile
from pathlib import Path
os.environ.setdefault("RETROBIOS_OFFLINE", "1")
# The modules under test import each other by bare name (common, verify), as
# the scripts do when run from scripts/, and install.py sits at the root.
_REPOSITORY = Path(__file__).resolve().parent.parent
for _path in (str(_REPOSITORY), str(_REPOSITORY / "scripts")):
if _path not in sys.path:
sys.path.insert(0, _path)
# The installer reads the XDG base directories as RetroArch and the
# emulators do. The CI runner sets XDG_CONFIG_HOME to its own home, so tests
# that fake HOME found the runner's folders instead of theirs. A test that
+3 -5
View File
@@ -9,21 +9,19 @@ corrected it later, every other reader of the resolution did not.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import hashlib
import json
import shutil
import sys
import tempfile
import unittest
import zlib
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(REPO_ROOT / "scripts"))
from common import adler32_of, resolve_local_file
from common import adler32_of, resolve_local_file # noqa: E402
REPO_ROOT = Path(__file__).resolve().parents[1]
class TheAcceptedChecksumWins(unittest.TestCase):
+4 -8
View File
@@ -12,20 +12,16 @@ BIOS root of platforms that do not run that emulator.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import hashlib
import sys
import tempfile
import unittest
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(REPO_ROOT / "scripts"))
import common # noqa: E402
import generate_pack as builder # noqa: E402
import packextras # noqa: E402
import common
import generate_pack as builder
import packextras
SIZE = 1024
+1 -3
View File
@@ -8,15 +8,13 @@ libretro core, while verify set the entry aside. Reads the repository.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import os
import sys
import unittest
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(REPO_ROOT / "scripts"))
class ScanFollowsTheBuild(unittest.TestCase):
+1 -3
View File
@@ -9,17 +9,15 @@ was not where it looks.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import hashlib
import os
import sys
import tempfile
import unittest
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(REPO_ROOT / "scripts"))
class AgnosticScan(unittest.TestCase):
+3 -5
View File
@@ -7,18 +7,16 @@ the slot missing and the manifest omitted it.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import re
import sys
import tempfile
import unittest
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(REPO_ROOT / "scripts"))
from validation import agnostic_substitute
from validation import agnostic_substitute # noqa: E402
REPO_ROOT = Path(__file__).resolve().parents[1]
class AgnosticSubstitute(unittest.TestCase):
+2 -7
View File
@@ -8,16 +8,11 @@ the firmware of cores its image never had.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import sys
import unittest
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(REPO_ROOT / "scripts"))
from scraper.targets import amberelec_targets_scraper as scraper # noqa: E402
from scraper.targets import amberelec_targets_scraper as scraper
MAKEFILE = """RG351P:
\tDEVICE=RG351P ARCH=aarch64 ./scripts/build_distro
+3 -5
View File
@@ -2,7 +2,7 @@
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import io
import json
@@ -11,14 +11,14 @@ import unittest
import zipfile
from pathlib import Path
from scripts.scraper import arcade_parent_importer as api
ROOT = Path(__file__).resolve().parent.parent
TMP_ROOT = ROOT / "tmp" / "tests"
TMP_ROOT.mkdir(parents=True, exist_ok=True)
FIXTURES = ROOT / "tests" / "fixtures" / "arcade_parents"
COMMITTED = ROOT / "games" / "arcade"
from scripts.scraper import arcade_parent_importer as api # noqa: E402
try:
from jsonschema import Draft202012Validator
except ImportError: # validate_schemas.py is the only tool that needs it
@@ -411,10 +411,8 @@ class CommittedIndex(unittest.TestCase):
@unittest.skipIf(Draft202012Validator is None, "jsonschema not installed")
def test_each_file_is_read_at_its_profile_pin(self) -> None:
"""A bumped profile kept the game-to-BIOS map of the old code."""
import sys
from unittest import mock
sys.path.insert(0, str(ROOT / "scripts"))
import validate_schemas
self.assertEqual(validate_schemas._arcade_pin_errors(), [])
+4 -5
View File
@@ -6,7 +6,7 @@ plus recipes/archives.json, without a copy of that archive from elsewhere.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import hashlib
import json
@@ -18,13 +18,12 @@ import zipfile
from pathlib import Path
from unittest import mock
import archive_build
from torrentzip import build_torrentzip
ROOT = Path(__file__).resolve().parent.parent
TMP_ROOT = ROOT / "tmp" / "tests"
TMP_ROOT.mkdir(parents=True, exist_ok=True)
sys.path.insert(0, str(ROOT / "scripts"))
import archive_build # noqa: E402
from torrentzip import build_torrentzip # noqa: E402
ROM_A = b"first rom payload" * 50
ROM_B = b"second rom payload" * 40
+1 -3
View File
@@ -7,12 +7,11 @@ seven of the eight members Batocera checks were missing.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import hashlib
import os
import shutil
import sys
import tempfile
import unittest
import zipfile
@@ -20,7 +19,6 @@ import zlib
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(REPO_ROOT / "scripts"))
class PreferredArchive(unittest.TestCase):
+1 -3
View File
@@ -9,17 +9,15 @@ those members were never read there, and the archive matched no recipe.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import hashlib
import sys
import unittest
import zipfile
from collections import defaultdict
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(REPO_ROOT / "scripts"))
# Sets whose archive also carries the ROMs of devices the machine references
# (listxml device_ref). A device looks for its ROMs under its own name, then
+7 -8
View File
@@ -7,7 +7,7 @@ ZIPs, which surfaces as BadZipFile far from its cause.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import os
import subprocess
@@ -17,19 +17,18 @@ import tempfile
import unittest
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(REPO_ROOT / "scripts"))
from common import ( # noqa: E402
from common import (
ArtifactLockBusy,
artifact_lock,
hold_artifact_lock,
hold_repository_outputs,
publish_hold,
)
from tests.scratchtree import scratch_checkout # noqa: E402
import artifacts # noqa: E402
from unittest import mock # noqa: E402
from tests.scratchtree import scratch_checkout
import artifacts
from unittest import mock
REPO_ROOT = Path(__file__).resolve().parent.parent
def _tempdir(test: unittest.TestCase) -> str:
+3 -4
View File
@@ -8,7 +8,7 @@ path in bios/: a scan running beside the copy hashed the truncated file.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import os
import sys
@@ -17,10 +17,9 @@ import unittest
from pathlib import Path
from unittest import mock
REPO_ROOT = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(REPO_ROOT / "scripts"))
import artifacts
import artifacts # noqa: E402
REPO_ROOT = Path(__file__).resolve().parent.parent
class WholeOrNothing(unittest.TestCase):
+4 -27
View File
@@ -2,7 +2,7 @@
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import ast
import contextlib
@@ -24,15 +24,9 @@ from unittest import mock
import yaml
try:
import jsonschema # noqa: F401
import jsonschema
except ImportError:
HAS_JSONSCHEMA = False
else:
HAS_JSONSCHEMA = True
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "scripts"))
jsonschema = None
import install
from scripts import pipeline, region, region_audit
from scripts.common import resolve_local_file, safe_extract_zip
@@ -42,6 +36,7 @@ from scripts.generate_pack import (
verify_pack_against_platform,
)
HAS_JSONSCHEMA = jsonschema is not None
ROOT = Path(__file__).resolve().parent.parent
TMP_ROOT = ROOT / "tmp" / "tests"
TMP_ROOT.mkdir(parents=True, exist_ok=True)
@@ -1003,7 +998,6 @@ class FaqRegressions(unittest.TestCase):
# Typed by hand, the table and the prose under it kept MAME 0.160
# 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.
sys.path.insert(0, str(ROOT / "scripts"))
import generate_site
from common import load_emulator_profiles
@@ -3200,7 +3194,6 @@ class ACheckThatCannotAnswerDoesNotPass(unittest.TestCase):
def test_an_unreachable_buildbot_is_not_a_fresh_verdict(self):
"""Every HEAD unanswered printed "16 unknown" and exited 0, so the
online pipeline printed check_buildbot OK."""
sys.path.insert(0, str(ROOT / "scripts"))
import check_buildbot_system as cbs
registry = str(ROOT / "platforms" / "_data_dirs.yml")
@@ -3306,7 +3299,6 @@ class ContributorsSurviveAFailedRequest(unittest.TestCase):
def _block(self, text: str):
import tempfile
sys.path.insert(0, str(ROOT / "scripts"))
from generate_readme import _existing_contributor_block
with tempfile.NamedTemporaryFile("w", suffix=".md", delete=False) as handle:
@@ -3335,7 +3327,6 @@ class ContributorsSurviveAFailedRequest(unittest.TestCase):
self.assertEqual(self._block("# Title\n\n## Other\n\ntext\n"), [])
def test_an_unreadable_file_yields_nothing(self):
sys.path.insert(0, str(ROOT / "scripts"))
from generate_readme import _existing_contributor_block
self.assertEqual(_existing_contributor_block("/nonexistent/README.md"), [])
@@ -3862,7 +3853,6 @@ class HashMergeBackupsAreNotSources(unittest.TestCase):
"""
def test_the_validator_skips_a_backup(self):
sys.path.insert(0, str(ROOT / "scripts"))
try:
from validate_schemas import _validate_yaml_directory
except ImportError as exc:
@@ -5286,7 +5276,6 @@ class PipelineDocstringNamesThePrintedSteps(unittest.TestCase):
source = (ROOT / "scripts" / "pipeline.py").read_text(encoding="utf-8")
doc = ast.get_docstring(ast.parse(source))
listed = set(re.findall(r"^ (\d[a-z0-9]*)\s{2,}", doc, re.M))
sys.path.insert(0, str(ROOT / "scripts"))
import pipeline
printed = {pipeline.step_number(key) for key in pipeline.STEP_LABELS}
@@ -5300,7 +5289,6 @@ class VerifyAllSummaryNamesWhatIsWrong(unittest.TestCase):
say which platform carried it."""
def test_counts_carry_platforms_and_core_misses(self):
sys.path.insert(0, str(ROOT / "scripts"))
import verify
clean = {"severity_counts": {}, "undeclared_files": []}
@@ -5322,7 +5310,6 @@ class VerifyAllSummaryNamesWhatIsWrong(unittest.TestCase):
def test_a_file_missing_on_several_platforms_is_counted_once(self):
"""sfiii2a.zip missing on 15 platforms read '24 core file(s)' for 10
distinct files, the name printed 15 times on one line."""
sys.path.insert(0, str(ROOT / "scripts"))
import verify
def missing(*names: str) -> dict:
@@ -5372,7 +5359,6 @@ class BundledFilesAreNotToSource(unittest.TestCase):
listed among the files to source, with 19 more like it."""
def test_verify_does_not_count_it_missing(self):
sys.path.insert(0, str(ROOT / "scripts"))
import verify
entry = {"name": "n64.psh", "required": True, "in_repo": False,
@@ -5384,7 +5370,6 @@ class BundledFilesAreNotToSource(unittest.TestCase):
self.assertNotIn("n64.psh", summary)
def test_the_site_gives_it_its_own_status(self):
sys.path.insert(0, str(ROOT / "scripts"))
import generate_site
rows = generate_site._gap_export_rows({}, {"daedalusx64": {
@@ -5397,7 +5382,6 @@ class BundledFilesAreNotToSource(unittest.TestCase):
def test_a_held_bundled_file_is_not_packed(self):
"""A file installed with the emulator is already on the user's
machine, so the pack leaves it out even when the collection holds it."""
sys.path.insert(0, str(ROOT / "scripts"))
import verify
entry = {"name": "n64.psh", "required": True, "in_repo": True,
@@ -5410,7 +5394,6 @@ class BundledFilesAreNotToSource(unittest.TestCase):
def test_a_build_scope_keeps_it_for_the_other_build(self):
"""PPSSPP's standalone release ships assets/, its libretro core does
not: bundled for one build, the entry still reaches a core's pack."""
sys.path.insert(0, str(ROOT / "scripts"))
from validation import deliverable
entries = [{"ref": "ppsspp-assets", "mode": "libretro"},
@@ -5423,7 +5406,6 @@ class BundledFilesAreNotToSource(unittest.TestCase):
def test_a_platform_package_can_differ_both_ways(self):
"""Batocera's hcl package installs the binary alone, its blueMSX core
package copies the machines beside the core."""
sys.path.insert(0, str(ROOT / "scripts"))
from validation import installed_with_emulator
hcl = {"name": "data.pak", "bundled": True, "not_bundled_on": ["batocera"]}
@@ -5435,7 +5417,6 @@ class BundledFilesAreNotToSource(unittest.TestCase):
self.assertTrue(installed_with_emulator(hcl))
def test_every_platform_named_is_registered(self):
sys.path.insert(0, str(ROOT / "scripts"))
from common import list_registered_platforms, load_emulator_profiles
known = set(list_registered_platforms(str(ROOT / "platforms")))
@@ -5457,7 +5438,6 @@ class BundledFilesAreNotToSource(unittest.TestCase):
import yaml as _yaml
sys.path.insert(0, str(ROOT / "scripts"))
import common
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as tmp:
@@ -5540,7 +5520,6 @@ class GapsPageCountsOneWay(unittest.TestCase):
def test_the_destination_is_the_list_entrys(self):
from scripts.generate_site import _declared_destination
sys.path.insert(0, str(ROOT / "scripts"))
from common import load_platform_config
config = load_platform_config("amberelec", str(ROOT / "platforms"))
@@ -5548,7 +5527,6 @@ class GapsPageCountsOneWay(unittest.TestCase):
self.assertEqual(_declared_destination(config, detail), "bios/quasi88/N88_KNJ1.ROM")
def test_verify_marks_the_settled_entry(self):
sys.path.insert(0, str(ROOT / "scripts"))
import verify
result = {"name": "cdibios.zip", "status": verify.Status.UNTESTED}
@@ -7373,7 +7351,6 @@ class SkipPacksHelpSaysWhatRuns(unittest.TestCase):
self.assertNotIn("docs/", text)
def test_every_step_it_names_is_one_it_skips(self):
sys.path.insert(0, str(ROOT / "scripts"))
import pipeline
source = (ROOT / "scripts" / "pipeline.py").read_text(encoding="utf-8")
+2 -6
View File
@@ -3,23 +3,19 @@ content, and nothing it serves is kept unless every declared hash holds."""
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import contextlib
import hashlib
import io
import os
import sys
import tempfile
import unittest
import urllib.error
from pathlib import Path
from unittest import mock
REPO_ROOT = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(REPO_ROOT / "scripts"))
import auto_fetch # noqa: E402
import auto_fetch
PAYLOAD = b"keyboard mcu"
SHA1 = hashlib.sha1(PAYLOAD).hexdigest()
+6 -7
View File
@@ -7,7 +7,7 @@ a function returning canned CI runs.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import contextlib
import io
@@ -23,13 +23,12 @@ import unittest.mock
from pathlib import Path
from types import MappingProxyType
REPO_ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(REPO_ROOT / "scripts"))
import autorun as ar
import bios_integrity as bib
import cleanup_disk as cd
import sync_release_assets as sra
import autorun as ar # noqa: E402
import bios_integrity as bib # noqa: E402
import cleanup_disk as cd # noqa: E402
import sync_release_assets as sra # noqa: E402
REPO_ROOT = Path(__file__).resolve().parents[1]
PY = "python"
_ENV_KEYS = ("GIT_CONFIG_GLOBAL", "GIT_CONFIG_NOSYSTEM")
+1 -4
View File
@@ -9,15 +9,12 @@ under it: amiberry, fsuae and vice were never in a target list.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import sys
import unittest
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(REPO_ROOT))
sys.path.insert(0, str(REPO_ROOT / "scripts"))
ES_SYSTEMS = """\
dos:
+13 -15
View File
@@ -9,33 +9,31 @@ a list, and verify accepts any listed md5.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import hashlib
import sys
import tempfile
import unittest
import zipfile
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(REPO_ROOT / "scripts"))
from common import resolve_local_file # noqa: E402
from exporter import discover_exporters # noqa: E402
from export_native import landed_changes # noqa: E402
from exporter.baseline import NativeFile, build_native_model # noqa: E402
from exporter.batocera_exporter import md5_list_support # noqa: E402
from scraper import rocknix_scraper # noqa: E402
from scraper.base_scraper import md5_field, requirement_entry # noqa: E402
from scraper.batocera_scraper import ( # noqa: E402
from common import resolve_local_file
from exporter import discover_exporters
from export_native import landed_changes
from exporter.baseline import NativeFile, 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
from scraper.batocera_scraper import (
SYSTEM_SLUG_MAP,
extract_systems_dict,
platform_systems,
requirements_from_systems,
)
from siteexports import describe_change # noqa: E402
from verify import Status, verify_entry_md5 # noqa: E402
from siteexports import describe_change
from verify import Status, verify_entry_md5
REPO_ROOT = Path(__file__).resolve().parents[1]
A = "dc2b9bf8da62ec93e868cfd29f0d067d"
B = "924e392ed05558ffdb115408c263dccf"
+3 -5
View File
@@ -9,17 +9,15 @@ the Batocera BIOS folder.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import sys
import unittest
from pathlib import Path
import yaml
REPO_ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(REPO_ROOT / "scripts"))
from packextras import _companion_extensions, _companions
from packextras import _companion_extensions, _companions # noqa: E402
REPO_ROOT = Path(__file__).resolve().parents[1]
class Companions(unittest.TestCase):
+1 -1
View File
@@ -7,7 +7,7 @@ Oric and Tangerine: one machine, two folders, two pages.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import subprocess
import unittest
+3 -5
View File
@@ -13,19 +13,17 @@ entry is written with the hash of the file the emulator ships.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import hashlib
import sys
import unittest
from pathlib import Path
import yaml
REPO_ROOT = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(REPO_ROOT / "scripts"))
from common import load_database, resolve_local_file
from common import load_database, resolve_local_file # noqa: E402
REPO_ROOT = Path(__file__).resolve().parent.parent
UNIDENTIFIED = {
"abuse": 3,
+1 -3
View File
@@ -10,15 +10,13 @@ directory cache is not a collection.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import os
import sys
import unittest
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(REPO_ROOT / "scripts"))
class DeclaredFilesResolveWithoutDataCaches(unittest.TestCase):
+1 -4
View File
@@ -10,7 +10,7 @@ resume and rerun on a changed core.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import contextlib
import hashlib
@@ -20,7 +20,6 @@ import os
import shutil
import struct
import subprocess
import sys
import tempfile
import unittest
import unittest.mock
@@ -29,8 +28,6 @@ from types import MappingProxyType
import yaml
sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "scripts"))
import campaign
import campaign_profiles
import campaign_rules as rules
+3 -4
View File
@@ -7,22 +7,21 @@ went red. The flag lived in retrobat.yml and vanished at the next scrape.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import contextlib
import hashlib
import io
import os
import sys
import tempfile
import unittest
from pathlib import Path
import yaml
from common import load_platform_config
REPO_ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(REPO_ROOT / "scripts"))
from common import load_platform_config # noqa: E402
class CaseInsensitiveWhereTheFilesystemIs(unittest.TestCase):
+3 -5
View File
@@ -2,16 +2,14 @@
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import sys
import unittest
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(REPO_ROOT / "scripts"))
from common import _casefold_name_index
from common import _casefold_name_index # noqa: E402
REPO_ROOT = Path(__file__).resolve().parents[1]
class CasefoldIndexFollowsItsSource(unittest.TestCase):
+4 -5
View File
@@ -8,7 +8,7 @@ report is folded, since each of those decides whether a row says STALE.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import json
import os
@@ -18,11 +18,10 @@ import unittest
from unittest import mock
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(REPO_ROOT / "scripts"))
import check_freshness as cf
from common import yaml_load
import check_freshness as cf # noqa: E402
from common import yaml_load # noqa: E402
REPO_ROOT = Path(__file__).resolve().parents[1]
class NativeCacheTests(unittest.TestCase):
+1 -5
View File
@@ -7,13 +7,9 @@ whose checksums every user's `sha256sum --check` rejected.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import sys
import unittest
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "scripts"))
import build_port
from check_release import SIGNATURE, SUMS, Asset, compare_release, parse_sums
+1 -3
View File
@@ -6,17 +6,15 @@ one. validate_schemas now refuses it.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import subprocess
import sys
import unittest
from pathlib import Path
import yaml
REPO_ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(REPO_ROOT / "scripts"))
class ChecksHaveValues(unittest.TestCase):
+4 -6
View File
@@ -7,18 +7,16 @@ does not hold the file.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import re
import sys
import unittest
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT / "scripts"))
import upstream
from safeparse import yaml_load
import upstream # noqa: E402
from safeparse import yaml_load # noqa: E402
ROOT = Path(__file__).resolve().parents[1]
CACHE = ROOT / ".cache" / "upstream"
+7 -9
View File
@@ -11,23 +11,21 @@ any flash image whose size is a whole number of 64 KiB.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import hashlib
import struct
import sys
import tempfile
import unittest
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(REPO_ROOT / "scripts"))
import common
import generate_pack as builder
import packextras
from romdir import romdir_accepts, walk
from validation import _build_validation_index, check_file_validation
import common # noqa: E402
import generate_pack as builder # noqa: E402
import packextras # noqa: E402
from romdir import romdir_accepts, walk # noqa: E402
from validation import _build_validation_index, check_file_validation # noqa: E402
REPO_ROOT = Path(__file__).resolve().parent.parent
# How each fork reads the table, as the profiles declare it.
WX = {"reset_compare": 5, "missing_reset": "rejects", "terminated_names": False,
+1 -5
View File
@@ -8,14 +8,10 @@ declared file meets the entry and the label is not shipped a second time.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import os
import sys
import unittest
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "scripts"))
from common import platform_declared_contents
from validation import declaration_settles
+4 -6
View File
@@ -6,19 +6,17 @@ the repository, five on the site, under two different titles.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import re
import sys
import unittest
from pathlib import Path
from unittest import mock
REPO_ROOT = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(REPO_ROOT / "scripts"))
import generate_readme
import generate_site
import generate_readme # noqa: E402
import generate_site # noqa: E402
REPO_ROOT = Path(__file__).resolve().parent.parent
def _normalized(text: str) -> str:
+5 -7
View File
@@ -10,19 +10,17 @@ reader now gets the tree, or the profile says its package installs it.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import os
import sys
import unittest
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(REPO_ROOT / "scripts"))
import common
import generate_pack as builder
from validation import deliverable, read_from_system_dir
import common # noqa: E402
import generate_pack as builder # noqa: E402
from validation import deliverable, read_from_system_dir # noqa: E402
REPO_ROOT = Path(__file__).resolve().parent.parent
PROFILES = {
"demo": {
+5 -7
View File
@@ -8,13 +8,12 @@ frontend sees a file at the path. verify kept it MISSING, so the pack said
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import hashlib
import contextlib
import io
import shutil
import sys
import tempfile
import unittest
import zipfile
@@ -24,12 +23,11 @@ from unittest import mock
import yaml
REPO_ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(REPO_ROOT / "scripts"))
from common import _emulator_profiles_cache, load_platform_config
from generate_pack import generate_pack
from verify import verify_platform
from common import _emulator_profiles_cache, load_platform_config # noqa: E402
from generate_pack import generate_pack # noqa: E402
from verify import verify_platform # noqa: E402
REPO_ROOT = Path(__file__).resolve().parents[1]
class ACoreFileFillsAFreeDeclaration(unittest.TestCase):
+1 -3
View File
@@ -7,7 +7,7 @@ probe on it: staging, the worker process, strace, the record and its schema.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import argparse
import contextlib
@@ -25,8 +25,6 @@ import unittest.mock
from pathlib import Path
from typing import ClassVar
sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "scripts"))
import core_probe
import measurement_records
+7 -9
View File
@@ -10,11 +10,10 @@ read one rule (validation.core_size_refusal).
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import hashlib
import os
import sys
import tempfile
import unittest
import zipfile
@@ -22,14 +21,13 @@ from pathlib import Path
import yaml
REPO_ROOT = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(REPO_ROOT / "scripts"))
import common
import generate_db
import generate_pack as builder
from validation import core_size_refusal
from verify import find_undeclared_files, verify_platform
import common # noqa: E402
import generate_db # noqa: E402
import generate_pack as builder # noqa: E402
from validation import core_size_refusal # noqa: E402
from verify import find_undeclared_files, verify_platform # noqa: E402
REPO_ROOT = Path(__file__).resolve().parent.parent
SIZED = """\
emulator: Sized
+3 -5
View File
@@ -9,18 +9,16 @@ tests change an input and expect a fresh computation.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import sys
import tempfile
import unittest
from pathlib import Path
from unittest import mock
REPO_ROOT = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(REPO_ROOT / "scripts"))
import generate_readme
import generate_readme # noqa: E402
REPO_ROOT = Path(__file__).resolve().parent.parent
class CoverageCache(unittest.TestCase):
+4 -6
View File
@@ -9,23 +9,21 @@ a directory called ROM).
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import sys
import tempfile
import unittest
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(REPO_ROOT / "scripts"))
from cross_reference import ( # noqa: E402
from cross_reference import (
_build_supplemental_index,
cross_reference,
entry_source,
print_report,
)
REPO_ROOT = Path(__file__).resolve().parent.parent
def _index(**over) -> dict:
base = {
+3 -5
View File
@@ -7,17 +7,15 @@ contributor with none of them.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import ast
import sys
import unittest
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(REPO_ROOT / "scripts"))
import crypto_verify
import crypto_verify # noqa: E402
REPO_ROOT = Path(__file__).resolve().parents[1]
STDLIB_OR_LOCAL = {"__future__", "hashlib", "struct", "collections", "pathlib", "sect233r1"}
+3 -7
View File
@@ -18,20 +18,16 @@ Layouts, from Azahar src/core/hw/unique_data.cpp and src/core/file_sys/otp.cpp:
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import hashlib
import struct
import sys
import tempfile
import unittest
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(REPO_ROOT / "scripts"))
import crypto_verify # noqa: E402
import sect233r1 as ec # noqa: E402
import crypto_verify
import sect233r1 as ec
# A 2048-bit RSA key, the size the 3DS signatures use, from two fixed primes
# so the fixture is reproducible and costs nothing to build.
+3 -7
View File
@@ -14,21 +14,17 @@ constants rather than against itself. The AES vector is from NIST SP 800-38A.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import hashlib
import shutil
import sys
import tempfile
import unittest
import unittest.mock
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(REPO_ROOT / "scripts"))
import crypto_verify # noqa: E402
import sect233r1 as ec # noqa: E402
import crypto_verify
import sect233r1 as ec
class FieldArithmetic(unittest.TestCase):
+1 -3
View File
@@ -6,14 +6,12 @@ verify only said "not cached" and refresh_data_dirs had nothing to fetch.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import sys
import unittest
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(REPO_ROOT / "scripts"))
class DataDirRefsAreRegistered(unittest.TestCase):
+1 -3
View File
@@ -2,14 +2,12 @@
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import sys
import unittest
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(REPO_ROOT / "scripts"))
try:
import validate_schemas
+1 -1
View File
@@ -7,7 +7,7 @@ TypeError on the first loop.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import ast
import unittest
+3 -3
View File
@@ -8,7 +8,7 @@ disk ROM then served the CoCo one.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import os
import sys
@@ -18,9 +18,9 @@ import unittest
from pathlib import Path
from unittest import mock
import generate_db
REPO_ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(REPO_ROOT / "scripts"))
import generate_db # noqa: E402
class _NoCoreInfo:
+4 -6
View File
@@ -8,21 +8,19 @@ set, enriched with every spelling the database knows.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import sys
import unittest
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(REPO_ROOT / "scripts"))
from cross_reference import ( # noqa: E402
from cross_reference import (
cross_reference,
declared_names,
load_platform_files,
)
REPO_ROOT = Path(__file__).resolve().parent.parent
class FlatDeclaredSet(unittest.TestCase):
def test_a_name_declared_under_another_system_id_is_not_a_gap(self):
+2 -6
View File
@@ -9,20 +9,16 @@ are both load-bearing.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import contextlib
import io
import os
import sys
import tempfile
import unittest
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(REPO_ROOT / "scripts"))
import dedup # noqa: E402
import dedup
class _Bios(unittest.TestCase):
+3 -5
View File
@@ -7,22 +7,20 @@ is two held ROMs end to end. The gap report listed them as acquisition targets.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import hashlib
import os
import shutil
import sys
import tempfile
import unittest
import unittest.mock
import zlib
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(REPO_ROOT / "scripts"))
import derivations
import derivations # noqa: E402
REPO_ROOT = Path(__file__).resolve().parent.parent
def _held(path: Path, data: bytes) -> dict:
+1 -1
View File
@@ -2,7 +2,7 @@
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import hashlib
import os
+8 -12
View File
@@ -9,11 +9,10 @@ reported missing while 3 584 collected files stayed out of every pack.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import hashlib
import json
import sys
import tempfile
import unittest
from unittest import mock
@@ -23,19 +22,16 @@ from pathlib import Path
import yaml
try:
import jsonschema # noqa: F401
import jsonschema
except ImportError:
HAS_JSONSCHEMA = False
else:
HAS_JSONSCHEMA = True
jsonschema = None
import common
import generate_db
import generate_pack as builder
import verify
HAS_JSONSCHEMA = jsonschema is not None
REPO_ROOT = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(REPO_ROOT / "scripts"))
import common # noqa: E402
import generate_db # noqa: E402
import generate_pack as builder # noqa: E402
import verify # noqa: E402
PROFILE = """\
emulator: Demo
+3 -4
View File
@@ -7,7 +7,7 @@ code moves, and nothing else notices.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import ast
import hashlib
@@ -20,11 +20,10 @@ import unittest
import zipfile
from pathlib import Path
from tests.test_prose_style import _python_prose, _sentence_case
ROOT = Path(__file__).resolve().parent.parent
WIKI = ROOT / "wiki"
sys.path.insert(0, str(ROOT / "scripts"))
from tests.test_prose_style import _python_prose, _sentence_case # noqa: E402
FENCED = re.compile(r"^```.*?^```", re.S | re.M)
PUBLISHED = sorted(WIKI.glob("*.md")) + [ROOT / "README.md", ROOT / "CONTRIBUTING.md"]
+5 -7
View File
@@ -9,21 +9,17 @@ tool prints, and a size is the one the release record holds.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import ast
import contextlib
import re
import sys
import unittest
from functools import cache
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(REPO_ROOT / "scripts"))
import release_record # noqa: E402
from generate_readme import ( # noqa: E402
import release_record
from generate_readme import (
SITE_URL,
asset_links,
contributing_text,
@@ -32,6 +28,8 @@ from generate_readme import ( # noqa: E402
format_size,
)
REPO_ROOT = Path(__file__).resolve().parent.parent
RECORD = release_record.load_record(REPO_ROOT / "release.json")
REPO = "https://github.com/Abdess/retrobios"
+3 -4
View File
@@ -9,7 +9,7 @@ checksum of each layout and the staging location.
"""
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import contextlib
import functools
@@ -30,6 +30,8 @@ import unittest
import zipfile
from pathlib import Path
import split_pack
REPO_ROOT = Path(__file__).resolve().parent.parent
_spec = importlib.util.spec_from_file_location(
"download", REPO_ROOT / "scripts" / "download.py"
@@ -42,9 +44,6 @@ _spec.loader.exec_module(download)
SHELL = REPO_ROOT / "scripts" / "download.sh"
sys.path.insert(0, str(REPO_ROOT / "scripts"))
import split_pack # noqa: E402
# A slice of a real release: two whole packs, three split, and the checksums.
RELEASE_ASSETS = [
"Batocera_43.1_BIOS_Pack.zip.001",
+4 -13
View File
@@ -17,7 +17,7 @@ Covers:
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import contextlib
import hashlib
@@ -31,8 +31,6 @@ import zipfile
from pathlib import Path
from unittest import mock
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "scripts"))
import largefiles
import yaml
from common import (
@@ -65,11 +63,10 @@ from verify import (
)
try:
import jsonschema # noqa: F401
import jsonschema
except ImportError:
HAS_JSONSCHEMA = False
else:
HAS_JSONSCHEMA = True
jsonschema = None
HAS_JSONSCHEMA = jsonschema is not None
def _h(data: bytes) -> dict:
@@ -2949,7 +2946,6 @@ class TestE2E(unittest.TestCase):
"""--platform + --system is accepted (not rejected at validation stage)."""
import argparse
sys.path.insert(0, "scripts")
# Build the same parser as generate_pack.main()
parser = argparse.ArgumentParser()
parser.add_argument("--platform", "-p")
@@ -3913,7 +3909,6 @@ class TestE2E(unittest.TestCase):
def test_93_parse_retroarch_cfg(self):
"""Parse system_directory from retroarch.cfg."""
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from install import _parse_retroarch_system_dir
cfg = os.path.join(self.root, "retroarch.cfg")
@@ -3935,7 +3930,6 @@ class TestE2E(unittest.TestCase):
def test_94_parse_emudeck_settings(self):
"""Parse emulationPath from EmuDeck settings.sh."""
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from install import _parse_bash_var
settings = os.path.join(self.root, "settings.sh")
@@ -3948,7 +3942,6 @@ class TestE2E(unittest.TestCase):
def test_95_parse_ps1_var(self):
"""Parse $emulationPath from EmuDeck settings.ps1."""
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from install import _parse_ps1_var
settings = os.path.join(self.root, "settings.ps1")
@@ -3959,7 +3952,6 @@ class TestE2E(unittest.TestCase):
def test_96_target_filtering(self):
"""--target filters files by cores field."""
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from install import _filter_by_target
files = [
@@ -3975,7 +3967,6 @@ class TestE2E(unittest.TestCase):
def test_97_standalone_copies(self):
"""Standalone keys copied to existing emulator dirs."""
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from install import do_standalone_copies
bios_dir = Path(self.root) / "bios"
+5 -7
View File
@@ -9,17 +9,13 @@ upstream files.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import sys
import unittest
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(REPO_ROOT / "scripts"))
from scraper import amberelec_scraper, emuelec_scraper, knulli_scraper # noqa: E402
from scraper.es_emulators import ( # noqa: E402
from scraper import amberelec_scraper, emuelec_scraper, knulli_scraper
from scraper.es_emulators import (
attach_system_cores,
es_cores,
json_systems,
@@ -27,6 +23,8 @@ from scraper.es_emulators import ( # noqa: E402
xml_systems,
)
REPO_ROOT = Path(__file__).resolve().parents[1]
CHECKER = '''
def checkBios(systems, prefix):
+3 -5
View File
@@ -9,17 +9,15 @@ firmware of cores its image never had.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import json
import sys
import unittest
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(REPO_ROOT / "scripts"))
from scraper.targets import emuelec_targets_scraper as scraper
from scraper.targets import emuelec_targets_scraper as scraper # noqa: E402
REPO_ROOT = Path(__file__).resolve().parents[1]
# packages/sx05re/emuelec/package.mk:8-77 at v4.8, PKG_EMUS and
# PKG_EXPERIMENTAL shortened.
+1 -2
View File
@@ -9,7 +9,7 @@ names and ten "missing".
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import re
import subprocess
@@ -80,7 +80,6 @@ class APlaceholderIsAnsweredByEvidence(unittest.TestCase):
import yaml
sys.path.insert(0, str(REPO_ROOT / "scripts"))
from common import _emulator_profiles_cache
from generate_pack import generate_emulator_pack
from verify import verify_emulator
+1 -5
View File
@@ -6,13 +6,9 @@ from what the cores the platform runs open, never from the entry's name.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import sys
import unittest
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "scripts"))
import verify
from exporter.candidates import (
+13 -15
View File
@@ -9,28 +9,26 @@ from a file other than the one the hash describes.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import json
import sys
import unittest
from collections import OrderedDict
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(REPO_ROOT / "scripts"))
from exporter.baseline import NativeFile, NativeSystem, Report, 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
from scraper.emudeck_scraper import FUNCTION_HASH_MAP
from exporter.emudeck_exporter import Exporter as EmuDeck
from exporter.retrobat_exporter import Exporter as RetroBat
from exporter.retrodeck_exporter import Exporter as RetroDeck
from exporter.recalbox_exporter import Exporter as Recalbox
from exporter.retropie_exporter import Exporter as RetroPie
from exporter.systemdat_exporter import Exporter as SystemDat
from exporter.baseline import NativeFile, NativeSystem, Report, build_native_model # noqa: E402
from exporter.bizhawk_exporter import Exporter as BizHawk # noqa: E402
from exporter.misterfpga_exporter import Exporter as Mister # noqa: E402
from exporter.romm_exporter import Exporter as Romm # noqa: E402
from scraper.emudeck_scraper import FUNCTION_HASH_MAP # noqa: E402
from exporter.emudeck_exporter import Exporter as EmuDeck # noqa: E402
from exporter.retrobat_exporter import Exporter as RetroBat # noqa: E402
from exporter.retrodeck_exporter import Exporter as RetroDeck # noqa: E402
from exporter.recalbox_exporter import Exporter as Recalbox # noqa: E402
from exporter.retropie_exporter import Exporter as RetroPie # noqa: E402
from exporter.systemdat_exporter import Exporter as SystemDat # noqa: E402
REPO_ROOT = Path(__file__).resolve().parents[1]
A = "a" * 32
B = "b" * 32
+4 -5
View File
@@ -9,18 +9,17 @@ libretro's System.dat (N88EXT0-3.ROM) as if libretro declared them.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import sys
import tempfile
import unittest
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(REPO_ROOT / "scripts"))
import common
from export_native import load_inputs
import common # noqa: E402
from export_native import load_inputs # noqa: E402
REPO_ROOT = Path(__file__).resolve().parent.parent
class TheNativeLayerIsThePlatformsOwn(unittest.TestCase):
+1 -4
View File
@@ -7,16 +7,13 @@ file from and no list to check the diff against.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import re
import sys
import tempfile
import unittest
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "scripts"))
import export_native
from siteexports import generate_exports_page, load_export_reports
+11 -10
View File
@@ -14,7 +14,7 @@ and skip when it has not been populated (python scripts/export_native.py
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import difflib
import io
@@ -30,18 +30,15 @@ import zipfile
from collections import OrderedDict
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(REPO_ROOT / "scripts"))
from common import ( # noqa: E402
from common import (
list_registered_platforms,
load_platform_config,
native_layer,
parse_untrusted_xml,
)
from exporter import discover_exporters # noqa: E402
from exporter.base_exporter import BaseExporter # noqa: E402
from export_native import ( # noqa: E402
from exporter import discover_exporters
from exporter.base_exporter import BaseExporter
from export_native import (
SOURCES_INDEX,
collect_originals,
fetch,
@@ -49,13 +46,15 @@ from export_native import ( # noqa: E402
pinned_base,
source_key,
)
from exporter.baseline import ( # noqa: E402
from exporter.baseline import (
NativeFile,
NativeSystem,
Report,
build_native_model,
)
REPO_ROOT = Path(__file__).resolve().parent.parent
UPSTREAM_CACHE = REPO_ROOT / ".cache" / "upstream-native"
@@ -1605,7 +1604,9 @@ class AnExportIsWrittenAsItsBytes(unittest.TestCase):
"rocknix-systems": "#!/usr/bin/python\n",
}, {"rocknix-systems": 0o755})
self.assertEqual((root / "FirmwareDatabase.cs").read_bytes(), b"a\r\nb\r\n")
mode = lambda name: stat.S_IMODE((root / name).stat().st_mode) # noqa: E731
def mode(name: str) -> int:
return stat.S_IMODE((root / name).stat().st_mode)
self.assertEqual(mode("rocknix-systems"), 0o755)
self.assertEqual(mode("FirmwareDatabase.cs"), 0o644)
self.assertEqual(sorted(p.name for p in root.iterdir()),
+5 -7
View File
@@ -8,18 +8,16 @@ Galaksija ROM and a PS2 ROM2.BIN.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import sys
import unittest
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(REPO_ROOT / "scripts"))
from common import PROFILE_IDENTITY_FIELDS
from packextras import _collect_emulator_extras
from verify import find_undeclared_files
from common import PROFILE_IDENTITY_FIELDS # noqa: E402
from packextras import _collect_emulator_extras # noqa: E402
from verify import find_undeclared_files # noqa: E402
REPO_ROOT = Path(__file__).resolve().parents[1]
ENTRY = {
"name": "bios.rom",
+4 -7
View File
@@ -9,17 +9,15 @@ have vanished with it.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import sys
import unittest
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(REPO_ROOT / "scripts"))
from common import load_platform_config, load_platform_registry
from generate_readme import extract_notes, extract_targets
from common import load_platform_config, load_platform_registry # noqa: E402
from generate_readme import extract_notes, extract_targets # noqa: E402
REPO_ROOT = Path(__file__).resolve().parent.parent
PLATFORMS = str(REPO_ROOT / "platforms")
@@ -69,7 +67,6 @@ class ThePackGuideNamesTheInstallerDefault(unittest.TestCase):
rule["path"] for rule in registry["retrobat"]["install"]["detect"]
if rule["os"] == "windows" and rule["method"] == "path_exists"
)
sys.path.insert(0, str(REPO_ROOT / "scripts"))
from siteguides import pack_manual
# The pack guide text is data (platforms/_guides.yml): read what the
+1 -1
View File
@@ -2,7 +2,7 @@
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import tempfile
import unittest
+4 -6
View File
@@ -8,19 +8,17 @@ homonym tests/test_game_data_homonyms.py forbids the resolver to serve.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import hashlib
import sys
import tempfile
import unittest
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(REPO_ROOT / "scripts"))
from cross_reference import FileConsumers, entry_target
from generate_site import generate_system_page
from cross_reference import FileConsumers, entry_target # noqa: E402
from generate_site import generate_system_page # noqa: E402
REPO_ROOT = Path(__file__).resolve().parent.parent
_TMP = tempfile.TemporaryDirectory()
_ROOT = Path(_TMP.name)
+1 -3
View File
@@ -8,7 +8,7 @@ directory, and only a manual reading found it.
"""
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import sys
import tempfile
@@ -16,8 +16,6 @@ import unittest
from pathlib import Path
from unittest import mock
sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "scripts"))
import fileless_audit
ROOT = Path(__file__).resolve().parent.parent
+3 -3
View File
@@ -7,7 +7,7 @@ attached to misterfpga by substring and checked against the full list:
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import os
import sys
@@ -16,9 +16,9 @@ import unittest
import zipfile
from pathlib import Path
from generate_pack import verify_and_finalize_packs
REPO_ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(REPO_ROOT / "scripts"))
from generate_pack import verify_and_finalize_packs # noqa: E402
class FinalizeByExactName(unittest.TestCase):
+2 -5
View File
@@ -3,7 +3,7 @@ the offset of every window that holds it, in a file or a ZIP member."""
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import contextlib
import hashlib
@@ -18,10 +18,7 @@ import zlib
from pathlib import Path
from unittest import mock
REPO_ROOT = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(REPO_ROOT / "scripts"))
import find_embedded # noqa: E402
import find_embedded
ROM = bytes(random.Random(8039).randrange(256) for _ in range(2048))
CRC = zlib.crc32(ROM)
+3 -8
View File
@@ -6,19 +6,14 @@ today's upstream no longer carries, but the bytes are in the project's history.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import hashlib
import sys
import unittest
from pathlib import Path
from unittest import mock
REPO_ROOT = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(REPO_ROOT / "scripts"))
import find_pinned_revision # noqa: E402
import upstream # noqa: E402
import find_pinned_revision
import upstream
class ThePinnedRevisionIsInTheHistory(unittest.TestCase):
+1 -1
View File
@@ -9,7 +9,7 @@ and put every file one directory too deep.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import unittest
from pathlib import Path
+4 -6
View File
@@ -9,20 +9,18 @@ to upstream PCSX2.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import hashlib
import os
import sys
import tempfile
import unittest
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(REPO_ROOT / "scripts"))
import generate_db
from common import resolve_local_file
import generate_db # noqa: E402
from common import resolve_local_file # noqa: E402
REPO_ROOT = Path(__file__).resolve().parent.parent
class ForeignTree(unittest.TestCase):
+3 -5
View File
@@ -9,20 +9,18 @@ served while data/bluemsx held the 8 KB one.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import hashlib
import os
import shutil
import sys
import tempfile
import unittest
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(REPO_ROOT / "scripts"))
from common import resolve_local_file
from common import resolve_local_file # noqa: E402
REPO_ROOT = Path(__file__).resolve().parents[1]
class ForeignTreeNames(unittest.TestCase):
+5 -6
View File
@@ -8,11 +8,10 @@ the pack and the manifest while verify, comparing md5, called it OK.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import hashlib
import os
import sys
import tempfile
import unittest
import zipfile
@@ -20,11 +19,11 @@ from pathlib import Path
import yaml
from common import load_platform_config
from generate_pack import generate_manifest, generate_pack
from verify import verify_platform
REPO_ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(REPO_ROOT / "scripts"))
from common import load_platform_config # noqa: E402
from generate_pack import generate_manifest, generate_pack # noqa: E402
from verify import verify_platform # noqa: E402
class FrontendDigestDecides(unittest.TestCase):
+4 -5
View File
@@ -2,7 +2,7 @@
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import json
import subprocess
@@ -11,14 +11,13 @@ import tempfile
import unittest
from pathlib import Path
from region import REGIONS
from scripts.scraper import game_dat_importer as importer
ROOT = Path(__file__).resolve().parent.parent
TMP_ROOT = ROOT / "tmp" / "tests"
TMP_ROOT.mkdir(parents=True, exist_ok=True)
FIXTURES = ROOT / "tests" / "fixtures" / "game_dats"
sys.path.insert(0, str(ROOT / "scripts"))
from region import REGIONS # noqa: E402
from scripts.scraper import game_dat_importer as importer # noqa: E402
try:
from jsonschema import Draft202012Validator
+4 -6
View File
@@ -12,19 +12,15 @@ carries `unsourceable:` until its own bytes are held.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import hashlib
import os
import re
import sys
import unittest
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(REPO_ROOT / "scripts"))
from common import ( # noqa: E402
from common import (
build_zip_contents_index,
load_data_dir_registry,
load_database,
@@ -33,6 +29,8 @@ from common import ( # noqa: E402
resolve_local_file,
)
REPO_ROOT = Path(__file__).resolve().parents[1]
def homonyms(claims: list[tuple[str, str, str, str]]) -> list[tuple[str, str, str]]:
"""(profile, destination, file) for name-only claims on a file that
+4 -6
View File
@@ -2,21 +2,19 @@
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import json
import re
import sys
import unittest
from pathlib import Path
import yaml
ROOT = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(ROOT / "scripts"))
from common import load_emulator_profiles
from region import REGIONS
from common import load_emulator_profiles # noqa: E402
from region import REGIONS # noqa: E402
ROOT = Path(__file__).resolve().parent.parent
try:
from jsonschema import Draft202012Validator
+4 -6
View File
@@ -8,19 +8,17 @@ can lose its backing, then on the repository's own files.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import copy
import json
import sys
import unittest
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(REPO_ROOT / "scripts"))
import game_rules
from common import load_emulator_profiles
import game_rules # noqa: E402
from common import load_emulator_profiles # noqa: E402
REPO_ROOT = Path(__file__).resolve().parents[1]
FIXTURES = REPO_ROOT / "tests" / "fixtures" / "game_rules"
+4 -6
View File
@@ -7,7 +7,7 @@ so a test pins the join and not the state of the data.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import json
import shutil
@@ -16,14 +16,12 @@ import tempfile
import unittest
from pathlib import Path
import generate_games_index as gi
from romfolders import SystemResolver, load_setups
ROOT = Path(__file__).resolve().parent.parent
TMP_ROOT = ROOT / "tmp" / "tests"
TMP_ROOT.mkdir(parents=True, exist_ok=True)
sys.path.insert(0, str(ROOT / "scripts"))
sys.path.insert(0, str(ROOT))
import generate_games_index as gi # noqa: E402
from romfolders import SystemResolver, load_setups # noqa: E402
SETUP = """\
setup: fixture
+4 -6
View File
@@ -7,17 +7,15 @@ it. RetroArch names Galaksija's 4 KiB galaksija/rom1.bin, so DOSBox's
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import sys
import unittest
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(REPO_ROOT / "scripts"))
from cross_reference import cross_reference
from validation import case_folded_slots, declaration_settles
from cross_reference import cross_reference # noqa: E402
from validation import case_folded_slots, declaration_settles # noqa: E402
REPO_ROOT = Path(__file__).resolve().parents[1]
SC55 = {"name": "ROM1.BIN", "path": "SC-55/ROM1.BIN", "size": 32768,
"validation": ["size"], "required": True}
+3 -4
View File
@@ -10,7 +10,7 @@ the pad reaching the console, a compositor covering it) is not exercised.
"""
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import contextlib
import hashlib
@@ -33,11 +33,10 @@ from pathlib import Path
import yaml
import build_port
REPO_ROOT = Path(__file__).resolve().parent.parent
PORTS = REPO_ROOT / "ports"
sys.path.insert(0, str(REPO_ROOT / "scripts"))
import build_port # noqa: E402
_spec = importlib.util.spec_from_file_location("install", REPO_ROOT / "install.py")
install = importlib.util.module_from_spec(_spec)
+1 -1
View File
@@ -2,7 +2,7 @@
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import json
import tempfile
+3 -5
View File
@@ -2,19 +2,17 @@
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import shutil
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 hashing
import hashing # noqa: E402
REPO_ROOT = Path(__file__).resolve().parents[1]
class HashesAreReadOncePerContent(unittest.TestCase):
+3 -5
View File
@@ -9,17 +9,15 @@ ROCKNIX's higan SGB1.sfc/program.rom under the file SGB1.sfc.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import os
import sys
import unittest
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(REPO_ROOT / "scripts"))
from packpaths import placement_block
from packpaths import placement_block # noqa: E402
REPO_ROOT = Path(__file__).resolve().parents[1]
class OneRule(unittest.TestCase):
+1 -4
View File
@@ -2,16 +2,13 @@
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import shutil
import sys
import tempfile
import unittest
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "scripts"))
import identity
+7 -23
View File
@@ -1,7 +1,7 @@
"""Tests for install.py platform detection and config parsing."""
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import argparse
import contextlib
@@ -32,14 +32,13 @@ import urllib.error
import zipfile
from pathlib import Path, PurePosixPath
from tests.netguard import module_guard
REPO_ROOT = Path(__file__).resolve().parent.parent
_spec = importlib.util.spec_from_file_location("install", REPO_ROOT / "install.py")
install = importlib.util.module_from_spec(_spec)
_spec.loader.exec_module(install)
sys.path.insert(0, str(REPO_ROOT / "tests"))
from netguard import module_guard # noqa: E402
# What a stale pin's failure says: the fix is one command.
PIN_ADVICE = "install.py changed: python scripts/pin_installer.py rewrites both pins"
@@ -477,7 +476,7 @@ class TheDataTreesCountInTheFreeSpace(unittest.TestCase):
files the first installed."""
from types import SimpleNamespace
from test_install_selection import FakeRepository
from tests.test_install_selection import FakeRepository
member = os.urandom(4096)
results = []
@@ -1829,9 +1828,6 @@ class TargetFlagIsAppliedOrRefused(unittest.TestCase):
self.assertEqual(targets[alias], targets["nintendo-switch"])
def test_every_alias_resolves_to_its_canonical_core_list(self):
import sys as _sys
_sys.path.insert(0, str(REPO_ROOT / "scripts"))
from common import load_target_config
for name in ("install/targets/retroarch.json",):
@@ -1865,9 +1861,6 @@ 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.
"""
import sys as _sys
_sys.path.insert(0, str(REPO_ROOT / "scripts"))
from common import list_available_targets, load_target_config
platforms = str(REPO_ROOT / "platforms")
@@ -2493,9 +2486,6 @@ class TestAvailablePlatforms(unittest.TestCase):
def test_every_registered_platform_is_installable(self):
"""The installer serves every registered platform from its manifest."""
import sys as _sys
_sys.path.insert(0, str(REPO_ROOT / "scripts"))
from common import list_registered_platforms
registered = set(
@@ -2527,7 +2517,6 @@ class TestAvailablePlatforms(unittest.TestCase):
def test_pin_script_writes_both_pins(self):
"""Every edit to install.py meant a sha256sum pasted by hand into two
files with two syntaxes, and the failing test named no command."""
sys.path.insert(0, str(REPO_ROOT / "scripts"))
import pin_installer
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp" / "tests") as directory:
@@ -3418,7 +3407,6 @@ 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).
sys.path.insert(0, str(REPO_ROOT / "scripts"))
from common import load_emulator_profiles
installed = {
@@ -4318,7 +4306,7 @@ class DataDirectoriesAreInstalled(unittest.TestCase):
self.assertEqual(sorted(p.name for p in (bios / "dolphin-emu").iterdir()), ["Sys"])
def test_the_run_ends_on_the_archive_bytes_too(self):
from test_install_selection import FakeRepository
from tests.test_install_selection import FakeRepository
member = os.urandom(300_000)
with FakeRepository() as repo:
@@ -4341,7 +4329,7 @@ class DataDirectoriesAreInstalled(unittest.TestCase):
def test_the_plan_announces_the_archive_not_the_tree(self):
"""yaps2's tarball is 21.2 MB for a 6.5 MB tree, Cemu's 21.4 MB for
9.9 KB: the plan announced the tree, and the run downloaded far more."""
from test_install_selection import FakeRepository
from tests.test_install_selection import FakeRepository
member = b"profile"
archive_size = 21_360_579
@@ -4483,7 +4471,6 @@ class DataDirectoriesAreInstalled(unittest.TestCase):
manifest = json.loads((REPO_ROOT / "install" / "retroarch.json").read_text())
dirs = manifest.get("data_directories") or []
files = sum(len(d["files"]) for d in dirs)
sys.path.insert(0, str(REPO_ROOT / "scripts"))
import generate_pack
written = generate_pack.PACK_DOCUMENTS + generate_pack.pack_markers(
@@ -4733,7 +4720,7 @@ class ACheckThatFindsFilesMissingIsNoFailure(unittest.TestCase):
BIOS folder to complete from a tool that never ran."""
def test_missing_is_3_and_a_failure_stays_1(self):
from test_install_selection import FakeRepository
from tests.test_install_selection import FakeRepository
with FakeRepository() as repo:
missing = repo.run("--no-input", "--check")
@@ -7100,7 +7087,6 @@ class TheEventSchemaFileIsEventKeys(unittest.TestCase):
outside Python could check a stream against."""
def _generator(self):
sys.path.insert(0, str(REPO_ROOT / "scripts"))
import generate_event_schema
return generate_event_schema
@@ -7148,7 +7134,6 @@ class TheInstallerPageIsWrittenFromTheCode(unittest.TestCase):
PAGE = REPO_ROOT / "wiki" / "installer.md"
def setUp(self):
sys.path.insert(0, str(REPO_ROOT / "scripts"))
import generate_installer_doc
self.generator = generate_installer_doc
@@ -7743,7 +7728,6 @@ class TheListVersionIsComparedWithTheSystems(unittest.TestCase):
"""A handheld without network installs from the pack: its manifest.json
records the list's version, which generate_pack takes from the
install list built with the same choices."""
sys.path.insert(0, str(REPO_ROOT / "scripts"))
import generate_pack
data = b"bios"
install_list = {"version": "43.1", "files": [
+4 -7
View File
@@ -8,7 +8,7 @@ menu) is not exercised.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import hashlib
import io
@@ -23,13 +23,10 @@ import zipfile
from pathlib import Path
from unittest import mock
REPO_ROOT = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(REPO_ROOT))
sys.path.insert(0, str(REPO_ROOT / "tests"))
sys.path.insert(0, str(REPO_ROOT / "scripts"))
import install
from tests.test_install_selection import FakeRepository
import install # noqa: E402
from test_install_selection import FakeRepository # noqa: E402
REPO_ROOT = Path(__file__).resolve().parent.parent
INDEX = REPO_ROOT / "install" / "launchers" / "index.json"
+4 -8
View File
@@ -8,7 +8,7 @@ which cores keep each system, the rule a pack built for a target follows.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import contextlib
import io
@@ -22,12 +22,10 @@ import unittest
from pathlib import Path
from unittest import mock
REPO_ROOT = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(REPO_ROOT))
sys.path.insert(0, str(REPO_ROOT / "tests"))
import install
from tests.test_install_selection import FakeRepository
import install # noqa: E402
from test_install_selection import FakeRepository # noqa: E402
REPO_ROOT = Path(__file__).resolve().parent.parent
class CoreDirectories(unittest.TestCase):
@@ -267,7 +265,6 @@ class TheBuildersOrder(unittest.TestCase):
db_path = REPO_ROOT / "database.json"
if not db_path.exists():
self.skipTest("database.json is not built")
sys.path.insert(0, str(REPO_ROOT / "scripts"))
import generate_pack as gp
from common import load_emulator_profiles
@@ -369,7 +366,6 @@ class APlatformOmissionKeepsItsClaim(unittest.TestCase):
self.assertEqual(omitted, [])
def test_the_generator_files_the_core_behind_the_platform(self):
sys.path.insert(0, str(REPO_ROOT / "scripts"))
import generate_pack as gp
held = {"cores": None}
+4 -9
View File
@@ -7,7 +7,7 @@ honours Retry-After, and large files that resume where they stopped.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import contextlib
import errno
@@ -25,12 +25,10 @@ import unittest
from pathlib import Path
from unittest import mock
REPO_ROOT = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(REPO_ROOT))
sys.path.insert(0, str(REPO_ROOT / "tests"))
import install
from tests.test_install_selection import FakeRepository
import install # noqa: E402
from test_install_selection import FakeRepository # noqa: E402
REPO_ROOT = Path(__file__).resolve().parent.parent
PAYLOAD = bytes(range(256)) * 400 # 102400 bytes
@@ -199,7 +197,6 @@ class ProgramsAreMarked(unittest.TestCase):
the git mode cannot, hundreds of MAME archives carrying an execute bit."""
def test_header_decides(self):
sys.path.insert(0, str(REPO_ROOT / "scripts"))
import generate_pack
with tempfile.TemporaryDirectory() as tmp:
@@ -227,7 +224,6 @@ class ManifestHashesMatchTheScan(unittest.TestCase):
file holds, the same wrong value in two runs."""
def test_a_contradicted_hash_is_refused(self):
sys.path.insert(0, str(REPO_ROOT / "scripts"))
import generate_pack
with tempfile.TemporaryDirectory() as tmp:
@@ -245,7 +241,6 @@ class ManifestHashesMatchTheScan(unittest.TestCase):
"""The retries went through the hash cache and got the first, wrong
value back: one read of the file, then a refusal a second read would
have avoided."""
sys.path.insert(0, str(REPO_ROOT / "scripts"))
import generate_pack
import hashing
+1 -2
View File
@@ -9,7 +9,7 @@ platform and compare each (dest, sha1) with what the installer keeps.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import contextlib
import copy
@@ -27,7 +27,6 @@ from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parent.parent
# install.py runs on 3.8, the scripts it is compared with need 3.9.
BUILDER_FLOOR = (3, 9)
sys.path.insert(0, str(REPO_ROOT / "scripts"))
_spec = importlib.util.spec_from_file_location("install", REPO_ROOT / "install.py")
install = importlib.util.module_from_spec(_spec)
+4 -7
View File
@@ -2,7 +2,7 @@
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import contextlib
import errno
@@ -12,18 +12,15 @@ import json
import os
import shutil
import subprocess
import sys
import tempfile
import unittest
from pathlib import Path
from unittest import mock
REPO_ROOT = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(REPO_ROOT))
sys.path.insert(0, str(REPO_ROOT / "tests"))
import install
from tests.test_install_selection import FakeRepository
import install # noqa: E402
from test_install_selection import FakeRepository # noqa: E402
REPO_ROOT = Path(__file__).resolve().parent.parent
class AndroidMediaScanner(unittest.TestCase):
+6 -8
View File
@@ -11,7 +11,7 @@ never moved, and checked again once written.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import contextlib
import copy
@@ -30,15 +30,13 @@ import zipfile
from pathlib import Path
from unittest import mock
REPO_ROOT = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(REPO_ROOT))
sys.path.insert(0, str(REPO_ROOT / "tests"))
import install # noqa: E402
from test_install_offline import ( # noqa: E402
import install
from tests.test_install_offline import (
EXTRA, GBA, JP, PAYLOAD, US, Scratch, _entry, _offline_env,
)
from test_install_selection import FakeRepository # noqa: E402
from tests.test_install_selection import FakeRepository
REPO_ROOT = Path(__file__).resolve().parent.parent
def _zip(path: Path, members: dict[str, bytes]) -> Path:
+3 -4
View File
@@ -8,7 +8,7 @@ index, published by scripts/generate_games_index.py.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import contextlib
import functools
@@ -30,11 +30,10 @@ import zlib
from pathlib import Path
from unittest import mock
import install
REPO_ROOT = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(REPO_ROOT))
import install # noqa: E402
TMP_ROOT = REPO_ROOT / "tmp" / "tests"
TMP_ROOT.mkdir(parents=True, exist_ok=True)
+5 -7
View File
@@ -12,7 +12,7 @@ one that lengthens it has to say so here too.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import functools
import hashlib
@@ -29,13 +29,11 @@ import time
import unittest
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(REPO_ROOT))
sys.path.insert(0, str(REPO_ROOT / "tests"))
import install
from tests import test_install_games as games
from tests.test_install_tui import DOWN, UP, Pty, pty, pyte
import install # noqa: E402
import test_install_games as games # noqa: E402
from test_install_tui import DOWN, UP, Pty, pty, pyte # noqa: E402
REPO_ROOT = Path(__file__).resolve().parent.parent
END = "\x1b[F"
ESC = "\x1b"
+8 -12
View File
@@ -9,7 +9,7 @@ installs again from disk, --from-pack, every file checked by its hash.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import contextlib
import hashlib
@@ -27,14 +27,11 @@ import unittest.mock
import zipfile
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(REPO_ROOT))
sys.path.insert(0, str(REPO_ROOT / "scripts"))
sys.path.insert(0, str(REPO_ROOT / "tests"))
import install
import split_pack
from tests.test_install_selection import FakeRepository
import install # noqa: E402
import split_pack # noqa: E402
from test_install_selection import FakeRepository # noqa: E402
REPO_ROOT = Path(__file__).resolve().parent.parent
US = b"us bios " * 64
JP = b"jp bios " * 64
@@ -435,7 +432,6 @@ class ABoardWithoutTheNetwork(Scratch):
if p.is_file()}
def test_the_builder_writes_both_into_the_pack_list(self):
sys.path.insert(0, str(REPO_ROOT / "scripts"))
import generate_pack
install_list = manifest()
@@ -725,7 +721,7 @@ class OfflineMakesNoRequest(Scratch):
learn its platform, since nothing said "make no request"."""
def _served(self, *options: str, env: dict | None = None):
import test_install_selection
from tests import test_install_selection
hits: list[str] = []
with FakeRepository() as repo, unittest.mock.patch.object(
@@ -1029,7 +1025,7 @@ class OneOfflineVocabulary(Scratch):
def test_the_command_suggested_keeps_the_offline_setting(self):
"""Sudo does not pass RETROBIOS_INSTALL_OFFLINE on."""
import test_install_tui as tui
from tests import test_install_tui as tui
args = tui._args(platform="retroarch", declared_only=False, offline=False)
hint = install.Invocation()
@@ -1048,7 +1044,7 @@ class OneOfflineVocabulary(Scratch):
def test_the_screen_says_missing_not_failed(self):
"""On the full screen: "Finished with errors, 20 failed"."""
import test_install_tui as tui
from tests import test_install_tui as tui
reason = f"not fetched: {install.OFFLINE_WORDS}"
state = tui._installed_state(self.dest, 1, [{"dest": f"f{n}.bin", "reason": reason}
+1 -1
View File
@@ -8,7 +8,7 @@ and a failure leaves no file behind.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import argparse
import functools
+4 -7
View File
@@ -9,7 +9,7 @@ records no install writes (a crafted one, a drive that folds case).
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import contextlib
import hashlib
@@ -18,7 +18,6 @@ import json
import os
import shutil
import subprocess
import sys
import tempfile
import types
import unittest
@@ -26,12 +25,10 @@ import zipfile
from pathlib import Path
from unittest import mock
REPO_ROOT = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(REPO_ROOT))
sys.path.insert(0, str(REPO_ROOT / "tests"))
import install
from tests.test_install_selection import FakeRepository
import install # noqa: E402
from test_install_selection import FakeRepository # noqa: E402
REPO_ROOT = Path(__file__).resolve().parent.parent
try:
import pty
+3 -5
View File
@@ -9,7 +9,7 @@ to one answer.
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import contextlib
import functools
@@ -30,10 +30,9 @@ import unittest
from unittest import mock
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(REPO_ROOT / "scripts"))
import region
import region # noqa: E402
REPO_ROOT = Path(__file__).resolve().parent.parent
_spec = importlib.util.spec_from_file_location("install", REPO_ROOT / "install.py")
install = importlib.util.module_from_spec(_spec)
@@ -1375,7 +1374,6 @@ class ThePlatformsOwnSystemNamesAreAccepted(unittest.TestCase):
source)
def test_every_listed_system_gets_the_title_the_site_prints(self):
sys.path.insert(0, str(REPO_ROOT / "scripts"))
from generate_pack import system_titles
files = [{"dest": "a.bin", "systems": ["sony-playstation", "nintendo-gba"]}]
+41 -56
View File
@@ -9,7 +9,7 @@ installs it).
from __future__ import annotations
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
import tests
import argparse
import contextlib
@@ -40,16 +40,14 @@ import zipfile
from pathlib import Path, PurePosixPath, PureWindowsPath
from unittest import mock
import install
from tests.test_install_app import make_card
from tests.test_install_selection import FakeRepository, _QuietHandler
from tests.netguard import module_guard
REPO_ROOT = Path(__file__).resolve().parent.parent
# install.py runs on 3.8, the scripts it is compared with need 3.9.
BUILDER_FLOOR = (3, 9)
sys.path.insert(0, str(REPO_ROOT))
sys.path.insert(0, str(REPO_ROOT / "tests"))
import install # noqa: E402
from test_install_app import make_card # noqa: E402
from test_install_selection import FakeRepository, _QuietHandler # noqa: E402
from netguard import module_guard # noqa: E402
# No connection off the loopback and no card of the host reaches a test, in
# this process or one it starts: 261 connections to
@@ -3373,21 +3371,19 @@ class AReadErrorIsNotAClosedWindow(unittest.TestCase):
import pty
master, slave = pty.openpty()
screen = open(os.dup(slave), "w", encoding="utf-8") # noqa: SIM115
terminal = mock.Mock(fd=slave, stdout=screen)
try:
card = OSError(errno.EIO, "Input/output error", "/media/card/bios/x.bin")
self.assertFalse(install._closed_terminal(card, terminal))
self.assertFalse(install._closed_terminal(
OSError(errno.ENOENT, "No such file"), terminal))
os.close(master)
master = -1
self.assertTrue(install._closed_terminal(card, terminal))
self.assertTrue(install._closed_terminal(termios.error(errno.EIO, "gone"),
terminal))
with open(os.dup(slave), "w", encoding="utf-8") as screen:
terminal = mock.Mock(fd=slave, stdout=screen)
card = OSError(errno.EIO, "Input/output error", "/media/card/bios/x.bin")
self.assertFalse(install._closed_terminal(card, terminal))
self.assertFalse(install._closed_terminal(
OSError(errno.ENOENT, "No such file"), terminal))
os.close(master)
master = -1
self.assertTrue(install._closed_terminal(card, terminal))
self.assertTrue(install._closed_terminal(termios.error(errno.EIO, "gone"),
terminal))
finally:
with contextlib.suppress(OSError):
screen.close()
os.close(slave)
if master >= 0:
os.close(master)
@@ -5076,7 +5072,7 @@ class SaveDirectoryRepository(FakeRepository):
def _app_card(test: unittest.TestCase, system: str) -> tuple[Path, Path]:
"""A card of system in the repository's tmp/, its root and BIOS folder."""
from test_install_app import make_card
from tests.test_install_app import make_card
(REPO_ROOT / "tmp").mkdir(exist_ok=True)
root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
@@ -5258,7 +5254,7 @@ class EndToEnd(unittest.TestCase):
def card_repo(self, system: str) -> tuple[Path, Path]:
from test_install_app import AppRepository, make_card
from tests.test_install_app import AppRepository, make_card
repo = self.repo(AppRepository)
root = repo.root / "card"
@@ -7599,7 +7595,7 @@ class _CardFixtures:
regions: bool = True) -> tuple[Path, Path, dict]:
"""A list of plat's shape (the MinUI family records cores and regions,
no system), the pack built from it and the files' payloads."""
from test_install_offline import GBA, JP, US
from tests.test_install_offline import GBA, JP, US
payloads = {"Bios/MGBA/gba_bios.bin": (GBA, "nintendo-gba", "mgba", None),
"Bios/PS/scph5501.bin": (US, "sony-playstation", "pcsx_rearmed",
@@ -7620,8 +7616,6 @@ class _CardFixtures:
if sys.version_info < BUILDER_FLOOR:
# generate_pack.py's context managers need Python 3.9.
return listing, None, {}
sys.path.insert(0, str(REPO_ROOT / "scripts"))
self.addCleanup(sys.path.remove, str(REPO_ROOT / "scripts"))
import generate_pack
pack_list = {"files": [{"path": dest, "sha1": entry["sha1"], "size": entry["size"]}
@@ -7864,7 +7858,7 @@ class _OutsideTextFindings:
return out.getvalue() + err.getvalue() + events.getvalue()
def test_a_pack_member_path_is_refused(self):
from test_install_offline import _pack, GBA
from tests.test_install_offline import _pack, GBA
pack = _pack(self.root, "RetroArch_v1_BIOS_Pack.zip", {f"x{self.OSC}.bin": GBA})
text = self.run_install(_args(platform="retroarch", dest=self.dest,
@@ -8461,7 +8455,7 @@ class LineModeAndScreenDecideAlike(_LineModeFindings, _OutsideTextFindings,
def test_a_pack_gets_the_menu_and_its_folder_named(self):
"""No menu and no folder before the copy, the pack's list
recording no system."""
from test_install_offline import _pack, PAYLOAD
from tests.test_install_offline import _pack, PAYLOAD
downloads = self.root / "downloads"
downloads.mkdir()
@@ -9251,8 +9245,6 @@ class PacksWordingAndDocs(unittest.TestCase):
@unittest.skipIf(sys.version_info < BUILDER_FLOOR,
"generate_pack.py's context managers need Python 3.9")
def test_a_pack_records_the_systems_of_its_files(self):
sys.path.insert(0, str(REPO_ROOT / "scripts"))
self.addCleanup(sys.path.remove, str(REPO_ROOT / "scripts"))
import generate_pack
install_list = {"files": [{"dest": "a.bin", "systems": ["3do"]},
@@ -9270,7 +9262,7 @@ class PacksWordingAndDocs(unittest.TestCase):
self.assertIn("systems", schema["properties"]["files"]["items"]["properties"])
def pack(self, systems: bool) -> Path:
from test_install_offline import GBA, US
from tests.test_install_offline import GBA, US
members = {"scph5501.bin": US, "gba_bios.bin": GBA}
listed = [{"path": path, "sha1": hashlib.sha1(data).hexdigest(),
@@ -9319,7 +9311,7 @@ class PacksWordingAndDocs(unittest.TestCase):
def test_a_pack_cannot_write_escapes_through_its_system_names(self):
"""The titles and ids a pack
records reached print() raw in the systems list."""
from test_install_offline import GBA, US
from tests.test_install_offline import GBA, US
members = {"scph5501.bin": US, "gba_bios.bin": GBA}
listed = [{"path": path, "sha1": hashlib.sha1(data).hexdigest(), "size": len(data),
@@ -10307,7 +10299,7 @@ class ScreenRowsAndFilters(unittest.TestCase):
"""Cannot create, then end 2 and nothing else."""
import subprocess
from test_install_offline import PAYLOAD, _offline_env, _pack
from tests.test_install_offline import PAYLOAD, _offline_env, _pack
if os.name == "nt" or os.geteuid() == 0:
self.skipTest("a folder that refuses writes is POSIX, and root writes anyway")
@@ -10626,8 +10618,6 @@ class CardNamesAndHelp(_CardFixtures, unittest.TestCase):
"""The table left out the
SHARE drives. It is generated: every card rule and SHARE drive file
is a row, about.info among them."""
sys.path.insert(0, str(REPO_ROOT / "scripts"))
self.addCleanup(sys.path.remove, str(REPO_ROOT / "scripts"))
import generate_installer_doc
page = (REPO_ROOT / "wiki" / "installer.md").read_text(encoding="utf-8")
@@ -11257,22 +11247,20 @@ class MouseOnAPty(unittest.TestCase):
master, slave = os.openpty()
self.addCleanup(os.close, master)
self.addCleanup(os.close, slave)
given = open(slave, encoding="utf-8", closefd=False) # noqa: SIM115
shown = open(slave, "w", encoding="utf-8", closefd=False) # noqa: SIM115
self.addCleanup(given.close)
self.addCleanup(shown.close)
terminal = install._TuiTerminal(given, shown)
terminal.mouse_allowed = True
terminal.enter()
terminal.set_mouse(True)
problems = install._tui_cleanup(terminal, [], {}, fresh_state())
self.assertEqual(problems, [])
raw = b""
while select.select([master], [], [], 0.2)[0]:
raw += os.read(master, 65536)
for mode in (b"1000", b"1006"):
self.assertGreater(raw.rfind(b"\x1b[?" + mode + b"l"),
raw.rfind(b"\x1b[?" + mode + b"h"))
with open(slave, encoding="utf-8", closefd=False) as given, \
open(slave, "w", encoding="utf-8", closefd=False) as shown:
terminal = install._TuiTerminal(given, shown)
terminal.mouse_allowed = True
terminal.enter()
terminal.set_mouse(True)
problems = install._tui_cleanup(terminal, [], {}, fresh_state())
self.assertEqual(problems, [])
raw = b""
while select.select([master], [], [], 0.2)[0]:
raw += os.read(master, 65536)
for mode in (b"1000", b"1006"):
self.assertGreater(raw.rfind(b"\x1b[?" + mode + b"l"),
raw.rfind(b"\x1b[?" + mode + b"h"))
def _painted_roles(text: str, style: str = "", colour: bool = True) -> list[tuple[str, str]]:
@@ -12854,7 +12842,7 @@ class TapsOnAPtySeeFirst(unittest.TestCase):
term.close()
def test_the_game_data_row_keeps_the_ticks_to_the_install(self):
from test_install_tui import GameDataRepository
from tests.test_install_tui import GameDataRepository
repo = self.repo(GameDataRepository)
term = self.start()
@@ -14704,8 +14692,6 @@ class ProvenCardsAndCounts(unittest.TestCase):
def test_which_pack_names_the_first_screen(self):
"""Which-pack said the command opens a screen
where Install and Choose systems are, the second screen."""
sys.path.insert(0, str(REPO_ROOT / "scripts"))
self.addCleanup(sys.path.remove, str(REPO_ROOT / "scripts"))
import generate_site
words = " ".join(generate_site.first_screen_words())
@@ -15285,7 +15271,7 @@ class GamesEndToEnd(unittest.TestCase):
"""The real --tui on a card with games, against a loopback repository."""
def test_the_plan_opens_on_the_games_and_installs_only_them(self):
import test_install_games as games
from tests import test_install_games as games
card = games.Card()
self.addCleanup(card.close)
@@ -16177,7 +16163,6 @@ class EmulatorChoiceMatchesTheEmulatorPack(unittest.TestCase):
if sys.version_info < BUILDER_FLOOR:
# The builder's floor: install.py alone keeps 3.8.
raise unittest.SkipTest("generate_pack.py needs Python 3.9 or newer")
sys.path.insert(0, str(REPO_ROOT / "scripts"))
import generate_pack as gp
from common import build_zip_contents_index
Loaded 100 of 281 files, more files were not shown because too many files have changed in this diff. Show more