Skip to content

Commit 08b6c0e

Browse files
committed
e2e 845 does not compare PENDIN, which the BSD kernel sets whenever ICANON is turned back on and the next read clears
1 parent 8fad76c commit 08b6c0e

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

‎tests/e2e/845_play_game_restores_the_terminal.sh‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,18 @@ while True:
9797
break
9898
raw += chunk
9999
break
100-
before = open("before.txt").read().strip() if os.path.exists("before.txt") else None
101-
after = open("after.txt").read().strip() if os.path.exists("after.txt") else None
100+
# PENDIN (0x20000000 in a BSD `stty -g` lflag) is the kernel's own
101+
# bookkeeping: macOS sets it whenever ICANON is turned back on, and the next
102+
# read clears it. It is not a mode mcpp left behind, so it is not compared.
103+
def mode_of(path):
104+
if not os.path.exists(path):
105+
return None
106+
g = open(path).read().strip()
107+
if g.startswith("gfmt1:"):
108+
g = ":".join(f"lflag={int(f[6:], 16) & ~0x20000000:x}" if f.startswith("lflag=") else f
109+
for f in g.split(":"))
110+
return g
111+
before, after = mode_of("before.txt"), mode_of("after.txt")
102112
plain = re.sub(r"\x1b\[[0-9;?]*[A-Za-z]", "", raw.decode("utf-8", "replace")).replace("\r\n", "\n")
103113
print(plain)
104114
assert during is not None, "the build ended before the game could be observed"

0 commit comments

Comments
 (0)