Fix test code
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 9c6e46a · Browse files · 1 file·+23 added−13 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+23 added−13 removed
- tests:+23 added−13 removed
Provenance
- Commit
5794fd4- Tree
3cdc16f- Author
Junegunn Choi <junegunn.c@gmail.com>- Committer
Junegunn Choi <junegunn.c@gmail.com>- Parent
9c6e46a
1 file changed+23 added−13 removed
modified:test/test_go.rb+23 added-13 removed
128 unmodified lines129 130 def until opts = {}131 lines = nil132 wait(opts) do133- yield lines = capture(opts)133+ lines = capture(opts)134+ class << lines135+ def item_count136+ self[-2] ? self[-2].strip.split('/').last.to_i : 0137+ end138+ end139+ yield lines140 end141 lines142 end143 144 def prepare139- self.send_keys 'echo hello', :Enter140- self.until { |lines| lines[-1].start_with?('hello') }141- self.send_keys 'clear', :Enter142- self.until { |lines| lines.empty? }145+ tries = 0146+ begin147+ self.send_keys 'C-u', 'hello'148+ self.until { |lines| lines[-1].end_with?('hello') }149+ rescue Exception150+ (tries += 1) < 5 ? retry : raise151+ end152+ self.send_keys 'C-u'153 end154 private155 def defaults opts156 { timeout: 10, pane: 0 }.merge(opts)241 unmodified lines398 end399 400 def test_query_unicode401 tmux.send_keys "(echo abc; echo 가나다) | #{fzf :query, '가다'}", :Enter392- tmux.until { |lines| lines.last.start_with? '>' }402+ tmux.until { |lines| lines[-2].include? '1/2' }403 tmux.send_keys :Enter404 tmux.until { |lines| lines[-1].include?(FIN) }405 assert_equal ['가나다'], readonce.split($/)406 end166 unmodified lines573 574 def test_ctrl_t575 tmux.prepare576 tmux.send_keys 'C-t', pane: 0567- lines = tmux.until(pane: 1) { |lines| lines[-1].start_with? '>' }577+ lines = tmux.until(pane: 1) { |lines| lines.item_count > 0 }578 expected = lines.values_at(-3, -4).map { |line| line[2..-1] }.join(' ')579 tmux.send_keys :BTab, :BTab, :Enter, pane: 1580 tmux.until(pane: 0) { |lines| lines[-1].include? expected }581 tmux.send_keys 'C-c'582 583 # FZF_TMUX=0584 new_shell585 tmux.send_keys 'C-t', pane: 0576- lines = tmux.until(pane: 0) { |lines| lines[-1].start_with? '>' }586+ lines = tmux.until(pane: 0) { |lines| lines.item_count > 0 }587 expected = lines.values_at(-3, -4).map { |line| line[2..-1] }.join(' ')588 tmux.send_keys :BTab, :BTab, :Enter, pane: 0589 tmux.until(pane: 0) { |lines| lines[-1].include? expected }590 tmux.send_keys 'C-c', 'C-d'1 unmodified line592 593 def test_alt_c594 tmux.prepare595 tmux.send_keys :Escape, :c, pane: 0586- lines = tmux.until(pane: 1) { |lines| lines[-1].start_with? '>' }596+ lines = tmux.until(pane: 1) { |lines| lines.item_count > 0 }597 expected = lines[-3][2..-1]598 p expected599 tmux.send_keys :Enter, pane: 1600 tmux.prepare8 unmodified lines609 tmux.send_keys 'echo 3d', :Enter; tmux.prepare610 tmux.send_keys 'echo 3rd', :Enter; tmux.prepare611 tmux.send_keys 'echo 4th', :Enter; tmux.prepare612 tmux.send_keys 'C-r', pane: 0603- tmux.until(pane: 1) { |lines| lines[-1].start_with? '>' }613+ tmux.until(pane: 1) { |lines| lines.item_count > 0 }614 tmux.send_keys '3d', pane: 1615 tmux.until(pane: 1) { |lines| lines[-3].end_with? 'echo 3rd' } # --no-sort616 tmux.send_keys :Enter, pane: 1617 tmux.until { |lines| lines[-1] == 'echo 3rd' }18 unmodified lines636 def test_file_completion637 tmux.send_keys 'mkdir -p /tmp/fzf-test; touch /tmp/fzf-test/{1..100}', :Enter638 tmux.prepare639 tmux.send_keys 'cat /tmp/fzf-test/10**', :Tab, pane: 0630- tmux.until(pane: 1) { |lines| lines[-1].start_with? '>' }640+ tmux.until(pane: 1) { |lines| lines.item_count > 0 }641 tmux.send_keys :BTab, :BTab, :Enter642 tmux.until do |lines|643 tmux.send_keys 'C-L'644 lines[-1].include?('/tmp/fzf-test/10') &&4 unmodified lines649 def test_dir_completion650 tmux.send_keys 'mkdir -p /tmp/fzf-test/d{1..100}; touch /tmp/fzf-test/d55/xxx', :Enter651 tmux.prepare652 tmux.send_keys 'cd /tmp/fzf-test/**', :Tab, pane: 0643- tmux.until(pane: 1) { |lines| lines[-1].start_with? '>' }653+ tmux.until(pane: 1) { |lines| lines.item_count > 0 }654 tmux.send_keys :BTab, :BTab # BTab does not work here655 tmux.send_keys 55656 tmux.until(pane: 1) { |lines| lines[-2].start_with? ' 1/' }657 tmux.send_keys :Enter20 unmodified lines678 lines = tmux.until { |lines| lines[-1].start_with? '[1]' }679 pid = lines[-1].split.last680 tmux.prepare681 tmux.send_keys 'kill ', :Tab, pane: 0672- tmux.until(pane: 1) { |lines| lines[-1].start_with? '>' }682+ tmux.until(pane: 1) { |lines| lines.item_count > 0 }683 tmux.send_keys 'sleep12345'684 tmux.until(pane: 1) { |lines| lines[-3].include? 'sleep 12345' }685 tmux.send_keys :Enter686 tmux.until do |lines|35 unmodified lines