refactor: release, installer_build, devtools pkgs

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.
This commit is contained in:
Abdessamad Derraz committed 2026-11-18 20:44:12 +01:00
1 parent 5b3b3f19e8
commit c4fdf12874
91 files changed
+3508 -3277

No files matched your search

+16
View File
@@ -29,6 +29,22 @@ COMMANDS = {
"refresh_data_dirs.py": ("packs/datadirs.py",),
"split_pack.py": ("packs/parts.py",),
"dedup.py": ("model/nodedup.py",),
"release_record.py": ("model/releaserecord.py", "release/record.py"),
"release_notes.py": ("release/notes.py",),
"check_release.py": ("release/check.py",),
"check_release_assets.py": ("release/assets.py",),
"sync_release_assets.py": ("release/sync.py",),
"restore_large_files.py": ("release/restore.py",),
"build_installer.py": ("installer_build/amalgamate.py",),
"pin_installer.py": ("installer_build/pins.py",),
"build_port.py": ("installer_build/port.py",),
"build_pypi.py": ("installer_build/pypi.py",),
"generate_launcher_index.py": ("installer_build/launcherindex.py",),
"generate_event_schema.py": ("installer_build/eventschema.py",),
"generate_installer_doc.py": ("installer_build/installerdoc.py",),
"commit_rules.py": ("devtools/commitrules.py",),
"pr_checks.py": ("devtools/prchecks.py",),
"check_buildbot_system.py": ("scraper/buildbot_system.py",),
"generate_site.py": (
"sitegen/config.py",
"sitegen/emulatorsindex.py",
+8 -6
View File
@@ -51,7 +51,6 @@ class WholeOrNothing(unittest.TestCase):
class EveryWriterGoesThroughIt(unittest.TestCase):
def test_manifests_record_and_restore_use_the_atomic_helpers(self):
scripts = REPO_ROOT / "scripts"
for name, helper in (
("generate_pack.py", "write_text_atomic("),
("release_record.py", "write_text_atomic("),
@@ -63,8 +62,8 @@ class EveryWriterGoesThroughIt(unittest.TestCase):
pack = script_source("generate_pack.py")
self.assertNotIn('with open(path, "w") as f:\n f.write(new_json)', pack)
self.assertNotIn("json.dump(result, f", pack)
self.assertNotIn("args.output.write_text(", (scripts / "release_record.py").read_text())
self.assertNotIn("shutil.copy2(source, path)", (scripts / "restore_large_files.py").read_text())
self.assertNotIn("args.output.write_text(", script_source("release_record.py"))
self.assertNotIn("shutil.copy2(source, path)", script_source("restore_large_files.py"))
def test_scrapers_write_whole_files(self):
@@ -95,10 +94,12 @@ class EveryWriterGoesThroughIt(unittest.TestCase):
sandbox = {"write_small_list", "Sandbox"}
offenders = []
for path in sorted((REPO_ROOT / "scripts").glob("generate_*.py")):
library = [REPO_ROOT / "scripts" / "installer_build" / name
for name in ("eventschema.py", "installerdoc.py", "launcherindex.py")]
for path in [*sorted((REPO_ROOT / "scripts").glob("generate_*.py")), *library]:
tree = ast.parse(path.read_text(encoding="utf-8"))
for top in tree.body:
if path.name == "generate_installer_doc.py" and getattr(top, "name", "") in sandbox:
if path.name == "installerdoc.py" and getattr(top, "name", "") in sandbox:
continue
offenders.extend(
f"{path.name}:{node.lineno}"
@@ -281,6 +282,7 @@ class RestoreSkipsDownloadsInProgress(unittest.TestCase):
def test_a_scratch_promoted_mid_scan_does_not_stop_the_restore(self) -> None:
import restore_large_files
from release import restore
with tempfile.TemporaryDirectory() as tmp:
cache = Path(tmp)
@@ -299,7 +301,7 @@ class RestoreSkipsDownloadsInProgress(unittest.TestCase):
with mock.patch.object(restore_large_files.os.path, "isfile",
side_effect=check_then_promote):
index = restore_large_files.index_cache(str(cache))
index = restore.index_cache(str(cache))
self.assertNotIn(str(scratch), index.values())
self.assertIn(str(cache / "done.bin"), index.values())
+22 -21
View File
@@ -2230,7 +2230,7 @@ class CheckoutCompletenessRegressions(unittest.TestCase):
self.assertLess(self._index(steps, "refresh_data_dirs.py"), generate)
def test_restore_matches_assets_by_content_not_by_name(self):
from scripts.restore_large_files import restore
from scripts.release.restore import restore
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
root = Path(directory)
@@ -2265,7 +2265,7 @@ class CheckoutCompletenessRegressions(unittest.TestCase):
restore, nothing unsatisfied, exit 0 with every asset absent."""
import subprocess
from scripts.restore_large_files import gitignored_paths
from scripts.release.restore import gitignored_paths
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
missing = str(Path(directory) / "absent")
@@ -2284,7 +2284,7 @@ class CheckoutCompletenessRegressions(unittest.TestCase):
"""The cache is hashed first and copied later: another run that
replaced the cached name in between put its bytes at a path the
database pins to the old ones."""
from scripts import restore_large_files
from scripts.release import restore as release_restore
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
root = Path(directory)
@@ -2298,7 +2298,7 @@ class CheckoutCompletenessRegressions(unittest.TestCase):
json.dumps({"files": {sha1: {"path": "bios/Sony/big.pup"}}}),
encoding="utf-8",
)
real_index = restore_large_files.index_cache
real_index = release_restore.index_cache
def index_then_replace(cache_dir: str) -> dict[str, str]:
index = real_index(cache_dir)
@@ -2308,8 +2308,8 @@ class CheckoutCompletenessRegressions(unittest.TestCase):
cwd = os.getcwd()
os.chdir(root)
try:
with mock.patch.object(restore_large_files, "index_cache", index_then_replace):
restored, unsatisfied = restore_large_files.restore(
with mock.patch.object(release_restore, "index_cache", index_then_replace):
restored, unsatisfied = release_restore.restore(
str(cache), "database.json", ".gitignore"
)
self.assertEqual((restored, unsatisfied), (0, ["bios/Sony/big.pup"]))
@@ -2319,7 +2319,7 @@ class CheckoutCompletenessRegressions(unittest.TestCase):
os.chdir(cwd)
def test_restore_leaves_tracked_paths_alone(self):
from scripts.restore_large_files import restore
from scripts.release.restore import restore
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
root = Path(directory)
@@ -2347,7 +2347,7 @@ class CheckoutCompletenessRegressions(unittest.TestCase):
def test_restore_without_a_cache_names_what_is_missing(self):
"""A job that skipped `mkdir .cache/large` exited 0 with every
gitignored file absent: the early return ran before the check."""
from scripts.restore_large_files import restore
from scripts.release.restore import restore
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
root = Path(directory)
@@ -2696,7 +2696,7 @@ class ReleaseAssetsMatchTheCollection(unittest.TestCase):
"""
def test_missing_and_resized_assets_are_reported_and_nothing_else(self):
from scripts import check_release_assets
from scripts.release import assets as release_assets
expected = {
"bios/Other/fbneo/fbneo/samples/twotiger.zip": 154985212,
@@ -2708,7 +2708,7 @@ class ReleaseAssetsMatchTheCollection(unittest.TestCase):
"MAME.0.174.Arcade.XML.dat": 53677408,
"unrelated.zip": 1,
}
findings = check_release_assets.compare(expected, assets)
findings = release_assets.compare(expected, assets)
self.assertEqual(
findings,
[
@@ -2718,7 +2718,7 @@ class ReleaseAssetsMatchTheCollection(unittest.TestCase):
)
def test_expected_assets_are_the_gitignored_database_entries(self):
from scripts import check_release_assets
from scripts.release import assets as release_assets
db = {
"files": {
@@ -2728,7 +2728,7 @@ class ReleaseAssetsMatchTheCollection(unittest.TestCase):
}
gitignore = "# large\nbios/Other/x/big.zip\ntmp/\n"
self.assertEqual(
check_release_assets.expected_assets(db, gitignore),
release_assets.expected_assets(db, gitignore),
{"bios/Other/x/big.zip": 10},
)
@@ -2741,7 +2741,7 @@ class ReleaseAssetsMatchTheCollection(unittest.TestCase):
description from the profile that declares the file, and an asset the
collection does not index is listed apart, with its size only.
"""
from scripts import check_release_assets
from scripts.release import assets as release_assets
db = {"files": {
"a" * 40: {"path": "bios/Nintendo/Wii/nand.bin", "size": 553649152},
@@ -2758,7 +2758,7 @@ class ReleaseAssetsMatchTheCollection(unittest.TestCase):
)
descriptions = {"nand.bin": "BootMii NAND backup"}
bundles = {"sdlpal-data.zip": "SDLPAL Chinese Paladin game data (.mkf archives)"}
body = check_release_assets.render_notes(
body = release_assets.render_notes(
db, gitignore, assets, previous, descriptions, bundles, {"sdlpal-data.zip": "d" * 40}
)
self.assertIn("| [twotiger.zip](https://github.com/Abdess/retrobios/releases/download/large-files/twotiger.zip) | Two Tigers samples | 148 MB | `" + "b" * 40 + "` |", body)
@@ -2774,9 +2774,9 @@ class ReleaseAssetsMatchTheCollection(unittest.TestCase):
))
def test_stale_notes_are_a_finding(self):
from scripts import check_release_assets
from scripts.release import assets as release_assets
findings = check_release_assets.compare({}, {}, notes_current=False)
findings = release_assets.compare({}, {}, notes_current=False)
self.assertEqual(findings, [("notes", "release description", 0, None)])
def test_pipeline_runs_the_check_online_and_marks_it_skipped_offline(self):
@@ -3168,7 +3168,7 @@ class ACheckThatCannotAnswerDoesNotPass(unittest.TestCase):
self.assertNotEqual(swept.returncode, 0, swept.stdout + swept.stderr)
def test_an_unsatisfiable_declared_path_is_reported(self):
from scripts.restore_large_files import restore
from scripts.release.restore import restore
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
root = Path(directory)
@@ -3194,19 +3194,20 @@ class ACheckThatCannotAnswerDoesNotPass(unittest.TestCase):
"""Every HEAD unanswered printed "16 unknown" and exited 0, so the
online pipeline printed check_buildbot OK."""
import check_buildbot_system as cbs
from scraper import buildbot_system
registry = str(ROOT / "platforms" / "_data_dirs.yml")
tracked = cbs.load_tracked_entries(registry)
tracked = buildbot_system.load_tracked_entries(registry)
self.assertTrue(tracked)
cases = {
"index unreachable": mock.patch.object(
cbs, "fetch_index", side_effect=OSError("down")),
buildbot_system, "fetch_index", side_effect=OSError("down")),
"every HEAD unanswered": mock.patch.object(
cbs, "fetch_index", return_value=set(tracked)),
buildbot_system, "fetch_index", return_value=set(tracked)),
}
for label, index in cases.items():
with self.subTest(label), index, \
mock.patch.object(cbs, "get_remote_etag", return_value=None), \
mock.patch.object(buildbot_system, "get_remote_etag", return_value=None), \
mock.patch.object(sys, "argv", ["check_buildbot_system.py",
"--registry", registry]), \
contextlib.redirect_stdout(io.StringIO()), \
+13 -13
View File
@@ -29,7 +29,7 @@ from core import hostguard
from core import statefile
import bios_integrity as bib
import cleanup_disk as cd
import sync_release_assets as sra
from release import sync
REPO_ROOT = Path(__file__).resolve().parents[1]
@@ -785,14 +785,14 @@ class AssetSync(Scratch):
(self.root / rel).parent.mkdir(parents=True, exist_ok=True)
(self.root / rel).write_bytes(data)
self.db = {"files": {
sra.sha1_of(self.root / "bios/A/big.bin"): {"path": "bios/A/big.bin", "size": 1},
sync.sha1_of(self.root / "bios/A/big.bin"): {"path": "bios/A/big.bin", "size": 1},
"0" * 40: {"path": "bios/C/solo.iso", "size": 1},
}}
def test_only_a_file_whose_sha1_matches_twice_is_cleared(self):
findings = [("missing", "bios/A/big.bin", 1, None), ("size", "bios/C/solo.iso", 1, 5),
("notes", "release description", 0, None)]
plans = sra.plan_uploads(self.root, self.db, self.GITIGNORE, findings)
plans = sync.plan_uploads(self.root, self.db, self.GITIGNORE, findings)
self.assertEqual([(p.path, p.asset, p.verdict) for p in plans], [
("bios/A/big.bin", "A--big.bin", "upload"),
("bios/C/solo.iso", "solo.iso", "refused"),
@@ -801,23 +801,23 @@ class AssetSync(Scratch):
def test_two_reads_that_disagree_refuse_the_upload(self):
reads = iter(["1" * 40, "2" * 40])
plans = sra.plan_uploads(self.root, self.db, self.GITIGNORE,
plans = sync.plan_uploads(self.root, self.db, self.GITIGNORE,
[("content", "bios/A/big.bin", 1, 1)],
hasher=lambda _p: next(reads))
self.assertEqual(plans[0].verdict, "refused")
self.assertIn("two reads disagree", plans[0].reason)
def test_an_upload_goes_under_its_asset_name_and_is_tried_twice(self):
plans = [sra.Upload("bios/A/big.bin", "A--big.bin", "missing", "upload"),
sra.Upload("bios/C/solo.iso", "solo.iso", "size", "refused", "x")]
plans = [sync.Upload("bios/A/big.bin", "A--big.bin", "missing", "upload"),
sync.Upload("bios/C/solo.iso", "solo.iso", "size", "refused", "x")]
seen = []
def upload(path: Path) -> int:
seen.append(path.name)
return 1
self.assertEqual(sra.upload_all(self.root, plans, upload), ["bios/A/big.bin"])
self.assertEqual(sync.upload_all(self.root, plans, upload), ["bios/A/big.bin"])
self.assertEqual(seen, ["A--big.bin", "A--big.bin"])
self.assertFalse((self.root / sra.STAGING / "A--big.bin").exists())
self.assertFalse((self.root / sync.STAGING / "A--big.bin").exists())
class BiosIntegrity(Scratch):
@@ -961,30 +961,30 @@ class SubjectsFollowTheRepositoryRules(unittest.TestCase):
calls: a copy in the hook alone let CI check only the shape."""
def test_the_runner_reads_the_tracked_rules(self):
import commit_rules
from devtools import commitrules
for subject in ("chore: fix the broken manifests", "update things", "chore: " + "a" * 60):
with self.subTest(subject=subject):
self.assertEqual(ar.check_subject(subject), commit_rules.problems(subject))
self.assertEqual(ar.check_subject(subject), commitrules.problems(subject))
self.assertTrue(ar.check_subject(subject))
self.assertEqual(ar.check_subject("chore: tidy the cache"), [])
def test_review_numbers_are_refused(self):
"""47 pushed subjects pointed at a numbered private review, which no
clone can follow. The subject says what the change does."""
import commit_rules
from devtools import commitrules
for subject in ("chore: audit 24 and 17 cases, host kept out",
"fix: polish the screens audit 11 named",
"chore: merge audit batch, resolver and profiles",
"fix: settle the review 3 notes"):
with self.subTest(subject=subject):
self.assertTrue(commit_rules.problems(subject))
self.assertTrue(commitrules.problems(subject))
for subject in ("fix: scroll long messages in the installer",
"feat: read regions in region_audit.py",
"chore: merge resolver and profile fixes"):
with self.subTest(subject=subject):
self.assertEqual(commit_rules.problems(subject), [])
self.assertEqual(commitrules.problems(subject), [])
def test_the_rules_run_as_a_hook(self):
with tempfile.TemporaryDirectory() as tmp:
+9 -9
View File
@@ -16,7 +16,7 @@ import textwrap
import unittest
from pathlib import Path
import build_installer
from installer_build import amalgamate
REPO_ROOT = Path(__file__).resolve().parents[1]
DOCSTRING = '"""A test installer."""\n'
@@ -33,13 +33,13 @@ def _package(root: Path, modules: dict[str, str]) -> Path:
class TheCommittedFileIsTheBuiltOne(unittest.TestCase):
def test_install_py_is_what_the_package_builds(self):
built = build_installer.build(REPO_ROOT / "installer")
built = amalgamate.build(REPO_ROOT / "installer")
self.assertEqual(built, (REPO_ROOT / "install.py").read_text(encoding="utf-8"),
f"install.py differs from installer/: run {build_installer.COMMAND}")
f"install.py differs from installer/: run {amalgamate.COMMAND}")
def test_two_builds_give_the_same_bytes(self):
self.assertEqual(build_installer.build(REPO_ROOT / "installer"),
build_installer.build(REPO_ROOT / "installer"))
self.assertEqual(amalgamate.build(REPO_ROOT / "installer"),
amalgamate.build(REPO_ROOT / "installer"))
def test_the_file_says_it_is_generated(self):
head = (REPO_ROOT / "install.py").read_text(encoding="utf-8").splitlines()[:3]
@@ -85,8 +85,8 @@ class JoiningRefusesWhatOneNamespaceCannotHold(unittest.TestCase):
def assert_refused(self, modules: dict[str, str], words: str) -> None:
package = _package(self.root, modules)
with self.assertRaises(build_installer.BuildError) as caught:
build_installer.build(package)
with self.assertRaises(amalgamate.BuildError) as caught:
amalgamate.build(package)
self.assertIn(words, str(caught.exception))
def test_a_package_joins_in_import_order(self):
@@ -111,7 +111,7 @@ class JoiningRefusesWhatOneNamespaceCannotHold(unittest.TestCase):
A = sys.platform + str(zlib.crc32(b""))
''',
})
text = build_installer.build(package)
text = amalgamate.build(package)
self.assertLess(text.index("A = sys.platform"), text.index("B = A + os.sep"))
self.assertIn("import os\nimport sys\n", text)
self.assertNotIn("from installer", text)
@@ -147,7 +147,7 @@ class JoiningRefusesWhatOneNamespaceCannotHold(unittest.TestCase):
'if TYPE_CHECKING:\n from installer.b import B\n\n\ndef f(b: B) -> None:\n return None\n'),
"b": '"""B."""\nfrom __future__ import annotations\n\nfrom installer.a import f\n\n\nclass B:\n pass\n',
})
text = build_installer.build(package)
text = amalgamate.build(package)
self.assertNotIn("TYPE_CHECKING", text)
self.assertLess(text.index("def f("), text.index("class B:"))
+4 -4
View File
@@ -742,19 +742,19 @@ class TheBuildbotIndexIsRead(unittest.TestCase):
def test_new_and_dropped_assets_are_stale(self):
from unittest import mock
import check_buildbot_system as cbs
from scraper import buildbot_system
report = {"entries": [
{"zip": "New.zip", "status": "NEW", "key": None},
{"zip": "Old.zip", "status": "OK", "key": "old"},
]}
with mock.patch.object(cbs, "check", lambda registry: report):
with mock.patch.object(buildbot_system, "check", lambda registry: report):
finding = cf._check_buildbot_system()
self.assertEqual(finding.status, cf.STALE)
self.assertIn("new New.zip", finding.detail)
with mock.patch.object(cbs, "check", lambda registry: {"error": "x", "entries": []}):
with mock.patch.object(buildbot_system, "check", lambda registry: {"error": "x", "entries": []}):
self.assertEqual(cf._check_buildbot_system().status, cf.UNKNOWN)
self.assertEqual([e["zip"] for e in cbs.pending(report)], ["New.zip"])
self.assertEqual([e["zip"] for e in buildbot_system.pending(report)], ["New.zip"])
+3 -3
View File
@@ -11,8 +11,8 @@ import tests
import unittest
import build_port
from check_release import SIGNATURE, SUMS, Asset, compare_release, parse_sums
from installer_build import port
from release.check import SIGNATURE, SUMS, Asset, compare_release, parse_sums
A = "a" * 64
B = "b" * 64
@@ -97,7 +97,7 @@ class ReleaseMatchesWhatWasBuilt(unittest.TestCase):
def test_a_handheld_launcher_is_no_release_file(self):
"""The site serves the launchers built from its own commit: one in
the checksum list or among the assets is refused."""
for name in build_port.ARCHIVES:
for name in port.ARCHIVES:
with self.subTest(name=name):
sums = {**SUMS_LIST, name: A}
assets = _assets()
+13 -13
View File
@@ -240,28 +240,28 @@ class OneCommandRunsTheChecks(unittest.TestCase):
r"|vermin|npm (?:ci|run build)|mypy|ruff check|shellcheck))")
def test_every_check_ci_runs_is_a_step(self):
import pr_checks
from devtools import prchecks
workflow = (REPO_ROOT / ".github" / "workflows" / "validate.yml").read_text(encoding="utf-8")
ran = {m.group(1) for line in workflow.splitlines()
if not line.strip().startswith("#") for m in [self.CHECK.search(line)] if m}
self.assertGreaterEqual(len(ran), 10)
steps = [step.command for step in pr_checks.STEPS]
steps = [step.command for step in prchecks.STEPS]
for check in sorted(ran):
with self.subTest(check=check):
self.assertTrue(any(command.startswith(check) for command in steps))
def test_a_step_ci_lets_fail_does_not_fail_the_run(self):
import pr_checks
from devtools import prchecks
workflow = (REPO_ROOT / ".github" / "workflows" / "validate.yml").read_text(encoding="utf-8")
tolerated = set(re.findall(r"continue-on-error: true\n\s*run: (\S+ \S+)", workflow))
for step in pr_checks.STEPS:
for step in prchecks.STEPS:
with self.subTest(step=step.command):
self.assertEqual(step.may_fail, " ".join(step.command.split()[:2]) in tolerated)
def test_steps_keep_ci_order(self):
import pr_checks
from devtools import prchecks
workflow = (REPO_ROOT / ".github" / "workflows" / "validate.yml").read_text(encoding="utf-8")
order = [workflow.index(key) for key in (
@@ -269,19 +269,19 @@ class OneCommandRunsTheChecks(unittest.TestCase):
"npm run build --prefix website", "python scripts/run_tests.py",
"validate_site.py")]
self.assertEqual(order, sorted(order))
commands = [step.command for step in pr_checks.STEPS]
commands = [step.command for step in prchecks.STEPS]
positions = [next(i for i, c in enumerate(commands) if key in c) for key in (
"refresh_data_dirs.py", "generate_site.py", "npm run build",
"run_tests.py", "validate_site.py")]
self.assertEqual(positions, sorted(positions))
def test_the_guide_gives_the_runner_and_what_it_runs(self):
import pr_checks
from devtools import prchecks
text = readme.generate_contributing()
section = text.split("## Before opening a PR", 1)[1].split("\n## ", 1)[0]
self.assertIn("python scripts/pr_checks.py\n", section)
for step in pr_checks.STEPS:
for step in prchecks.STEPS:
with self.subTest(step=step.command):
self.assertIn(step.command, section)
@@ -289,17 +289,17 @@ class OneCommandRunsTheChecks(unittest.TestCase):
import contextlib
import io
import pr_checks
from devtools import prchecks
steps = (
pr_checks.Step("python -c raise(SystemExit(3))", "fails"),
pr_checks.Step("no-such-tool-here --x", "absent", needs="no-such-tool-here",
prchecks.Step("python -c raise(SystemExit(3))", "fails"),
prchecks.Step("no-such-tool-here --x", "absent", needs="no-such-tool-here",
provider="nothing"),
pr_checks.Step("python -c pass", "passes"),
prchecks.Step("python -c pass", "passes"),
)
out = io.StringIO()
with contextlib.redirect_stdout(out):
code = pr_checks.run(steps)
code = prchecks.run(steps)
self.assertEqual(code, 1)
self.assertIn("FAILED python -c raise(SystemExit(3)) (exit 3)", out.getvalue())
self.assertIn("NOT RUN no-such-tool-here --x", out.getvalue())
+14 -13
View File
@@ -97,17 +97,17 @@ class InstallerOutputExample(unittest.TestCase):
prints each one with install.py from the committed list."""
def test_the_samples_are_the_ones_the_installer_prints(self):
import generate_installer_doc
from installer_build import installerdoc
page = _page("installer.md")
self.assertEqual(generate_installer_doc.render(page), page,
self.assertEqual(installerdoc.render(page), page,
"run python scripts/generate_installer_doc.py")
for name in ("dry-run", "run-date", "run-index", "run-download", "run-end", "run-check"):
with self.subTest(sample=name):
self.assertIn(f"<!-- generated: {name} -->", page)
def test_a_retyped_count_fails_the_check(self):
import generate_installer_doc
from installer_build import installerdoc
page = _page("installer.md")
for name in ("dry-run", "run-end", "bulk-hint"):
@@ -116,10 +116,10 @@ class InstallerOutputExample(unittest.TestCase):
edited = re.sub(r"\d+", lambda m: str(int(m.group(0)) + 1), body, count=1)
stale = page.replace(body, edited)
self.assertNotEqual(stale, page)
self.assertEqual(generate_installer_doc.render(stale), page)
self.assertEqual(installerdoc.render(stale), page)
def test_a_sample_is_dated_by_its_list_never_by_the_day_it_ran(self):
import generate_installer_doc
from installer_build import installerdoc
page = _page("installer.md")
for name, platform in (("dry-run", "retroarch"), ("run-date", "batocera")):
@@ -128,7 +128,7 @@ class InstallerOutputExample(unittest.TestCase):
date = json.loads(listed)["generated"][:10]
self.assertIn(f"the list of {date}", _generated(page, name))
self.assertNotIn(str(ROOT), page)
home = f"{generate_installer_doc.SHOWN_HOME}/.config/retroarch"
home = f"{installerdoc.SHOWN_HOME}/.config/retroarch"
self.assertIn(home, _generated(page, "dry-run"))
def test_run_and_menu_show_one_run_of_the_manifest(self):
@@ -222,13 +222,13 @@ class InstallerSamplesSayWhatTheCodePrints(unittest.TestCase):
import socket
from unittest import mock
import generate_installer_doc
from installer_build import installerdoc
def no_lookup(*_args: object) -> str:
raise AssertionError("the sandbox asked for a name")
with mock.patch.object(socket, "getfqdn", no_lookup), \
generate_installer_doc.Sandbox() as box:
installerdoc.Sandbox() as box:
self.assertEqual(box.server.server_name, "127.0.0.1")
@@ -1808,7 +1808,7 @@ class ReportExcerptIsTheRun(unittest.TestCase):
def test_every_quoted_line_is_printed(self):
import subprocess
from restore_large_files import gitignored_paths
from release.restore import gitignored_paths
# The excerpt is a run over the whole collection. A checkout without
# the release assets (the PR workflow restores none) prints other
@@ -2074,10 +2074,10 @@ class LandingAChangeNamesTheCommitRules(unittest.TestCase):
return _section(_page("testing-guide.md"), "Landing a change")
def test_every_refusal_is_on_the_page(self):
import commit_rules
from devtools import commitrules
section = self._landing()
words = re.search(r"\\b\((.*?)\)", commit_rules.REFUSED_WORDS.pattern).group(1)
words = re.search(r"\\b\((.*?)\)", commitrules.REFUSED_WORDS.pattern).group(1)
from tests.test_prose_style import NoMarketingVocabulary
for word in words.replace("|", " ").split():
@@ -2099,8 +2099,9 @@ class LandingAChangeNamesTheCommitRules(unittest.TestCase):
clone = Path(scratch)
(clone / ".git" / "hooks").mkdir(parents=True)
(clone / "scripts").mkdir()
(clone / "scripts" / "commit_rules.py").write_bytes(
(ROOT / "scripts" / "commit_rules.py").read_bytes())
for name in ("commit_rules.py", "devtools/__init__.py", "devtools/commitrules.py"):
(clone / "scripts" / name).parent.mkdir(exist_ok=True)
(clone / "scripts" / name).write_bytes((ROOT / "scripts" / name).read_bytes())
subprocess.run(["sh", "-c", block], cwd=clone, check=True)
message = clone / "MSG"
message.write_text("fix: address review 3 notes\n", encoding="utf-8")
+5 -5
View File
@@ -19,7 +19,7 @@ import unittest
from functools import cache
from pathlib import Path
import release_record
from model import releaserecord
from sitegen.readme import (
SITE_URL,
asset_links,
@@ -31,7 +31,7 @@ from sitegen.readme import (
REPO_ROOT = Path(__file__).resolve().parent.parent
RECORD = release_record.load_record(REPO_ROOT / "release.json")
RECORD = releaserecord.load_record(REPO_ROOT / "release.json")
REPO = "https://github.com/Abdess/retrobios"
SPLIT_RECORD = {
@@ -217,10 +217,10 @@ class DownloadLinksKeepTheirAddress(unittest.TestCase):
from model.platforms import load_platform_config
from sitegen import install
record = release_record.load_advertised()
record = releaserecord.load_advertised()
page = _which_pack()
for key in list_registered_platforms("platforms"):
if release_record.pack_for(key, record) is not None:
if releaserecord.pack_for(key, record) is not None:
continue
label = load_platform_config(key, "platforms").get("platform", key)
row = next(line for line in page.splitlines() if line.startswith(f"| [{label}]("))
@@ -380,7 +380,7 @@ class SizesComeFromTheRecord(unittest.TestCase):
tag, platform, download, extracted = quoted.groups()
if tag != RECORD.get("tag"):
self.skipTest(f"release.json records {RECORD.get('tag')}, not {tag}")
pack = release_record.pack_for(platform.lower(), RECORD)
pack = releaserecord.pack_for(platform.lower(), RECORD)
self.assertEqual(download, format_size(pack["download_size"]))
self.assertEqual(extracted, format_size(pack["extracted_size"]))
+1 -1
View File
@@ -132,7 +132,7 @@ class FixtureImport(unittest.TestCase):
class Selection(unittest.TestCase):
def test_every_system_is_a_repository_system(self) -> None:
from romfolders import SystemResolver
from model.romfolders import SystemResolver
ids = SystemResolver.from_repo().ids
wanted = [s for s, _ in importer.NOINTRO_DATS.values()]
+1 -1
View File
@@ -123,7 +123,7 @@ class HeaderReaders(unittest.TestCase):
self.assertIn(core, self.profiles, system)
def test_every_system_is_a_repository_system(self) -> None:
from romfolders import SystemResolver
from model.romfolders import SystemResolver
ids = SystemResolver.from_repo().ids
self.assertEqual([s for s in self.doc["systems"] if s not in ids], [])
+4 -4
View File
@@ -17,7 +17,7 @@ import unittest
from pathlib import Path
import generate_games_index as gi
from romfolders import SystemResolver, load_setups
from model.romfolders import SystemResolver, load_setups
ROOT = Path(__file__).resolve().parent.parent
TMP_ROOT = ROOT / "tmp" / "tests"
@@ -237,7 +237,7 @@ class CommittedData(unittest.TestCase):
if not setups:
self.skipTest("no setup scraped")
from model.profiles import load_emulator_profiles
from romfolders import ProfileResolver
from model.romfolders import ProfileResolver
resolver = SystemResolver.from_repo(str(ROOT / "emulators"), str(ROOT / "platforms"))
cores = ProfileResolver.from_repo(str(ROOT / "emulators"))
@@ -258,7 +258,7 @@ class CommittedData(unittest.TestCase):
folder run by mednafen_pce_fast, which lists nec-pc-engine, got no
System Card."""
from model.profiles import load_emulator_profiles
from romfolders import ProfileResolver, folder_names
from model.romfolders import ProfileResolver, folder_names
setups = load_setups(ROOT / "platforms" / "romfolders")
if not setups:
@@ -345,7 +345,7 @@ KNOWN_UNRESOLVED = {
class EveryCoreResolvesOrIsExplained(unittest.TestCase):
def setUp(self) -> None:
from model.profiles import load_emulator_profiles
from romfolders import ProfileResolver
from model.romfolders import ProfileResolver
self.resolver = SystemResolver.from_repo(str(ROOT / "emulators"), str(ROOT / "platforms"))
self.cores = ProfileResolver.from_repo(str(ROOT / "emulators"))
+28 -28
View File
@@ -33,7 +33,7 @@ from pathlib import Path
import yaml
import build_port
from installer_build import port
REPO_ROOT = Path(__file__).resolve().parent.parent
PORTS = REPO_ROOT / "ports"
@@ -275,22 +275,22 @@ class TheSdlModel(unittest.TestCase):
class TheArchives(unittest.TestCase):
LAYOUT = {
build_port.PORT_ZIP: ("RetroBIOS.sh", "retrobios"),
build_port.BATOCERA_ZIP: ("RetroBIOS.sh", "retrobios"),
build_port.MUOS_APP: (None, "RetroBIOS"),
build_port.TOOLS_ZIP: ("RetroBIOS.sh", "retrobios"),
port.PORT_ZIP: ("RetroBIOS.sh", "retrobios"),
port.BATOCERA_ZIP: ("RetroBIOS.sh", "retrobios"),
port.MUOS_APP: (None, "RetroBIOS"),
port.TOOLS_ZIP: ("RetroBIOS.sh", "retrobios"),
}
def setUp(self):
self.out = _tempdir(self)
def test_every_release_archive_is_built(self):
self.assertEqual(set(build_port.ARCHIVES), set(self.LAYOUT))
self.assertEqual(set(port.ARCHIVES), set(self.LAYOUT))
def test_layout(self):
for name, (script, folder) in self.LAYOUT.items():
with self.subTest(archive=name):
with zipfile.ZipFile(build_port.build_archive(name, self.out / name)) as zf:
with zipfile.ZipFile(port.build_archive(name, self.out / name)) as zf:
names = zf.namelist()
modes = {n: zf.getinfo(n).external_attr >> 16 for n in names}
self.assertEqual(names, sorted(names))
@@ -301,7 +301,7 @@ class TheArchives(unittest.TestCase):
self.assertIn(f"{folder}/{member}", names)
launcher = script or f"{folder}/mux_launch.sh"
self.assertTrue(modes[launcher] & 0o111, launcher)
if name == build_port.BATOCERA_ZIP:
if name == port.BATOCERA_ZIP:
self.assertEqual(top, ["RetroBIOS.sh", "RetroBIOS.sh.keys"])
self.assertNotIn("retrobios/retrobios.gptk", names)
elif script:
@@ -316,8 +316,8 @@ class TheArchives(unittest.TestCase):
muxapp named an icon it did not carry."""
header = (REPO_ROOT / "ports" / "muos" / "mux_launch.sh").read_text()
icon = re.search(r"^# ICON: (\S+)$", header, re.MULTILINE).group(1)
name = build_port.MUOS_APP
with zipfile.ZipFile(build_port.build_archive(name, self.out / name)) as zf:
name = port.MUOS_APP
with zipfile.ZipFile(port.build_archive(name, self.out / name)) as zf:
data = zf.read(f"RetroBIOS/glyph/{icon}.png")
self.assertEqual(data[:8], b"\x89PNG\r\n\x1a\n")
@@ -326,26 +326,26 @@ class TheArchives(unittest.TestCase):
system's extension (.sh for Tools and Ports): batocera-emulationstation
and EmulationStation-fcamod SystemData.cpp drop a folder with none.
The support folders must keep none, or each shows up in the menu."""
for name in (build_port.TOOLS_ZIP, build_port.PORT_ZIP, build_port.BATOCERA_ZIP):
for name in (port.TOOLS_ZIP, port.PORT_ZIP, port.BATOCERA_ZIP):
with self.subTest(archive=name):
with zipfile.ZipFile(build_port.build_archive(name, self.out / name)) as zf:
with zipfile.ZipFile(port.build_archive(name, self.out / name)) as zf:
inside = [n for n in zf.namelist()
if "/" in n and n.lower().endswith(".sh")]
self.assertEqual(inside, [])
def test_each_carries_the_pinned_installer(self):
pinned = build_port.pinned_installer_sha256()
pinned = port.pinned_installer_sha256()
for name, (_script, folder) in self.LAYOUT.items():
with self.subTest(archive=name):
with zipfile.ZipFile(build_port.build_archive(name, self.out / name)) as zf:
with zipfile.ZipFile(port.build_archive(name, self.out / name)) as zf:
bundled = hashlib.sha256(zf.read(f"{folder}/install.py")).hexdigest()
self.assertEqual(bundled, pinned)
def test_reproducible(self):
for name in build_port.ARCHIVES:
for name in port.ARCHIVES:
with self.subTest(archive=name):
first = build_port.build_archive(name, self.out / f"a-{name}").read_bytes()
second = build_port.build_archive(name, self.out / f"b-{name}").read_bytes()
first = port.build_archive(name, self.out / f"a-{name}").read_bytes()
second = port.build_archive(name, self.out / f"b-{name}").read_bytes()
self.assertEqual(first, second)
def test_each_names_the_release_packs(self):
@@ -354,13 +354,13 @@ class TheArchives(unittest.TestCase):
registry = yaml.safe_load((REPO_ROOT / "platforms" / "_registry.yml").read_text())
released = {name for name, entry in registry["platforms"].items()
if entry.get("release_pack") is True}
labels = build_port.release_pack_labels()
labels = port.release_pack_labels()
self.assertEqual(set(labels), released)
self.assertEqual(labels["retroarch"], "RetroArch")
expected = "".join(f"{p}\t{label}\n" for p, label in sorted(labels.items()))
for name, (_script, folder) in self.LAYOUT.items():
with self.subTest(archive=name), \
zipfile.ZipFile(build_port.build_archive(name, self.out / name)) as zf:
zipfile.ZipFile(port.build_archive(name, self.out / name)) as zf:
self.assertEqual(zf.read(f"{folder}/packs.txt").decode(), expected)
def test_an_unpinned_installer_is_refused(self):
@@ -370,9 +370,9 @@ class TheArchives(unittest.TestCase):
shutil.copytree(PORTS, root / "ports")
with (root / "install.py").open("a") as fh:
fh.write("\n")
for name in build_port.ARCHIVES:
for name in port.ARCHIVES:
with self.subTest(archive=name), self.assertRaises(ValueError):
build_port.build_archive(name, self.out / name, root)
port.build_archive(name, self.out / name, root)
def test_the_site_serves_each_and_the_release_none(self):
"""Each archive carries install.py: the site serves it from its own
@@ -380,7 +380,7 @@ class TheArchives(unittest.TestCase):
text = (REPO_ROOT / "wiki" / "release-process.md").read_text(encoding="utf-8")
self.assertNotIn("scripts/build_port.py", text)
installer = (REPO_ROOT / "wiki" / "installer.md").read_text(encoding="utf-8")
for name in build_port.ARCHIVES:
for name in port.ARCHIVES:
with self.subTest(archive=name):
self.assertNotIn(name, text)
self.assertIn(f"](../get/handheld/{name})", installer)
@@ -763,7 +763,7 @@ class Device:
"""The launcher archive extracted where the firmware keeps it, with
the fake installer in place of install.py."""
into.mkdir(parents=True, exist_ok=True)
built = build_port.build_archive(archive, self.root / "dist" / archive)
built = port.build_archive(archive, self.root / "dist" / archive)
with zipfile.ZipFile(built) as zf:
zf.extractall(into)
for info in zf.infolist():
@@ -946,7 +946,7 @@ class ThePortMasterPort(unittest.TestCase):
def device(self, console: str | None = None, **env: str) -> Device:
device = Device(self, **env)
roms = device.root / "roms"
self.gamedir = device.unpack(build_port.PORT_ZIP, roms / "ports") / "retrobios"
self.gamedir = device.unpack(port.PORT_ZIP, roms / "ports") / "retrobios"
control = device.root / "xdg" / "PortMaster"
control.mkdir(parents=True)
self.control = control
@@ -1530,7 +1530,7 @@ class ThePortMasterPort(unittest.TestCase):
class TheBatoceraPort(unittest.TestCase):
def device(self, **env: str) -> tuple[Device, Path]:
device = Device(self, **env)
ports = device.unpack(build_port.BATOCERA_ZIP, device.root / "userdata" / "roms" / "ports")
ports = device.unpack(port.BATOCERA_ZIP, device.root / "userdata" / "roms" / "ports")
return device, ports
def console_switch(self, device: Device) -> dict[str, str]:
@@ -1637,7 +1637,7 @@ class TheBatoceraPort(unittest.TestCase):
class TheMuosApp(unittest.TestCase):
def device(self, muxterm: bool, gptokeyb2: bool = True) -> tuple[Device, Path]:
device = Device(self)
apps = device.unpack(build_port.MUOS_APP, device.root / "mmc" / "MUOS" / "application")
apps = device.unpack(port.MUOS_APP, device.root / "mmc" / "MUOS" / "application")
muos = device.root / "opt-muos"
(muos / "script" / "var").mkdir(parents=True)
(muos / "script" / "var" / "retro.sh").write_text(
@@ -1858,7 +1858,7 @@ class TheMuosApp(unittest.TestCase):
class TheToolsEntry(unittest.TestCase):
def device(self, **env: str) -> tuple[Device, Path]:
device = Device(self, **env)
tools = device.unpack(build_port.TOOLS_ZIP, device.root / "tools")
tools = device.unpack(port.TOOLS_ZIP, device.root / "tools")
device.env["RB_ROOT"] = str(device.root / "fs")
return device, tools
@@ -2100,7 +2100,7 @@ class TheDocs(unittest.TestCase):
def test_the_offline_packs_named_are_the_ones_that_serve(self):
"""The wiki names the pack each firmware takes offline: the release
pack of the platform install.py detects it as, or none."""
labels = build_port.release_pack_labels()
labels = port.release_pack_labels()
served = {}
for rule in install._EMBEDDED_RULES:
served.setdefault(rule.name, labels.get(rule.manifest))
+16 -13
View File
@@ -2517,7 +2517,7 @@ 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."""
import pin_installer
from installer_build import pins
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp" / "tests") as directory:
root = Path(directory)
@@ -2525,9 +2525,9 @@ class TestAvailablePlatforms(unittest.TestCase):
shutil.copy2(REPO_ROOT / name, root / name)
(root / "install.py").write_text("# changed\n", encoding="utf-8")
sh_mode = (root / "install.sh").stat().st_mode
self.assertEqual(pin_installer.stale_pins(root), ["install.sh", "install.ps1"])
self.assertEqual(pin_installer.write_pins(root), ["install.sh", "install.ps1"])
self.assertEqual(pin_installer.stale_pins(root), [])
self.assertEqual(pins.stale_pins(root), ["install.sh", "install.ps1"])
self.assertEqual(pins.write_pins(root), ["install.sh", "install.ps1"])
self.assertEqual(pins.stale_pins(root), [])
digest = hashlib.sha256(b"# changed\n").hexdigest()
for name in ("install.sh", "install.ps1"):
before = (REPO_ROOT / name).read_text(encoding="utf-8").splitlines()
@@ -7088,9 +7088,9 @@ class TheEventSchemaFileIsEventKeys(unittest.TestCase):
outside Python could check a stream against."""
def _generator(self):
import generate_event_schema
from installer_build import eventschema
return generate_event_schema
return eventschema
def test_the_committed_file_is_the_generated_one(self):
generator = self._generator()
@@ -7117,7 +7117,8 @@ class TheEventSchemaFileIsEventKeys(unittest.TestCase):
generator.build_schema()
def test_the_check_command_fails_on_a_stale_file(self):
generator = self._generator()
import generate_event_schema as generator
scratch = Path(_tempdir(self)) / "events.schema.json"
scratch.write_text("{}\n", encoding="utf-8")
with contextlib.redirect_stdout(io.StringIO()), \
@@ -7136,8 +7137,10 @@ class TheInstallerPageIsWrittenFromTheCode(unittest.TestCase):
def setUp(self):
import generate_installer_doc
from installer_build import installerdoc
self.generator = generate_installer_doc
self.doc = installerdoc
self.scratch = Path(_tempdir(self)) / "installer.md"
self.scratch.write_text(self.PAGE.read_text(encoding="utf-8"), encoding="utf-8")
@@ -7175,7 +7178,7 @@ class TheInstallerPageIsWrittenFromTheCode(unittest.TestCase):
self.assertEqual(self.run_generator("--check")[0], 0)
def test_what_the_code_gains_stops_it_until_the_page_says_it(self):
real = self.generator._install.build_parser
real = self.doc._install.build_parser
def gained() -> argparse.ArgumentParser:
parser = real()
@@ -7183,12 +7186,12 @@ class TheInstallerPageIsWrittenFromTheCode(unittest.TestCase):
return parser
page = self.scratch.read_text(encoding="utf-8")
events = {**self.generator._install.EVENT_KEYS, "brand_new": ("thing",)}
events = {**self.doc._install.EVENT_KEYS, "brand_new": ("thing",)}
for name, patch in (
("--brand-new", unittest.mock.patch.object(
self.generator._install, "build_parser", gained)),
self.doc._install, "build_parser", gained)),
("brand_new", unittest.mock.patch.object(
self.generator._install, "EVENT_KEYS", events))):
self.doc._install, "EVENT_KEYS", events))):
with self.subTest(gained=name), patch:
code, said = self.run_generator()
self.assertEqual(code, 1)
@@ -7200,13 +7203,13 @@ class TheInstallerPageIsWrittenFromTheCode(unittest.TestCase):
self.scratch.write_text(
page.replace(close, "\n| `--brand-new` | Something new |" + close, 1),
encoding="utf-8")
with unittest.mock.patch.object(self.generator._install, "build_parser", gained):
with unittest.mock.patch.object(self.doc._install, "build_parser", gained):
self.assertEqual(self.run_generator()[0], 0)
self.assertIn('| <span id="option-brand-new"></span>`--brand-new` | Something new |',
self.scratch.read_text(encoding="utf-8"))
def test_the_exit_codes_are_the_ones_install_py_exits_with(self):
self.assertEqual(self.generator.exit_codes(), [0, 1, 2, 3, 4, 130, 141])
self.assertEqual(self.doc.exit_codes(), [0, 1, 2, 3, 4, 130, 141])
def test_a_missing_marker_stops_it(self):
page = self.scratch.read_text(encoding="utf-8")
+3 -3
View File
@@ -214,9 +214,9 @@ class TheList(unittest.TestCase):
if "repo_path" in entry else entry["content"].encode())
for entry in launcher["members"]]
data = install.app_archive(members)
import build_port
built = _tempdir(self) / build_port.MUOS_APP
build_port.build_archive(build_port.MUOS_APP, built)
from installer_build import port
built = _tempdir(self) / port.MUOS_APP
port.build_archive(port.MUOS_APP, built)
with zipfile.ZipFile(built) as release, zipfile.ZipFile(io.BytesIO(data)) as ours:
self.assertEqual(release.namelist(), ours.namelist())
for name in release.namelist():
+7 -6
View File
@@ -10,7 +10,7 @@ installs it).
from __future__ import annotations
import tests
from tests.sources import script_source
from tests.sources import script_paths, script_source
import argparse
import contextlib
@@ -9559,9 +9559,10 @@ class PacksWordingAndDocs(unittest.TestCase):
env = page[page.index("## Environment overrides"):]
self.assertIn("`TERMINFO`", env)
self.assertIn("`TERMINFO_DIRS`", env)
script = (REPO_ROOT / "scripts" / "generate_installer_doc.py").read_text(encoding="utf-8")
self.assertEqual([n for n, line in enumerate(script.splitlines(), 1) if len(line) > 100],
[])
for path in script_paths("generate_installer_doc.py"):
script = path.read_text(encoding="utf-8")
self.assertEqual(
[n for n, line in enumerate(script.splitlines(), 1) if len(line) > 100], [])
class OneDeviceRegistry(unittest.TestCase):
@@ -10620,7 +10621,7 @@ 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."""
import generate_installer_doc
from installer_build import installerdoc
page = (REPO_ROOT / "wiki" / "installer.md").read_text(encoding="utf-8")
block = page[page.index("<!-- generated: card-markers -->"):
@@ -10631,7 +10632,7 @@ class CardNamesAndHelp(_CardFixtures, unittest.TestCase):
self.assertIn(f"`{marker}`", block)
self.assertIn(self.ABOUT, block)
self.assertIn("Recalbox SHARE drive", block)
self.assertEqual(generate_installer_doc.render(page), page)
self.assertEqual(installerdoc.render(page), page)
class TheAndroidResultReadsWhole(unittest.TestCase):
"""A run on Android 17 under Termux: the result named /sdcard and
+8 -8
View File
@@ -25,7 +25,7 @@ from unittest import mock
from model.composition import GAME_DATA_TOPS, composition_tier
from model.profiles import load_emulator_profiles
from model import largefiles
import check_release_assets
from release import assets as release_assets
REPO_ROOT = Path(__file__).resolve().parent.parent
@@ -573,14 +573,14 @@ class ReleaseAssetNames(unittest.TestCase):
sizes = {self.ET: 228138631, self.RTCW: 122757192, self.PUP: 10}
published = {expected[p]: size for p, size in sizes.items()}
self.assertEqual(
check_release_assets.compare(
release_assets.compare(
sizes, published, registered=self.REGISTERED
),
[],
)
# The old basename-only asset must not satisfy either pak.
self.assertEqual(
{f[1] for f in check_release_assets.compare(
{f[1] for f in release_assets.compare(
sizes, {"pak0.pk3": 228138631, "PS3UPDAT.PUP": 10},
registered=self.REGISTERED,
)},
@@ -591,7 +591,7 @@ class ReleaseAssetNames(unittest.TestCase):
"b" * 40: {"path": self.RTCW, "size": sizes[self.RTCW]},
"c" * 40: {"path": self.PUP, "size": sizes[self.PUP]},
}}
body = check_release_assets.render_notes(
body = release_assets.render_notes(
db, gitignore, published, "", {}, {}, {}
)
self.assertIn(f"[{expected[self.ET]}]", body)
@@ -740,7 +740,7 @@ class GameDataHasOneDefinition(unittest.TestCase):
with self.subTest(path=path):
self.assertEqual(composition_tier(path), "game_data")
self.assertEqual(
check_release_assets._section_for(path), "Game engine data"
release_assets._section_for(path), "Game engine data"
)
def test_a_tree_of_game_data_alone_is_a_game_data_tree(self):
@@ -829,21 +829,21 @@ class ASameSizeReuploadIsSeen(unittest.TestCase):
assets = {"dsi_nand.bin": 8}
ours = {"bios/Nintendo/DSi/dsi_nand.bin": "a" * 64}
self.assertEqual(
[f[0] for f in check_release_assets.compare(
[f[0] for f in release_assets.compare(
expected, assets, expected_digests=ours,
asset_digests={"dsi_nand.bin": "b" * 64},
)],
["content"],
)
self.assertEqual(
check_release_assets.compare(
release_assets.compare(
expected, assets, expected_digests=ours,
asset_digests={"dsi_nand.bin": "a" * 64},
),
[],
)
self.assertEqual(
check_release_assets.digests_of(
release_assets.digests_of(
[{"name": "x", "digest": "sha256:ABC"}, {"name": "y"}]
),
{"x": "abc"},
+11 -21
View File
@@ -20,7 +20,8 @@ from pathlib import Path
SCRIPTS = Path(__file__).resolve().parent.parent / "scripts"
PACKAGE_LAYERS = {"core": 0, "model": 1, "resolve": 2, "packs": 3, "scraper": 3, "exporter": 3,
"probes": 3, "profiling": 3, "sitegen": 3, "romrecipes": 3, "acquire": 3}
"probes": 3, "profiling": 3, "sitegen": 3, "romrecipes": 3, "acquire": 3,
"release": 3, "installer_build": 3, "devtools": 3}
LIBRARY_LAYER = 3
COMMAND_LAYER = 4
@@ -34,17 +35,20 @@ SIBLING_IMPORTS: dict[str, frozenset[str]] = {
"profiling": frozenset(),
"romrecipes": frozenset(),
# The site prints the recipe counts and the dump-catalog coverage report
# those two packages compute.
"sitegen": frozenset({"acquire", "packs", "romrecipes"}),
# those two packages compute, serves the handheld launchers and prints the
# CI checks.
"sitegen": frozenset({"acquire", "packs", "romrecipes", "installer_build", "devtools"}),
# The record names its packs as the pack builder does.
"release": frozenset({"packs"}),
# The launcher archives are written by the pack member writer.
"installer_build": frozenset({"packs"}),
"devtools": frozenset(),
}
# Top-level modules other modules of scripts/ import: library code that a
# later wave moves into a package.
NOT_YET_PACKAGED = frozenset({
"autorun", "build_port",
"check_buildbot_system", "check_release_assets", "commit_rules",
"generate_event_schema", "pin_installer", "pr_checks",
"release_record", "romfolders",
"autorun",
})
# Top-level files that stay whole at their path although packages import them:
@@ -60,20 +64,6 @@ PENDING_TOP_LEVEL_IMPORTS = frozenset({
("probes.gate", "autorun"),
("probes.host", "autorun"),
("probes.packprobe", "autorun"),
("sitegen.build", "release_record"),
("sitegen.config", "release_record"),
("sitegen.decorate", "release_record"),
("sitegen.descriptions", "release_record"),
("sitegen.getpages", "release_record"),
("sitegen.guidepage", "release_record"),
("sitegen.handheld", "build_port"),
("sitegen.platformindex", "release_record"),
("sitegen.publish", "release_record"),
("sitegen.readme", "pr_checks"),
("sitegen.readme", "release_record"),
("sitegen.validate", "release_record"),
("sitegen.versions", "release_record"),
("sitegen.whichpack", "release_record"),
})
+8 -6
View File
@@ -39,7 +39,9 @@ from packs import platformpack
from sitegen import readme as sitegen_readme
from sitegen import home
import release_notes
import release_record
from release import notes
from release import record as release_record
from model import releaserecord
from packs import parts
HAS_JSONSCHEMA = jsonschema is not None
@@ -483,9 +485,9 @@ class ReleaseRecord(unittest.TestCase):
record["packs"]["Whole_1.0_BIOS_Pack.zip"], files=99, platforms=["other"]
)
self.assertEqual(
release_record.pack_name_for("whole", record), "Whole_1.0_BIOS_Pack.zip"
releaserecord.pack_name_for("whole", record), "Whole_1.0_BIOS_Pack.zip"
)
self.assertEqual(release_record.pack_for("whole", record)["files"], 2)
self.assertEqual(releaserecord.pack_for("whole", record)["files"], 2)
def test_the_owners_are_the_full_pack_names_the_builder_writes(self):
owners = release_record.release_owners(str(REPO_ROOT / "platforms"))
@@ -589,7 +591,7 @@ class TheReleaseNotesReadTheRecord(unittest.TestCase):
}}
def render(self, record=None):
return release_notes.render(record or self.RECORD, str(REPO_ROOT / "platforms"),
return notes.render(record or self.RECORD, str(REPO_ROOT / "platforms"),
"### What changed\n\n- x\n")
def test_each_pack_row_carries_the_record(self):
@@ -620,11 +622,11 @@ class TheReleaseNotesReadTheRecord(unittest.TestCase):
text = self.render().split("### What changed")[0]
self.assertNotIn("every file its emulators", text)
self.assertIn("https://abdess.github.io/retrobios/gaps/", text)
self.assertEqual(release_notes.refused_words(text), [])
self.assertEqual(notes.refused_words(text), [])
def test_a_judging_whats_new_is_refused(self):
self.assertEqual(
release_notes.refused_words(
notes.refused_words(
"- Every hash comes from the emulator's source, never from a forum list.\n"
"- So a game never stops on a missing file."),
["forum", "never stops"])
+12 -12
View File
@@ -24,7 +24,7 @@ import unittest
import zipfile
from pathlib import Path
import build_port
from installer_build import port as installer_build_port
REPO_ROOT = Path(__file__).resolve().parent.parent
PORT = REPO_ROOT / "ports" / "RetroBIOS"
@@ -80,7 +80,7 @@ class ThePortArchive(unittest.TestCase):
self.out = _tempdir(self)
def _build(self, name: str = "RetroBIOS.zip") -> Path:
return build_port.build_port(self.out / name)
return installer_build_port.build_port(self.out / name)
def test_layout_portmaster_installs(self):
"""One launch script at the top, one folder holding port.json: what
@@ -107,7 +107,7 @@ class ThePortArchive(unittest.TestCase):
def test_bundled_installer_is_the_pinned_one(self):
with zipfile.ZipFile(self._build()) as zf:
bundled = hashlib.sha256(zf.read("retrobios/install.py")).hexdigest()
self.assertEqual(bundled, build_port.pinned_installer_sha256())
self.assertEqual(bundled, installer_build_port.pinned_installer_sha256())
install_sh = (REPO_ROOT / "install.sh").read_text(encoding="utf-8")
self.assertIn(f'DEFAULT_INSTALL_SHA256="{bundled}"', install_sh)
@@ -117,11 +117,11 @@ class LauncherIndex(unittest.TestCase):
the archives built from the same tree, each with its size and hash."""
def test_the_committed_list_is_current(self):
import generate_launcher_index
from installer_build import launcherindex
text = generate_launcher_index.render(generate_launcher_index.build_index())
text = launcherindex.render(launcherindex.build_index())
self.assertEqual(
generate_launcher_index.OUTPUT.read_text(encoding="utf-8"), text,
launcherindex.OUTPUT.read_text(encoding="utf-8"), text,
"install/launchers/index.json is stale: run "
"python scripts/generate_launcher_index.py")
@@ -133,31 +133,31 @@ class LauncherIndex(unittest.TestCase):
self.assertIn("scripts/generate_launcher_index.py", section)
def test_every_member_of_the_archives_is_listed(self):
import generate_launcher_index
from installer_build import launcherindex
index = json.loads(generate_launcher_index.OUTPUT.read_text(encoding="utf-8"))
index = json.loads(launcherindex.OUTPUT.read_text(encoding="utf-8"))
places = {place.key: place for place in install.APP_PLACES.values()}
for key, archive in generate_launcher_index.LAUNCHER_ARCHIVES.items():
for key, archive in launcherindex.LAUNCHER_ARCHIVES.items():
with self.subTest(key=key):
launcher = index["launchers"][key]
listed = launcher.get("members") or launcher["files"]
names = [entry.get("name") or entry["dest"] for entry in listed]
prefix = "" if "members" in launcher else places[key].folder + "/"
self.assertEqual(sorted(names), sorted(
prefix + name for name, _path in build_port.archive_members(archive)))
prefix + name for name, _path in installer_build_port.archive_members(archive)))
for entry in listed:
if "repo_path" in entry:
data = (REPO_ROOT / entry["repo_path"]).read_bytes()
self.assertEqual(hashlib.sha256(data).hexdigest(), entry["sha256"])
def test_the_list_refuses_an_installer_the_bootstraps_do_not_pin(self):
import generate_launcher_index
from installer_build import launcherindex
root = _tempdir(self)
shutil.copyfile(REPO_ROOT / "install.py", root / "install.py")
(root / "install.sh").write_text('DEFAULT_INSTALL_SHA256="' + "0" * 64 + '"\n')
with self.assertRaises(ValueError):
generate_launcher_index.build_index(root)
launcherindex.build_index(root)
class EventRecords(unittest.TestCase):
+1 -1
View File
@@ -170,7 +170,7 @@ class NoMarketingVocabulary(unittest.TestCase):
offenders = []
for path in _tracked():
# This file and the commit rules have to name the words they refuse.
if path.name in {"test_prose_style.py", "commit_rules.py"}:
if path.name in {"test_prose_style.py", "commit_rules.py", "commitrules.py"}:
continue
text = path.read_text(encoding="utf-8", errors="replace")
for number, line in enumerate(text.splitlines(), 1):
+10 -10
View File
@@ -23,7 +23,7 @@ import unittest
import zipfile
from pathlib import Path
import build_pypi
from installer_build import pypi
REPO_ROOT = Path(__file__).resolve().parent.parent
@@ -47,7 +47,7 @@ class Built(unittest.TestCase):
raise unittest.SkipTest("uv is not installed")
cls._scratch = tempfile.TemporaryDirectory(prefix="pypi-")
cls.scratch = Path(cls._scratch.name)
cls.wheel, cls.sdist = build_pypi.build(cls.scratch / "dist")
cls.wheel, cls.sdist = pypi.build(cls.scratch / "dist")
cls.version = cls.wheel.name.split("-")[1]
@classmethod
@@ -121,7 +121,7 @@ class TheArchivesHoldTheInstallerAndNothingElse(Built):
def test_build_is_reproducible(self):
# SOURCE_DATE_EPOCH is install.py's commit time, so the clock moving
# between the two builds changes no byte.
again = build_pypi.build(self.scratch / "again")
again = pypi.build(self.scratch / "again")
self.assertEqual([path.read_bytes() for path in again],
[self.wheel.read_bytes(), self.sdist.read_bytes()])
@@ -132,15 +132,15 @@ class TheVersionIsInstallPyCommitDate(unittest.TestCase):
def test_one_change_that_day(self):
# 2026-11-09 12:00 UTC, then a change the day before.
self.assertEqual(build_pypi.package_version([1794225600, 1794139200]), "2026.11.9")
self.assertEqual(pypi.package_version([1794225600, 1794139200]), "2026.11.9")
def test_the_rank_in_the_day(self):
self.assertEqual(build_pypi.package_version([1794229200, 1794225600, 1794222000]),
self.assertEqual(pypi.package_version([1794229200, 1794225600, 1794222000]),
"2026.11.9.3")
def test_no_commit_refused(self):
with self.assertRaises(ValueError):
build_pypi.package_version([])
pypi.package_version([])
class AnUnpinnedInstallerIsRefused(unittest.TestCase):
@@ -151,13 +151,13 @@ class AnUnpinnedInstallerIsRefused(unittest.TestCase):
root = Path(name)
(root / "install.py").write_bytes(b"print('another')\n")
shutil.copyfile(REPO_ROOT / "install.sh", root / "install.sh")
original = build_pypi.ROOT
build_pypi.ROOT = root
original = pypi.ROOT
pypi.ROOT = root
try:
with self.assertRaises(ValueError):
build_pypi.installer_bytes()
pypi.installer_bytes()
finally:
build_pypi.ROOT = original
pypi.ROOT = original
def _python38() -> str | None:
+3 -3
View File
@@ -21,7 +21,7 @@ import zipfile
from pathlib import Path
from unittest import mock
import check_buildbot_system
from scraper import buildbot_system
from packs import datadirs
REPO_ROOT = Path(__file__).resolve().parent.parent
@@ -140,10 +140,10 @@ class RefreshFailuresAreFailures(unittest.TestCase):
report = {"entries": [{"status": "UPDATED", "key": "dolphin-sys"},
{"status": "OK", "key": "ppsspp-assets"}]}
with mock.patch.object(
check_buildbot_system.subprocess, "run",
buildbot_system.subprocess, "run",
return_value=subprocess.CompletedProcess([], 1),
):
self.assertEqual(check_buildbot_system.update_changed(report), ["dolphin-sys"])
self.assertEqual(buildbot_system.update_changed(report), ["dolphin-sys"])
source = (REPO_ROOT / "scripts" / "check_buildbot_system.py").read_text(encoding="utf-8")
self.assertIn("failed = update_changed(report)", source)
self.assertIn("sys.exit(1)", source[source.index("failed = update_changed(report)"):])
+27 -25
View File
@@ -28,7 +28,8 @@ from unittest import mock
import yaml
from model.registry import list_registered_platforms, list_release_pack_platforms
import release_record
from release import record as release_record
from model import releaserecord
REPO_ROOT = Path(__file__).resolve().parent.parent
@@ -225,7 +226,7 @@ class TheReleaseCheckReadsTheField(unittest.TestCase):
}}
def test_a_missing_and_an_unlisted_pack_are_reported(self):
from check_release import Asset, compare_release
from release.check import Asset, compare_release
sums = {"A_BIOS_Pack.zip": "a" * 64, "K_BIOS_Pack.zip": "b" * 64}
assets = {name: Asset(1, digest) for name, digest in sums.items()}
@@ -245,12 +246,12 @@ class TheTablesFollowTheField(unittest.TestCase):
"assets": ["x.zip"]},
"Recalbox_BIOS_Pack.zip": {"platforms": ["recalbox"], "assets": ["y.zip"]},
}}
shown = release_record.advertised(record, PLATFORMS)
shown = releaserecord.advertised(record, PLATFORMS)
self.assertEqual(list(shown["packs"]), ["RetroArch_Lakka_BIOS_Pack.zip"])
self.assertEqual(shown["packs"]["RetroArch_Lakka_BIOS_Pack.zip"]["platforms"],
["retroarch"])
self.assertIsNone(release_record.pack_for("lakka", shown))
self.assertEqual(release_record.advertised({}, PLATFORMS), {})
self.assertIsNone(releaserecord.pack_for("lakka", shown))
self.assertEqual(releaserecord.advertised({}, PLATFORMS), {})
class EverySurfaceSaysWhy(unittest.TestCase):
@@ -312,9 +313,9 @@ class TheReleaseNotesNameTheSetupsWithoutAZip(unittest.TestCase):
}}
def test_the_paragraph_names_them_and_points_to_the_command(self):
import release_notes
from release import notes
text = release_notes.render(self.RECORD, PLATFORMS, "### What changed\n\n- x\n")
text = notes.render(self.RECORD, PLATFORMS, "### What changed\n\n- x\n")
paragraph = next(line for line in text.splitlines()
if line.startswith("Only the most used setups have a pack"))
for name in ("KNULLI", "Recalbox", "RetroPie", "Lakka"):
@@ -328,9 +329,9 @@ class TheReleaseNotesNameTheSetupsWithoutAZip(unittest.TestCase):
def test_the_rows_link_this_release_files(self):
"""The files sit right below the notes: a row sends nobody to the
site to find them (owner, 2026-11-10)."""
import release_notes
from release import notes
text = release_notes.render(self.RECORD, PLATFORMS, "x")
text = notes.render(self.RECORD, PLATFORMS, "x")
self.assertIn(
"[Download](https://github.com/Abdess/retrobios/releases/download/"
"v2026.10.24/RomM_5_BIOS_Pack.zip)", text)
@@ -342,9 +343,9 @@ class TheReleaseNotesNameTheSetupsWithoutAZip(unittest.TestCase):
def test_the_command_comes_before_the_packs(self):
"""Most readers need a few files, not a pack of several GB (owner,
2026-11-10): the command and the handheld app open the notes."""
import release_notes
from release import notes
text = release_notes.render(self.RECORD, PLATFORMS, "### What changed\n\n- x\n")
text = notes.render(self.RECORD, PLATFORMS, "### What changed\n\n- x\n")
command = text.index("```sh")
# The installer's handheld section, which opens on every download.
handheld = text.index(f"{SITE}wiki/installer/#on-a-handheld-the-retrobios-port")
@@ -407,14 +408,14 @@ class TheReleaseNotesThankPeople(unittest.TestCase):
self.calls = []
def test_the_base_is_the_previous_release_record(self):
import release_notes
from release import notes
self.assertEqual(release_notes.previous_record_commit("v2026.11.10", self.fake), "c1")
self.assertEqual(notes.previous_record_commit("v2026.11.10", self.fake), "c1")
def test_everyone_since_the_start_is_thanked_once(self):
import release_notes
from release import notes
lines = release_notes.gather_thanks(self.fake)
lines = notes.gather_thanks(self.fake)
self.assertEqual(lines, [
"- **Code and data**: @closedwithoutmerge, @dajiaohuang, @habib256 and @zed.",
"- **Reports**: @72374 and @paperweightorder.",
@@ -430,25 +431,26 @@ class TheReleaseNotesThankPeople(unittest.TestCase):
self.assertEqual(issues[issues.index("--state") + 1], "all")
def test_the_notes_end_with_thanks_then_the_changelog(self):
import release_notes
from release import notes
closing = release_notes.closing_lines(
closing = notes.closing_lines(
["- **Code and data**: @habib256."],
release_notes.changelog_url("55eb95344" + "0" * 31, "v2026.11.10"))
text = release_notes.render(TheReleaseNotesNameTheSetupsWithoutAZip.RECORD, PLATFORMS,
notes.changelog_url("55eb95344" + "0" * 31, "v2026.11.10"))
text = notes.render(TheReleaseNotesNameTheSetupsWithoutAZip.RECORD, PLATFORMS,
"### What changed\n\n- x\n", closing)
self.assertLess(text.index("### What changed"), text.index("### Thanks"))
self.assertIn("### Thanks\n\n<details>\n"
"<summary>Everyone who helped since the start</summary>\n\n"
"- **Code and data**: @habib256.\n\n</details>\n\n**Full changelog**",
text)
self.assertEqual(release_notes.refused_words(text), [])
self.assertEqual(notes.refused_words(text), [])
self.assertTrue(text.rstrip().endswith(
"**Full changelog**: https://github.com/Abdess/retrobios/compare/"
"55eb95344...v2026.11.10"))
def test_a_checked_list_replaces_the_one_gh_gives(self):
import release_notes
from release import notes
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
tmp = Path(tmp)
@@ -461,7 +463,7 @@ class TheReleaseNotesThankPeople(unittest.TestCase):
"--whats-new", str(tmp / "whats-new.md"), "--thanks", str(tmp / "thanks.md"),
"--platforms-dir", PLATFORMS, "--output", str(tmp / "notes.md")]
with mock.patch.object(sys, "argv", argv), \
mock.patch.object(release_notes, "_run", self.fake), \
mock.patch.object(notes, "_run", self.fake), \
mock.patch.object(release_notes, "gather_thanks",
side_effect=AssertionError("gh read")), \
contextlib.redirect_stdout(io.StringIO()):
@@ -475,11 +477,11 @@ class EveryPlatformHasAPermanentPage(unittest.TestCase):
def test_a_page_for_every_registered_platform(self):
from sitegen import getpages
record = release_record.load_advertised()
record = releaserecord.load_advertised()
with contextlib.chdir(REPO_ROOT):
for name in list_registered_platforms(PLATFORMS):
page = getpages.generate_get_page(name)
pack = release_record.pack_for(name, record)
pack = releaserecord.pack_for(name, record)
with self.subTest(platform=name):
self.assertRegex(page, r"\n# (.+ )?BIOS (pack|files)( for .+)?\n")
if name in RELEASED and pack:
@@ -494,13 +496,13 @@ class EveryPlatformHasAPermanentPage(unittest.TestCase):
def test_the_generator_writes_and_sweeps_them(self):
from sitegen import config
self.assertIn(release_record.GET_DIR, config.GENERATED_DIRS)
self.assertIn(releaserecord.GET_DIR, config.GENERATED_DIRS)
source = script_source("generate_site.py")
self.assertIn('write_if_changed(str(get_dir / f"{name}.md"), generate_get_page(name))',
source)
def test_built_pages_exist(self):
docs = REPO_ROOT / "website" / "src" / "content" / "docs" / release_record.GET_DIR
docs = REPO_ROOT / "website" / "src" / "content" / "docs" / releaserecord.GET_DIR
if not docs.is_dir():
self.skipTest("the site is not generated")
for name in list_registered_platforms(PLATFORMS):
+1 -1
View File
@@ -13,7 +13,7 @@ import json
import unittest
from pathlib import Path
from romfolders import split_refs
from model.romfolders import split_refs
from model.safeparse import yaml_load
from scraper.romfolders import SourceError, load_sources, scrape_setup
from scraper.romfolders.__main__ import dump_setup
+1 -1
View File
@@ -15,7 +15,7 @@ import json
import unittest
from pathlib import Path
from romfolders import setup_paths, split_refs
from model.romfolders import setup_paths, split_refs
from scraper.romfolders import (
Fetcher,
SourceError,
+2 -2
View File
@@ -54,9 +54,9 @@ class TheGuideDrivesTheInstaller(unittest.TestCase):
fact is held to install.py, so the guide cannot drift from it."""
def setUp(self) -> None:
import generate_installer_doc
from installer_build import installerdoc
self.doc = generate_installer_doc
self.doc = installerdoc
self.text = siteagents.llms_txt([("retroarch", "RetroArch")])
self.section = self.text.split("\n## Driving the installer for a user\n", 1)[1].split("\n## ", 1)[0]
+15 -15
View File
@@ -53,7 +53,7 @@ from sitegen import nav as sitegen_nav
from sitegen import platformindex
from sitegen import reference
from sitegen import versions
import release_record
from model import releaserecord
from model import guides
from sitegen import markup as sitemarkup
from model.platforms import load_platform_config
@@ -209,9 +209,9 @@ class GetYourFilesOrder(unittest.TestCase):
def test_a_setup_after_the_release_says_no_zip_yet(self):
text = _page("which-pack.md")
self.assertNotIn("Not in v", text)
record = release_record.load_advertised()
record = releaserecord.load_advertised()
pending = [k for k in REGISTRY if REGISTRY[k].get("release_pack")
and not release_record.pack_for(k, record)]
and not releaserecord.pack_for(k, record)]
if record.get("tag") and pending:
self.assertIn("No ZIP yet. [Use the command]", text)
self.assertIn("Setups added after the last release have no ZIP until the next one.",
@@ -283,8 +283,8 @@ class PackManualReadsThePageFolders(unittest.TestCase):
class DownloadNamesTheRelease(unittest.TestCase):
def test_tag_date_checksums_and_signature(self):
record = release_record.load_record()
if not release_record.pack_for("batocera", record):
record = releaserecord.load_record()
if not releaserecord.pack_for("batocera", record):
self.skipTest("release.json has no Batocera pack")
tag = record["tag"]
lines = versions.release_line("batocera", record)
@@ -461,11 +461,11 @@ class HandheldWayIn(unittest.TestCase):
class PackNamesItsVersion(unittest.TestCase):
def test_the_line_under_the_release(self):
record = release_record.load_record()
if not release_record.pack_for("batocera", record):
record = releaserecord.load_record()
if not releaserecord.pack_for("batocera", record):
self.skipTest("release.json has no Batocera pack")
block = guidepage._pack_buttons("batocera")
name = release_record.pack_name_for("batocera", record)
name = releaserecord.pack_name_for("batocera", record)
version = versions._pack_version(name, ["batocera"])
self.assertIn(f"Made for Batocera {version}. "
+ versions.other_version("batocera"), block)
@@ -577,12 +577,12 @@ class GetYourFilesListsEachSetupOnce(unittest.TestCase):
self.assertNotIn("**Self-hosted game library**", self.text)
def test_no_unzip_into_without_a_zip(self):
record = release_record.load_record()
record = releaserecord.load_record()
for line in self.text.splitlines():
if "Unzip into" in line:
key = re.search(r"/retrobios/platforms/([a-z0-9]+)/", line)[1]
with self.subTest(platform=key):
self.assertTrue(release_record.pack_for(key, record))
self.assertTrue(releaserecord.pack_for(key, record))
def test_parts_are_buttons_with_the_size_after(self):
"""A row links the setup's get/ page, which lists every part, with the
@@ -665,8 +665,8 @@ class TileLogosLoadWhenSeen(unittest.TestCase):
class DownloadLine(unittest.TestCase):
def test_checksums_and_signature_read_as_two(self):
record = release_record.load_record()
if not release_record.pack_for("batocera", record):
record = releaserecord.load_record()
if not releaserecord.pack_for("batocera", record):
self.skipTest("release.json has no Batocera pack")
line = versions.release_line("batocera", record)[0]
self.assertRegex(line, r"\[SHA256SUMS\.txt\]\([^)]+\) and its \[signature\]\([^)]+\)\.$")
@@ -682,7 +682,7 @@ def _plain_page(name: str) -> str:
def _with_zip(name: str) -> bool:
pack = release_record.pack_for(name, release_record.load_advertised())
pack = releaserecord.pack_for(name, releaserecord.load_advertised())
return bool(pack and pack.get("assets"))
@@ -1113,10 +1113,10 @@ class TheSiteSaysWhatTheInstallerShows(unittest.TestCase):
self.assertNotIn("offers to install everything or to choose systems", readme)
source = script_source("generate_readme.py")
self.assertIn("_installer_words().TUI_SYSTEMS_ROW", source)
import generate_installer_doc
from installer_build import installerdoc
page = (REPO_ROOT / "wiki" / "installer.md").read_text(encoding="utf-8")
self.assertIn(generate_installer_doc.line_menu(), page)
self.assertIn(installerdoc.line_menu(), page)
menu = page.split("<!-- generated: line-menu -->", 1)[1]
outside = page.replace(menu.split("<!-- /generated: line-menu -->", 1)[0], "")
for line in self.MENU_LINES:
+25 -24
View File
@@ -21,9 +21,10 @@ import unittest
from pathlib import Path
from unittest import mock
import build_port
from installer_build import port
from model.registry import list_registered_platforms
from sitegen import handheld as sitehandheld
from installer_build import handhelds
REPO_ROOT = Path(__file__).resolve().parents[1]
@@ -36,8 +37,8 @@ def _pages() -> dict[str, str]:
with contextlib.chdir(REPO_ROOT):
pages = {f"get/{key}.md": getpages.generate_get_page(key)
for key in sorted(set(sitehandheld.PLATFORM_OF.values()))}
pages[f"get/{sitehandheld.GROUP_PAGE}.md"] = sitehandheld.group_page(REPO_ROOT)
for key in sorted(set(handhelds.PLATFORM_OF.values()))}
pages[f"get/{handhelds.GROUP_PAGE}.md"] = sitehandheld.group_page(REPO_ROOT)
return pages
@@ -50,11 +51,11 @@ class TheSiteServesTheLaunchers(unittest.TestCase):
def test_the_written_archives_are_the_ones_build_port_writes(self):
written = sitehandheld.write_launchers(self.tmp / "public", REPO_ROOT)
self.assertEqual([path.name for path in written], list(build_port.ARCHIVES))
self.assertEqual([path.name for path in written], list(port.ARCHIVES))
for path in written:
with self.subTest(archive=path.name):
self.assertEqual(path.parent, self.tmp / "public" / "get" / "handheld")
built = build_port.build_archive(path.name, self.tmp / "built" / path.name)
built = port.build_archive(path.name, self.tmp / "built" / path.name)
self.assertEqual(path.read_bytes(), built.read_bytes())
def test_an_unchanged_archive_is_not_rewritten(self):
@@ -67,7 +68,7 @@ class TheSiteServesTheLaunchers(unittest.TestCase):
"""build_port refuses an install.py the bootstraps do not pin: served,
that launcher would refuse its own installer."""
with mock.patch.dict(sitehandheld._built, clear=True), \
mock.patch.object(build_port, "pinned_installer_sha256", return_value="0" * 64), \
mock.patch.object(port, "pinned_installer_sha256", return_value="0" * 64), \
self.assertRaisesRegex(ValueError, "re-pin the bootstraps"):
sitehandheld.write_launchers(self.tmp / "public", REPO_ROOT)
self.assertFalse(list((self.tmp / "public").rglob("RetroBIOS*")))
@@ -76,7 +77,7 @@ class TheSiteServesTheLaunchers(unittest.TestCase):
public = self.tmp / "public"
written = {path.name: path for path in sitehandheld.write_launchers(public, REPO_ROOT)}
pages = _pages()
for name in build_port.ARCHIVES:
for name in port.ARCHIVES:
with self.subTest(archive=name):
data = written[name].read_bytes()
digest = hashlib.sha256(data).hexdigest()
@@ -98,8 +99,8 @@ class TheSiteServesTheLaunchers(unittest.TestCase):
class WhereEachSystemFindsItsFile(unittest.TestCase):
def test_each_platform_page_is_a_registered_platform(self):
registered = set(list_registered_platforms(PLATFORMS))
self.assertLessEqual(set(sitehandheld.PLATFORM_OF.values()), registered)
self.assertNotIn(sitehandheld.GROUP_PAGE, registered)
self.assertLessEqual(set(handhelds.PLATFORM_OF.values()), registered)
self.assertNotIn(handhelds.GROUP_PAGE, registered)
def test_the_group_page_sits_with_the_handheld_guide(self):
"""It shares the guide's name, so the sidebar files it with it, and
@@ -109,31 +110,31 @@ class WhereEachSystemFindsItsFile(unittest.TestCase):
from sitegen import guidepage
guide = guides.HANDHELD_GUIDE
self.assertEqual(sitehandheld.GROUP_PAGE, guide.page)
self.assertEqual(handhelds.GROUP_PAGE, guide.page)
with contextlib.chdir(REPO_ROOT):
self.assertIn(f"(../get/{sitehandheld.GROUP_PAGE}.md)",
self.assertIn(f"(../get/{handhelds.GROUP_PAGE}.md)",
guidepage.generate_handheld_guide(guide))
self.assertIn(f"]({sitehandheld.GROUP_PAGE}.md)", getpages.generate_get_index())
self.assertIn(f"]({handhelds.GROUP_PAGE}.md)", getpages.generate_get_index())
def test_every_system_has_its_launchers_on_its_page(self):
pages = _pages()
for system in sitehandheld.systems():
page = sitehandheld.page_of(system)
for system in handhelds.systems():
page = handhelds.page_of(system)
with self.subTest(system=system):
self.assertIn(page, pages)
for launcher in sitehandheld.launchers_for(system):
for launcher in handhelds.launchers_for(system):
self.assertIn(f'href="handheld/{launcher.archive}"', pages[page])
self.assertIn(launcher.folder_for(system), pages[page])
self.assertIn(launcher.start, pages[page])
for system in sitehandheld.group_systems():
self.assertIn(f"\n## {system}\n", pages[f"get/{sitehandheld.GROUP_PAGE}.md"])
self.assertIn(f"\n## {system}\n", pages[f"get/{handhelds.GROUP_PAGE}.md"])
def test_the_installer_table_is_written_from_the_same_rows(self):
text = (REPO_ROOT / "wiki" / "installer.md").read_text(encoding="utf-8")
block = re.search(r"<!-- generated: handheld -->\n(.*?)<!-- /generated: handheld -->",
text, re.S)
self.assertIsNotNone(block)
self.assertEqual(block.group(1).strip(), "\n".join(sitehandheld.table_rows()))
self.assertEqual(block.group(1).strip(), "\n".join(handhelds.table_rows()))
self.assertNotIn("releases/latest", text.split("## On a handheld", 1)[1].split("\n## ")[0])
def test_the_installer_section_opens_on_the_downloads(self):
@@ -145,18 +146,18 @@ class WhereEachSystemFindsItsFile(unittest.TestCase):
block = re.search(r"<!-- generated: handheld-downloads -->\n(.*?)"
r"<!-- /generated: handheld-downloads -->", section, re.S)
self.assertIsNotNone(block)
self.assertEqual(block.group(1).strip(), "\n".join(sitehandheld.download_rows()))
self.assertEqual(block.group(1).strip(), "\n".join(handhelds.download_rows()))
self.assertLess(block.start(), section.index("### Where each file goes"))
self.assertLess(len(section[:block.start()].split()), 40)
for system in sitehandheld.systems():
for system in handhelds.systems():
with self.subTest(system=system):
row = next(line for line in block.group(1).splitlines()
if line.startswith(f"| {system} |"))
for launcher in sitehandheld.launchers_for(system):
self.assertIn(f"](../{sitehandheld.SERVED_DIR}/{launcher.archive})", row)
self.assertIn(f"](../{sitehandheld.page_of(system)}#", row)
for name in build_port.ARCHIVES:
self.assertIn(f"](../{sitehandheld.SERVED_DIR}/{name})", block.group(1))
for launcher in handhelds.launchers_for(system):
self.assertIn(f"](../{handhelds.SERVED_DIR}/{launcher.archive})", row)
self.assertIn(f"](../{handhelds.page_of(system)}#", row)
for name in port.ARCHIVES:
self.assertIn(f"](../{handhelds.SERVED_DIR}/{name})", block.group(1))
def test_the_generator_writes_them(self):
source = script_source("generate_site.py")
+4 -4
View File
@@ -189,17 +189,17 @@ class SitePronouns(unittest.TestCase):
def test_release_notes(self):
"""The release page is public text too. Rendered from the committed
record, and once more with a pack in parts, its own paragraph."""
import release_notes
import release_record
from release import notes
from model import releaserecord
record = release_record.load_record(ROOT / "release.json")
record = releaserecord.load_record(ROOT / "release.json")
first = next(iter(record["packs"]))
parted = {**record, "packs": {**record["packs"], first: {
**record["packs"][first], "assets": ["a.part1of2.zip", "a.part2of2.zip"]}}}
platforms = str(ROOT / "platforms")
hits = [f"release notes:{number}: {line}"
for sample in (record, parted)
for number, line in pronouns(release_notes.render(sample, platforms, "x"))]
for number, line in pronouns(notes.render(sample, platforms, "x"))]
self.assertEqual(hits, [], "\n".join(hits))
def test_every_allowed_quote_says_why(self):
+5 -5
View File
@@ -78,7 +78,7 @@ from sitegen.sources import launcher_ref_markdown, list_source
import check_platform_folder
import core
from sitegen import sources
import release_record
from model import releaserecord
from core import upstream
REPO_ROOT = Path(__file__).resolve().parents[1]
@@ -1230,8 +1230,8 @@ class TheReleaseRecordHasAVersion(unittest.TestCase):
"""8.9."""
def test_the_writer_and_the_committed_record(self):
self.assertEqual(release_record.SCHEMA_VERSION, 1)
source = (REPO_ROOT / "scripts" / "release_record.py").read_text(encoding="utf-8")
self.assertEqual(releaserecord.SCHEMA_VERSION, 1)
source = script_source("release_record.py")
self.assertIn('{"schema_version": SCHEMA_VERSION, "tag": tag, "packs": packs}', source)
schema = json.loads((REPO_ROOT / "schemas" / "release.schema.json").read_text())
self.assertIn("schema_version", schema["required"])
@@ -1320,13 +1320,13 @@ class OneAnswerOnReleasePacks(unittest.TestCase):
else None) as folder:
publish.write_release_advertised(Path(folder))
written = json.loads((Path(folder) / "release-advertised.json").read_text())
self.assertEqual(written, release_record.load_advertised())
self.assertEqual(written, releaserecord.load_advertised())
served = {p for pack in written.get("packs", {}).values() for p in pack["platforms"]}
self.assertLessEqual(served, _released())
def test_the_built_picker_file(self):
written = json.loads(_built(GENERATED / "release-advertised.json").read_text())
self.assertEqual(written, release_record.load_advertised())
self.assertEqual(written, releaserecord.load_advertised())
def _properties(node: object, path: str = ""):
+5 -5
View File
@@ -45,8 +45,8 @@ import importlib.util
from sitegen import diagrams
from model.guides import INSTALL_SH
from tests import sitepages
import build_port
from check_release import SUMS, Asset, compare_release
from installer_build import port
from release.check import SUMS, Asset, compare_release
REPO_ROOT = Path(__file__).resolve().parents[1]
@@ -880,11 +880,11 @@ class PinnedInstaller(unittest.TestCase):
"""The handheld launchers carry install.py: the site serves them
from its own commit, the release never does."""
record = {"tag": "v1", "packs": {"P.zip": {"download_size": 5, "assets": ["P.zip"]}}}
sums = _sums_with(["P.zip", *build_port.ARCHIVES])
sums = _sums_with(["P.zip", *port.ARCHIVES])
assets = {name: Asset(5, digest) for name, digest in sums.items()}
assets[SUMS] = Asset(1, None)
kinds = {(f.kind, f.name) for f in compare_release(record, sums, assets, "v1")}
self.assertEqual(kinds, {("unrecorded", name) for name in build_port.ARCHIVES})
self.assertEqual(kinds, {("unrecorded", name) for name in port.ARCHIVES})
def test_the_release_steps_ship_none(self):
text = _wiki("release-process.md")
@@ -897,7 +897,7 @@ class PinnedInstaller(unittest.TestCase):
self.assertNotIn(name, sums)
self.assertNotIn(name, upload)
# A launcher built into dist/ is never caught by the glob either.
for archive in build_port.ARCHIVES:
for archive in port.ARCHIVES:
with self.subTest(archive=archive):
self.assertFalse(fnmatch.fnmatch(archive, "*_BIOS_Pack*.zip"))
self.assertIn("*_BIOS_Pack*.zip", sums)
+3 -3
View File
@@ -27,16 +27,16 @@ class WhichPackRows(unittest.TestCase):
release asset: the asset URL dies with its tag."""
from sitegen import install
from sitegen import whichpack
import release_record
from model import releaserecord
record = release_record.load_advertised()
record = releaserecord.load_advertised()
page = whichpack.generate_which_pack()
row = re.compile(r"^\| \[[^\]]+\]\(platforms/([a-z0-9]+)\.md\) \|(.*)$", re.M)
get = re.compile(r'href="get/([a-z0-9]+)\.md"')
checked = 0
for key, rest in row.findall(page):
linked = set(get.findall(rest))
pack = release_record.pack_for(key, record)
pack = releaserecord.pack_for(key, record)
with self.subTest(platform=key):
self.assertNotIn("/releases/download/", rest)
self.assertLessEqual(linked, {key})