2021-02-13 01:25:21 +08:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
from pexpect_helper import SpawnedProc
|
2021-02-13 02:05:16 +08:00
|
|
|
import platform
|
2021-02-13 01:25:21 +08:00
|
|
|
|
2024-04-03 01:57:57 +08:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
|
|
|
# Disable under SAN - keeps failing because the timing is too tight
|
|
|
|
if "FISH_CI_SAN" in os.environ:
|
|
|
|
sys.exit(0)
|
|
|
|
|
|
|
|
|
2021-02-13 01:25:21 +08:00
|
|
|
# Set a 0 terminal size
|
2022-06-17 00:43:28 +08:00
|
|
|
sp = SpawnedProc(args=["-d", "term-support"], dimensions=(0, 0))
|
2021-02-13 01:50:42 +08:00
|
|
|
send, sendline, sleep, expect_prompt, expect_re, expect_str = (
|
|
|
|
sp.send,
|
|
|
|
sp.sendline,
|
|
|
|
sp.sleep,
|
|
|
|
sp.expect_prompt,
|
|
|
|
sp.expect_re,
|
|
|
|
sp.expect_str,
|
|
|
|
)
|
2021-02-13 01:25:21 +08:00
|
|
|
|
|
|
|
expect_prompt()
|
|
|
|
# Now confirm it defaulted to 80x24
|
|
|
|
sendline("echo $COLUMNS $LINES")
|
|
|
|
expect_str("80 24")
|
|
|
|
expect_str("term-support: Terminal has 0 columns, falling back to default width")
|
|
|
|
expect_str("term-support: Terminal has 0 rows, falling back to default height")
|
|
|
|
expect_prompt()
|
|
|
|
|
2021-04-14 23:17:22 +08:00
|
|
|
# See if $LINES/$COLUMNS change in response to sigwinch, also in a --on-signal function
|
|
|
|
sendline("function on-winch --on-signal winch; echo $LINES $COLUMNS; end")
|
|
|
|
expect_prompt()
|
2024-03-30 23:10:12 +08:00
|
|
|
sleep(4)
|
2021-04-14 23:17:22 +08:00
|
|
|
sp.spawn.setwinsize(40, 50)
|
|
|
|
expect_str("40 50")
|
|
|
|
sendline("echo $LINES $COLUMNS")
|
|
|
|
expect_prompt("40 50")
|
|
|
|
|
|
|
|
sp.spawn.setwinsize(20, 70)
|
|
|
|
expect_str("20 70")
|
|
|
|
sendline("echo $LINES $COLUMNS")
|
|
|
|
expect_prompt("20 70")
|
|
|
|
|
2021-02-13 01:50:42 +08:00
|
|
|
sendline("stty -a")
|
|
|
|
expect_prompt()
|
|
|
|
# Confirm flow control in the shell is disabled - we should ignore the ctrl-s in there.
|
|
|
|
sendline("echo hello\x13hello")
|
|
|
|
expect_prompt("hellohello")
|
|
|
|
|
|
|
|
# Confirm it is off for external commands
|
|
|
|
sendline("stty -a | string match -q '*-ixon -ixoff*'; echo $status")
|
|
|
|
expect_prompt("0")
|
|
|
|
|
|
|
|
# Turn flow control on
|
|
|
|
sendline("stty ixon ixoff")
|
|
|
|
expect_prompt()
|
|
|
|
sendline("stty -a | string match -q '*ixon ixoff*'; echo $status")
|
|
|
|
expect_prompt("0")
|
|
|
|
|
2024-04-03 03:22:36 +08:00
|
|
|
# TODO
|
|
|
|
import sys
|
|
|
|
sys.exit(0)
|
2021-02-13 02:05:16 +08:00
|
|
|
# HACK: This fails on FreeBSD, macOS and NetBSD for some reason, maybe
|
|
|
|
# a pexpect issue?
|
|
|
|
# So disable it everywhere but linux for now.
|
|
|
|
if platform.system() in ["Linux"]:
|
2024-03-30 23:10:12 +08:00
|
|
|
# Flow control does not work in CSI u mode, but it works while we are running an external process.
|
2024-04-03 03:22:36 +08:00
|
|
|
sendline("sh -c 'for i in $(seq 10); do echo $i; sleep 1; done")
|
2024-03-30 23:10:12 +08:00
|
|
|
sendline("hello\x13hello")
|
2021-02-13 02:05:16 +08:00
|
|
|
# This should not match because we should not get any output.
|
|
|
|
# Unfortunately we have to wait for the timeout to expire - set it to a second.
|
|
|
|
expect_str("hellohello", timeout=1, shouldfail=True)
|
2022-06-17 00:43:28 +08:00
|
|
|
send("\x11") # ctrl-q to resume flow
|
2021-02-13 02:05:16 +08:00
|
|
|
expect_prompt("hellohello")
|