Skip to content
Myr

Fix test cases

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

We were not properly waiting for truthy-ness in until blocks. Need Minitest with https://github.com/seattlerb/minitest/commit/21d9e804b63c619f602f3f4ece6c71b48974707a

authored by Junegunn Choi · committed by Junegunn Choi · parent d2d4d68 · Browse files · 2 files+20 added−16 removed
This commit

State

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

Diff stats

2 files+20 added−16 removed

  • tests:+19 added−15 removed
  • other:+1 added−1 removed

2 files+20 added−16 removed

modified:test/test_go.rb+19 added-15 removed
9 unmodified lines
1011TEMPLATE = DATA.read12UNSETS = %w[13 FZF_DEFAULT_COMMAND FZF_DEFAULT_OPTS14 FZF_TMUX FZF_TMUX_OPTS15 FZF_CTRL_T_COMMAND FZF_CTRL_T_OPTS16 FZF_ALT_C_COMMAND17 FZF_ALT_C_OPTS FZF_CTRL_R_OPTS18 fish_history19].freeze19DEFAULT_TIMEOUT = 2020DEFAULT_TIMEOUT = 102122FILE = File.expand_path(__FILE__)23BASE = File.expand_path('..', __dir__)24Dir.chdir(BASE)
1 unmodified line
2627def wait28 since = Time.now29 begin29 yield30 yield or raise Minitest::Assertion, 'Assertion failure'31 rescue Minitest::Assertion32 raise if Time.now - since > DEFAULT_TIMEOUT3334 sleep(0.05)
42 unmodified lines
77 go(%W[set-window-option -t #{@win} pane-base-index 0])78 return unless shell == :fish7980 send_keys 'function fish_prompt; end; clear', :Enter80 self.until { |lines| raise Minitest::Assertion unless lines.empty? }81 self.until(&:empty?)82 end8384 def kill85 go(%W[kill-window -t #{win}])
63 unmodified lines
149 tries = 0150 begin151 self.until do |lines|152 send_keys ' ', 'C-u', :Enter, 'hello', :Left, :Right152 raise Minitest::Assertion unless lines[-1] == 'hello'153 lines[-1] == 'hello'154 end155 rescue Minitest::Assertion156 (tries += 1) < 5 ? retry : raise157 end
1632 unmodified lines
1790 end17911792 def test_preview_scroll_begin_constant1793 tmux.send_keys "echo foo 123 321 | #{FZF} --preview 'seq 1000' --preview-window left:+123", :Enter1793 tmux.until { |lines| lines.item_count == 1 }1794 tmux.until { |lines| assert_match %r{1/1}, lines[-2] }1795 tmux.until { |lines| assert_match %r{123.*123/1000}, lines[1] }1796 end17971798 def test_preview_scroll_begin_expr1799 tmux.send_keys "echo foo 123 321 | #{FZF} --preview 'seq 1000' --preview-window left:+{3}", :Enter1799 tmux.until { |lines| lines.item_count == 1 }1800 tmux.until { |lines| assert_match %r{1/1}, lines[-2] }1801 tmux.until { |lines| assert_match %r{321.*321/1000}, lines[1] }1802 end18031804 def test_preview_scroll_begin_and_offset1805 ['echo foo 123 321', 'echo foo :123: 321'].each do |input|1806 tmux.send_keys "#{input} | #{FZF} --preview 'seq 1000' --preview-window left:+{2}-2", :Enter1806 tmux.until { |lines| lines.item_count == 1 }1807 tmux.until { |lines| assert_match %r{1/1}, lines[-2] }1808 tmux.until { |lines| assert_match %r{121.*121/1000}, lines[1] }1809 tmux.send_keys 'C-c'1810 end1811 end
158 unmodified lines
1970 def test_file_completion1971 FileUtils.mkdir_p('/tmp/fzf-test')1972 FileUtils.mkdir_p('/tmp/fzf test')1973 (1..100).each { |i| FileUtils.touch("/tmp/fzf-test/#{i}") }1973 ['no~such~user', '/tmp/fzf test/foobar', '~/.fzf-home'].each do |f|1974 ['no~such~user', '/tmp/fzf test/foobar'].each do |f|1975 FileUtils.touch(File.expand_path(f))1976 end1977 tmux.prepare1978 tmux.send_keys 'cat /tmp/fzf-test/10**', :Tab
7 unmodified lines
1986 assert_equal 'cat /tmp/fzf-test/10 /tmp/fzf-test/100', lines[-1]1987 end19881989 # ~USERNAME**<TAB>1990 user = ENV['USER']1991 tmux.send_keys 'C-u'1990 tmux.send_keys "cat ~#{ENV['USER']}**", :Tab1992 tmux.send_keys "cat ~#{user}**", :Tab1993 tmux.until { |lines| assert_operator lines.match_count, :>, 0 }1992 tmux.send_keys "'.fzf-home"1993 tmux.until { |lines| assert(lines.any? { |l| l.end_with?('/.fzf-home') }) }1994 tmux.send_keys "/#{user}"1995 tmux.until { |lines| assert(lines.any? { |l| l.end_with?("/#{user}") }) }1996 tmux.send_keys :Enter1997 tmux.until(true) do |lines|1996 assert_match %r{cat .*/\.fzf-home}, lines[-1]1998 assert_match %r{cat .*/#{user}}, lines[-1]1999 end20002001 # ~INVALID_USERNAME**<TAB>2002 tmux.send_keys 'C-u'
239 unmodified lines
2242 end2243end22442245__END__2246PS1= PROMPT_COMMAND= HISTFILE= HISTSIZE=1002247unset <%= UNSETS.join(' ') %>2248unset $(env | sed -n /^_fzf_orig/s/=.*//p)2249unset $(declare -F | sed -n "/_fzf/s/.*-f //p")22502251# Setup fzf2252# ---------2253if [[ ! "$PATH" == *<%= BASE %>/bin* ]]; then2254 export PATH="${PATH:+${PATH}:}<%= BASE %>/bin"
6 unmodified lines
2261# Key bindings2262# ------------2263source "<%= BASE %>/shell/key-bindings.<%= __method__ %>"22642258PS1= PROMPT_COMMAND= HISTFILE= HISTSIZE=1002259unset <%= UNSETS.join(' ') %>22602265# Old API2266_fzf_complete_f() {2267 _fzf_complete "+m --multi --prompt \"prompt-f> \"" "$@" < <(2268 echo foo
33 unmodified lines
modified:Dockerfile+1 added-1 removed
1FROM archlinux/base:latest2RUN pacman -Sy && pacman --noconfirm -S awk git tmux zsh fish ruby procps go make gcc3RUN gem install --no-document minitest3RUN gem install --no-document -v 5.14.2 minitest4RUN echo '. /usr/share/bash-completion/completions/git' >> ~/.bashrc5RUN echo '. ~/.bashrc' >> ~/.bash_profile67# Do not set default PS1
4 unmodified lines