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
Provenance
- Commit
2166b4c- Tree
fb2e48a- Author
Junegunn Choi <junegunn.c@gmail.com>- Committer
Junegunn Choi <junegunn.c@gmail.com>- Parent
d2d4d68
2 files changed+20 added−16 removed
modified:test/test_go.rb+19 added-15 removed
9 unmodified lines10 11 TEMPLATE = DATA.read12 UNSETS = %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 ].freeze19-DEFAULT_TIMEOUT = 2020+DEFAULT_TIMEOUT = 1021 22 FILE = File.expand_path(__FILE__)23 BASE = File.expand_path('..', __dir__)24 Dir.chdir(BASE)1 unmodified line26 27 def wait28 since = Time.now29 begin29- yield30+ yield or raise Minitest::Assertion, 'Assertion failure'31 rescue Minitest::Assertion32 raise if Time.now - since > DEFAULT_TIMEOUT33 34 sleep(0.05)42 unmodified lines77 go(%W[set-window-option -t #{@win} pane-base-index 0])78 return unless shell == :fish79 80 send_keys 'function fish_prompt; end; clear', :Enter80- self.until { |lines| raise Minitest::Assertion unless lines.empty? }81+ self.until(&:empty?)82 end83 84 def kill85 go(%W[kill-window -t #{win}])63 unmodified lines149 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 end1632 unmodified lines1790 end1791 1792 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 end1797 1798 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 end1803 1804 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 end158 unmodified lines1970 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**', :Tab7 unmodified lines1986 assert_equal 'cat /tmp/fzf-test/10 /tmp/fzf-test/100', lines[-1]1987 end1988 1989 # ~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 end2000 2001 # ~INVALID_USERNAME**<TAB>2002 tmux.send_keys 'C-u'239 unmodified lines2242 end2243 end2244 2245 __END__2246+PS1= PROMPT_COMMAND= HISTFILE= HISTSIZE=1002247+unset <%= UNSETS.join(' ') %>2248+unset $(env | sed -n /^_fzf_orig/s/=.*//p)2249+unset $(declare -F | sed -n "/_fzf/s/.*-f //p")2250+2251 # Setup fzf2252 # ---------2253 if [[ ! "$PATH" == *<%= BASE %>/bin* ]]; then2254 export PATH="${PATH:+${PATH}:}<%= BASE %>/bin"6 unmodified lines2261 # Key bindings2262 # ------------2263 source "<%= BASE %>/shell/key-bindings.<%= __method__ %>"2264 2258-PS1= PROMPT_COMMAND= HISTFILE= HISTSIZE=1002259-unset <%= UNSETS.join(' ') %>2260-2265 # Old API2266 _fzf_complete_f() {2267 _fzf_complete "+m --multi --prompt \"prompt-f> \"" "$@" < <(2268 echo foo33 unmodified linesmodified:Dockerfile+1 added-1 removed
1 FROM archlinux/base:latest2 RUN pacman -Sy && pacman --noconfirm -S awk git tmux zsh fish ruby procps go make gcc3-RUN gem install --no-document minitest3+RUN gem install --no-document -v 5.14.2 minitest4 RUN echo '. /usr/share/bash-completion/completions/git' >> ~/.bashrc5 RUN echo '. ~/.bashrc' >> ~/.bash_profile6 7 # Do not set default PS14 unmodified lines