Move commandline test to pexpect

This commit is contained in:
Fabian Homborg 2020-06-08 17:08:48 +02:00
parent 413a6aec98
commit 7076880da9
4 changed files with 21 additions and 38 deletions

View File

@ -1,30 +0,0 @@
# vim: set filetype=expect:
spawn $fish
expect_prompt
send_line "bind '~' 'handle_tilde'"
expect_prompt
# printing the current buffer should not remove quoting
send_line "function handle_tilde; echo; echo '@GUARD:1@'; commandline -b; echo '@/GUARD:1@'; commandline -b ''; end"
expect_prompt
send_line {echo \en one "two three" four'five six'{7} 'eight~}
expect_prompt -re {\r\n@GUARD:1@\r\n(.*)\r\n@/GUARD:1@\r\n} {
puts "a:"
puts $expect_out(1,string)
} unmatched {
abort "Couldn't find guard 1"
}
# printing the buffer with -o should remove quoting
send_line "function handle_tilde; echo; echo '@GUARD:2@'; commandline -bo; echo '@/GUARD:2@'; commandline -b ''; end"
expect_prompt
send_line {echo one "two three" four'five six'{7} 'eight~}
expect_prompt -re {\r\n@GUARD:2@\r\n(.*)\r\n@/GUARD:2@\r\n} {
puts "b:"
puts [string map {\r {}} $expect_out(1,string)]
} unmatched {
abort "Couldn't find guard 2"
}

View File

@ -1,8 +0,0 @@
a:
echo \en one "two three" four'five six'{7} 'eight
b:
echo
one
two three
fourfive six{7}
eight

View File

@ -0,0 +1,21 @@
#!/usr/bin/env python3
from pexpect_helper import SpawnedProc
sp = SpawnedProc()
send, sendline, sleep, expect_prompt = sp.send, sp.sendline, sp.sleep, sp.expect_prompt
expect_prompt()
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")
expect_prompt()
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")
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")