Retry flaky test cases

This commit is contained in:
Junegunn Choi 2017-01-09 13:22:24 +09:00
parent 6c6c0a4778
commit d18b8e0d2c
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627

View File

@ -1241,9 +1241,11 @@ module TestShell
def test_ctrl_t
set_var "FZF_CTRL_T_COMMAND", "seq 100"
lines = retries do
tmux.prepare
tmux.send_keys 'C-t'
lines = tmux.until { |lines| lines.item_count == 100 }
tmux.until { |lines| lines.item_count == 100 }
end
tmux.send_keys :Tab, :Tab, :Tab
tmux.until { |lines| lines.any_include? ' (3)' }
tmux.send_keys :Enter
@ -1255,9 +1257,11 @@ module TestShell
writelines tempname, ['fzf-unicode 테스트1', 'fzf-unicode 테스트2']
set_var "FZF_CTRL_T_COMMAND", "cat #{tempname}"
retries do
tmux.prepare
tmux.send_keys 'echo ', 'C-t'
tmux.until { |lines| lines.item_count == 2 }
end
tmux.send_keys 'fzf-unicode'
tmux.until { |lines| lines.match_count == 2 }
@ -1281,9 +1285,11 @@ module TestShell
end
def test_alt_c
lines = retries do
tmux.prepare
tmux.send_keys :Escape, :c
lines = tmux.until { |lines| lines.item_count > 0 }
tmux.until { |lines| lines.item_count > 0 }
end
expected = lines.reverse.select { |l| l.start_with? '>' }.first[2..-1]
tmux.send_keys :Enter
tmux.prepare
@ -1297,9 +1303,11 @@ module TestShell
tmux.prepare
tmux.send_keys 'cd /', :Enter
retries do
tmux.prepare
tmux.send_keys :Escape, :c
lines = tmux.until { |lines| lines.item_count == 1 }
end
tmux.send_keys :Enter
tmux.prepare
@ -1313,9 +1321,12 @@ module TestShell
tmux.send_keys 'echo 2nd', :Enter; tmux.prepare
tmux.send_keys 'echo 3d', :Enter; tmux.prepare
tmux.send_keys 'echo 3rd', :Enter; tmux.prepare
tmux.send_keys 'echo 4th', :Enter; tmux.prepare
tmux.send_keys 'echo 4th', :Enter
retries do
tmux.prepare
tmux.send_keys 'C-r'
tmux.until { |lines| lines.item_count > 0 }
end
tmux.send_keys '3d'
tmux.until { |lines| lines[-3].end_with? 'echo 3rd' }
tmux.send_keys :Enter
@ -1323,6 +1334,16 @@ module TestShell
tmux.send_keys :Enter
tmux.until { |lines| lines[-1] == '3rd' }
end
def retries times = 3, &block
(times - 1).times do |t|
begin
return block.call
rescue RuntimeError
end
end
block.call
end
end
module CompletionTest