2022-10-23 11:03:04 +08:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
from pexpect_helper import SpawnedProc
|
|
|
|
import os
|
|
|
|
import platform
|
|
|
|
import sys
|
|
|
|
|
|
|
|
sp = SpawnedProc()
|
|
|
|
send, sendline, sleep, expect_prompt, expect_re, expect_str = (
|
|
|
|
sp.send,
|
|
|
|
sp.sendline,
|
|
|
|
sp.sleep,
|
|
|
|
sp.expect_prompt,
|
|
|
|
sp.expect_re,
|
|
|
|
sp.expect_str,
|
|
|
|
)
|
|
|
|
expect_prompt()
|
|
|
|
|
|
|
|
# Fish should start in default-mode (i.e., emacs) bindings. The default escape
|
|
|
|
# timeout is 30ms.
|
|
|
|
#
|
|
|
|
# Because common CI systems are awful, we have to increase this:
|
|
|
|
|
|
|
|
sendline("set -g fish_escape_delay_ms 120")
|
|
|
|
expect_prompt("")
|
|
|
|
|
|
|
|
# Validate standalone behavior
|
|
|
|
sendline("status current-commandline")
|
2024-04-03 03:22:36 +08:00
|
|
|
expect_prompt("\r\n.*status current-commandline\r\n")
|
2022-10-23 11:03:04 +08:00
|
|
|
|
|
|
|
# Validate behavior as part of a command chain
|
2023-06-02 00:20:19 +08:00
|
|
|
sendline("true 7 && status current-commandline")
|
2024-04-03 03:22:36 +08:00
|
|
|
expect_prompt("\r\n.*true 7 && status current-commandline\r\n")
|
2022-10-23 11:03:04 +08:00
|
|
|
|
|
|
|
# Validate behavior when used in a function
|
2023-06-02 00:20:19 +08:00
|
|
|
sendline("function report; set -g last_cmdline (status current-commandline); end")
|
2022-10-23 11:03:04 +08:00
|
|
|
expect_prompt("")
|
|
|
|
sendline("report 27")
|
|
|
|
expect_prompt("")
|
|
|
|
sendline("echo $last_cmdline")
|
2024-04-03 03:22:36 +08:00
|
|
|
expect_prompt("\r\n.*report 27\r\n")
|
2022-10-23 11:03:04 +08:00
|
|
|
|
|
|
|
# Exit
|
2023-06-02 00:20:19 +08:00
|
|
|
send("\x04") # <c-d>
|
2022-10-23 11:03:04 +08:00
|
|
|
expect_str("")
|