fix: count only the names retropie help gains

The report listed every file a profiled core reads as added (1360),
while the export appends one name to one scriptmodule.
This commit is contained in:
Abdessamad Derraz committed 2026-10-21 05:05:00 +02:00
1 parent 348c56e94c
commit f796155e1a
3 files changed
+46 -12232

No files matched your search

-12231
View File
File diff suppressed because it is too large. Load diff
+15 -1
View File
@@ -316,6 +316,7 @@ class Exporter(BaseExporter):
str(a).lower() for a in (fe.native("aliases", []) or [])
)
self._skipped: dict[str, list[str]] = {}
self._named: set[int] = set()
produced: dict[str, str] = {}
def skip(reason: str, module: str) -> None:
@@ -360,7 +361,8 @@ class Exporter(BaseExporter):
| {str(a).lower() for a in (fe.native("aliases", []) or [])}) & listed
and (slot := self._slot_of(fe)) is not None
}
missing = self._in_search_order(self._one_per_slot(candidates, filled))
proposed = self._one_per_slot(candidates, filled)
missing = self._in_search_order(proposed)
if not missing:
continue
@@ -383,9 +385,21 @@ class Exporter(BaseExporter):
f'rp_module_help="{new_help}"',
1,
)
self._named.update(id(fe) for fe in proposed)
return produced
def lands(self, fe: NativeFile) -> bool:
"""An addition lands only where a help sentence now names it.
Every file a profiled core reads is writable in principle, yet the
render appends names to a handful of sentences: counting the rest
listed 1360 additions for one changed scriptmodule.
"""
if fe.platform is not None:
return self.writable(fe)
return id(fe) in getattr(self, "_named", set())
def outcome(
self,
systems: dict[str, NativeSystem],
+31
View File
@@ -289,6 +289,37 @@ class ReportedChangesAreTheDiff(unittest.TestCase):
}
self.assertEqual(reported_added, added)
def test_retropie(self):
"""Each addition is a name a help sentence gains, and no other: the
report counted every file a profiled core reads as added."""
from common import load_platform_config, native_layer
from exporter import discover_exporters
from exporter.baseline import build_native_model
archive = UPSTREAM_CACHE / "retropie" / "RetroPie-Setup.tar.gz"
if not archive.is_file():
self.skipTest("no cached original for retropie")
config = load_platform_config("retropie", str(ROOT / "platforms"))
truth = export_native.current_truth("retropie", config, str(ROOT / "platforms"))
scraped = native_layer(config)
systems, report = build_native_model(truth, scraped)
exporter = discover_exporters()["retropie"]()
originals = exporter.unpack(archive.read_bytes())
produced = exporter.render(systems, report, originals, scraped)
self.assertTrue(produced, "nothing changed, the comparison proves nothing")
gained: set[str] = set()
for relative, text in produced.items():
before = exporter.modules({relative: originals[relative]})[relative][1]
after = exporter.modules({relative: text})[relative][1]
gained |= exporter._listed(after) - exporter._listed(before)
changes = export_native.landed_changes(exporter, systems).records
reported = {c["name"].lower() for c in changes if c["kind"] == "added"}
self.assertEqual(reported, gained)
self.assertEqual(
sum(c["kind"] == "added" for c in changes), len(gained),
"one name counted under several entries",
)
class ThePageShowsEachValueBeforeAndAfter(unittest.TestCase):
"""A list of names gave a maintainer nothing to check a correction