diff --git a/tests/test_leonida_launcher.py b/tests/test_leonida_launcher.py index 87d9b9ca0..399354179 100644 --- a/tests/test_leonida_launcher.py +++ b/tests/test_leonida_launcher.py @@ -1996,13 +1996,15 @@ class LauncherBatTests(unittest.TestCase): def test_an_update_that_replaces_it_while_it_runs_ends_cleanly(self): # cmd reads the next line of a running batch file from the byte where it stopped. The Launcher.bat before # the overhaul stopped at byte 749 (after its python line, CRLF): there the new file must hold only :: lines - # (labels, skipped from any byte) up to a plain exit, and its own python line must end the script itself. - # That exit is `exit /b` with no code: an update run from the console keeps git's or the build's code there. + # (labels, skipped from any byte) up to the exit, and its own python line must end the script itself. + # The exit passes ERRORLEVEL explicitly so Wine's CMD also returns git's or the build's status. raw = (ROOT / "Launcher.bat").read_bytes() if b"\r\n" not in raw: # a checkout without the CRLF attribute applied raw = raw.replace(b"\n", b"\r\n") start = raw.index(b"goto :start\r\n") + len(b"goto :start\r\n") - stop = raw.index(b"exit /b\r\n:start\r\n") + resume_exit = b"exit /b %ERRORLEVEL%\r\n:start\r\n" + self.assertIn(resume_exit, raw, "the replacement batch must return the updater's status") + stop = raw.index(resume_exit) self.assertLess(start, 749) self.assertGreater(stop, 749 + 200) self.assertTrue(all(line and set(line) == {":"} for line in raw[start:stop].decode("ascii").split("\r\n")[:-1]))