Skip to content
Myr

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

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by yoshida.shinya · committed by Junegunn Choi · parent e2e8d94 · Browse files · 1 file+94 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+94 added−0 removed

  • tests:+94 added−0 removed

1 file+94 added−0 removed

modified:test/test_go.rb+94 added
1920 unmodified lines
1921 tmux.until { |lines| assert_equal 100, lines.item_count }1922 tmux.send_keys 991923 tmux.until { |lines| assert_equal 1, lines.match_count }1924 end19251926 def test_kill_default_command_on_abort1927 script = tempname + '.sh'1928 writelines(script,1929 ['#!/usr/bin/env bash',1930 "echo 'Started'",1931 'while :; do sleep 1; done'])1932 system("chmod +x #{script}")19331934 tmux.send_keys fzf.sub('FZF_DEFAULT_COMMAND=', "FZF_DEFAULT_COMMAND=#{script}"), :Enter1935 tmux.until { |lines| assert_equal 1, lines.item_count }1936 tmux.send_keys 'C-c'1937 tmux.send_keys 'C-l', 'closed'1938 tmux.until { |lines| assert_includes lines[0], 'closed' }1939 wait { refute system("pgrep -f #{script}") }1940 ensure1941 system("pkill -9 -f #{script}")1942 begin1943 File.unlink(script)1944 rescue StandardError1945 nil1946 end1947 end19481949 def test_kill_default_command_on_accept1950 script = tempname + '.sh'1951 writelines(script,1952 ['#!/usr/bin/env bash',1953 "echo 'Started'",1954 'while :; do sleep 1; done'])1955 system("chmod +x #{script}")19561957 tmux.send_keys fzf.sub('FZF_DEFAULT_COMMAND=', "FZF_DEFAULT_COMMAND=#{script}"), :Enter1958 tmux.until { |lines| assert_equal 1, lines.item_count }1959 tmux.send_keys :Enter1960 assert_equal 'Started', readonce.chomp1961 wait { refute system("pgrep -f #{script}") }1962 ensure1963 system("pkill -9 -f #{script}")1964 begin1965 File.unlink(script)1966 rescue StandardError1967 nil1968 end1969 end19701971 def test_kill_reload_command_on_abort1972 script = tempname + '.sh'1973 writelines(script,1974 ['#!/usr/bin/env bash',1975 "echo 'Started'",1976 'while :; do sleep 1; done'])1977 system("chmod +x #{script}")19781979 tmux.send_keys "seq 1 3 | #{fzf("--bind 'ctrl-r:reload(#{script})'")}", :Enter1980 tmux.until { |lines| assert_equal 3, lines.item_count }1981 tmux.send_keys 'C-r'1982 tmux.until { |lines| assert_equal 1, lines.item_count }1983 tmux.send_keys 'C-c'1984 tmux.send_keys 'C-l', 'closed'1985 tmux.until { |lines| assert_includes lines[0], 'closed' }1986 wait { refute system("pgrep -f #{script}") }1987 ensure1988 system("pkill -9 -f #{script}")1989 begin1990 File.unlink(script)1991 rescue StandardError1992 nil1993 end1994 end19951996 def test_kill_reload_command_on_accept1997 script = tempname + '.sh'1998 writelines(script,1999 ['#!/usr/bin/env bash',2000 "echo 'Started'",2001 'while :; do sleep 1; done'])2002 system("chmod +x #{script}")20032004 tmux.send_keys "seq 1 3 | #{fzf("--bind 'ctrl-r:reload(#{script})'")}", :Enter2005 tmux.until { |lines| assert_equal 3, lines.item_count }2006 tmux.send_keys 'C-r'2007 tmux.until { |lines| assert_equal 1, lines.item_count }2008 tmux.send_keys :Enter2009 assert_equal 'Started', readonce.chomp2010 wait { refute system("pgrep -f #{script}") }2011 ensure2012 system("pkill -9 -f #{script}")2013 begin2014 File.unlink(script)2015 rescue StandardError2016 nil2017 end2018 end2019end20202021module TestShell2022 def setup
478 unmodified lines