fix: fail install --check when files are missing

This commit is contained in:
Abdessamad Derraz committed 2026-10-16 22:09:12 +02:00
1 parent a906a49643
commit 8892432866
5 files changed
+17 -3

No files matched your search

+1 -1
View File
@@ -8,7 +8,7 @@ param(
$ErrorActionPreference = "Stop"
$defaultInstallUrl = "https://raw.githubusercontent.com/Abdess/retrobios/main/install.py"
$defaultInstallSha256 = "f9e46dd53fc7501ddf18ece3fc7f08dbf738c617fec93707c6a7f40e8db39673"
$defaultInstallSha256 = "e0d8fad4e7e55afa57c412e98726992d82b92286b752c9a8cce0978f0a355127"
$maximumInstallerBytes = 2MB
$installer = if ($PSScriptRoot) { Join-Path $PSScriptRoot "install.py" } else { $null }
$temporary = $null
+5
View File
@@ -2702,6 +2702,7 @@ def _install(args: argparse.Namespace, real_stdout) -> None:
total_bytes = 0
total_seconds = 0.0
total_declined = 0
check_pending = 0
failures: list[tuple[str, str]] = []
installed_paths: list[Path] = []
@@ -2881,6 +2882,7 @@ def _install(args: argparse.Namespace, real_stdout) -> None:
if args.check:
if to_download:
print(f"\n {len(to_download)} files need downloading.")
check_pending += len(to_download)
else:
print("\n All files up to date.")
continue
@@ -2960,6 +2962,9 @@ def _install(args: argparse.Namespace, real_stdout) -> None:
)
sys.stdout = real_stdout
# A check scripted as `--check && launch` reads the exit code only.
if args.check and check_pending:
sys.exit(1)
if not args.check and not listing and not args.dry_run:
_report_outcome(
installed_paths,
+1 -1
View File
@@ -18,7 +18,7 @@ esac
TEMP_INSTALLER=""
TEMP_DIRECTORY=""
DEFAULT_INSTALL_URL="https://raw.githubusercontent.com/Abdess/retrobios/main/install.py"
DEFAULT_INSTALL_SHA256="f9e46dd53fc7501ddf18ece3fc7f08dbf738c617fec93707c6a7f40e8db39673"
DEFAULT_INSTALL_SHA256="e0d8fad4e7e55afa57c412e98726992d82b92286b752c9a8cce0978f0a355127"
MAX_INSTALLER_BYTES=2097152
cleanup() {
+8
View File
@@ -946,6 +946,14 @@ class InstallerStaysOnPython38AndTheStdlib(unittest.TestCase):
self.assertEqual(proc.returncode, 0, proc.stdout + proc.stderr)
self.assertNotIn("Traceback", proc.stderr)
self.assertTrue((dest / "lynxboot.img").is_file())
# A check is scripted as `--check && launch`: missing files fail it.
proc = subprocess.run(
base + ["--dest", str(home / "empty"), "--system", "atari-lynx", "--check"],
cwd=REPO_ROOT, env=env, capture_output=True, text=True, timeout=300,
check=False,
)
self.assertEqual(proc.returncode, 1, proc.stdout + proc.stderr)
self.assertIn("need downloading", proc.stdout)
def test_no_syntax_a_312_parser_lets_through(self):
"""Parenthesized context managers (3.9) and f-strings reusing their
+2 -1
View File
@@ -224,7 +224,8 @@ what the options name, everything by default.
| `--standalone-copies` | Also copy into detected standalone emulator directories |
| `--help`, `-h` | Print the option list and exit |
`--check` reads the same file list, hashes the destination and exits. Without
`--check` reads the same file list, hashes the destination and exits, with
code 1 when a file is missing or does not match and 0 when every one does. Without
it, a file already present with the expected hash is left untouched, and one
whose contents do not match is re-downloaded and replaced by the verified copy.
Files the list does not name are never read, moved or deleted.