Skip to content
Myr

Fix flaky tests

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

authored by Junegunn Choi · committed by Junegunn Choi · parent c3a198d · Browse files · 1 file+19 added−21 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+19 added−21 removed

  • tests:+19 added−21 removed

1 file+19 added−21 removed

modified:test/test_go.rb+19 added-21 removed
13 unmodified lines
1415 attr_reader :win1617 def initialize shell = 'bash'18 @win = go("new-window -P -F '#I' 'bash --rcfile ~/.fzf.#{shell}'").first18 @win = go("new-window -d -P -F '#I' 'PS1= bash --rcfile ~/.fzf.#{shell}'").first19 @lines = `tput lines`.chomp.to_i20 end2122 def self.current23 `tmux display-message -p '#I'`.split($/).first24 end2526 def self.select id27 system "tmux select-window -t #{id}"28 end2922 def closed?23 !go("list-window -F '#I'").include?(win)24 end25
50 unmodified lines
76 def tempname77 '/tmp/output'78 end7980 def rmtemp81 while File.exists? tempname82 File.unlink tempname rescue nil83 end84 end8586 def readtemp87 waited = 088 while waited < 589 begin
8 unmodified lines
9899 def setup100 ENV.delete 'FZF_DEFAULT_OPTS'101 ENV.delete 'FZF_DEFAULT_COMMAND'104 @prev = Tmux.current102 @tmux = Tmux.new106 File.unlink tempname rescue nil103 rmtemp104 end105106 def teardown107 @tmux.kill111 Tmux.select @prev108 end109110 def test_vanilla111 tmux.send_keys "seq 1 100000 | fzf > #{tempname}", :Enter
93 unmodified lines
205 tmux.close206 end207208 def test_multi_order213 tmux.send_keys "seq 1 10 | fzf --multi > #{tempname}", :Enter209 tmux.send_keys "seq 1 10 | fzf --multi > #{tempname} && echo -n done", :Enter210 tmux.until { |lines| lines.last =~ /^>/ }211212 tmux.send_keys :Tab, :Up, :Up, :Tab, :Tab, :Tab, # 3, 2213 'C-K', 'C-K', 'C-K', 'C-K', :BTab, :BTab, # 5, 6214 :PgUp, 'C-J', :Down, :Tab, :Tab # 8, 7215 tmux.until { |lines| lines[-2].include? '(6)' }216 tmux.send_keys "C-M"217 tmux.until { |lines| lines[-1].include?('done') }218 assert_equal %w[3 2 5 6 8 7], readtemp.split($/)219 tmux.close220 end221222 def test_with_nth223 [true, false].each do |multi|224 rmtemp225226 tmux.send_keys "(echo ' 1st 2nd 3rd/';227 echo ' first second third/') |229 fzf #{"--multi" if multi} -x --nth 2 --with-nth 2,-1,1 > #{tempname}",228 fzf #{"--multi" if multi} -x --nth 2 --with-nth 2,-1,1 > #{tempname} && echo -n done",229 :Enter230 tmux.until { |lines| lines[-2].include?('2/2') }231232 # Transformed list
3 unmodified lines
236237 # However, the output must not be transformed238 if multi239 tmux.send_keys :BTab, :BTab, :Enter240 tmux.until { |lines| lines[-1].include?('done') }241 assert_equal [' 1st 2nd 3rd/', ' first second third/'], readtemp.split($/)242 else243 tmux.send_keys '^', '3'244 tmux.until { |lines| lines[-2].include?('1/2') }245 tmux.send_keys :Enter246 tmux.send_keys 'echo -n done', :Enter246 tmux.until { |lines| lines[-1].include?('done') }247 assert_equal [' 1st 2nd 3rd/'], readtemp.split($/)248 end249 end250 end251252 def test_scroll253 [true, false].each do |rev|255 tmux.send_keys "seq 1 100 | fzf #{'--reverse' if rev} > #{tempname}", :Enter256 tmux.until { |lines| rev ? lines.first == '>' : lines.last == '>' }254 rmtemp255258 110.times do259 tmux.send_keys rev ? :Down : :Up260 end256 tmux.send_keys "seq 1 100 | fzf #{'--reverse' if rev} > #{tempname} && echo -n done", :Enter257 tmux.until { |lines| rev ? lines.first == '>' : lines.last == '>' }258 tmux.send_keys *110.times.map { rev ? :Down : :Up }259 tmux.until { |lines| lines.include? '> 100' }260 tmux.send_keys :Enter262 tmux.send_keys 'echo -n done', :Enter261 tmux.until { |lines| lines[-1].include?('done') }262 assert_equal '100', readtemp.chomp263 end264 end
14 unmodified lines