mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-13 21:44:16 +00:00
Reformat pexpects
These are now python scripts
This commit is contained in:
parent
3c6055c3e0
commit
10fbdd34e7
4 changed files with 39 additions and 13 deletions
|
@ -10,7 +10,9 @@ expect_prompt()
|
|||
|
||||
send("echo ready to go\r")
|
||||
expect_prompt("\r\nready to go\r\n")
|
||||
send("function add_change --on-variable fish_bind_mode ; set -g MODE_CHANGES $MODE_CHANGES $fish_bind_mode ; end\r")
|
||||
send(
|
||||
"function add_change --on-variable fish_bind_mode ; set -g MODE_CHANGES $MODE_CHANGES $fish_bind_mode ; end\r"
|
||||
)
|
||||
expect_prompt()
|
||||
|
||||
# normal mode
|
||||
|
|
|
@ -9,13 +9,17 @@ sendline("bind '~' 'handle_tilde'")
|
|||
expect_prompt()
|
||||
|
||||
# printing the current buffer should not remove quoting
|
||||
sendline("function handle_tilde; echo; echo '@GUARD:1@'; commandline -b; echo '@/GUARD:1@'; commandline -b ''; end")
|
||||
sendline(
|
||||
"function handle_tilde; echo; echo '@GUARD:1@'; commandline -b; echo '@/GUARD:1@'; commandline -b ''; end"
|
||||
)
|
||||
expect_prompt()
|
||||
sendline ("echo \en one \"two three\" four'five six'{7} 'eight~")
|
||||
sendline("echo \en one \"two three\" four'five six'{7} 'eight~")
|
||||
expect_prompt("\r\n@GUARD:1@\r\n(.*)\r\n@/GUARD:1@\r\n")
|
||||
|
||||
# printing the buffer with -o should remove quoting
|
||||
sendline("function handle_tilde; echo; echo '@GUARD:2@'; commandline -bo; echo '@/GUARD:2@'; commandline -b ''; end")
|
||||
sendline(
|
||||
"function handle_tilde; echo; echo '@GUARD:2@'; commandline -bo; echo '@/GUARD:2@'; commandline -b ''; end"
|
||||
)
|
||||
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")
|
||||
|
|
|
@ -2,10 +2,17 @@
|
|||
from pexpect_helper import SpawnedProc
|
||||
|
||||
sp = SpawnedProc()
|
||||
send, sendline, sleep, expect_prompt, expect_re = sp.send, sp.sendline, sp.sleep, sp.expect_prompt, sp.expect_re
|
||||
send, sendline, sleep, expect_prompt, expect_re = (
|
||||
sp.send,
|
||||
sp.sendline,
|
||||
sp.sleep,
|
||||
sp.expect_prompt,
|
||||
sp.expect_re,
|
||||
)
|
||||
expect_prompt()
|
||||
|
||||
sendline("""
|
||||
sendline(
|
||||
"""
|
||||
complete -c my_is -n 'test (count (commandline -opc)) = 1' -xa arg
|
||||
complete -c my_is -n '__fish_seen_subcommand_from not' -xa '(
|
||||
set -l cmd (commandline -opc) (commandline -ct)
|
||||
|
@ -13,7 +20,8 @@ sendline("""
|
|||
commandline --replace --current-process $cmd
|
||||
complete -C"$cmd"
|
||||
)'
|
||||
""")
|
||||
"""
|
||||
)
|
||||
|
||||
send("my_is not \t")
|
||||
send("still.alive")
|
||||
|
|
|
@ -4,7 +4,13 @@ import subprocess
|
|||
import sys
|
||||
|
||||
sp = SpawnedProc()
|
||||
send, sendline, sleep, expect_prompt, expect_re = sp.send, sp.sendline, sp.sleep, sp.expect_prompt, sp.expect_re
|
||||
send, sendline, sleep, expect_prompt, expect_re = (
|
||||
sp.send,
|
||||
sp.sendline,
|
||||
sp.sleep,
|
||||
sp.expect_prompt,
|
||||
sp.expect_re,
|
||||
)
|
||||
expect_prompt()
|
||||
|
||||
# Verify that if we attempt to exit with a job in the background we get warned
|
||||
|
@ -12,13 +18,15 @@ expect_prompt()
|
|||
send("sleep 111 &\r")
|
||||
expect_prompt()
|
||||
send("exit\r")
|
||||
expect_re("""There are still jobs active:\r
|
||||
expect_re(
|
||||
"""There are still jobs active:\r
|
||||
\r
|
||||
PID Command\r
|
||||
*\\d+ sleep 111 &\r
|
||||
\r
|
||||
A second attempt to exit will terminate them.\r
|
||||
Use 'disown PID' to remove jobs from the list without terminating them.\r""")
|
||||
Use 'disown PID' to remove jobs from the list without terminating them.\r"""
|
||||
)
|
||||
expect_prompt()
|
||||
|
||||
# Running anything other than `exit` should result in the same warning with
|
||||
|
@ -26,20 +34,24 @@ expect_prompt()
|
|||
send("sleep 113 &\r")
|
||||
expect_prompt()
|
||||
send("exit\r")
|
||||
expect_re("""There are still jobs active:\r
|
||||
expect_re(
|
||||
"""There are still jobs active:\r
|
||||
\r
|
||||
PID Command\r
|
||||
*\\d+ sleep 113 &\r
|
||||
*\\d+ sleep 111 &\r
|
||||
\r
|
||||
A second attempt to exit will terminate them.\r
|
||||
Use 'disown PID' to remove jobs from the list without terminating them.\r""")
|
||||
Use 'disown PID' to remove jobs from the list without terminating them.\r"""
|
||||
)
|
||||
expect_prompt()
|
||||
|
||||
# Verify that asking to exit a second time does so.
|
||||
send("exit\r")
|
||||
|
||||
proc = subprocess.run(["pgrep", "-l", "-f", "sleep 11"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
proc = subprocess.run(
|
||||
["pgrep", "-l", "-f", "sleep 11"], stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
||||
)
|
||||
if proc.returncode == 0:
|
||||
print("Commands still running")
|
||||
print(proc.stdout)
|
||||
|
|
Loading…
Reference in a new issue