2020-06-08 15:12:49 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
from pexpect_helper import SpawnedProc
|
2021-07-11 23:50:21 +00:00
|
|
|
import os
|
2024-03-30 15:10:12 +00:00
|
|
|
import sys
|
2021-07-11 23:50:21 +00:00
|
|
|
import signal
|
2024-03-30 15:10:12 +00:00
|
|
|
import platform
|
|
|
|
|
2024-04-12 10:32:46 +00:00
|
|
|
if platform.system() == "FreeBSD": # Spurious failure. TODO Only disable this in CI.
|
|
|
|
sys.exit(127)
|
|
|
|
|
2024-03-30 15:10:12 +00:00
|
|
|
if "CI" in os.environ and platform.system() == "Darwin":
|
|
|
|
sys.exit(127)
|
2020-06-08 15:12:49 +00:00
|
|
|
|
|
|
|
sp = SpawnedProc()
|
|
|
|
send, sendline, sleep, expect_prompt = sp.send, sp.sendline, sp.sleep, sp.expect_prompt
|
|
|
|
expect_prompt()
|
|
|
|
|
|
|
|
send("set -g fish_key_bindings fish_vi_key_bindings\r")
|
|
|
|
expect_prompt()
|
|
|
|
|
|
|
|
send("echo ready to go\r")
|
2024-04-02 19:22:36 +00:00
|
|
|
expect_prompt(f"\r\n.*ready to go\r\n")
|
2020-06-08 15:32:56 +00:00
|
|
|
send(
|
|
|
|
"function add_change --on-variable fish_bind_mode ; set -g MODE_CHANGES $MODE_CHANGES $fish_bind_mode ; end\r"
|
|
|
|
)
|
2020-06-08 15:12:49 +00:00
|
|
|
expect_prompt()
|
|
|
|
|
2024-05-06 01:23:05 +00:00
|
|
|
sendline("echo 'Catch' 'up'")
|
|
|
|
expect_prompt("Catch up")
|
|
|
|
|
2020-06-08 15:12:49 +00:00
|
|
|
# normal mode
|
|
|
|
send("\033")
|
2024-03-30 15:10:12 +00:00
|
|
|
sleep(10 if "CI" in os.environ else 1)
|
2020-06-08 15:12:49 +00:00
|
|
|
|
|
|
|
# insert mode
|
|
|
|
send("i")
|
2024-03-30 15:10:12 +00:00
|
|
|
sleep(10 if "CI" in os.environ else 1)
|
2020-06-08 15:12:49 +00:00
|
|
|
|
|
|
|
# back to normal mode
|
|
|
|
send("\033")
|
2024-03-30 15:10:12 +00:00
|
|
|
sleep(10 if "CI" in os.environ else 1)
|
2020-06-08 15:12:49 +00:00
|
|
|
|
|
|
|
# insert mode again
|
|
|
|
send("i")
|
2024-03-30 15:10:12 +00:00
|
|
|
sleep(10 if "CI" in os.environ else 1)
|
2020-06-08 15:12:49 +00:00
|
|
|
|
|
|
|
send("echo mode changes: $MODE_CHANGES\r")
|
2024-04-02 19:22:36 +00:00
|
|
|
expect_prompt("\r\n.*mode changes: default insert default insert\r\n")
|
2021-07-11 23:50:21 +00:00
|
|
|
|
|
|
|
# Regression test for #8125.
|
|
|
|
# Control-C should return us to insert mode.
|
|
|
|
send("set -e MODE_CHANGES\r")
|
|
|
|
expect_prompt()
|
|
|
|
|
2021-07-12 16:45:46 +00:00
|
|
|
timeout = 0.15
|
2021-07-12 16:54:40 +00:00
|
|
|
|
2021-07-12 16:45:46 +00:00
|
|
|
if "CI" in os.environ:
|
2021-12-29 05:35:30 +00:00
|
|
|
# This doesn't work under TSan, because TSan prevents select() being
|
|
|
|
# interrupted by a signal.
|
2021-07-12 16:54:40 +00:00
|
|
|
import sys
|
2022-06-16 16:43:28 +00:00
|
|
|
|
2021-07-12 16:54:40 +00:00
|
|
|
print("SKIPPING the last of bind_mode_events.py")
|
|
|
|
sys.exit(0)
|
2021-07-12 16:45:46 +00:00
|
|
|
|
2021-07-11 23:50:21 +00:00
|
|
|
# Put some text on the command line and then go back to normal mode.
|
|
|
|
send("echo stuff")
|
|
|
|
sp.expect_str("echo stuff")
|
|
|
|
send("\033")
|
2021-07-12 16:45:46 +00:00
|
|
|
sleep(timeout)
|
2021-07-11 23:50:21 +00:00
|
|
|
|
|
|
|
os.kill(sp.spawn.pid, signal.SIGINT)
|
2021-07-12 16:45:46 +00:00
|
|
|
sleep(timeout)
|
2021-07-11 23:50:21 +00:00
|
|
|
|
|
|
|
# We should be back in insert mode now.
|
|
|
|
send("echo mode changes: $MODE_CHANGES\r")
|
2024-04-02 19:22:36 +00:00
|
|
|
expect_prompt("\r\n.*mode changes: default insert\r\n")
|