Test modules passed dir= the repository's tmp/ or a hard-coded tmp/tests by hand, and seven modules kept their own _tempdir copy. Under run_tests.py the literal tmp/tests did not exist in a fresh clone (FileNotFoundError in test_core_probe and scratch_checkout), and dir=tmp/ wrote beside the per-module scratch folders. Every temporary directory now lands in the folder tests/__init__ sets, and scratch_dir() replaces the copies. The X socket binds by a relative name, since a scratch path can exceed the 108-byte AF_UNIX limit. The journeys keep the short tmp/ root: their word budgets count the printed card path.
model.largefiles.restore_verified replaces generate_db _restore and
release restore _copy_verified: a scratch copy beside the target,
hashed, then renamed into place with a plain mode.
generate_db now refuses to put back a cached asset whose copy does not
hash to its database entry. The entry is still kept, as for an asset
the cache cannot supply. The restore script copies once instead of
through a second scratch.
Each network job had several copies. One is kept per job and
every caller uses it.
- Source revision: model.sourcerevision (source_revision, required_revision,
platform_revision) replaces BaseTargetScraper's pattern list, the
exporter's _REVISION, the four launcher_revision copies and RetroBat's
own YAML reader. It reads the union of the shapes: GitHub raw, blob and
tree with or without a path after the revision, GitLab raw, blob, tree
and archive, codeload tar.gz and zip. The target scrapers now answer
for RetroDECK, NextUI, MinUI and MyMinUI, whose tree URLs end at the
commit, and the exporter reads GitLab blob and tree and codeload zip.
EmuDeck and RetroBat still require a 40-hex commit, and each launcher
reader requires its own repository in the URL.
- Latest release: fetch_github_latest_version, type-checked, is the only
lookup. mame_hash_scraper, romset_dat_importer and the Lakka target
scraper call it. romset_dat_importer's NoReleaseError is gone: a
release without a tag raises RuntimeError.
- Tree listing: github_tree and tree_entries refuse a truncated or
unreadable listing. The libretro and core-info scrapers share
core_info_files and fetch_info_file, with libretro's refusal of an empty
listing. The core-info listing and the RetroDECK, ROCKNIX launcher and
libretro listings were not checked for truncation before.
- GET: fetch_bytes is the one request path. fetch_text, fetch_present
(None on 404 only), github_json and download are built on it, so every
read retries 429 and 5xx, caps the body and raises FetchError, a
ConnectionError carrying the HTTP status. The target scrapers' own
fetch_text raised RuntimeError: they now raise FetchError, and an
optional Batocera board include is skipped on 404 only, not on any
failure. The exporter's originals, MiSTer, RetroPie, redump and the
buildbot index go through it too.
- Headers: core.upstream.forge_headers is the one builder. The token goes
to api.github.com and raw.githubusercontent.com, the host compared
whole, as Bearer. A URL that only names api.github.com in its query
got the scrapers' token before, and profile_sync sent its token to
github.com, whose release downloads redirect to asset storage with the
header. Scraper reads of raw files now carry the token.
- Submodule commit: submodule_commit checks that the path is a
submodule. Batocera's target scraper accepted any contents answer with
a sha, a directory's tree sha included.
- Download: download streams through a scratch file renamed into place,
retries like fetch_bytes, can keep an existing file and returns the
Content-Disposition. It replaces the _download of romset_dat_importer
and game_dat_importer.
The release tools, the installer build tools and the repository's
commit and PR checks keep their commands and move their code into
three packages. The release record readers move to model.releaserecord,
romfolders to model, the buildbot check to scraper. The site reads the
handheld launchers and the bootstrap pin from installer_build.
core: cli (run_cli, input errors, name hints), github (token), paths.
model: sources, database, composition, registry, platforms,
declarations, targets, systems, profiles, cliargs. resolve: content,
ownership, datadirs, archives, localfile, directories, layout,
contentlayout, standalone, grouping, cores.
Definitions move verbatim; common.py and its re-exports are gone and
every importer, patch target and code-in-string names the new home. A
test that stubbed common.load_platform_config stubs each module that
reads the loader by its own name.
core: hashing, artifacts, ziptools, deterministic_zip, romdir, sect233r1,
crypto_verify, paths (REPO_ROOT). model: safeparse (needs yaml),
dumpcatalog, largefiles, alternatives. resolve: nativemode, validation,
launchers, slot, truth, gamedata, and exporter/baseline.py and
exporter/candidates.py as resolve/reconcile.py and resolve/categories.py,
which truth and gamedata read.
Every importer follows. Modules one level deeper read the repository
root from core.paths instead of __file__.
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.
pyproject.toml now carries the ruff rule set: pyflakes, the B rules,
simplify, perf, pyupgrade, complexity and size limits. This commit
applies the fixes that change no behavior and the small defects the
first run named:
- tests/test_install.py used argparse without importing it
- three loops rebound the outer `profile` with each layout
(packextras, slots, verify); the loop variable is now `layout`
- profile_sync loops shadowed dataclasses.field
- generate_readme and packextras computed values nothing read
- stale noqa markers for rules the project does not enforce
Complexity, size and the remaining findings are handled next.
tests/__init__.py keeps a run offline, its scratch under tmp/ and its
installer cache its own, but only discover -s tests -t . imported it.
discover tests ran with RETROBIOS_OFFLINE unset, scratch on the /tmp
tmpfs and the user's real installer cache, the setting in which e2e
fixtures had written into the shared .cache/large. Every test module now
imports the package first, and a test fails on a module that does not.
test_verify_listing.py took its line with the previous commit.
install/games/, the event schema, the launcher index and wiki/installer.md were truncated at their final name, so an interrupted run left a committed-looking partial JSON document. They now go through write_text_atomic.
plain_file_mode and safe_extract_zip set the umask to 0 to read it. Two threads doing so could restore 0 last, leaving every later file world-writable. Both now read it through process_umask, which holds a lock.
mkstemp creates its scratch 0600 and os.replace kept that mode, so
database.json, the manifests, the packs, the recipe snapshots and the
large-file cache were readable by their owner only. set_plain_mode
gives the scratch 0o666 less the umask, as open() would, before each
rename. A test walks every function that renames a mkstemp file.