fix: make two installer tests runner-proof

The old-card test read the screen without reading what the key just drew, and pressed Enter twelve rows past its folder on a slow runner. The launcher device now has a sudo that refuses, as a runner's passwordless sudo ran the fake mapper as root and recorded nothing.
This commit is contained in:
Abdessamad Derraz committed 2026-10-23 23:49:52 +02:00
1 parent 3609f66401
commit 702e059863
2 files changed
+21 -1

No files matched your search

+4
View File
@@ -677,6 +677,10 @@ class Device:
# A probe that cannot connect is offline (curl exit 7).
self.tool("curl", '#!/bin/sh\nexit "${FAKE_CURL:-0}"\n')
self.tool("pgrep", '#!/bin/sh\nexit "${FAKE_PGREP:-1}"\n')
# A runner's real sudo needs no password: the Tools entry then ran
# the fake mapper as root, with a reset environment, and recorded
# nothing. A device has no sudo unless a test gives it one.
self.tool("sudo", "#!/bin/sh\nexit 1\n")
fonts = self.root / "fonts"
fonts.mkdir()
for name in ("Lat7-TerminusBold32x16", "Lat7-TerminusBold22x11",
+17 -1
View File
@@ -2818,6 +2818,21 @@ class Pty:
def text(self) -> str:
return "\n".join(line.rstrip() for line in self.screen.display)
def settle(self, quiet: float = 0.3, timeout: float = 10.0) -> str:
"""The screen once nothing more arrives for `quiet` seconds.
text() shows only what was read: a loop that sent a key and looked
again saw the screen before the key, and on a slow runner pressed
Enter twelve rows past the folder it was looking for.
"""
end = time.monotonic() + timeout
while time.monotonic() < end:
if not select.select([self.fd], [], [], quiet)[0]:
break
if not self._pump(0):
break
return self.text()
def wait(self, needle: str, timeout: float = 20.0) -> str:
end = time.monotonic() + timeout
while time.monotonic() < end:
@@ -3124,9 +3139,10 @@ class EndToEnd(unittest.TestCase):
term.send(DOWN, DOWN, "\r")
term.wait("Choose the old card")
for _ in range(12):
if "> oldcard/" in term.text():
if "> oldcard/" in term.settle():
break
term.send(DOWN)
self.assertIn("> oldcard/", term.settle())
term.send("\r")
term.wait("> Use this folder")
term.send("\r")