chore: merge site fixes, fourth pass

This commit is contained in:
Abdessamad Derraz committed 2026-11-06 10:33:56 +01:00
commit 25b11fa497
36 files changed
+878 -125

No files matched your search

+9
View File
@@ -44,3 +44,12 @@ def pages() -> list[Path]:
def name(path: Path) -> str:
"""A page file's docs path, the name tests use for it."""
return path.relative_to(CONTENT).with_suffix(".md").as_posix()
def generator_sources() -> list[Path]:
"""Every module whose strings reach a page: generate_site.py, each
scripts/site*.py and the pack README writer. Listed by glob, so text
moved out of generate_site.py stays under the guards that read it."""
scripts = REPO_ROOT / "scripts"
return sorted({*scripts.glob("site*.py"), scripts / "generate_site.py",
scripts / "packreadme.py"})
+85 -3
View File
@@ -1145,9 +1145,12 @@ class PipelineRegressions(unittest.TestCase):
argv = ["pipeline.py", "--offline", "--skip-packs", "--skip-docs",
"--with-export", "--target", "switch"]
# The originals the offline export patches are not cached in a
# checkout: the run would be refused before any step.
with mock.patch.object(sys, "argv", argv), mock.patch.object(
pipeline, "run", side_effect=fake_run
), contextlib.redirect_stdout(io.StringIO()), contextlib.suppress(SystemExit):
), mock.patch.object(pipeline, "_refuse_offline_export_without_originals"), \
contextlib.redirect_stdout(io.StringIO()), contextlib.suppress(SystemExit):
pipeline.main()
truth_runs = [c for c in commands if "scripts/generate_truth.py" in c]
export = next(c for c in commands if "scripts/export_native.py" in c)
@@ -5218,8 +5221,32 @@ class UnsourceableCardSaysWhy(unittest.TestCase):
text = "\n".join(_render_emulator_file(
entry, {"files": [entry]}, None, [entry], lambda f: False, "file-x",
))
self.assertIn("Not collectable: written by the firmware editor", text)
self.assertIn("../gaps.md#acknowledged-gaps", text)
self.assertIn("Not collected yet: written by the firmware editor", text)
self.assertIn("../gaps.md#not-collected-yet", text)
self.assertNotIn("collectable", text)
def test_the_gaps_page_names_where_a_wanted_file_is_listed(self):
"""The section read "Acknowledged gaps ... (verified from source
code)" while No-Intro lists XM7's KANJI2.ROM and MAME's fm7740sx.zip
carries it: the flag only keeps a homonym out, the file is wanted."""
from scripts.generate_site import generate_gap_analysis
unsourced = {"name": "KANJI2.ROM", "reason": "no dump distributed", "source_ref": ""}
report = {"xm7": {"emulator": "XM7", "gaps": 0, "gap_missing": 0, "gap_bios": 0,
"unsourceable": [unsourced], "gap_details": []}}
catalogued = {"no-intro": {"missing": [{
"name": "KANJI2.rom",
"romsets": [{"source": "mame", "archive": "fm7740sx.zip"}],
"needed_by": [{"emulator": "xm7", "name": "KANJI2.ROM", "required": True}],
}]}}
page = generate_gap_analysis(
{"xm7": {"emulator": "XM7", "files": []}}, {}, {"files": {}, "indexes": {}},
gap_report=report, catalogued=catalogued)
self.assertIn("## Not collected yet", page)
self.assertIn('<span id="acknowledged-gaps"></span>', page)
self.assertIn("| No-Intro `KANJI2.rom`, mame `fm7740sx.zip` |", page)
self.assertNotIn("Acknowledged", page)
self.assertNotIn("verified from source code", page)
@@ -5258,6 +5285,61 @@ class CollectionCardsCarryFullHashes(unittest.TestCase):
self.assertIn(f'<dd class="rb-hash">{value}</dd>', text)
class AHeldRevisionLinksItsBuildFile(unittest.TestCase):
"""advanced_drastic's page printed the KNULLI build file that holds its
revision as plain text, while pin_build carries the repository, the tag
and the path a pinned link needs. 36 profiles carry one."""
def test_the_build_file_row(self):
from scripts.generate_site import _build_rows
rows = _build_rows({"pin_frozen": "KNULLI builds this revision.", "pin_build": [{
"platform": "knulli", "repo": "https://github.com/knulli-cfw/knulli-linux",
"revision": "20260511", "path": "package/emulators/advanced_drastic/advanced_drastic.mk",
"variable": "ADVANCED_DRASTIC_VERSION", "value": "eaf41ab9"}]})
# A tag can move: named, never linked.
self.assertIn(
"| Build file | KNULLI `package/emulators/advanced_drastic/advanced_drastic.mk` "
"at `20260511` sets `ADVANCED_DRASTIC_VERSION` |", rows)
def test_a_build_read_at_a_recorded_commit_links(self):
from scripts.generate_site import _build_rows
pin = "46128cd252cdecae852a4d0bafa2aaf9d03ab563"
rows = _build_rows({"pin_build": [{
"platform": "retropie", "repo": "https://github.com/RetroPie/RetroPie-Setup",
"revision": pin, "path": "scriptmodules/emulators/advmame-1.4.sh",
"variable": "rp_module_repo", "value": "x"}]})
self.assertIn(
f"[RetroPie `scriptmodules/emulators/advmame-1.4.sh`](https://github.com/RetroPie/"
f"RetroPie-Setup/blob/{pin}/scriptmodules/emulators/advmame-1.4.sh)", rows[0])
def test_the_record_holds_the_build_files(self):
import sitesources # noqa: PLC0415
files = sitesources.build_files({"pin_build": [
{"repo": "https://github.com/o/r", "revision": "a" * 40, "path": "p.mk"},
{"repo": "https://github.com/o/r", "revision": "v1", "path": "q.mk"}]})
self.assertEqual([(f[1], f[2]) for f in files], [("a" * 40, "p.mk")])
class AVariantCardSaysWhatToSaveItAs(unittest.TestCase):
"""The Download button of a .variants/ card saved advision.zip.1c086064,
the storage name, and nothing said RetroBat looks for advision.zip."""
def test_the_name_to_save_it_under(self):
from scripts.generate_site import FileConsumers, _system_file_card
entry = {"name": "advision.zip", "size": 10, "sha1": "a" * 40,
"path": "bios/Entex/Adventure Vision/.variants/advision.zip.1c086064"}
text = "\n".join(_system_file_card(entry, FileConsumers({}, {})))
self.assertIn("Save as", text)
self.assertIn("advision.zip.1c086064", text)
plain = "\n".join(_system_file_card(
{**entry, "path": "bios/Entex/Adventure Vision/advision.zip"}, FileConsumers({}, {})))
self.assertNotIn("Save as", plain)
class NullReadsAsNone(unittest.TestCase):
"""`upstream: ~` printed `| Upstream | None |` and `bios_filename: null`
+19
View File
@@ -1984,5 +1984,24 @@ class ArchivedIsWhatTheToolsDo(unittest.TestCase):
self.assertNotIn("list_platforms", workflow.read_text(encoding="utf-8"))
class TheCatalogRowsStateFacts(unittest.TestCase):
"""tools.md said "redump.org serves stale DATs" and "Dat-o-Matic blocks
automation", verdicts on two preservation projects, and gave Redump's
/static/bios links, which the scraper no longer reads."""
def test_dates_and_routes_not_verdicts(self):
text = (WIKI / "tools.md").read_text(encoding="utf-8")
rows = [line for line in text.splitlines()
if line.startswith(("| Redump |", "| No-Intro |"))]
self.assertEqual(len(rows), 2)
for word in ("stale", "blocks"):
self.assertNotIn(word, " ".join(rows))
scraper = (ROOT / "scripts" / "scraper" / "redump_dat_scraper.py").read_text(encoding="utf-8")
self.assertIn("/bios/<CODE>", scraper)
self.assertIn("`/bios/<CODE>`", rows[0])
if __name__ == "__main__":
unittest.main()
+31
View File
@@ -11,12 +11,14 @@ installer fetches and leaves out the data directories a pack also carries.
from __future__ import annotations
import hashlib
import io
import json
import sys
import tempfile
import unittest
import zipfile
from pathlib import Path
from unittest import mock
import yaml
@@ -552,6 +554,35 @@ class TheReleaseNotesReadTheRecord(unittest.TestCase):
def test_the_notes_never_open_on_the_collection(self):
self.assertNotIn("collection", self.render().split("### What changed")[0])
def test_the_notes_claim_only_what_the_gaps_allow(self):
"""v2026.10.10 said a pack holds every file its emulators open, "so a
game never stops on a missing file", and that hashes never come
"from a forum list". The gap analysis lists what no pack carries."""
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), [])
def test_a_judging_whats_new_is_refused(self):
self.assertEqual(
release_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"])
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
whats_new = Path(tmp) / "whats-new.md"
whats_new.write_text("- Hashes never from a forum list\n", encoding="utf-8")
record = Path(tmp) / "release.json"
record.write_text(json.dumps(self.RECORD), encoding="utf-8")
argv = ["release_notes.py", "--record", str(record), "--whats-new", str(whats_new),
"--platforms-dir", str(REPO_ROOT / "platforms"),
"--output", str(Path(tmp) / "notes.md")]
with mock.patch.object(sys, "argv", argv), \
mock.patch("sys.stderr", new_callable=io.StringIO) as err:
self.assertEqual(release_notes.main(), 1)
self.assertIn("'forum'", err.getvalue())
self.assertFalse((Path(tmp) / "notes.md").exists())
def test_the_release_process_runs_it(self):
page = (REPO_ROOT / "wiki" / "release-process.md").read_text(encoding="utf-8")
self.assertIn("scripts/release_notes.py", page)
+7
View File
@@ -124,6 +124,13 @@ class LauncherIndex(unittest.TestCase):
"install/launchers/index.json is stale: run "
"python scripts/generate_launcher_index.py")
def test_the_installer_page_says_when_to_rewrite_it(self):
"""The list records install.py's SHA-256, and the page that says
what a change to install.py rewrites named only the two pins."""
page = (REPO_ROOT / "wiki" / "installer.md").read_text(encoding="utf-8")
section = page.split("## Changing the installer", 1)[1].split("\n## ", 1)[0]
self.assertIn("scripts/generate_launcher_index.py", section)
def test_every_member_of_the_archives_is_listed(self):
import generate_launcher_index # noqa: PLC0415
+12
View File
@@ -386,6 +386,18 @@ class NoClauseSemicolons(unittest.TestCase):
]
self.assertEqual(offenders, [], "\n".join(offenders[:20]))
def test_bold_labels_do_not_run_together(self):
"""community-tools.md wrote Author, Repository and License on three
lines of one paragraph: rendered, the three ran on one line."""
label = r"\*\*[^*\n]+:\*\*"
run = re.compile(rf"^{label}.*\n{label}", re.M)
offenders = [
f"{p.relative_to(ROOT)}: {m.group(0).splitlines()[0]}"
for p in _tracked() if p.suffix == ".md"
for m in run.finditer(FENCED.sub("", p.read_text(encoding="utf-8")))
]
self.assertEqual(offenders, [], "\n".join(offenders[:20]))
def test_wiki_headings_use_sentence_case(self):
"""The gaps page and two wiki pages titled in Title Case ("What Each
Pack Contains") beside sentence-case pages ("Quick install")."""
+59
View File
@@ -832,6 +832,65 @@ class AnArchiveMemberIsFoundByItsCrc(unittest.TestCase):
self.assertIn("byLayer('archive-member')", script)
class AWantedDumpIsFoundByItsHash(unittest.TestCase):
"""The SHA1 of a PS2 SCPH-30005R BIOS, which Redump lists as
ps2-dvd-212k.bin and the Wanted page asks for, answered that no file
the site knows has it."""
def test_each_hash_of_a_wanted_row_is_a_record(self):
import generate_site # noqa: PLC0415
row = {"catalog": "redump", "dat": "Sony - PlayStation 2 - BIOS Images",
"name": "ps2-dvd-212k.bin", "description": "", "size": "4194304",
"crc32": "1A2B3C4D", "md5": "", "sha1": "5b346eb9258d710609a9855befd35cab8f3a334a"}
records = generate_site.file_lookup_records(
{"files": {}, "indexes": {}}, {}, {}, [], wanted=[row, {**row, "dat": "other"}])
self.assertEqual(records, [
{"value": "1a2b3c4d", "algorithm": "crc32", "layer": "wanted", "owner": "Redump",
"name": "ps2-dvd-212k.bin", "url": "/retrobios/provenance/#redump"},
{"value": "5b346eb9258d710609a9855befd35cab8f3a334a", "algorithm": "sha1",
"layer": "wanted", "owner": "Redump", "name": "ps2-dvd-212k.bin",
"url": "/retrobios/provenance/#redump"},
])
def test_the_schema_and_the_page_carry_the_layer(self):
import json as _json # noqa: PLC0415
import generate_site # noqa: PLC0415
root = Path(__file__).resolve().parents[1]
schema = _json.loads((root / "schemas" / "site-api-envelope.schema.json").read_text())
self.assertIn('"wanted"', _json.dumps(schema))
self.assertIn("byLayer('wanted')", (root / "website" / "src" / "scripts" / "site.ts").read_text())
source = Path(generate_site.__file__).read_text(encoding="utf-8")
self.assertIn('retired_files.load(_REPO_ROOT / "retired.json"), wanted)', source)
class AMovedPartCardReachesItsPage(unittest.TestCase):
"""One entry added to mame.yml moved 938 of its 1,585 cards from one
part page to another, and emulators/mame-files-1/#file-mackbd-m0110a-zip
led to a page without the card: part pages have no card index, and
site.js redirected only sha1- ids."""
def test_a_part_page_sends_a_missing_card_to_the_emulator_page(self):
import re as _re # noqa: PLC0415
import generate_site # noqa: PLC0415
script = (Path(__file__).resolve().parents[1] / "website" / "src" / "scripts"
/ "site.ts").read_text(encoding="utf-8")
body = script.split("const followMovedCard = () => {", 1)[1].split("\n};", 1)[0]
pattern = _re.search(r"const part = /(.+?)/\.exec\(location\.pathname\)", body).group(1)
files = [{"name": f"f{i}.bin", "path": f"f{i}.bin", "required": True} for i in range(600)]
stem = generate_site.emulator_parts("mame", files)[1][0]
found = _re.search(pattern.replace("\\/", "/"), f"/retrobios/emulators/{stem}/")
self.assertEqual(found.group(1), "mame")
self.assertIn("emulators/${part[1]}/#", body)
self.assertIn("id.startsWith('file-')", body)
# The emulator page holds the index whose row leads to the card.
self.assertIn("closest('.rb-card-index tr')", body)
class AFileHasAnAddressByContent(unittest.TestCase):
"""mt32_control.rom moved from the Commodore page to the Roland page and
every link to its card broke: the anchor was content-based, the page
+122
View File
@@ -0,0 +1,122 @@
"""generate_site --db, --emulators-dir and --platforms-dir reach every page.
The run loaded the given database, but the page-finishing pass reloaded the
repository's database.json: a card held only by the given collection stopped
the whole run on a KeyError. The emulator names and engine sections came from
./emulators, and has_release_pack read `platforms` relative to the working
directory, so a get/ page said "No ZIP" for a setup the API marked as released.
"""
from __future__ import annotations
import ast
import json
import os
import shutil
import sys
import tempfile
import unittest
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(REPO_ROOT / "scripts"))
import generate_site # noqa: E402
import sitediagrams # noqa: E402
import siteinputs # noqa: E402
SHA1 = "0123456789ab" + "c" * 28
class _Inputs(unittest.TestCase):
def use(self, **paths: Path) -> None:
siteinputs.use(siteinputs.SiteInputs(**paths))
self.addCleanup(siteinputs.use, siteinputs.SiteInputs())
class TheGivenDatabase(_Inputs):
def setUp(self) -> None:
tmp = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp" if (REPO_ROOT / "tmp").is_dir() else None))
self.addCleanup(shutil.rmtree, tmp)
self.db = tmp / "database.json"
self.db.write_text(json.dumps({"files": {SHA1: {"path": "bios/X/only-here.bin"}}}))
def test_a_card_held_elsewhere_resolves_in_the_given_collection(self) -> None:
self.use(db=self.db)
page = generate_site._cards_elsewhere("[x](#sha1-0123456789ab) ")
self.assertIn(f"files/?sha1={SHA1}", page)
def test_paths_are_read_from_the_given_collection(self) -> None:
self.use(db=self.db)
self.assertEqual(generate_site._collection_sha1_by_path(), {"bios/X/only-here.bin": SHA1})
class TheGivenProfilesAndPlatforms(_Inputs):
def setUp(self) -> None:
tmp = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp" if (REPO_ROOT / "tmp").is_dir() else None))
self.addCleanup(shutil.rmtree, tmp)
self.emulators = tmp / "emulators"
self.emulators.mkdir()
(self.emulators / "fixturecore.yml").write_text(
"emulator: Fixture Core\ntype: libretro\nsystems: [fixture-system]\nfiles: []\n")
self.platforms = tmp / "platforms"
shutil.copytree(REPO_ROOT / "platforms", self.platforms)
def test_emulator_names_come_from_the_given_profiles(self) -> None:
self.use(emulators=self.emulators)
self.assertEqual(set(generate_site._profiles_on_disk()), {"fixturecore"})
self.assertEqual(generate_site._emulator_named_link("fixturecore"),
"[Fixture Core](emulators/fixturecore.md)")
def test_release_pack_does_not_depend_on_the_working_directory(self) -> None:
released = generate_site._release_pack_platforms()
self.assertIn("retroarch", released)
here = os.getcwd()
os.chdir(REPO_ROOT / "scripts")
self.addCleanup(os.chdir, here)
self.assertTrue(generate_site.has_release_pack("retroarch"))
self.assertEqual(generate_site.get_page_title("retroarch", "RetroArch"), "RetroArch BIOS pack")
def test_the_registry_comes_from_the_given_platforms(self) -> None:
registry = self.platforms / "_registry.yml"
registry.write_text(registry.read_text().replace("release_pack: true", "release_pack: false"))
self.use(platforms=self.platforms)
self.assertFalse(generate_site.has_release_pack("retroarch"))
self.assertEqual(sitediagrams.registry()["retroarch"].get("release_pack"), False)
class NoPageModuleReadsTheRepositoryInputs(unittest.TestCase):
"""A helper that opens the repository's database, profiles or platform
files itself bypasses the flags. siteinputs.current() is the one source."""
MODULES = ("generate_site.py", "siterender.py", "sitediagrams.py")
INPUTS = {"database.json", "emulators", "platforms"}
def test_no_literal_input_path(self) -> None:
found = []
for module in self.MODULES:
tree = ast.parse((REPO_ROOT / "scripts" / module).read_text(encoding="utf-8"))
for node in ast.walk(tree):
if isinstance(node, ast.BinOp) and isinstance(node.op, ast.Div) \
and getattr(node.left, "id", "") in ("_REPO_ROOT", "ROOT") \
and isinstance(node.right, ast.Constant) and node.right.value in self.INPUTS:
found.append(f"{module}:{node.lineno}")
if isinstance(node, ast.Call) and getattr(node.func, "id", getattr(node.func, "attr", "")) in (
"load_platform_config", "load_platform_registry", "load_emulator_profiles",
"list_registered_platforms", "load_database", "extract_notes",
"load_data_dir_registry"):
for arg in node.args:
if isinstance(arg, ast.Constant) and arg.value in self.INPUTS:
found.append(f"{module}:{node.lineno}")
self.assertEqual(found, [])
def test_generate_installs_the_inputs_first(self) -> None:
source = ast.get_source_segment(
(REPO_ROOT / "scripts" / "generate_site.py").read_text(encoding="utf-8"),
next(n for n in ast.parse((REPO_ROOT / "scripts" / "generate_site.py").read_text(encoding="utf-8")).body
if isinstance(n, ast.FunctionDef) and n.name == "_generate"))
self.assertLess(source.index("siteinputs.use("), source.index("load_database("))
if __name__ == "__main__":
unittest.main()
+15
View File
@@ -117,6 +117,21 @@ class SourcePathsFreshness(unittest.TestCase):
finding = check_freshness.check_source_paths(profiles)
self.assertEqual(finding.status, check_freshness.OK, finding.detail)
def test_a_recorded_build_file_tree_is_pinned(self):
"""The record holds the platform trees pin_build reads at a commit,
and the check called them orphaned."""
import sitesources # noqa: PLC0415
pin = "a" * 40
profile = {"pin_build": [{"repo": "https://github.com/o/r", "revision": pin,
"path": "p.mk"}]}
with tempfile.TemporaryDirectory() as tmp:
path = Path(tmp) / "source-paths.json"
path.write_text(json.dumps({f"github.com/o/r@{pin}": ["p.mk"]}), encoding="utf-8")
with mock.patch.object(sitesources, "SOURCE_PATHS", path):
finding = check_freshness.check_source_paths({"p": profile})
self.assertEqual(finding.status, check_freshness.OK, finding.detail)
def test_a_moved_pin_is_stale(self):
profile = _profile("geolith")
moved = dict(profile, source_commit="f" * 40, upstream_commit="e" * 40)
+5 -4
View File
@@ -50,15 +50,16 @@ class EveryPageAddressesPlatformsAsPeers(unittest.TestCase):
text every site generator writes, docstrings and bare identifiers aside."""
WORDS = ("their file", "theirs", "of ours", "corrected", "left out", "drift")
SOURCES = ("generate_site.py", "siterender.py", "sitesources.py", "siteexports.py")
def test_no_page_text_judges_another_project(self):
import ast
import re
from tests.sitepages import generator_sources
found = []
for name in self.SOURCES:
tree = ast.parse((REPO_ROOT / "scripts" / name).read_text(encoding="utf-8"))
for source in generator_sources():
name = source.name
tree = ast.parse(source.read_text(encoding="utf-8"))
docstrings = {
id(node.body[0].value) for node in ast.walk(tree)
if isinstance(node, (ast.Module, ast.ClassDef, ast.FunctionDef,
+13 -5
View File
@@ -349,9 +349,13 @@ class TheSitemapIsAnnouncedWhereCrawlersLook(unittest.TestCase):
config = (root / "website" / "astro.config.mjs").read_text()
self.assertIn("site: SITE", config)
self.assertIn("sitemap.xml", config)
source = (root / "scripts" / "generate_site.py").read_text()
self.assertNotIn('"robots.txt"),\n "User-agent', source)
self.assertNotIn("Sitemap: https://", source)
from tests.sitepages import generator_sources
for path in generator_sources():
source = path.read_text(encoding="utf-8")
with self.subTest(module=path.name):
self.assertNotIn('"robots.txt"),\n "User-agent', source)
self.assertNotIn("Sitemap: https://", source)
@@ -409,8 +413,12 @@ class PlainHouseStyle(unittest.TestCase):
def test_headings_do_not_repeat_the_site_name(self):
# The header bar already names the site, and the browser title gets
# it from the theme: "# DuckStation - RetroBIOS" said it twice.
source = (ROOT / "scripts" / "generate_site.py").read_text(encoding="utf-8")
self.assertNotRegex(source, r'"# [^"]* - (?:\{SITE_NAME\}|RetroBIOS)')
from tests.sitepages import generator_sources
for path in generator_sources():
with self.subTest(module=path.name):
self.assertNotRegex(path.read_text(encoding="utf-8"),
r'"# [^"]* - (?:\{SITE_NAME\}|RetroBIOS)')
for page in sorted((ROOT / "wiki").glob("*.md")):
first = page.read_text(encoding="utf-8").splitlines()[0]
with self.subTest(page=page.name):
+20
View File
@@ -426,6 +426,19 @@ def _entry(profile: dict, name: str) -> dict:
raise AssertionError(f"{name} not in the profile")
class TheFaqAnswersWithACommand(unittest.TestCase):
""""Do I need every file of a console?" answered `--region us keeps only
your region's BIOS`, with no command to run, and that run kept 44 files
of the PlayStation set, Japanese PS2 images among them. `--core pcsx1`
is the lever the installer itself names."""
def test_every_file_of_a_console(self):
section = _section(_wiki("faq.md"), "Do I need every file of a console?")
self.assertIn("<!-- os-tabs -->", section)
self.assertIn("--system sony-playstation --core pcsx1", section)
self.assertNotIn("only your region", section)
class LegalOpensInPlainWords(unittest.TestCase):
"""C5: Is it legal? is a Start here page and opened on case law."""
@@ -455,6 +468,13 @@ class LegalOpensInPlainWords(unittest.TestCase):
self.assertEqual(re.findall(r"(?m)^## ", detail), [])
self.assertIn("### Emulation and BIOS redistribution", detail)
def test_said_once(self):
"""A closing Summary restated the opening lines, and "not legal
advice" came three times."""
self.assertEqual(self.text.count("legal advice"), 1)
self.assertNotIn("### Summary", self.text)
self.assertIn("The project accepts that risk deliberately", self.text)
def test_a_contact_section_names_only_a_channel_that_exists(self):
section = _section(self.text, "Contact")
self.assertIn("https://github.com/Abdess/retrobios/issues", section)
+77
View File
@@ -175,6 +175,83 @@ class AnOfflineRunWithNoCacheStopsFirst(unittest.TestCase):
parser.error.assert_not_called()
class AnOfflineExportWithNoOriginalsStopsFirst(unittest.TestCase):
"""pipeline.py --offline --with-export, which tools.md listed as a
standard command, built the database, verify and the truth model on a
fresh clone, then failed step 2e on every platform whose own file it
patches: --offline never passes --fetch."""
def _args(self, **flags):
import argparse
return argparse.Namespace(**{"offline": True, "with_export": True, **flags})
def test_refused_before_any_step(self):
from exporter import discover_exporters
patched = sorted(n for n, e in discover_exporters().items() if e.needs_original())
self.assertIn("batocera", patched)
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
parser = mock.Mock()
pipeline._refuse_offline_export_without_originals(parser, self._args(), tmp)
message = parser.error.call_args.args[0]
self.assertIn("export_native.py --all --refresh-cache", message)
self.assertIn("batocera", message)
for args in (self._args(offline=False), self._args(with_export=False)):
parser = mock.Mock()
pipeline._refuse_offline_export_without_originals(parser, args, tmp)
parser.error.assert_not_called()
for name in patched:
(Path(tmp) / name).mkdir()
(Path(tmp) / name / "original").write_text("x")
parser = mock.Mock()
pipeline._refuse_offline_export_without_originals(parser, self._args(), tmp)
parser.error.assert_not_called()
def test_the_tools_page_says_so(self):
text = (REPO_ROOT / "wiki" / "tools.md").read_text(encoding="utf-8")
self.assertIn("export_native.py --all --refresh-cache", text)
class ThePipelineFlagTableSaysEveryRefusal(unittest.TestCase):
"""tools.md said --full-narrowings is refused with --skip-packs only, and
advanced-usage.md kept its own shorter list: `--source truth
--full-narrowings` failed with nothing on either page saying so."""
PAIRS = {"--source": "platform", "--all-variants": True, "--full-narrowings": True,
"--skip-packs": True}
def _refused(self, flags: dict) -> bool:
import argparse
args = argparse.Namespace(source=None, all_variants=False, full_narrowings=False,
skip_packs=False)
for flag, value in flags.items():
setattr(args, flag.lstrip("-").replace("-", "_"), value)
parser = mock.Mock()
pipeline._refuse_unapplied_flags(parser, args)
return parser.error.called
def test_each_refused_pair_is_in_the_row_of_a_flag(self):
import itertools
text = (REPO_ROOT / "wiki" / "tools.md").read_text(encoding="utf-8")
rows = {line.split("`")[1].split()[0]: line for line in text.splitlines()
if line.startswith("| `--")}
for (a, va), (b, vb) in itertools.combinations(self.PAIRS.items(), 2):
if not self._refused({a: va, b: vb}):
continue
with self.subTest(pair=(a, b)):
self.assertTrue(f"`{b}" in rows.get(a, "") or f"`{a}" in rows.get(b, ""),
f"{a} with {b} is refused, and neither row says so")
self.assertIn("`--source truth`", rows["--full-narrowings"])
def test_one_list_of_refusals(self):
text = (REPO_ROOT / "wiki" / "advanced-usage.md").read_text(encoding="utf-8")
self.assertNotIn("are refused with", text)
self.assertIn("tools.md#pipeline", text)
class TheTruthDiffShowsWhereAndAsksNothing(unittest.TestCase):
"""The markdown wrote `**Remove** hiscore.dat (phantom)` beside six
`**Add** hiscore.dat`, none with a path, for files profiled cores read."""