mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 08:58:36 +00:00
Check the explicit launcher update exit status
(cherry picked from commit 674c6676ee)
This commit is contained in:
@ -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]))
|
||||
|
||||
Reference in New Issue
Block a user