From f96e7c10f400e934fead8375a28a80a987f2b079 Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Fri, 6 Nov 2026 03:27:29 +0100 Subject: [PATCH] fix: name a missing --from-md5-file --- scripts/generate_pack.py | 3 +++ tests/test_system_selection.py | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/scripts/generate_pack.py b/scripts/generate_pack.py index 87e5cadb6..196bda7ec 100644 --- a/scripts/generate_pack.py +++ b/scripts/generate_pack.py @@ -3573,6 +3573,9 @@ def _main(held: contextlib.ExitStack) -> None: except ValueError as exc: print(f"ERROR: {exc}", file=sys.stderr) sys.exit(1) + except OSError as exc: + print(f"ERROR: --from-md5-file {args.from_md5_file}: {exc.strerror}", file=sys.stderr) + sys.exit(1) if not hashes: print( f"ERROR: no hash in the input. Accepted: {ACCEPTED_HASHES}", diff --git a/tests/test_system_selection.py b/tests/test_system_selection.py index 3d554abf3..4811bcf25 100644 --- a/tests/test_system_selection.py +++ b/tests/test_system_selection.py @@ -375,6 +375,29 @@ class AMissingPlatformsDirIsRefused(unittest.TestCase): self.assertRegex(proc.stderr, r"ERROR: .*nosuch") +class AMissingInputFileIsNamed(unittest.TestCase): + """The documented `--from-md5-file missing.txt` ended on a + FileNotFoundError at the bottom of a stack trace.""" + + def _refused(self, argv: list[str], message: str) -> None: + proc = subprocess.run( + [sys.executable, *argv], capture_output=True, text=True, + cwd=str(REPO_ROOT), timeout=600, check=False, + env={**os.environ, "RETROBIOS_OFFLINE": "1"}, + ) + self.assertNotEqual(proc.returncode, 0, proc.stdout[-500:]) + self.assertNotIn("Traceback", proc.stderr, proc.stderr[-1500:]) + self.assertIn(message, proc.stderr) + + def test_a_missing_hash_list_is_named(self): + with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp: + self._refused( + ["scripts/generate_pack.py", "--platform", "batocera", "--from-md5-file", + "nosuch.txt", "--offline", "--output-dir", tmp], + "ERROR: --from-md5-file nosuch.txt: No such file or directory", + ) + + class StrictVerifyFailsOnACriticalMiss(unittest.TestCase): """verify exited 0 with a required file missing on an md5 platform, so the pipeline printed "verify OK" over a pack the frontend rejects."""