2020-06-08 15:08:48 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
from pexpect_helper import SpawnedProc
|
|
|
|
|
|
|
|
sp = SpawnedProc()
|
2021-07-27 16:49:55 +00:00
|
|
|
send, sendline, sleep, expect_prompt, expect_str = sp.send, sp.sendline, sp.sleep, sp.expect_prompt, sp.expect_str
|
2020-06-08 15:08:48 +00:00
|
|
|
expect_prompt()
|
|
|
|
|
|
|
|
sendline("bind '~' 'handle_tilde'")
|
|
|
|
expect_prompt()
|
|
|
|
|
|
|
|
# printing the current buffer should not remove quoting
|
2020-06-08 15:32:56 +00:00
|
|
|
sendline(
|
|
|
|
"function handle_tilde; echo; echo '@GUARD:1@'; commandline -b; echo '@/GUARD:1@'; commandline -b ''; end"
|
|
|
|
)
|
2020-06-08 15:08:48 +00:00
|
|
|
expect_prompt()
|
2020-06-08 15:32:56 +00:00
|
|
|
sendline("echo \en one \"two three\" four'five six'{7} 'eight~")
|
2020-06-08 15:08:48 +00:00
|
|
|
expect_prompt("\r\n@GUARD:1@\r\n(.*)\r\n@/GUARD:1@\r\n")
|
|
|
|
|
|
|
|
# printing the buffer with -o should remove quoting
|
2020-06-08 15:32:56 +00:00
|
|
|
sendline(
|
|
|
|
"function handle_tilde; echo; echo '@GUARD:2@'; commandline -bo; echo '@/GUARD:2@'; commandline -b ''; end"
|
|
|
|
)
|
2020-06-08 15:08:48 +00:00
|
|
|
expect_prompt()
|
|
|
|
sendline("echo one \"two three\" four'five six'{7} 'eight~")
|
|
|
|
expect_prompt("\r\n@GUARD:2@\r\n(.*)\r\n@/GUARD:2@\r\n")
|
2020-09-11 17:23:26 +00:00
|
|
|
|
|
|
|
# Check that we don't infinitely loop here.
|
|
|
|
sendline("function fish_mode_prompt; commandline -f repaint; end")
|
|
|
|
expect_prompt()
|
|
|
|
|
|
|
|
sendline("echo foo")
|
|
|
|
expect_prompt("foo")
|
2021-07-20 20:18:03 +00:00
|
|
|
|
|
|
|
# commandline is empty when a command is executed.
|
|
|
|
sendline("set what (commandline)")
|
|
|
|
expect_prompt()
|
|
|
|
sendline('echo "<$what>"')
|
|
|
|
expect_prompt("<>")
|
2021-07-21 22:35:22 +00:00
|
|
|
|
|
|
|
# Test for undocumented -I flag.
|
|
|
|
# TODO: consider removing.
|
|
|
|
sendline("commandline -I foo")
|
|
|
|
expect_prompt("foo")
|
2021-07-27 16:49:55 +00:00
|
|
|
|
|
|
|
# See that the commandline is updated immediately inside completions.
|
|
|
|
sendline("complete -c foo -xa '(commandline)'")
|
|
|
|
expect_prompt()
|
|
|
|
send("foo bar \t")
|
|
|
|
expect_str("foo bar foo\ bar\ ")
|