mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-23 18:17:53 -06:00
feat: write the verify excerpt from a real run
The RetroDECK excerpt of wiki/reading-reports.md went stale with every file the collection gained, three times on 2026-11-12. It now sits between generated markers, and generate_report_excerpt.py writes it from verify.py --platform retrodeck at pipeline step 7 (--check reports a stale block).
This commit is contained in:
1 parent
865f56b539
commit
16b452bf3c
6 files changed
+141
-3
No files matched your search
@@ -0,0 +1,88 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Write the verify excerpt of wiki/reading-reports.md from a real run.
|
||||
|
||||
Usage:
|
||||
python scripts/generate_report_excerpt.py # rewrite the block
|
||||
python scripts/generate_report_excerpt.py --check # exit 1 when stale
|
||||
|
||||
The page quotes `verify.py --platform retrodeck` to show how a report reads.
|
||||
Written by hand, it went stale with every file the collection gained: three
|
||||
times on 2026-11-12, each time a red test. The block between
|
||||
`<!-- generated: verify-retrodeck -->` and its closing marker is the run's
|
||||
own output: its first line, the entries a reader learns the shapes from
|
||||
(the first UNTESTED line, the first DISCREPANCY with the line under it),
|
||||
then every count line.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
PAGE = ROOT / "wiki" / "reading-reports.md"
|
||||
BLOCK = re.compile(
|
||||
r"(<!-- generated: verify-retrodeck -->\n```\n)(.*?)(```\n<!-- /generated: verify-retrodeck -->)",
|
||||
re.S)
|
||||
# The count lines, in the order verify prints them.
|
||||
COUNTS = (" Core files:", " Bundled with their emulator", " Core files held",
|
||||
" Game data:", " Game data held", " Launcher reads", " Launcher records",
|
||||
" No external files:", " Ground truth:", " ")
|
||||
|
||||
|
||||
def excerpt(lines: list[str]) -> list[str]:
|
||||
"""The lines of a verify run the page shows."""
|
||||
kept = [lines[0]]
|
||||
untested = next((line for line in lines if line.startswith(" UNTESTED")), None)
|
||||
if untested:
|
||||
kept.append(untested)
|
||||
for index, line in enumerate(lines):
|
||||
if line.startswith(" DISCREPANCY") and index + 1 < len(lines) \
|
||||
and lines[index + 1].startswith(" "):
|
||||
kept += [line, lines[index + 1]]
|
||||
break
|
||||
counts_from = next(i for i, line in enumerate(lines) if line.startswith(" Core files:"))
|
||||
kept += [line for line in lines[counts_from:] if line.startswith(COUNTS)]
|
||||
return kept
|
||||
|
||||
|
||||
def run() -> list[str]:
|
||||
proc = subprocess.run([sys.executable, str(ROOT / "scripts" / "verify.py"),
|
||||
"--platform", "retrodeck"], capture_output=True, text=True,
|
||||
cwd=ROOT, check=False)
|
||||
lines = proc.stdout.splitlines()
|
||||
if not lines or not lines[0].startswith("RetroDECK:"):
|
||||
raise SystemExit(f"verify did not run: {proc.stderr[-300:]}")
|
||||
return lines
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser(allow_abbrev=False,
|
||||
description=__doc__.split("\n\n", 1)[0])
|
||||
parser.add_argument("--check", action="store_true",
|
||||
help="exit 1, writing nothing, when the block is not the run's")
|
||||
args = parser.parse_args()
|
||||
text = PAGE.read_text(encoding="utf-8")
|
||||
found = BLOCK.search(text)
|
||||
if found is None:
|
||||
print(f"{PAGE.relative_to(ROOT)}: no verify-retrodeck block", file=sys.stderr)
|
||||
return 1
|
||||
body = "\n".join(excerpt(run())) + "\n"
|
||||
if found.group(2) == body:
|
||||
return 0
|
||||
if args.check:
|
||||
print(f"STALE {PAGE.relative_to(ROOT)}: the verify excerpt is not the run's. "
|
||||
"Run python scripts/generate_report_excerpt.py", file=sys.stderr)
|
||||
return 1
|
||||
PAGE.write_text(text[:found.start(2)] + body + text[found.end(2):], encoding="utf-8")
|
||||
print(f"Wrote {PAGE.relative_to(ROOT)}")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
from common import run_cli
|
||||
|
||||
run_cli(main)
|
||||
+5
-1
@@ -28,6 +28,7 @@ Steps, numbered as the run prints them:
|
||||
6 --verify-packs pack integrity, extraction and hashes
|
||||
7 generate_readme.py README.md and CONTRIBUTING.md
|
||||
generate_installer_doc.py run samples and tables of wiki/installer.md
|
||||
generate_report_excerpt.py the verify excerpt of wiki/reading-reports.md
|
||||
8 generate_site.py site pages, into the Starlight project in website/
|
||||
8b npm run build (website/) rendered as the site deploy renders it, then validate_site.py
|
||||
|
||||
@@ -1526,7 +1527,10 @@ def main() -> None:
|
||||
# the manifests step 4b just wrote.
|
||||
doc_ok, _ = run([sys.executable, "scripts/generate_installer_doc.py"],
|
||||
"7 generate installer page")
|
||||
ok = ok and doc_ok
|
||||
# The verify excerpt of wiki/reading-reports.md, from this run's data.
|
||||
excerpt_ok, _ = run([sys.executable, "scripts/generate_report_excerpt.py"],
|
||||
"7 generate report excerpt")
|
||||
ok = ok and doc_ok and excerpt_ok
|
||||
results["generate_readme"] = ok
|
||||
all_ok = all_ok and ok
|
||||
else:
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
"""The verify excerpt of wiki/reading-reports.md is written from a run: it
|
||||
went stale with every file the collection gained."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import tests # noqa: F401 offline, scratch under tmp/, the suite's own cache
|
||||
|
||||
import sys
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||
sys.path.insert(0, str(REPO_ROOT / "scripts"))
|
||||
|
||||
import generate_report_excerpt # noqa: E402
|
||||
|
||||
RUN = [
|
||||
"RetroDECK: 9/10 OK, 1 untested [md5]",
|
||||
" UNTESTED (required): a/x.bin: declared hash contradicted by the local file",
|
||||
" UNTESTED (required): a/y.bin: declared hash contradicted by the local file",
|
||||
" DISCREPANCY: a/z.rom: RetroDECK says OK but core says size mismatch",
|
||||
" core [size]",
|
||||
" DISCREPANCY: a/w.rom: another one",
|
||||
" core [size]",
|
||||
" Core files: 5 in pack, 0 required missing, 1 optional missing (--verbose lists them)",
|
||||
" Game data: 2 in pack, 0 missing",
|
||||
" Ground truth: 1/10 files have emulator validation (10%)",
|
||||
" 9 platform-only (no emulator profile)",
|
||||
]
|
||||
|
||||
|
||||
class TheExcerptIsTheRun(unittest.TestCase):
|
||||
def test_one_entry_of_each_shape_then_every_count(self):
|
||||
self.assertEqual(generate_report_excerpt.excerpt(RUN), [
|
||||
RUN[0], RUN[1], RUN[3], RUN[4], RUN[7], RUN[8], RUN[9], RUN[10]])
|
||||
|
||||
def test_the_page_carries_the_block(self):
|
||||
text = generate_report_excerpt.PAGE.read_text(encoding="utf-8")
|
||||
self.assertIsNotNone(generate_report_excerpt.BLOCK.search(text))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -102,12 +102,13 @@ the entries that need attention, one per line as `STATUS (required|optional):
|
||||
system/file`, followed by a reason where there is one, then the counts of the
|
||||
files the emulator cores add. From `python scripts/verify.py --platform retrodeck`:
|
||||
|
||||
<!-- generated: verify-retrodeck -->
|
||||
```
|
||||
RetroDECK: 2007/2008 OK, 1 untested [md5]
|
||||
UNTESTED (required): nintendo-ds/dsifirmware.bin: declared hash contradicted by the local file
|
||||
DISCREPANCY: nintendo-snes/sgb2.boot.rom: RetroDECK says OK but supersnes9x says size mismatch: got 524288, accepted [256]
|
||||
supersnes9x [size]
|
||||
Core files: 4947 in pack, 0 required missing, 124 optional missing (--verbose lists them)
|
||||
Core files: 5007 in pack, 0 required missing, 64 optional missing (--verbose lists them)
|
||||
Bundled with their emulator, not collected: 34 (cg.dll, cg2.dll, cgGL.dll, libCg.so, libCgGL.so, libstdc++.so.5, libstdc++.so.6, 27 more, --verbose lists them)
|
||||
Core files held but not packed: 397 (245 read in a folder the platform keeps outside the BIOS tree, 140 installed with its emulator, 8 read below a save folder per system and no system runs the core there, 4 a packed file occupies its directory)
|
||||
Game data: 5146 in pack, 51 missing (--verbose lists them)
|
||||
@@ -118,6 +119,7 @@ RetroDECK: 2007/2008 OK, 1 untested [md5]
|
||||
Ground truth: 109/2008 files have emulator validation (5%)
|
||||
441 platform-only (no emulator profile)
|
||||
```
|
||||
<!-- /generated: verify-retrodeck -->
|
||||
|
||||
The run prints more `DISCREPANCY` lines than this excerpt shows. The core
|
||||
and game data lines count what the emulator cores add beyond the platform's
|
||||
|
||||
@@ -77,7 +77,7 @@ Every module in `tests/`, by the area it guards.
|
||||
| Pack probe | the cores a platform runs for a system, staging grown to a fixed point, runs mapped to pack and manifest entries, the line and its schema, the probe lock per run, that no page shows its lines. One class builds a real pack narrowed to PlayStation and lays it out both ways, from the archive and with `install.py --dest`, and skips without the collection | `test_pack_probe` |
|
||||
| Automation runner, disk cleanup, asset sync and bit-flip repair | fake jobs, git repositories with a bare origin and session worktrees, a committed file with one bit flipped, canned CI runs in place of `gh` | `test_autorun` |
|
||||
| Truth and native export | synthetic + cached originals | `test_export_counts`, `test_export_native_layer`, `test_export_report`, `test_exporters`, `test_truth_data_dir_readers`, `test_truth_diff`, `test_truth_layout` |
|
||||
| Scrapers, upstream and provenance | inline sources, synthetic | `test_auto_fetch_lookup`, `test_batocera_md5_list`, `test_find_embedded`, `test_check_freshness`, `test_cited_lines`, `test_contributing_text`, `test_coverage_cache`, `test_data_dir_refs`, `test_dataclass_defaults`, `test_dedup`, `test_doc_pages`, `test_doc_surfaces`, `test_elec_scrapers`, `test_fbneo_parser`, `test_find_pinned_revision`, `test_hash_merge`, `test_launchers`, `test_launchers_amberelec`, `test_launchers_emudeck`, `test_launchers_emuelec`, `test_launchers_knulli`, `test_launchers_recalbox`, `test_launchers_retrobat`, `test_launchers_retrodeck`, `test_launchers_retropie`, `test_launchers_rocknix`, `test_mame_devices`, `test_mame_parser`, `test_mame_ref_audit`, `test_optional_dependencies`, `test_pin_build`, `test_profile_sync`, `test_prose_style`, `test_provenance`, `test_refresh_data_dirs`, `test_refresh_failures`, `test_refresh_stale`, `test_retired_files`, `test_retrodeck_scraper_errors`, `test_romset_recipes`, `test_schema_semantic_gate`, `test_scraper_contract`, `test_site_agents`, `test_site_arcade_boards`, `test_site_availability`, `test_site_bootstrap`, `test_site_built_gate`, `test_site_components`, `test_site_console_folders`, `test_site_content_data`, `test_site_copy`, `test_site_cores`, `test_site_css`, `test_site_demo`, `test_site_density_cards`, `test_site_emulator_page`, `test_site_emulators`, `test_site_entry`, `test_site_entry_tables`, `test_site_exports`, `test_site_freshness`, `test_site_funnel`, `test_site_images`, `test_site_inputs`, `test_site_insights`, `test_site_integration`, `test_site_nav`, `test_site_page_text`, `test_site_picker`, `test_site_platform_density`, `test_site_platform_hashes`, `test_site_privacy`, `test_site_pronouns`, `test_site_reference`, `test_site_render`, `test_site_search`, `test_site_steps`, `test_site_system_links`, `test_site_system_names`, `test_site_system_sections`, `test_site_systems`, `test_site_validation`, `test_site_weight`, `test_site_wiki`, `test_site_write`, `test_source_ref_targets`, `test_upstream`, `test_upstream_index`, `test_validate_pr`, `test_validate_pr_flow`, `test_validate_pr_hashes`, `test_version_basis`, `test_workflow_paths` |
|
||||
| Scrapers, upstream and provenance | inline sources, synthetic | `test_auto_fetch_lookup`, `test_batocera_md5_list`, `test_find_embedded`, `test_report_excerpt`, `test_check_freshness`, `test_cited_lines`, `test_contributing_text`, `test_coverage_cache`, `test_data_dir_refs`, `test_dataclass_defaults`, `test_dedup`, `test_doc_pages`, `test_doc_surfaces`, `test_elec_scrapers`, `test_fbneo_parser`, `test_find_pinned_revision`, `test_hash_merge`, `test_launchers`, `test_launchers_amberelec`, `test_launchers_emudeck`, `test_launchers_emuelec`, `test_launchers_knulli`, `test_launchers_recalbox`, `test_launchers_retrobat`, `test_launchers_retrodeck`, `test_launchers_retropie`, `test_launchers_rocknix`, `test_mame_devices`, `test_mame_parser`, `test_mame_ref_audit`, `test_optional_dependencies`, `test_pin_build`, `test_profile_sync`, `test_prose_style`, `test_provenance`, `test_refresh_data_dirs`, `test_refresh_failures`, `test_refresh_stale`, `test_retired_files`, `test_retrodeck_scraper_errors`, `test_romset_recipes`, `test_schema_semantic_gate`, `test_scraper_contract`, `test_site_agents`, `test_site_arcade_boards`, `test_site_availability`, `test_site_bootstrap`, `test_site_built_gate`, `test_site_components`, `test_site_console_folders`, `test_site_content_data`, `test_site_copy`, `test_site_cores`, `test_site_css`, `test_site_demo`, `test_site_density_cards`, `test_site_emulator_page`, `test_site_emulators`, `test_site_entry`, `test_site_entry_tables`, `test_site_exports`, `test_site_freshness`, `test_site_funnel`, `test_site_images`, `test_site_inputs`, `test_site_insights`, `test_site_integration`, `test_site_nav`, `test_site_page_text`, `test_site_picker`, `test_site_platform_density`, `test_site_platform_hashes`, `test_site_privacy`, `test_site_pronouns`, `test_site_reference`, `test_site_render`, `test_site_search`, `test_site_steps`, `test_site_system_links`, `test_site_system_names`, `test_site_system_sections`, `test_site_systems`, `test_site_validation`, `test_site_weight`, `test_site_wiki`, `test_site_write`, `test_source_ref_targets`, `test_upstream`, `test_upstream_index`, `test_validate_pr`, `test_validate_pr_flow`, `test_validate_pr_hashes`, `test_version_basis`, `test_workflow_paths` |
|
||||
| Games on the card | small DATs, listxml and setup sources, a fake fetcher, fixture install lists, and the committed data against its schemas | `test_arcade_parents`, `test_game_catalogs`, `test_game_headers`, `test_game_regions`, `test_games_index`, `test_romfolders_card`, `test_romfolders_es` |
|
||||
|
||||
## Test architecture
|
||||
|
||||
@@ -1399,6 +1399,7 @@ Further options, by script:
|
||||
|--------|---------|
|
||||
| `auto_fetch.py` | `--create-issues` prints a GitHub issue body per platform for the files still missing, with their full hashes. It posts nothing. `--sha1` looks a file up by its hash alone, in the database, Software Heritage and archive.org, and writes what it finds to `tmp/acquire/` |
|
||||
| `find_embedded.py` | `--crc32` and `--size` name the file looked for inside other files (every offset, ZIP members read), `--sha1` confirms a hit, `--extract` writes a confirmed one to `tmp/acquire/` |
|
||||
| `generate_report_excerpt.py` | `--check` exits 1, writing nothing, when the verify excerpt of `wiki/reading-reports.md` is not what `verify.py --platform retrodeck` prints now |
|
||||
| `run_tests.py` | `--jobs` sets how many test modules run at once (default a third of the cores, at most 6) |
|
||||
| `check_buildbot_system.py` | `--update` refreshes the entries found stale, `--json`, `--registry` |
|
||||
| `check_freshness.py` | `--cache-dir`, `--native-cache-dir` (originals of the native export) and `--truth-dir` move the caches it reads |
|
||||
|
||||
Reference in new issue
Block a user