From 4accc6902212fde0bf4fa53e1dbe4de96978a11a Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Tue, 8 Nov 2016 02:19:05 +0900 Subject: [PATCH] Fix flaky test cases --- test/test_go.rb | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/test/test_go.rb b/test/test_go.rb index 3fdfddd6..4cd4a4f7 100644 --- a/test/test_go.rb +++ b/test/test_go.rb @@ -1253,24 +1253,29 @@ module TestShell tmux.send_keys 'cat ', 'C-t', pane: 0 tmux.until(1) { |lines| lines.item_count >= 1 } tmux.send_keys 'fzf-unicode', pane: 1 - tmux.until(1) { |lines| lines[-2].start_with? ' 2/' } + redraw = ->() { tmux.send_keys 'C-l', pane: 1 } + tmux.until(1) { |lines| redraw.(); lines[-2] =~ %r(^ *2/) } tmux.send_keys '1', pane: 1 - tmux.until(1) { |lines| lines[-2].start_with? ' 1/' } + tmux.until(1) { |lines| redraw.(); lines[-2] =~ %r(^ *1/) } tmux.send_keys :BTab, pane: 1 - tmux.until(1) { |lines| lines[-2].include? '(1)' } + tmux.until(1) { |lines| redraw.(); lines[-2].include? '(1)' } tmux.send_keys :BSpace, pane: 1 - tmux.until(1) { |lines| lines[-2].start_with? ' 2/' } + tmux.until(1) { |lines| redraw.(); lines[-2] =~ %r(^ *2/) } tmux.send_keys '2', pane: 1 - tmux.until(1) { |lines| lines[-2].start_with? ' 1/' } + tmux.until(1) { |lines| redraw.(); lines[-2] =~ %r(^ *1/) } tmux.send_keys :BTab, pane: 1 - tmux.until(1) { |lines| lines[-2].include? '(2)' } + tmux.until(1) { |lines| redraw.(); lines[-2].include? '(2)' } tmux.send_keys :Enter, pane: 1 - tmux.until { |lines| lines[-1].include?('cat') || lines[-2].include?('cat') } - tmux.until { |lines| lines[-1].include?('fzf-unicode') || lines[-2].include?('fzf-unicode') } + tmux.until do |lines| + tmux.send_keys 'C-l' + [-1, -2].map { |offset| lines[offset] }.any? do |line| + line.start_with?('cat') && line.include?('fzf-unicode') + end + end tmux.send_keys :Enter tmux.until { |lines| lines[-1].include? 'test1test2' } end @@ -1481,23 +1486,27 @@ module CompletionTest tmux.paste 'cd /tmp/fzf-test; echo -n test3 > "fzf-unicode 테스트1"; echo -n test4 > "fzf-unicode 테스트2"' tmux.prepare tmux.send_keys 'cat fzf-unicode**', :Tab, pane: 0 - tmux.until(1) { |lines| lines[-2].start_with? ' 2/' } + redraw = ->() { tmux.send_keys 'C-l', pane: 1 } + tmux.until(1) { |lines| redraw.(); lines[-2] =~ %r(^ *2/) } tmux.send_keys '1', pane: 1 - tmux.until(1) { |lines| lines[-2].start_with? ' 1/' } + tmux.until(1) { |lines| redraw.(); lines[-2] =~ %r(^ *1/) } tmux.send_keys :BTab, pane: 1 - tmux.until(1) { |lines| lines[-2].include? '(1)' } + tmux.until(1) { |lines| redraw.(); lines[-2].include? '(1)' } tmux.send_keys :BSpace, pane: 1 - tmux.until(1) { |lines| lines[-2].start_with? ' 2/' } + tmux.until(1) { |lines| redraw.(); lines[-2] =~ %r(^ *2/) } tmux.send_keys '2', pane: 1 - tmux.until(1) { |lines| lines[-2].start_with? ' 1/' } + tmux.until(1) { |lines| redraw.(); lines[-2] =~ %r(^ *1/) } tmux.send_keys :BTab, pane: 1 - tmux.until(1) { |lines| lines[-2].include? '(2)' } + tmux.until(1) { |lines| redraw.(); lines[-2].include? '(2)' } tmux.send_keys :Enter, pane: 1 - tmux.until { |lines| lines[-1].include?('cat') || lines[-2].include?('cat') } + tmux.until do |lines| + tmux.send_keys 'C-l' + lines[-1].include?('cat') || lines[-2].include?('cat') + end tmux.send_keys :Enter tmux.until { |lines| lines[-1].include? 'test3test4' } end