fix: stop the windows bootstrap on a silent server

This commit is contained in:
Abdessamad Derraz committed 2026-11-05 19:26:12 +01:00
1 parent c54a68c6ca
commit 62568f6d76
2 files changed
+28 -1

No files matched your search

+5 -1
View File
@@ -42,7 +42,11 @@
}
$temporary = Join-Path ([IO.Path]::GetTempPath()) ("retrobios-install-{0}.py" -f [Guid]::NewGuid())
try {
Invoke-WebRequest -Uri $uri -OutFile $temporary -UseBasicParsing
# A server that takes the connection and never answers (a
# captive portal, a proxy) held the window forever with no
# line: the wait for an answer stops after 30 s, as curl's
# --connect-timeout in install.sh.
Invoke-WebRequest -Uri $uri -OutFile $temporary -UseBasicParsing -TimeoutSec 30
} catch {
# The raw WebException read as a crash and named no next step.
throw ("The installer could not be downloaded from {0}: {1} " +
+23
View File
@@ -2807,6 +2807,29 @@ class APyLauncherWithoutARuntimeIsPassed(unittest.TestCase):
self.assertIn("installer ran", proc.stdout)
@unittest.skipUnless(shutil.which("pwsh"), "needs PowerShell")
class APowerShellDownloadThatNeverAnswersEnds(unittest.TestCase):
"""Invoke-WebRequest had no timeout: behind a server that takes the
connection and never answers, the window waited forever with no line."""
def test_a_silent_server_ends_on_the_network_advice(self):
folder = Path(_tempdir(self))
shutil.copy(REPO_ROOT / "install.ps1", folder / "install.ps1")
with socket.socket() as listener:
listener.bind(("127.0.0.1", 0))
listener.listen(4)
port = listener.getsockname()[1]
started = time.monotonic()
proc = subprocess.run(
["pwsh", "-NoProfile", "-File", str(folder / "install.ps1"), "--check"],
env={**os.environ,
"RETROBIOS_INSTALL_URL": f"https://127.0.0.1:{port}/install.py"},
capture_output=True, text=True, timeout=150, stdin=subprocess.DEVNULL)
self.assertLess(time.monotonic() - started, 120)
self.assertNotEqual(proc.returncode, 0)
self.assertIn("could not be downloaded", " ".join((proc.stdout + proc.stderr).split()))
class ThePowerShellWrapperPassesTheStatusOn(unittest.TestCase):
"""Every non-zero exit became a red "installer failed" exception and
code 1: a --check that found work read as a crash, 2 and 130 were lost."""