From 12d28c0879f3de74fc5c64b779e5a0805299d964 Mon Sep 17 00:00:00 2001 From: natterman12 <92529018+natterman12@users.noreply.github.com> Date: Mon, 23 Nov 2026 21:14:02 -0500 Subject: [PATCH] tests: the drive-root cases give check() a manifest, and the mods run case writes the launcher Windows looks for Two standard-library tests fail on native Windows and are skipped or pass elsewhere: - test_make_game_paths: since BUILD-2367 main() takes a drive-root dump's top-level names from the version manifest, but the two drive-root cases still mocked check() as {} and patched os.listdir, so main() raised KeyError: 'expected_exe' before reaching the rule under test. They now pass a manifest with the same entries. - test_leonida_mods: test_run_print_builds_gta6rt_command wrote only gta6rt.sh, and runtime_executable() accepts only gta6rt.exe on Windows. It now writes the launcher of the platform it runs on. Tests only; no tool changes. Co-Authored-By: Claude Fable 5.2 --- tests/test_leonida_mods.py | 4 +++- tests/test_make_game_paths.py | 33 +++++++++++++++++++++------------ 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/tests/test_leonida_mods.py b/tests/test_leonida_mods.py index 6f9b43cfca..256bfe0920 100644 --- a/tests/test_leonida_mods.py +++ b/tests/test_leonida_mods.py @@ -152,7 +152,9 @@ def test_run_print_builds_gta6rt_command(self): game = Path(tmp, "game") port.mkdir() game.mkdir() - port.joinpath("gta6rt.sh").write_text("#!/bin/sh\n", encoding="utf-8") + # the launcher runtime_executable() looks for here: Windows takes only gta6rt.exe + launcher = "gta6rt.exe" if os.name == "nt" else "gta6rt.sh" + port.joinpath(launcher).write_bytes(b"MZ" if os.name == "nt" else b"#!/bin/sh\n") port.joinpath("game_path.txt").write_text(str(game) + "\n", encoding="utf-8") image = game / leonida_mods.EXPECTED_EXE image.write_bytes(b"MZ") diff --git a/tests/test_make_game_paths.py b/tests/test_make_game_paths.py index 7f7d8a5700..bee52e281f 100644 --- a/tests/test_make_game_paths.py +++ b/tests/test_make_game_paths.py @@ -39,13 +39,20 @@ def link(self, target, path): os.symlink(target, path, target_is_directory=True) self.addCleanup(os.unlink, path) - def run_build(self, game, out, work, rejected): + @staticmethod + def version(*top_level): + """A version manifest whose files sit in these top-level folders: at a drive-root --game, main() takes the + dump's own entries from the manifest (BUILD-2367), not from os.listdir.""" + return {"expected_exe": top_level[0] + "\\game.exe", + "files": {f"{name}/a.rpf": {} for name in top_level}} + + def run_build(self, game, out, work, rejected, version=None): argv = ["make_game.py", "--game", game, "--out", out, "--work", work, "--stages", "runtime", "--no-tui"] with ExitStack() as stack: stack.enter_context(patch.object(sys, "argv", argv)) stack.enter_context(patch("make_game.below_normal")) - stack.enter_context(patch("make_game.check", return_value={})) + stack.enter_context(patch("make_game.check", return_value=version or {})) stack.enter_context(patch("make_game.log")) preflight = stack.enter_context(patch("make_game.preflight")) build_runtime = stack.enter_context(patch("make_game.runtime")) @@ -94,13 +101,14 @@ def test_drive_root_game_folder_rules(self): drive = os.path.splitdrive(self.root)[0] + "\\" content_dir = os.path.join(drive, "Content") independent_dir = os.path.join(drive, "Leonida_Build") - with patch("os.listdir", return_value=["Content"]): - # Allowed: destination is an independent folder on the drive root - self.run_build(drive, independent_dir, os.path.join(independent_dir, "work"), rejected=False) - # Rejected: destination is inside the game dump's own top-level entry - self.run_build(drive, os.path.join(content_dir, "out"), os.path.join(self.root, "work"), rejected=True) - # Rejected: destination is the drive root itself - self.run_build(drive, drive, os.path.join(self.root, "work"), rejected=True) + version = self.version("Content") + # Allowed: destination is an independent folder on the drive root + self.run_build(drive, independent_dir, os.path.join(independent_dir, "work"), rejected=False, version=version) + # Rejected: destination is inside the game dump's own top-level entry + self.run_build(drive, os.path.join(content_dir, "out"), os.path.join(self.root, "work"), rejected=True, + version=version) + # Rejected: destination is the drive root itself + self.run_build(drive, drive, os.path.join(self.root, "work"), rejected=True, version=version) def test_drive_root_checks_entries_on_each_volume(self): if os.name != "nt": @@ -120,14 +128,15 @@ def realpath(path): (["MountedContent", "Content"], os.path.join(root, "Content")), (["Content", "MountedContent"], mounted_content), ): - with patch("os.listdir", return_value=entries), patch("os.path.realpath", side_effect=realpath): + version = self.version(*entries) + with patch("os.path.realpath", side_effect=realpath): for option in ("out", "work"): with self.subTest(protected=protected, option=option): destinations = {name: os.path.join(self.root, name) for name in ("out", "work")} destinations[option] = os.path.join(protected, "build") - self.run_build(root, **destinations, rejected=True) + self.run_build(root, **destinations, rejected=True, version=version) self.run_build(root, os.path.join(other_root, "Build"), - os.path.join(other_root, "Scratch"), rejected=False) + os.path.join(other_root, "Scratch"), rejected=False, version=version) if __name__ == "__main__":