summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authoryoshida.shinya <yoshida.shinya@linecorp.com>2021-03-06 14:48:48 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2021-03-07 11:36:00 +0900
commit9fe2393a007fd3771f3e6b7badf4c1c2686c065d (patch)
treefbe3f03e465655f4242dad248a19c44899b6d832 /test
parente2e8d94b147c164c9c0bf8c2b70e84eb3395657c (diff)
Add test cases for killing input command on terminate (#2381 #2382)
Diffstat (limited to 'test')
-rwxr-xr-xtest/test_go.rb94
1 files changed, 94 insertions, 0 deletions
diff --git a/test/test_go.rb b/test/test_go.rb
index 9ac1be76..74c4db66 100755
--- a/test/test_go.rb
+++ b/test/test_go.rb
@@ -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