Update test_execute (#590)

This commit is contained in:
Junegunn Choi 2016-06-08 02:04:40 +09:00
parent 95b34de339
commit 3a644b16a4
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627

View File

@ -869,31 +869,34 @@ class TestGoFZF < TestBase
def test_execute
output = '/tmp/fzf-test-execute'
opts = %[--bind \\"alt-a:execute(echo '[{}]' >> #{output}),alt-b:execute[echo '({}), ({})' >> #{output}],C:execute:echo '({}), [{}], @{}@' >> #{output}\\"]
opts = %[--bind \\"alt-a:execute(echo [{}] >> #{output}),alt-b:execute[echo /{}{}/ >> #{output}],C:execute:echo /{}{}{}/ >> #{output}\\"]
wait = lambda { |exp| tmux.until { |lines| lines[-2].include? exp } }
tmux.send_keys "seq 100 | #{fzf opts}; sync", :Enter
wait['100/100']
writelines tempname, %w[foo'bar foo"bar foo$bar]
tmux.send_keys "cat #{tempname} | #{fzf opts}; sync", :Enter
wait['3/3']
tmux.send_keys :Escape, :a
wait['/100']
wait['/3']
tmux.send_keys :Escape, :a
wait['/100']
wait['/3']
tmux.send_keys :Up
tmux.send_keys :Escape, :b
wait['/100']
wait['/3']
tmux.send_keys :Escape, :b
wait['/100']
wait['/3']
tmux.send_keys :Up
tmux.send_keys :C
wait['100/100']
tmux.send_keys 'foobar'
wait['0/100']
wait['3/3']
tmux.send_keys 'barfoo'
wait['0/3']
tmux.send_keys :Escape, :a
wait['/100']
wait['/3']
tmux.send_keys :Escape, :b
wait['/100']
wait['/3']
tmux.send_keys :Enter
readonce
assert_equal ['["1"]', '["1"]', '("2"), ("2")', '("2"), ("2")', '("3"), ["3"], @"3"@'],
assert_equal %w[[foo'bar] [foo'bar]
/foo"barfoo"bar/ /foo"barfoo"bar/
/foo$barfoo$barfoo$bar/],
File.readlines(output).map(&:chomp)
ensure
File.unlink output rescue nil