Add test cases for killing input command on terminate (#2381 #2382)

pull/2379/head
yoshida.shinya 3 years ago committed by Junegunn Choi
parent e2e8d94b14
commit 9fe2393a00
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627

@ -1922,6 +1922,100 @@ class TestGoFZF < TestBase
tmux.send_keys 99
tmux.until { |lines| assert_equal 1, lines.match_count }
end
def test_kill_default_command_on_abort
script = tempname + '.sh'
writelines(script,
['#!/usr/bin/env bash',
"echo 'Started'",
'while :; do sleep 1; done'])
system("chmod +x #{script}")
tmux.send_keys fzf.sub('FZF_DEFAULT_COMMAND=', "FZF_DEFAULT_COMMAND=#{script}"), :Enter
tmux.until { |lines| assert_equal 1, lines.item_count }
tmux.send_keys 'C-c'
tmux.send_keys 'C-l', 'closed'
tmux.until { |lines| assert_includes lines[0], 'closed' }
wait { refute system("pgrep -f #{script}") }
ensure
system("pkill -9 -f #{script}")
begin
File.unlink(script)
rescue StandardError
nil
end
end
def test_kill_default_command_on_accept
script = tempname + '.sh'
writelines(script,
['#!/usr/bin/env bash',
"echo 'Started'",
'while :; do sleep 1; done'])
system("chmod +x #{script}")
tmux.send_keys fzf.sub('FZF_DEFAULT_COMMAND=', "FZF_DEFAULT_COMMAND=#{script}"), :Enter
tmux.until { |lines| assert_equal 1, lines.item_count }
tmux.send_keys :Enter
assert_equal 'Started', readonce.chomp
wait { refute system("pgrep -f #{script}") }
ensure
system("pkill -9 -f #{script}")
begin
File.unlink(script)
rescue StandardError
nil
end
end
def test_kill_reload_command_on_abort
script = tempname + '.sh'
writelines(script,
['#!/usr/bin/env bash',
"echo 'Started'",
'while :; do sleep 1; done'])
system("chmod +x #{script}")
tmux.send_keys "seq 1 3 | #{fzf("--bind 'ctrl-r:reload(#{script})'")}", :Enter
tmux.until { |lines| assert_equal 3, lines.item_count }
tmux.send_keys 'C-r'
tmux.until { |lines| assert_equal 1, lines.item_count }
tmux.send_keys 'C-c'
tmux.send_keys 'C-l', 'closed'
tmux.until { |lines| assert_includes lines[0], 'closed' }
wait { refute system("pgrep -f #{script}") }
ensure
system("pkill -9 -f #{script}")
begin
File.unlink(script)
rescue StandardError
nil
end
end
def test_kill_reload_command_on_accept
script = tempname + '.sh'
writelines(script,
['#!/usr/bin/env bash',
"echo 'Started'",
'while :; do sleep 1; done'])
system("chmod +x #{script}")
tmux.send_keys "seq 1 3 | #{fzf("--bind 'ctrl-r:reload(#{script})'")}", :Enter
tmux.until { |lines| assert_equal 3, lines.item_count }
tmux.send_keys 'C-r'
tmux.until { |lines| assert_equal 1, lines.item_count }
tmux.send_keys :Enter
assert_equal 'Started', readonce.chomp
wait { refute system("pgrep -f #{script}") }
ensure
system("pkill -9 -f #{script}")
begin
File.unlink(script)
rescue StandardError
nil
end
end
end
module TestShell

Loading…
Cancel
Save