chore: merge site and docs fixes, fifth pass

This commit is contained in:
Abdessamad Derraz committed 2026-11-06 17:15:57 +01:00
commit b9f309940c
67 files changed
+1495 -786

No files matched your search

+95 -2
View File
@@ -1985,7 +1985,6 @@ class NoTextClaimsAScheduledScrape(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
@@ -2003,6 +2002,100 @@ class TheCatalogRowsStateFacts(unittest.TestCase):
self.assertIn("`/bios/<CODE>`", rows[0])
class RegionFreeRuleNamesWhereItDoesNotHold(unittest.TestCase):
"""advanced-usage.md said psxonpsp660.bin is declared [world] and always
survives --region. PCSX ReARMed declares it [japan], and on the platforms
where it is the only PlayStation core the filter drops it."""
def test_every_platform_that_drops_a_named_file_is_named(self):
from common import (list_registered_platforms, load_emulator_profiles,
load_platform_config)
from region import WORLD, platform_region_index
section = _section(_page("advanced-usage.md"), "Region filtering")
bullet = next(p for p in section.split("\n- ") if "Region-free" in p)
files = re.findall(r"`([^`]+\.bin)`", bullet)
self.assertTrue(files)
profiles = load_emulator_profiles(str(ROOT / "emulators"))
for platform in list_registered_platforms(str(ROOT / "platforms")):
config = load_platform_config(platform, str(ROOT / "platforms"))
index = platform_region_index(config, profiles)
for name in files:
entry = index.get(name)
drops = bool(entry and entry["regions"] and WORLD not in entry["regions"]
and not entry["has_untagged"])
if drops:
with self.subTest(platform=platform, file=name):
self.assertRegex(bullet, rf"(?i)\b{re.escape(platform)}\b")
class BuildYourOwnPackSaysWhatTheCloneCosts(unittest.TestCase):
"""The README sent a user after a minimal pack to "Clone the repo", with no
command and no size, and the clone runs to several gigabytes."""
def test_readme_gives_the_clone_command_and_its_size(self):
import generate_readme
db = json.loads((ROOT / "database.json").read_text(encoding="utf-8"))
line = generate_readme.clone_line(db)
self.assertIn("git clone --depth 1", line)
self.assertRegex(line, r"over \d+(\.\d)? GB")
section = _section((ROOT / "README.md").read_text(encoding="utf-8"),
"Build your own pack")
self.assertIn("git clone --depth 1", section)
def test_advanced_usage_names_the_shallow_clone(self):
self.assertIn("--depth 1", _page("advanced-usage.md").split("## Custom packs")[0])
class LandingAChangeNamesTheCommitRules(unittest.TestCase):
"""The page left out the review-tag rule scripts/commit_rules.py
enforces, and never said where the rules live or how a clone runs them:
the hook is not versioned."""
def _landing(self) -> str:
return _section(_page("testing-guide.md"), "Landing a change")
def test_every_refusal_is_on_the_page(self):
import commit_rules
section = self._landing()
words = re.search(r"\\b\((.*?)\)", commit_rules.REFUSED_WORDS.pattern).group(1)
from tests.test_prose_style import NoMarketingVocabulary
for word in words.replace("|", " ").split():
if NoMarketingVocabulary.WORDS.search(word):
# Named by "the marketing vocabulary above": spelled out,
# the page would fail that test.
continue
with self.subTest(word=word):
self.assertIn(word, section.lower())
self.assertIn("which review asked for it", section)
self.assertIn("scripts/commit_rules.py", section)
def test_the_hook_command_on_the_page_refuses_a_review_tag(self):
import subprocess
import tempfile
block = re.search(r"```bash\n(.*?)```", self._landing(), re.S).group(1)
with tempfile.TemporaryDirectory(dir=ROOT / "tmp") as scratch:
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())
subprocess.run(["sh", "-c", block], cwd=clone, check=True)
message = clone / "MSG"
message.write_text("fix: address review 3 notes\n", encoding="utf-8")
refused = subprocess.run([str(clone / ".git" / "hooks" / "commit-msg"), "MSG"],
cwd=clone, capture_output=True, text=True)
message.write_text("fix: say what the change does\n", encoding="utf-8")
accepted = subprocess.run([str(clone / ".git" / "hooks" / "commit-msg"), "MSG"],
cwd=clone, capture_output=True, text=True)
self.assertEqual(refused.returncode, 1, refused.stderr)
self.assertIn("which review asked for it", refused.stderr)
self.assertEqual(accepted.returncode, 0, accepted.stderr)
if __name__ == "__main__":
unittest.main()