Fix flaky test case: test_execute

Should wait until execute action completes
This commit is contained in:
Junegunn Choi 2016-05-11 01:40:49 +09:00
parent 73cb70dbb3
commit 4ab75b68dc
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627

View File

@ -859,16 +859,27 @@ class TestGoFZF < TestBase
def test_execute def test_execute
output = '/tmp/fzf-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}\\"]
tmux.send_keys "seq 100 | #{fzf opts}", :Enter wait = lambda { |exp| tmux.until { |lines| lines[-2].include? exp } }
tmux.until { |lines| lines[-2].include? '100/100' } tmux.send_keys "seq 100 | #{fzf opts}; sync", :Enter
tmux.send_keys :Escape, :a, :Escape, :a wait['100/100']
tmux.send_keys :Escape, :a
wait['/100']
tmux.send_keys :Escape, :a
wait['/100']
tmux.send_keys :Up tmux.send_keys :Up
tmux.send_keys :Escape, :b, :Escape, :b tmux.send_keys :Escape, :b
wait['/100']
tmux.send_keys :Escape, :b
wait['/100']
tmux.send_keys :Up tmux.send_keys :Up
tmux.send_keys :C tmux.send_keys :C
wait['100/100']
tmux.send_keys 'foobar' tmux.send_keys 'foobar'
tmux.until { |lines| lines[-2].include? '0/100' } wait['0/100']
tmux.send_keys :Escape, :a, :Escape, :b, :Escape, :c tmux.send_keys :Escape, :a
wait['/100']
tmux.send_keys :Escape, :b
wait['/100']
tmux.send_keys :Enter tmux.send_keys :Enter
readonce readonce
assert_equal ['["1"]', '["1"]', '("2"), ("2")', '("2"), ("2")', '("3"), ["3"], @"3"@'], assert_equal ['["1"]', '["1"]', '("2"), ("2")', '("2"), ("2")', '("3"), ["3"], @"3"@'],