mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 05:13:10 +00:00
fix unit tests related to the escape timeout
This commit is contained in:
parent
814cb51eb5
commit
6969cfab3d
4 changed files with 48 additions and 32 deletions
|
@ -1,48 +1,55 @@
|
||||||
# vim: set filetype=expect:
|
# vim: set filetype=expect:
|
||||||
|
|
||||||
spawn $fish
|
spawn $fish
|
||||||
|
|
||||||
expect_prompt
|
expect_prompt
|
||||||
|
|
||||||
# test switching key bindings
|
# Test switching key bindings to vi mode.
|
||||||
# this should leave the mode in the appropriate state
|
# This should leave the mode in the appropriate state (i.e., insert mode).
|
||||||
|
|
||||||
send_line "set -g fish_key_bindings fish_vi_key_bindings"
|
send "set -g fish_key_bindings fish_vi_key_bindings\r"
|
||||||
expect_prompt
|
expect_prompt
|
||||||
send_line -h "echo fail\033ddiecho success"
|
send -h "echo fail\033"
|
||||||
|
# Delay needed to allow fish to transition to vi "normal" mode.
|
||||||
|
sleep 0.510
|
||||||
|
send -h "ddiecho success\r"
|
||||||
expect_prompt -re {\r\nsuccess\r\n} {
|
expect_prompt -re {\r\nsuccess\r\n} {
|
||||||
puts "success"
|
puts "vi replace line success"
|
||||||
} -nounmatched -re {\r\nfail} {
|
} -nounmatched -re {\r\nfail} {
|
||||||
puts stderr "fail"
|
puts stderr "vi replace line fail"
|
||||||
} unmatched {
|
|
||||||
puts stderr "Couldn't find expected output 'success'"
|
|
||||||
}
|
|
||||||
# try again without the human typing
|
|
||||||
send_line -h "echo fail\033ddiecho success"
|
|
||||||
expect_prompt -re {\r\nsuccess\r\n} {
|
|
||||||
puts "success"
|
|
||||||
} -nounmatched -re {\r\nfail} {
|
|
||||||
puts stderr "fail"
|
|
||||||
} unmatched {
|
} unmatched {
|
||||||
puts stderr "Couldn't find expected output 'success'"
|
puts stderr "Couldn't find expected output 'success'"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Test lowercase-r replace
|
# Verify that a human can transpose words using \et (which is an emacs default
|
||||||
send_line -h "\033ddiecho TEXT\033hhrAi"
|
# binding but should be valid while in vi insert mode).
|
||||||
|
send "echo abc def\033"
|
||||||
|
# Fish should still be in vi "insert" mode after this delay.
|
||||||
|
sleep 0.400
|
||||||
|
send "t\r"
|
||||||
|
expect_prompt -re {\r\ndef abc\r\n} {
|
||||||
|
puts "vi transpose words success"
|
||||||
|
} unmatched {
|
||||||
|
puts stderr "vi transpose words fail"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Test replacing a single character.
|
||||||
|
send -h "echo TEXT\033"
|
||||||
|
# Delay needed to allow fish to transition to vi "normal" mode.
|
||||||
|
sleep 0.510
|
||||||
|
send -h "hhrAi\r"
|
||||||
expect_prompt -re {\r\nTAXT\r\n} {
|
expect_prompt -re {\r\nTAXT\r\n} {
|
||||||
puts "replace success"
|
puts "vi mode replace success"
|
||||||
} -nounmatched -re {\r\nfail} {
|
} -nounmatched -re {\r\nfail} {
|
||||||
puts stderr "replace fail"
|
puts stderr "vi mode replace fail"
|
||||||
} unmatched {
|
} unmatched {
|
||||||
puts stderr "Couldn't find expected output 'TAXT'"
|
puts stderr "Couldn't find expected output 'TAXT'"
|
||||||
}
|
}
|
||||||
|
|
||||||
# still in insert mode, switch back to regular key bindings
|
# Switch back to regular (emacs mode) key bindings.
|
||||||
send_line -h "set -g fish_key_bindings fish_default_key_bindings"
|
send -h "set -g fish_key_bindings fish_default_key_bindings\r"
|
||||||
expect_prompt
|
expect_prompt
|
||||||
send_line "echo success"
|
send "echo success\r"
|
||||||
expect_prompt -re {\r\nsuccess\r\n} {
|
expect_prompt -re {\r\nsuccess\r\n} {
|
||||||
puts "success"
|
puts "emacs success"
|
||||||
} unmatched {
|
} unmatched {
|
||||||
puts stderr "Couldn't find expected output 'success'"
|
puts stderr "Couldn't find expected output 'success'"
|
||||||
} timeout {
|
} timeout {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
success
|
vi replace line success
|
||||||
success
|
vi transpose words success
|
||||||
replace success
|
vi mode replace success
|
||||||
success
|
emacs success
|
||||||
|
|
14
tests/interactive.fish
Normal file → Executable file
14
tests/interactive.fish
Normal file → Executable file
|
@ -2,7 +2,17 @@
|
||||||
#
|
#
|
||||||
# Interactive tests using `expect`
|
# Interactive tests using `expect`
|
||||||
|
|
||||||
source test_util.fish (status -f); or exit
|
# Change to directory containing this script
|
||||||
|
cd (dirname (status -f))
|
||||||
|
|
||||||
|
# Test files specified on commandline, or all *.expect files
|
||||||
|
if set -q argv[1]
|
||||||
|
set files_to_test $argv.expect
|
||||||
|
else
|
||||||
|
set files_to_test *.expect
|
||||||
|
end
|
||||||
|
|
||||||
|
source test_util.fish (status -f) $argv; or exit
|
||||||
|
|
||||||
say -o cyan "Testing interactive functionality"
|
say -o cyan "Testing interactive functionality"
|
||||||
if not type -q expect
|
if not type -q expect
|
||||||
|
@ -65,7 +75,7 @@ function test_file
|
||||||
end
|
end
|
||||||
|
|
||||||
set -l failed
|
set -l failed
|
||||||
for i in *.expect
|
for i in $files_to_test
|
||||||
if not test_file $i
|
if not test_file $i
|
||||||
set failed $failed $i
|
set failed $failed $i
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
cd (dirname (status -f))
|
cd (dirname (status -f))
|
||||||
|
|
||||||
# Test files specified on commandline, or all *.in files
|
# Test files specified on commandline, or all *.in files
|
||||||
set -q argv[1]
|
|
||||||
if set -q argv[1]
|
if set -q argv[1]
|
||||||
set files_to_test $argv.in
|
set files_to_test $argv.in
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue