From 0530c007a8482b28547fb50c98d5d382f413051b Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Sat, 21 Nov 2026 21:41:18 +0100 Subject: [PATCH] fix: run only programs of proven launchers --- scripts/resolve/launchers.py | 6 +++--- scripts/resolve/standalone.py | 2 +- tests/test_launcher_evidence.py | 15 ++++++++++++++- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/scripts/resolve/launchers.py b/scripts/resolve/launchers.py index 0d0a058a6..0f4e14784 100644 --- a/scripts/resolve/launchers.py +++ b/scripts/resolve/launchers.py @@ -953,11 +953,11 @@ class ExecutedFile: source_ref: str -def executed_files(config: dict) -> list[ExecutedFile]: - """Every file a platform's launchers execute, from records passing it to exec.""" +def executed_files(config: dict, profiles: Mapping[str, dict]) -> list[ExecutedFile]: + """Every file a platform's launchers execute, from bound records passing it to exec.""" base = str(config.get("base_destination") or "bios") found: list[ExecutedFile] = [] - for record in config.get("launchers") or []: + for record in bound_launchers(config, profiles): if record.get("kind") not in ("fixed_name", "names_searched"): continue if str(record.get("passes_to") or "").strip() != "exec": diff --git a/scripts/resolve/standalone.py b/scripts/resolve/standalone.py index dd28a650b..46775e619 100644 --- a/scripts/resolve/standalone.py +++ b/scripts/resolve/standalone.py @@ -143,7 +143,7 @@ def standalone_set(config: dict, profiles: Mapping[str, dict]) -> set[str]: } names |= { EXECUTED_PREFIX + json.dumps([run.emulator, run.name, run.place, run.source_ref]) - for run in executed_files(config) + for run in executed_files(config, profiles) } return names | content_folder_tags(config) diff --git a/tests/test_launcher_evidence.py b/tests/test_launcher_evidence.py index e6e7740c2..e6b23b345 100644 --- a/tests/test_launcher_evidence.py +++ b/tests/test_launcher_evidence.py @@ -18,7 +18,7 @@ import yaml from model.platforms import load_platform_config from model.profiles import load_emulator_profiles from resolve.categories import EntryCategories -from resolve.layout import HANDED_PREFIX +from resolve.layout import EXECUTED_PREFIX, HANDED_PREFIX from resolve.standalone import standalone_set from resolve.launchers import ( bound_launchers, @@ -217,6 +217,19 @@ class Gate(unittest.TestCase): self.assertFalse([t for t in standalone_set(config, {"duck": profile(config_reads=[])}) if t.startswith(HANDED_PREFIX)]) + def test_an_unproven_record_executes_nothing(self) -> None: + code = {"emulator": "duck", "kind": "fixed_name", "names": ["run.sh"], "passes_to": "exec", + "search_dir": "/storage/roms/bios", "source_ref": "start.sh:3"} + cited = {**code, "source_ref": "duck/config/settings.ini:4, start.sh:3"} + + def executed(launcher: dict) -> list[str]: + config = {**self.config(launcher), "standalone_cores": ["duck"]} + return [t for t in standalone_set(config, {"duck": profile()}) + if t.startswith(EXECUTED_PREFIX)] + + self.assertEqual(len(executed(code)), 1) + self.assertEqual(executed(cited), []) + def test_an_unproven_record_proves_no_read(self) -> None: named = record(kind="fixed_name", names=["tos.img"], passes_to="settings.ini [BIOS] PathPAL") config = {**self.config(named), "cores": ["duck"], "standalone_cores": ["duck"],