From f49a4e7e745a07bca64cc84f3714027a2fa32618 Mon Sep 17 00:00:00 2001 From: MoonEyes <14891700+MoonEyes@users.noreply.github.com> Date: Wed, 2 Dec 2026 11:04:33 +0100 Subject: [PATCH] leonida_mods: launch check reports a missing DLL and checks the executable it starts Two points raised in review of #358: - check_launch_files left out a manifest DLL that the package does not contain, so a partially copied package passed. Every DLL the manifest lists is now checked; a missing one fails with check_files' "cannot read it". - The check read the executable name from the manifest while runtime_command starts EXPECTED_EXE. The check now uses EXPECTED_EXE, so what is verified is what is started. Two tests cover them. Co-Authored-By: Claude Opus 5.5 --- tests/test_leonida_mods.py | 18 ++++++++++++++++++ tools/leonida_mods.py | 6 +++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/tests/test_leonida_mods.py b/tests/test_leonida_mods.py index 244764c88..457f5f93f 100644 --- a/tests/test_leonida_mods.py +++ b/tests/test_leonida_mods.py @@ -334,6 +334,7 @@ class LaunchCheckTests(unittest.TestCase): tmp = tempfile.TemporaryDirectory() self.addCleanup(tmp.cleanup) self.port, self.game, versions = (Path(tmp.name, n) for n in ("port", "game", "versions")) + self.versions = versions for folder in (self.port, self.game, versions): folder.mkdir() launcher = "gta6rt.exe" if os.name == "nt" else "gta6rt.sh" @@ -397,6 +398,23 @@ class LaunchCheckTests(unittest.TestCase): self.assertIn("no version manifest", err) self.assertEqual(self.run_cli("--image", str(self.game / leonida_mods.EXPECTED_EXE)), (0, "", True)) + def test_declared_dll_missing_from_the_package_refuses_to_start(self): + self.game.joinpath("Fake.dll").unlink() + code, err, started = self.run_cli() + self.assertEqual((code, started), (2, False)) + self.assertIn("Fake.dll: cannot read it", err) + self.assertEqual(len(err.strip().splitlines()), 1) + + def test_checks_the_executable_that_is_started_not_the_manifest_name(self): + manifest = self.versions / "xbox-9.9.json" + data = json.loads(manifest.read_text(encoding="utf-8")) + data["expected_exe"] = "other_name.exe" + write_json(manifest, data) + self.game.joinpath(leonida_mods.EXPECTED_EXE).write_bytes(self.exe + b"!") + code, err, started = self.run_cli() + self.assertEqual((code, started), (2, False)) + self.assertIn(f"{leonida_mods.EXPECTED_EXE}: size is ", err) + def test_print_reads_nothing(self): self.game.joinpath("Fake.dll").write_bytes(b"MZ") with mock.patch.object(leonida_mods, "check_files", side_effect=AssertionError("checked")): diff --git a/tools/leonida_mods.py b/tools/leonida_mods.py index 63f947b52..39c5244fb 100644 --- a/tools/leonida_mods.py +++ b/tools/leonida_mods.py @@ -645,11 +645,11 @@ def check_launch_files(args: argparse.Namespace) -> None: raise ModsError(f"{game}: no version manifest in game/ matches its MicrosoftGame.Config, so " f"{EXPECTED_EXE} and its DLLs can't be checked; pass --image to run a stand-in executable") files = [(os.path.join(game, rel), info["size"], info["sha256"]) for rel, info in version["files"].items() - if rel.lower().endswith(".dll") and os.path.isfile(os.path.join(game, rel))] + if rel.lower().endswith(".dll")] # a declared DLL the package lacks is a mismatch too if not args.image: - exe = version.get("expected_exe", EXPECTED_EXE) if "expected_exe_sha256" in version: - files.append((os.path.join(game, exe), version["expected_exe_size"], version["expected_exe_sha256"])) + # the file runtime_command starts, so the check cannot pass on a different one + files.append((os.path.join(game, EXPECTED_EXE), version["expected_exe_size"], version["expected_exe_sha256"])) try: check_files(files, os.path.join(port, LAUNCH_CACHE)) except ManifestError as exc: