chore: merge site and docs batch

This commit is contained in:
Abdessamad Derraz committed 2026-11-05 14:37:10 +01:00
commit 4ee0fd67a2
48 files changed
+1366 -332

No files matched your search

+48
View File
@@ -5015,6 +5015,28 @@ class GapsPageCountsOneWay(unittest.TestCase):
self.assertIn('rb-badge-danger">1 name</span>', text)
self.assertNotIn("1 missing", text)
def test_a_missing_row_links_each_entry_and_names_its_folder(self):
"""The row said `N88_KNJ1.ROM | unread | yes | AmberELEC` in plain text:
neither where the list puts it nor which cores were examined."""
from scripts.generate_site import _render_problem_files
problems = [{"platform": "AmberELEC", "platform_key": "amberelec", "name": "N88_KNJ1.ROM",
"status": "missing", "required": True, "reason": "", "discrepancy": "",
"category": "unread", "system": "nec-pc-88",
"destination": "bios/quasi88/N88_KNJ1.ROM"}]
text = "\n".join(_render_problem_files(problems))
self.assertIn("| [AmberELEC](platforms/amberelec.md#nec-pc-88) "
"`bios/quasi88/N88_KNJ1.ROM` |", text)
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"))
detail = {"name": "N88_KNJ1.ROM", "system": "nec-pc-88"}
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
@@ -5274,6 +5296,32 @@ class TheCollectionShipsADat(unittest.TestCase):
self.assertIn(("Nintendo\\GameCube", "GC\\USA\\IPL.bin"), roms)
self.assertEqual(roms[("Sony\\PlayStation", "scph5501.bin")].crc32, "8d8cb7e4")
def test_each_setup_has_a_dat_of_its_installed_folder(self):
"""A Batocera user auditing share/bios against the collection DAT met
thousands of sets laid out by manufacturer, and nothing of the folder
Batocera reads."""
sys.path.insert(0, str(ROOT / "scripts" / "scraper"))
from logiqx_parser import parse_logiqx
from scripts.generate_site import _platform_data_links, platform_dat
db = {"files": {"a" * 40: {"size": 4, "crc32": "8D8CB7E4", "md5": "1" * 32,
"sha1": "a" * 40}}}
manifest = {
"platform": "batocera", "display_name": "Batocera", "base_destination": "bios",
"files": [{"dest": "dc/naomi2.zip", "sha1": "a" * 40, "size": 4},
{"dest": "saves/x.bin", "sha1": "a" * 40, "size": 4, "root": "save"}],
"data_directories": [{"dest": "dolphin-emu/Sys",
"files": {"GC/font.bin": {"sha1": "c" * 40, "size": 2}}}],
}
dat = parse_logiqx(platform_dat(manifest, db, {"c" * 40: {"md5": "3" * 32}},
"2026-11-05T00:00:00Z"))
roms = {(r.game, r.name): r for r in dat.roms}
self.assertEqual(set(roms), {("bios", "dc\\naomi2.zip"),
("bios", "dolphin-emu\\Sys\\GC\\font.bin")})
self.assertEqual(roms[("bios", "dc\\naomi2.zip")].md5, "1" * 32)
self.assertEqual(roms[("bios", "dolphin-emu\\Sys\\GC\\font.bin")].md5, "3" * 32)
self.assertIn("[DAT](../downloads/dat/batocera.dat)", _platform_data_links("batocera"))
class ZippedFileMd5IsParsedOnce(unittest.TestCase):
-1
View File
@@ -275,7 +275,6 @@ class GithubTokenPerStep(Scratch):
def test_the_committed_registry(self):
jobs = ar.load_jobs()
self.assertTrue(all(step.github_token for step in jobs["nightly"].steps))
self.assertFalse(any(step.github_token for step in jobs["campaign"].steps + jobs["campaign"].gate))
class ReportAlert(Scratch):
+7 -30
View File
@@ -1019,24 +1019,6 @@ class ContentFile(Workspace):
self.assertIn("Other Game (Japan)", out.getvalue())
class InstallTimer(unittest.TestCase):
def test_writes_the_units_and_enables_only_when_asked(self) -> None:
calls = []
real_run = subprocess.run
def fake_run(argv: list[str], **kwargs: object) -> subprocess.CompletedProcess:
if "install-timers" not in argv:
return real_run(argv, **kwargs)
calls.append(argv)
return subprocess.CompletedProcess(argv, 0)
with unittest.mock.patch.object(campaign.subprocess, "run", fake_run):
self.assertEqual(campaign.main(["install-timer"]), 0)
self.assertEqual(campaign.main(["install-timer", "--enable"]), 0)
self.assertEqual([argv[2:] for argv in calls],
[["install-timers"], ["install-timers", "--enable"]])
self.assertTrue(calls[0][1].endswith("scripts/autorun.py"))
class Registry(unittest.TestCase):
def test_no_profile_takes_a_campaign_file_name(self) -> None:
stems = {p.stem for p in (REPO_ROOT / "emulators").glob("*.yml")}
@@ -1054,18 +1036,13 @@ class Registry(unittest.TestCase):
self.assertGreater(len(item.reason), 40)
self.assertGreater(item.frames, item.frame_hash_every)
def test_the_autorun_job(self) -> None:
jobs = campaign.autorun.load_jobs()
job = jobs["campaign"]
self.assertTrue(job.lock and job.worktree and job.schedule)
self.assertEqual(job.gate[0].argv, ("python", "scripts/campaign.py", "gate"))
self.assertEqual({p for rule in job.commits for p in rule.paths},
{"measurements/*.jsonl", "emulators/*.yml"})
self.assertGreater(job.schedule, jobs["nightly"].schedule)
def test_autorun_tells_its_steps_the_lock_is_held(self) -> None:
job = campaign.autorun.load_jobs()["campaign"]
self.assertEqual(campaign.autorun.job_env(job)[campaign.LOCK_HELD_ENV], "1")
def test_no_job_runs_a_standing_campaign(self) -> None:
"""A daily pass over every profile contradicted the rule that probes
run on demand, for a question that names its profiles."""
for name, job in campaign.autorun.load_jobs().items():
for step in [*job.steps, *job.gate]:
with self.subTest(job=name):
self.assertNotIn("scripts/campaign.py", step.argv)
@unittest.skipUnless(shutil.which("cc") and shutil.which("strace"), "no C compiler or no strace")
+5
View File
@@ -72,6 +72,11 @@ class BeforeOpeningAPullRequest(unittest.TestCase):
self.assertNotIn("pipeline.py", block)
workflow = (REPO_ROOT / ".github" / "workflows" / "validate.yml").read_text(encoding="utf-8")
self.assertIn("validate_schemas.py --source-only", workflow)
# CI holds added profiles to their upstream, not edited ones: --changed
# failed a contributor on refs they never wrote.
self.assertIn("profile_sync.py --added --base", workflow)
self.assertIn("profile_sync.py --added --base upstream/main --strict", block)
self.assertNotIn("--changed --strict", block)
def test_it_installs_what_the_checks_need_and_no_site_package(self):
"""The site is built by Node from website/package-lock.json: a pip
+116
View File
@@ -1678,5 +1678,121 @@ class InstallerPagesFollowTheCode(unittest.TestCase):
self.assertEqual(len(unserved_one_liners("installer.md", old)), 2)
class InstallerVariablesAreDocumented(unittest.TestCase):
"""RETROBIOS_CACHE moved a cache that --for-games writes, even under
--dry-run, and no page named it or the folder it defaults to."""
# Set by the full-screen interface for the runs it starts, never by a user.
INTERNAL = {"RETROBIOS_TUI_LIST"}
def test_every_variable_install_py_reads_is_in_the_table(self):
source = (ROOT / "install.py").read_text(encoding="utf-8")
page = (WIKI / "installer.md").read_text(encoding="utf-8")
table = page[page.index("## Environment overrides"):]
table = table[:table.index("\n## ", 1)]
for name in sorted(set(re.findall(r'"(RETROBIOS_[A-Z_]+)"', source)) - self.INTERNAL):
with self.subTest(variable=name):
self.assertIn(f"`{name}`", table)
def test_the_faq_names_the_cache(self):
faq = (WIKI / "faq.md").read_text(encoding="utf-8")
section = faq[faq.index("## Is the command safe?"):]
self.assertIn("cache", section[:section.index("\n## ", 1)])
class ReadmeKeepsItsPointers(unittest.TestCase):
def test_the_bare_minimum_is_built_below(self):
"""The README sent a reader to 'build your own pack below' for a bare
minimum, and the block below never named --required-only."""
readme = (ROOT / "README.md").read_text(encoding="utf-8")
self.assertIn("For a bare minimum, build your own pack below.", readme)
block = readme[readme.index("## Build your own pack"):]
block = block[:block.index("\n## ", 1)]
self.assertIn("--required-only", block)
def test_unsourceable_files_are_not_said_to_exist_nowhere(self):
"""The README said 138 files 'cannot be sourced at all (... dumps
nobody has made)', while most of their reasons read 'retail data the
collection does not hold'."""
readme = (ROOT / "README.md").read_text(encoding="utf-8")
self.assertNotIn("sourced at all", readme)
self.assertNotIn("nobody has made", readme)
self.assertRegex(readme, r"more the collection does not hold and does not serve by name")
class ArchitectureStatesTheArbitration(unittest.TestCase):
"""architecture.md said the profile takes precedence for pack generation,
while slots.arbitrate() keeps the platform's file where its frontend
checks the content: RetroBat's ATARIOSB.ROM."""
def test_the_page_says_what_arbitrate_decides(self):
import slots # noqa: PLC0415
page = (WIKI / "architecture.md").read_text(encoding="utf-8")
self.assertNotIn("the profile takes precedence for pack generation", page)
section = page[page.index("### When both layers claim one destination"):]
section = section[:section.index("\n## ")]
self.assertIn("`slots.arbitrate()`", section)
source = inspect.getsource(slots.arbitrate)
# The three outcomes the section describes.
for outcome in ("ADDRESSEE", "SERVES_BOTH", "FRONTEND_CHECKS_CONTENT"):
self.assertIn(outcome, source)
for said in ("--emulator", "`existence`", "the platform's file stays"):
self.assertIn(said, section)
class VersionBasisReferenceIsTheSchema(unittest.TestCase):
"""profiling.md listed five kinds of version_basis: `unverified`, its
`why` and the `url`, `commit` and `match` keys 18 profiles use were in
the schema alone."""
def test_the_row_names_every_kind_reason_and_key(self):
schema = json.loads((ROOT / "schemas" / "emulator.schema.json").read_text(encoding="utf-8"))
basis = schema["$defs"]["version_basis"]["properties"]
page = (WIKI / "profiling.md").read_text(encoding="utf-8")
row = next(line for line in page.splitlines() if line.startswith("| `version_basis` |"))
for word in [*basis["kind"]["enum"], *basis["why"]["enum"], *basis]:
with self.subTest(word=word):
self.assertIn(f"`{word}`", row)
tools = (WIKI / "tools.md").read_text(encoding="utf-8")
self.assertIn("`unverified`", tools)
class ProfilingStatesTheHashRuleOnce(unittest.TestCase):
"""profiling.md let an .info MD5 in ('source confirmation makes it more
reliable') and a file the code never loads stay ('can be left out'),
beside the strict rule of the same paragraph."""
def test_no_permissive_form_remains(self):
page = (WIKI / "profiling.md").read_text(encoding="utf-8")
self.assertNotIn("source confirmation makes it more reliable", page)
self.assertNotIn("it can be left out of the profile", page)
self.assertIn("An MD5 the .info or\n the docs alone give is not written", page)
class ReportExcerptIsTheRun(unittest.TestCase):
"""reading-reports.md quoted 'From python scripts/verify.py --platform
retrodeck' a run that said 0 required missing after the command had started
naming one, and never showed the line that names it."""
def test_every_quoted_line_is_printed(self):
import subprocess # noqa: PLC0415
page = (WIKI / "reading-reports.md").read_text(encoding="utf-8")
intro = "From `python scripts/verify.py --platform retrodeck`:"
start = page.index("```\n", page.index(intro)) + 4
quoted = page[start:page.index("```", start)].splitlines()
run = subprocess.run(
[sys.executable, str(ROOT / "scripts" / "verify.py"), "--platform", "retrodeck"],
capture_output=True, text=True, cwd=ROOT, check=False,
)
printed = run.stdout.splitlines()
if not any(line.startswith("RetroDECK:") for line in printed):
self.skipTest(f"verify did not run: {run.stderr[-200:]}")
for line in quoted:
with self.subTest(line=line):
self.assertIn(line, printed)
if __name__ == "__main__":
unittest.main()
+1
View File
@@ -309,6 +309,7 @@ class ShownOutputIsPrintedOutput(unittest.TestCase):
(r"^ Core files held but not packed: \d+ \(.+\)$", '" Core files held but not packed: '),
(r"^ Game data: \d+ in pack, (0 missing|\d+ missing \(--verbose lists them\))$",
'" Game data: {gd_packed} in pack'),
(r"^ Game data held but not packed: \d+ \(.+\)$", '" Game data held but not packed: '),
(r"^ No external files: \d+ cores \(--verbose lists them\)$",
'" No external files: {len(exclusions)} cores (--verbose lists them)"'),
(r"^ Ground truth: \d+/\d+ files have emulator validation \(\d+%\)$",
+11
View File
@@ -89,6 +89,17 @@ class CorrectedFilesPage(unittest.TestCase):
self.page,
)
def test_every_section_links_its_changes_as_json(self):
"""exports/batocera.json listed 141 changes and no page or catalog
entry named it: a maintainer had to scrape the HTML."""
for platform in ("recalbox", "retropie"):
self.assertIn(f'href="api/v1/exports/{platform}.json"', self.page)
source = (ROOT / "scripts" / "generate_site.py").read_text(encoding="utf-8")
publish = source[source.index("def _publish_manifests("):]
publish = publish[:publish.index("\ndef ")]
self.assertIn('(_REPO_ROOT / "exports").glob("*.json")', publish)
self.assertIn('exports = api / "exports"', publish)
def test_several_files_link_to_their_directory(self):
self.assertIn("tree/main/exports/retropie", self.page)
self.assertIn("<summary>The 2 original files it is based on</summary>", self.page)
+16
View File
@@ -111,5 +111,21 @@ class TheOneLinerFollowsTheRegistry(unittest.TestCase):
self.assertEqual(packreadme.INSTALL_PS1, f"{INSTALL_BASE}/{sitebootstrap.PS1_NAME}")
class GuidesInstallFromTheZipInHand(unittest.TestCase):
"""Option A sent a user holding the ZIP to the one-liner, which downloads
every file again. --from-pack installs from the archive itself."""
def test_every_automatic_guide_names_from_pack(self):
for name, data in _registry()["platforms"].items():
detect = (data.get("install", {}) or {}).get("detect", [])
if not detect:
continue
text = _build_readme(name, name, "", 1, 1, detect=detect)
if "Option A: Automatic" not in text:
continue
with self.subTest(platform=name):
self.assertIn(f"--platform {name} --from-pack ", text)
if __name__ == "__main__":
unittest.main()
+3 -2
View File
@@ -5008,7 +5008,8 @@ class AnUnreadTreeKeepsItsRecord(unittest.TestCase):
kept = sitesources.keep_unread(
{"a@1": ["x.c"]}, ["b@2", "c@3"], {"b@2": ["y.c"], "a@1": ["old.c"]}
)
self.assertEqual(kept, {"a@1": ["x.c"], "b@2": ["y.c"]})
# c@3 was never read: recorded empty, it confirms no path.
self.assertEqual(kept, {"a@1": ["x.c"], "b@2": ["y.c"], "c@3": []})
class FreshRefusesOffline(unittest.TestCase):
@@ -5953,7 +5954,7 @@ class TestBranchCheckIsWired(unittest.TestCase):
import generate_readme # noqa: PLC0415
text = generate_readme.generate_contributing()
self.assertIn("profile_sync.py --changed --strict", text)
self.assertIn("profile_sync.py --added --base upstream/main --strict", text)
self.assertNotIn("--emulator NAME --strict", text)
workflow = (root / ".github" / "workflows" / "validate.yml").read_text()
self.assertIn("profile_sync.py --added --base", workflow)
+6
View File
@@ -470,6 +470,12 @@ class TestProvenancePage(unittest.TestCase):
self.assertIn("14df4f6c1e367ce097c11deae21566b4fe5647a9", page)
self.assertIn("### Redump", page)
def test_the_wanted_list_links_its_csv(self):
"""provenance-wanted.csv was linked from the data page alone."""
page = self._page()
wanted = page[page.index("## Wanted: catalogued dumps"):]
self.assertIn('href="downloads/provenance-wanted.csv"', wanted[:wanted.index("###")])
def test_page_has_anchor_targets_for_badges(self):
"""System-page badges link to ../provenance.md#<source>."""
page = self._page()
+86
View File
@@ -4,6 +4,7 @@ from __future__ import annotations
import hashlib
import json
import os
import sqlite3
import sys
import tempfile
@@ -670,6 +671,69 @@ class AHashFindsEveryPageThatNamesIt(unittest.TestCase):
downloaded. files/?hash= reads one shard instead, and it must answer at
least what the search answered: the card, the platforms, the profiles."""
def test_an_archive_answers_for_the_rom_a_list_pins_inside_it(self):
"""Batocera checks naomi2.zip by the md5 of 315-6146.bin inside it:
dropped on the lookup, the archive listed every setup but Batocera,
and 335 of its 337 zipped_file entries were unreachable that way."""
import json as _json
import generate_site # noqa: PLC0415
from common import load_platform_config # noqa: PLC0415
from cross_reference import FileConsumers # noqa: PLC0415
from ziptools import build_zip_contents_index # noqa: PLC0415
root = Path(__file__).resolve().parents[1]
db = _json.loads((root / "database.json").read_text(encoding="utf-8"))
config = load_platform_config("batocera", str(root / "platforms"))
entry = next(e for system in config["systems"].values() for e in system.get("files") or []
if e.get("name") == "naomi2.zip" and e.get("zipped_file"))
cwd = Path.cwd()
try:
os.chdir(root)
consumers = FileConsumers(db, build_zip_contents_index(db))
archive = consumers.sha1_of(entry)
finally:
os.chdir(cwd)
if archive is None:
self.skipTest("no copy of naomi2.zip holding the pinned ROM")
coverages = {"batocera": {"config": {"systems": {"sega-naomi2": {"files": [entry]}}}}}
records = generate_site.file_lookup_records(db, coverages, {}, [], None, consumers)
found = {(r["owner"], r["value"]) for r in records if r["layer"] == "platform"}
self.assertIn(("batocera", archive), found)
pinned = next(r for r in records if r["layer"] == "platform" and r["algorithm"] == "md5")
self.assertEqual(pinned["sha1"], archive)
def test_a_data_directory_member_answers_every_hash(self):
"""Dolphin's ApprovedInis.json was found by its SHA1 only: its MD5
and CRC32 answered no match although the pack ships it."""
import hashlib
import tempfile
import zlib
import generate_site # noqa: PLC0415
body = b"approved inis\n"
sha1 = hashlib.sha1(body).hexdigest()
with tempfile.TemporaryDirectory(dir=Path(__file__).resolve().parents[1] / "tmp") as tmp:
member = Path(tmp, "data", "dolphin-sys", "ApprovedInis.json")
member.parent.mkdir(parents=True)
member.write_bytes(body)
stale = Path(tmp, "data", "dolphin-sys", "Stale.json")
stale.write_bytes(b"other bytes")
members = {"dolphin-sys": {"ApprovedInis.json": {"sha1": sha1},
"Stale.json": {"sha1": "ef" * 20}}}
registry = {"dolphin-sys": {"local_cache": "data/dolphin-sys"}}
digests = generate_site._data_member_digests(members, registry, Path(tmp))
self.assertEqual(digests, {sha1: {
"sha1": sha1, "md5": hashlib.md5(body).hexdigest(),
"sha256": hashlib.sha256(body).hexdigest(),
"crc32": f"{zlib.crc32(body):08x}"}})
with mock.patch.object(generate_site, "_data_member_digests", return_value=digests):
records = generate_site.file_lookup_records(
{"files": {}}, {}, {}, [{"sha1": sha1, "url": "u"}],
{"dolphin-sys": {"ApprovedInis.json": {"sha1": sha1}}})
self.assertEqual({r["algorithm"]: r["value"] for r in records}, digests[sha1])
def test_records_cover_every_layer_and_shard_by_prefix(self):
import json as _json
import tempfile
@@ -800,6 +864,28 @@ class ProseCitationsLinkToThePin(unittest.TestCase):
two = {**self.PROFILE, "upstream": "https://github.com/x/y", "upstream_commit": "a" * 40}
self.assertEqual(link_prose_citations(two, "src/a.c:5"), "src/a.c:5")
def test_two_repositories_link_into_the_one_holding_the_path(self):
"""1,044 citations in 86 profiles that read two repositories stayed
text, the swanstation note on FindBIOSImageInDirectory among them."""
from sitesources import link_prose_citations
two = {**self.PROFILE, "upstream": "https://github.com/x/y", "upstream_commit": "a" * 40}
def holds(repo, _pin, path):
return path == "src/both.c" or (path == "src/port.c") == (repo.owner == "libretro")
with mock.patch("sitesources.tree_holds", holds):
text = link_prose_citations(two, "src/port.c:5, src/emu.c:7 and src/both.c:9")
upstream_only = link_prose_citations(two, "upstream src/port.c:5")
named = link_prose_citations(two, "upstream src/both.c:9")
self.assertIn("[`src/both.c:9`](https://github.com/x/y/blob/", named)
self.assertIn("[`src/port.c:5`](https://github.com/libretro/FreeChaF/blob/", text)
self.assertIn("[`src/emu.c:7`](https://github.com/x/y/blob/" + "a" * 40, text)
# Held by both: the citation does not say which it means.
self.assertIn(" src/both.c:9", text)
# The role word names a repository that does not hold it.
self.assertNotIn("](", upstream_only)
class ACitationSaysWhoseCodeItIs(unittest.TestCase):
"""Readers could not tell whether the libretro core or the emulator asked
+2 -2
View File
@@ -126,8 +126,8 @@ class ARowPerFile(unittest.TestCase):
def test_status_words(self):
cases = {
("missing", ""): ("Missing", "danger"),
("untested", "declared hash contradicted by the local file"): ("Wrong hash", "warning"),
("untested", "expected 1234... got 5678..."): ("Wrong hash", "warning"),
("untested", "declared hash contradicted by the local file"): ("Other hash", "warning"),
("untested", "expected 1234... got 5678..."): ("Other hash", "warning"),
("untested", "bios/x read error"): ("Untested", "warning"),
}
for (status, reason), (word, tone) in cases.items():
+22
View File
@@ -279,6 +279,28 @@ class Redirects(unittest.TestCase):
source = Path(generate_site.__file__).read_text(encoding="utf-8")
self.assertIn('generated / "redirects.json"', source)
def test_a_list_part_gone_with_its_rows_redirects_to_its_page(self):
"""Only platform parts were recorded: gaps-files-to-source-7, gone
once 29 files were collected, ended on the 404 page."""
with tempfile.TemporaryDirectory() as tmp:
docs = Path(tmp)
part = '---\nlevel: reference\nparent:\n label: "Gaps"\n link: "/gaps/"\n---\n\n# P\n'
(docs / "gaps-files-to-source-7.md").write_text(part, encoding="utf-8")
(docs / "gaps.md").write_text("# Gaps\n", encoding="utf-8")
kept = {"platforms/b-atari-st.md": "platforms/b.md#atari-st"}
published = generate_site.record_parts(
docs, {"gaps-files-to-source-7.md", "gaps.md"}, kept)
self.assertEqual(published, {"gaps-files-to-source-7.md": "gaps.md", **kept})
# An emulator part names its parent with the site's base.
self.assertEqual(generate_site._parent_page("/retrobios/emulators/amiberry/"),
"emulators/amiberry.md")
self.assertEqual(generate_site._parent_page("/platforms/b/#atari-st"),
"platforms/b.md#atari-st")
# The next run made six parts.
self.assertEqual(
sitestarlight.redirects({}, {"gaps.md", "platforms/b.md"}, published),
{"/gaps-files-to-source-7/": "/gaps/", "/platforms/b-atari-st/": "/platforms/b/#atari-st"})
class PlatformShareCards(unittest.TestCase):
def test_every_platform_page_shares_its_own_card(self):
+36 -1
View File
@@ -129,13 +129,32 @@ class EvidenceLinksItsSource(unittest.TestCase):
evidence = {"read_by": [{"emulator": "launcher", "proof": "launcher",
"entries": [], "runs_system": True}]}
config = load_platform_config("batocera", PLATFORMS)
launched = generate_site._launcher_refs("batocera", config)["scph1001.bin"]
launched = generate_site._launcher_refs(config)["scph1001.bin"]
text = generate_site._category_evidence_md(evidence, launched)
self.assertNotIn("(by launcher)", text)
self.assertIn("https://github.com/batocera-linux/batocera.linux/blob/batocera-43.1/"
"package/batocera/core/batocera-configgen/", text)
self.assertIn("duckstationGenerator.py:115-136", text)
def test_every_platform_links_its_launchers(self):
"""Only Batocera and RetroBat were linked: Recalbox, ROCKNIX, EmuDeck,
RetroPie and RetroDECK read their launchers in the list's repository
too, and their citations came out as plain code."""
checked = 0
for path in sorted(Path(PLATFORMS).glob("*.yml")):
if not path.stem[0].isalpha():
continue
config = load_platform_config(path.stem, PLATFORMS)
if not config.get("launchers"):
continue
with self.subTest(platform=path.stem):
rendered = [text for texts in generate_site._launcher_refs(config).values()
for text in texts]
self.assertTrue(rendered)
self.assertFalse([t for t in rendered if " at `" in t])
checked += 1
self.assertGreaterEqual(checked, 7)
def test_a_launcher_in_another_repository_is_not_linked(self):
source = list_source("https://gitlab.com/recalbox/recalbox/-/raw/10.1.1/x/es_bios.xml")
self.assertEqual(launcher_ref_markdown(None, "a/b.py:3"), "`b.py:3`")
@@ -206,6 +225,22 @@ class PlatformReferenceInWords(unittest.TestCase):
self.assertIn("[r repository at commit aaaaaaaaaaaa](https://github.com/o/r/tree/"
+ "a" * 40 + ")", page)
def test_every_check_label_reads_the_hash_rule(self):
"""RomM's badge and table rows said MD5 beside a sentence saying it
accepts the size and any one hash."""
details = [{"name": "f.bin", "status": "ok", "system": "sony-playstation"}]
cov = {"platform": "RomM", "details": details, "total": 1, "verified": 1,
"present": 1, "missing": 0, "untested": 0, "mode": "md5",
"core_present": 0, "core_missing": 0, "core_unsourceable": 0,
"config": {"hash_type": "md5", "hash_rule": "size_and_any_hash",
"systems": {"sony-playstation": {"files": [{"name": "f.bin"}]}},
"source": "https://github.com/o/r/tree/" + "a" * 40}}
page = generate_site.generate_platform_page("romm", cov, {})
self.assertIn(">size, then any hash</span>", page)
self.assertNotIn(">MD5</span>", page)
table = "\n".join(generate_site.setup_table({"romm": cov}, {}))
self.assertIn("| size, then any hash |", table)
def test_systems_by_name_with_the_id_in_small_text(self):
systems = {"sony-playstation": {"files": [{"name": "f.bin"}]}}
page = self._page("md5", "md5", systems)
+1 -1
View File
@@ -267,7 +267,7 @@ class EveryEnvelopeCarriesTheCommit(unittest.TestCase):
raise unittest.SkipTest("not a git checkout")
lacking = [
path.relative_to(API).as_posix() for path in sorted(API.rglob("*.json"))
if path.parent.name not in ("schemas", "manifests", "targets")
if path.parent.name not in ("schemas", "manifests", "targets", "exports")
and path.name not in ("database.json", "stats.json", "release.json")
and "commit" not in json.loads(path.read_text())
]
+33
View File
@@ -265,5 +265,38 @@ class CopyButtonInTheHeader(unittest.TestCase):
self.assertIn(".expressive-code .frame.has-title .copy { inset-block-start:", source)
class AChecksumLineIsAHash(unittest.TestCase):
"""The lookup and the search took a bare hash only: the line md5sum,
shasum --tag, certutil or Get-FileHash prints was refused whole."""
def test_the_hash_is_read_out_of_the_line(self):
source = _read(SITE_TS)
code = (source[source.index("const HASH_LENGTHS"):source.index("\n", source.index("const HASH_LENGTHS"))]
+ source[source.index("const normalizeHash"):source.index("// Tables")])
md5, sha1 = "490f666e1afb15b7362b406ed1cea246", "b05def971d8ec59f346f2d9ac21fb742e3eb6917"
spaced = " ".join(sha1[i:i + 2] for i in range(0, 40, 2))
cases = [
f"{md5} scph5501.bin",
f"SHA1 (scph5501.bin) = {sha1}",
f"SHA1 hash of scph5501.bin:\r\n{spaced}\r\nCertUtil: -hashfile command completed successfully.",
f"Algorithm Hash Path\n--------- ---- ----\nSHA1 {sha1.upper()} C:\\bios\\scph5501.bin",
f" 0x{md5.upper()} ",
"8d8cb7e4",
"deadbeef.bin",
f"{md5} {sha1}",
]
out = _node(code + f"console.log(JSON.stringify({json.dumps(cases)}.map((c) => "
"[normalizeHash(c), isHash(normalizeHash(c))])));")
self.assertEqual(json.loads(out), [
[md5, True], [sha1, True], [sha1, True], [sha1, True], [md5, True],
["8d8cb7e4", True], ["deadbeef.bin", False], [md5 + sha1, False],
])
def test_the_form_takes_the_line(self):
source = _read(REPO_ROOT / "scripts" / "generate_site.py")
start = source.index('<input id="rb-hash"')
self.assertNotIn("pattern=", source[start:source.index("required>", start)])
if __name__ == "__main__":
unittest.main()
+16
View File
@@ -85,6 +85,22 @@ class NoZipNoUnzipText(unittest.TestCase):
self.assertIn("Needs the device on your network.", text)
self.assertIn(f"--platform {name} --dest {share}\n", text)
def test_a_mac_and_a_linux_desktop_reach_the_share_too(self):
"""The share route was a PowerShell tab alone: a Mac user with Recalbox
on Wi-Fi fell back to SSH or to taking the card out."""
args, how = generate_site._share_tabs("recalbox", "\\\\RECALBOX\\share\\bios")
self.assertEqual(args["macos"], "--platform recalbox --dest /Volumes/share/bios")
self.assertIn("`smb://recalbox/share`", how["macos"])
self.assertEqual(args["linux"], "--platform recalbox --dest /path/to/share/bios")
self.assertIn("`smb://recalbox/share`", how["linux"])
lines = generate_site._setup_routes("recalbox", "Recalbox")
routes = "\n".join(lines[:lines.index("## On the device { #install }")])
for label in ("Windows", "macOS", "Linux"):
self.assertIn(f'label="{label}"', routes)
# The setup page sends a Mac or Linux reader to those tabs.
lines = generate_site._setup_routes("recalbox", "Recalbox", page_link=True)
self.assertIn("[Mac or Linux](../get/recalbox.md#from-your-computer)", lines)
def test_the_network_route_needs_a_share_and_no_zip(self):
for name in SETUPS:
share = generate_site._network_share(name, siteguides.GUIDES[name])
+32
View File
@@ -13,6 +13,7 @@ import glob
import json
import re
import sys
import tempfile
import unittest
from pathlib import Path
from unittest import mock
@@ -123,6 +124,37 @@ class SourcePathsFreshness(unittest.TestCase):
self.assertEqual(finding.status, check_freshness.STALE)
self.assertIn("sitesources.py --fetch", finding.detail)
def test_a_pinned_tree_never_read_is_stale(self):
"""fbneo moved to two new pins while fbneo_cps12 kept the old ones:
no recorded tree was orphaned, so the check said OK and 174 citations
stayed unlinked."""
import sitesources # noqa: PLC0415
profile = _profile("geolith")
trees = [sitesources.tree_key(r, p) for r, p in sitesources.profile_trees(profile)]
record = json.loads(sitesources.SOURCE_PATHS.read_text(encoding="utf-8"))
for key in trees:
record.pop(key, None)
# Kept pinned by another profile, as fbneo_cps12 kept the old FBNeo trees.
record.update({key: [] for key in trees[1:]})
with tempfile.TemporaryDirectory() as tmp:
path = Path(tmp) / "source-paths.json"
path.write_text(json.dumps(record), encoding="utf-8")
with mock.patch.object(sitesources, "SOURCE_PATHS", path):
finding = check_freshness.check_source_paths({"geolith": profile})
self.assertEqual(finding.status, check_freshness.STALE)
self.assertIn("1 pinned trees not recorded", finding.detail)
def test_a_tree_read_with_no_cited_path_is_recorded(self):
import sitesources # noqa: PLC0415
profile = {"source": "https://github.com/o/r", "source_commit": "e" * 40,
"files": [{"source_ref": "src/a.c:5"}]}
with mock.patch.object(sitesources, "_cached_tree", return_value=frozenset({"x.c"})):
held, unread = sitesources.build_source_paths({"p": profile}, [Path("tmp")])
self.assertEqual(held, {"github.com/o/r@" + "e" * 40: []})
self.assertEqual(unread, [])
class OptionsGlanceFromTheParser(unittest.TestCase):
"""--declared-only and --offline reached install.py and its Options
+9 -2
View File
@@ -59,8 +59,14 @@ class GetPagesGiveTheSetupsOwnRoutes(unittest.TestCase):
def test_every_command_on_a_get_page_is_on_its_setup_page(self):
for name in SETUPS:
get = set(COMMAND.findall(_page(f"get/{name}.md")))
setup = set(COMMAND.findall(_page(f"platforms/{name}.md")))
page = _page(f"platforms/{name}.md")
setup = set(COMMAND.findall(page))
with self.subTest(setup=name):
# The Mac and Linux lines of the network folder live on the
# get/ page alone, which the setup page links for them.
if f"(/retrobios/get/{name}/#from-your-computer)" in page:
get = {c for c in get if "--dest /Volumes/" not in c
and "--dest /path/to/" not in c}
self.assertTrue(get <= setup, sorted(get - setup))
if not _with_zip(name):
self.assertTrue(get, "a setup with no ZIP gets its command")
@@ -82,7 +88,8 @@ class GetPagesGiveTheSetupsOwnRoutes(unittest.TestCase):
allowed = {labels[key] for key in guide.run}
allowed |= {labels[key] for key in guide.card_run or ("windows", "macos", "linux")}
if generate_site._network_share(name, guide):
allowed.add(labels["windows"])
# The network folder is reached from any computer.
allowed |= {labels[key] for key in ("windows", "macos", "linux")}
with self.subTest(setup=name):
self.assertLessEqual(_tab_labels(_page(f"get/{name}.md")), allowed)
self.assertNotIn("Android (Termux", _page(f"get/{name}.md"))
+20
View File
@@ -8,6 +8,8 @@ import unittest
from pathlib import Path
from unittest import mock
import yaml
REPO_ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(REPO_ROOT / "scripts"))
@@ -100,6 +102,24 @@ class BundledFilesAreNotToSource(unittest.TestCase):
self.assertIn("| [ZQuest Classic](emulators/zq.md) | 4 | 1 | 0 | 0 | 2 | "
'<span class="rb-badge rb-badge-danger">1</span> |', page)
def test_a_row_names_only_the_platforms_that_read_it(self):
"""cdbios.bin, read by standalone BlastEm only and never on RetroBat,
was badged retroarch, lakka and retrobat."""
import generate_site
from common import load_platform_config, resolve_platform_cores
root = Path(__file__).resolve().parents[1]
profile = yaml.safe_load((root / "emulators" / "blastem.yml").read_text(encoding="utf-8"))
configs = {}
for name in ("retroarch", "lakka", "retrobat", "batocera"):
config = load_platform_config(name, str(root / "platforms"))
if "blastem" in resolve_platform_cores(config, {"blastem": profile}):
configs[name] = config
self.assertIn("retroarch", configs)
self.assertIn("retrobat", configs)
found = generate_site.reading_platforms("blastem", profile, "cdbios.bin", configs)
self.assertFalse(found & {"retroarch", "lakka", "retrobat"}, found)
class StructuredBlocks(unittest.TestCase):
PIN = "1e0de94dc7e669c0925a22c0fccf6cdc837af0a0"
+22
View File
@@ -192,5 +192,27 @@ class ASingleTargetFiltersNothing(unittest.TestCase):
checked += 1
self.assertGreaterEqual(checked, 3)
class PublishedListsAreNotNarrowed(unittest.TestCase):
"""pipeline --target switch wrote install/retroarch_nintendoswitch.json
next to the published lists. The site picker then replaced RetroArch's
file list with the Switch one and check_release asked for it as an asset."""
def test_pipeline_writes_install_unfiltered(self):
pipeline = (REPO_ROOT / "scripts" / "pipeline.py").read_text()
self.assertNotIn('manifest_cmd.extend(["--target"', pipeline)
def test_every_install_list_is_a_whole_platform(self):
import json # noqa: PLC0415
for path in sorted((REPO_ROOT / "install").glob("*.json")):
data = json.loads(path.read_text(encoding="utf-8"))
with self.subTest(path=path.name):
self.assertEqual(path.stem, data["platform"])
self.assertNotIn("target", data)
self.assertNotIn("no_game_data", data)
self.assertEqual(data["source"], "full")
self.assertEqual(data["regions"], [])
if __name__ == "__main__":
unittest.main()
+5
View File
@@ -142,6 +142,11 @@ class ThePullRequestBuildsTheSite(unittest.TestCase):
)
suite = next(i for i, run in enumerate(runs) if "unittest discover" in run)
self.assertLess(generate, suite)
# The built pages too: about fifty tests read website/dist.
build = next(i for i, run in enumerate(runs) if "npm run build" in run)
self.assertLess(generate, build)
self.assertLess(build, suite)
self.assertEqual(steps[build].get("if"), "${{ !cancelled() }}")
self.assertEqual(steps[suite].get("if"), "${{ !cancelled() }}")
# A failed data fetch skipped the generator, and all 228 site tests
# then failed under it: the generator runs whatever came before.