mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-03-27 14:45:13 +08:00
Reformat pexpects
These are now python scripts
This commit is contained in:
parent
3c6055c3e0
commit
10fbdd34e7
@ -10,7 +10,9 @@ expect_prompt()
|
|||||||
|
|
||||||
send("echo ready to go\r")
|
send("echo ready to go\r")
|
||||||
expect_prompt("\r\nready to go\r\n")
|
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()
|
expect_prompt()
|
||||||
|
|
||||||
# normal mode
|
# normal mode
|
||||||
|
@ -9,13 +9,17 @@ sendline("bind '~' 'handle_tilde'")
|
|||||||
expect_prompt()
|
expect_prompt()
|
||||||
|
|
||||||
# printing the current buffer should not remove quoting
|
# 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()
|
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")
|
expect_prompt("\r\n@GUARD:1@\r\n(.*)\r\n@/GUARD:1@\r\n")
|
||||||
|
|
||||||
# printing the buffer with -o should remove quoting
|
# 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()
|
expect_prompt()
|
||||||
sendline("echo one \"two three\" four'five six'{7} 'eight~")
|
sendline("echo one \"two three\" four'five six'{7} 'eight~")
|
||||||
expect_prompt("\r\n@GUARD:2@\r\n(.*)\r\n@/GUARD:2@\r\n")
|
expect_prompt("\r\n@GUARD:2@\r\n(.*)\r\n@/GUARD:2@\r\n")
|
||||||
|
@ -2,10 +2,17 @@
|
|||||||
from pexpect_helper import SpawnedProc
|
from pexpect_helper import SpawnedProc
|
||||||
|
|
||||||
sp = 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()
|
expect_prompt()
|
||||||
|
|
||||||
sendline("""
|
sendline(
|
||||||
|
"""
|
||||||
complete -c my_is -n 'test (count (commandline -opc)) = 1' -xa arg
|
complete -c my_is -n 'test (count (commandline -opc)) = 1' -xa arg
|
||||||
complete -c my_is -n '__fish_seen_subcommand_from not' -xa '(
|
complete -c my_is -n '__fish_seen_subcommand_from not' -xa '(
|
||||||
set -l cmd (commandline -opc) (commandline -ct)
|
set -l cmd (commandline -opc) (commandline -ct)
|
||||||
@ -13,7 +20,8 @@ sendline("""
|
|||||||
commandline --replace --current-process $cmd
|
commandline --replace --current-process $cmd
|
||||||
complete -C"$cmd"
|
complete -C"$cmd"
|
||||||
)'
|
)'
|
||||||
""")
|
"""
|
||||||
|
)
|
||||||
|
|
||||||
send("my_is not \t")
|
send("my_is not \t")
|
||||||
send("still.alive")
|
send("still.alive")
|
||||||
|
@ -4,7 +4,13 @@ import subprocess
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
sp = 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()
|
expect_prompt()
|
||||||
|
|
||||||
# Verify that if we attempt to exit with a job in the background we get warned
|
# 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")
|
send("sleep 111 &\r")
|
||||||
expect_prompt()
|
expect_prompt()
|
||||||
send("exit\r")
|
send("exit\r")
|
||||||
expect_re("""There are still jobs active:\r
|
expect_re(
|
||||||
|
"""There are still jobs active:\r
|
||||||
\r
|
\r
|
||||||
PID Command\r
|
PID Command\r
|
||||||
*\\d+ sleep 111 &\r
|
*\\d+ sleep 111 &\r
|
||||||
\r
|
\r
|
||||||
A second attempt to exit will terminate them.\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()
|
expect_prompt()
|
||||||
|
|
||||||
# Running anything other than `exit` should result in the same warning with
|
# Running anything other than `exit` should result in the same warning with
|
||||||
@ -26,20 +34,24 @@ expect_prompt()
|
|||||||
send("sleep 113 &\r")
|
send("sleep 113 &\r")
|
||||||
expect_prompt()
|
expect_prompt()
|
||||||
send("exit\r")
|
send("exit\r")
|
||||||
expect_re("""There are still jobs active:\r
|
expect_re(
|
||||||
|
"""There are still jobs active:\r
|
||||||
\r
|
\r
|
||||||
PID Command\r
|
PID Command\r
|
||||||
*\\d+ sleep 113 &\r
|
*\\d+ sleep 113 &\r
|
||||||
*\\d+ sleep 111 &\r
|
*\\d+ sleep 111 &\r
|
||||||
\r
|
\r
|
||||||
A second attempt to exit will terminate them.\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()
|
expect_prompt()
|
||||||
|
|
||||||
# Verify that asking to exit a second time does so.
|
# Verify that asking to exit a second time does so.
|
||||||
send("exit\r")
|
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:
|
if proc.returncode == 0:
|
||||||
print("Commands still running")
|
print("Commands still running")
|
||||||
print(proc.stdout)
|
print(proc.stdout)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user