mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-11 07:34:32 +00:00
Port generic.expect to pexpect
Removes a dumb workaround. Huzzah!
This commit is contained in:
parent
339a5a2196
commit
f66edfdec2
4 changed files with 55 additions and 63 deletions
|
@ -1,63 +0,0 @@
|
|||
# vim: set filetype=expect:
|
||||
#
|
||||
# General tests that don't belong elsewhere
|
||||
|
||||
spawn $fish
|
||||
|
||||
expect_prompt
|
||||
|
||||
# ensure the Apple key () is typeable
|
||||
send_line "echo "
|
||||
expect_prompt "" {} unmatched {
|
||||
puts stderr "Couldn't type apple key ()"
|
||||
}
|
||||
|
||||
# check that history is returned in the right order (#2028)
|
||||
# this hist_command nonsense is the cleanest way to send the $ char
|
||||
set hist_command "echo \$history\[1\]"
|
||||
|
||||
# first send 'echo stuff'
|
||||
send_line "echo stuff"
|
||||
expect_prompt "stuff" {} unmatched {
|
||||
puts stderr "Couldn't find expected output 'stuff'"
|
||||
}
|
||||
|
||||
# last history item should be 'echo stuff'
|
||||
send_line $hist_command
|
||||
expect_prompt "echo stuff" {} unmatched {
|
||||
puts stderr "Couldn't find expected output 'echo stuff'"
|
||||
}
|
||||
|
||||
# last history command should be the one that printed the history
|
||||
send_line $hist_command
|
||||
expect_prompt -re {echo .history.*} {} unmatched {
|
||||
puts stderr "Couldn't find expected output $hist_command"
|
||||
}
|
||||
|
||||
# Backslashes at end of comments (#1255)
|
||||
# This backslash should NOT cause the line to continue
|
||||
send_line "echo -n #comment\\"
|
||||
expect_prompt
|
||||
|
||||
# a pipe at the end of the line (#1285)
|
||||
send_line "echo hoge |\n cat"
|
||||
expect_prompt "hoge" {} unmatched {
|
||||
puts stderr "Error with a pipe at the end of the line"
|
||||
}
|
||||
send_line "echo hoge | \n cat"
|
||||
expect_prompt "hoge" {} unmatched {
|
||||
puts stderr "Error with a pipe at the end of the line with whitespaces"
|
||||
}
|
||||
send_line "echo hoge 2>| \n cat"
|
||||
expect_prompt "hoge" {} unmatched {
|
||||
puts stderr "Error with a pipe with redirection at the end of the line"
|
||||
}
|
||||
send_line "echo hoge >| \n cat"
|
||||
expect_prompt "hoge" {} unmatched {
|
||||
puts stderr "Error with a pipe with redirection at the end of the line"
|
||||
}
|
||||
|
||||
send_line "source; or echo failed"
|
||||
expect_prompt "failed" {} unmatched {
|
||||
puts stderr "Error with sourcing from the terminal"
|
||||
}
|
55
tests/pexpects/generic.py
Normal file
55
tests/pexpects/generic.py
Normal file
|
@ -0,0 +1,55 @@
|
|||
#!/usr/bin/env python3
|
||||
from pexpect_helper import SpawnedProc
|
||||
import subprocess
|
||||
import sys
|
||||
from time import sleep
|
||||
import os
|
||||
|
||||
SpawnedProc()
|
||||
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()
|
||||
|
||||
# ensure the Apple key () is typeable
|
||||
sendline("echo ")
|
||||
expect_prompt("")
|
||||
|
||||
# check that history is returned in the right order (#2028)
|
||||
# first send 'echo stuff'
|
||||
sendline("echo stuff")
|
||||
expect_prompt("stuff")
|
||||
|
||||
# last history item should be 'echo stuff'
|
||||
sendline("echo $history[1]")
|
||||
expect_prompt("echo stuff")
|
||||
|
||||
# last history command should be the one that printed the history
|
||||
sendline("echo $history[1]")
|
||||
expect_prompt("echo .history.*")
|
||||
|
||||
# Backslashes at end of comments (#1255)
|
||||
# This backslash should NOT cause the line to continue
|
||||
sendline("echo -n #comment\\")
|
||||
expect_prompt()
|
||||
|
||||
# a pipe at the end of the line (#1285)
|
||||
sendline("echo hoge |\n cat")
|
||||
expect_prompt("hoge")
|
||||
|
||||
sendline("echo hoge | \n cat")
|
||||
expect_prompt("hoge")
|
||||
|
||||
sendline("echo hoge 2>| \n cat")
|
||||
expect_prompt("hoge")
|
||||
sendline("echo hoge >| \n cat")
|
||||
expect_prompt("hoge")
|
||||
|
||||
sendline("source; or echo failed")
|
||||
expect_prompt("failed")
|
Loading…
Reference in a new issue