Repository: junegunn/fzf
File: test/test_go.rb (Ruby)

Code before:
  def test_file_completion
    FileUtils.mkdir_p('/tmp/fzf-test')
    FileUtils.mkdir_p('/tmp/fzf test')
    (1..100).each { |i| FileUtils.touch("/tmp/fzf-test/#{i}") }
    ['no~such~user', '/tmp/fzf test/foobar', '~/.fzf-home'].each do |f|
      FileUtils.touch(File.expand_path(f))
    end
    tmux.prepare
    tmux.send_keys 'cat /tmp/fzf-test/10**', :Tab
    tmux.until { |lines| lines.match_count > 0 }
    tmux.send_keys ' !d'
    tmux.until { |lines| lines.match_count == 2 }
    tmux.send_keys :Tab, :Tab
    tmux.until { |lines| lines.select_count == 2 }
    tmux.send_keys :Enter
    tmux.until(true) do |lines|
      lines[-1].include?('/tmp/fzf-test/10') &&
        lines[-1].include?('/tmp/fzf-test/100')
    end

    # ~USERNAME**<TAB>
    tmux.send_keys 'C-u'
    tmux.send_keys "cat ~#{ENV['USER']}**", :Tab
    tmux.until { |lines| lines.match_count > 0 }
    tmux.send_keys "'.fzf-home"
    tmux.until { |lines| lines.count { |l| l.include?('.fzf-home') } > 1 }
    tmux.send_keys :Enter
    tmux.until(true) do |lines|
      lines[-1] =~ %r{cat .*/\.fzf-home}
    end

    # ~INVALID_USERNAME**<TAB>
    tmux.send_keys 'C-u'
    tmux.send_keys 'cat ~such**', :Tab
    tmux.until(true) { |lines| lines.any_include?('no~such~user') }
    tmux.send_keys :Enter
    tmux.until(true) { |lines| lines[-1].end_with?('no~such~user') }

    # /tmp/fzf\ test**<TAB>
    tmux.send_keys 'C-u'
    tmux.send_keys 'cat /tmp/fzf\ test/**', :Tab
    tmux.until { |lines| lines.match_count > 0 }
    tmux.send_keys 'foobar$'
    tmux.until { |lines| lines.match_count == 1 }
    tmux.send_keys :Enter
    tmux.until(true) { |lines| lines[-1].end_with?('/tmp/fzf\ test/foobar') }

    # Should include hidden files
    (1..100).each { |i| FileUtils.touch("/tmp/fzf-test/.hidden-#{i}") }
    tmux.send_keys 'C-u'
    tmux.send_keys 'cat /tmp/fzf-test/hidden**', :Tab

Review comment (bug):
I had to add this `retries` due to Travis CI failure and I believe it helped.

https://github.com/junegunn/fzf/commit/7c40a424c0bf5a8967816d51ead6a71a334f30bb

Can you explain why you decided that retries are no longer needed here?

Code after:
  end
end

module CompletionTest
  def test_file_completion
    FileUtils.mkdir_p('/tmp/fzf-test')
    FileUtils.mkdir_p('/tmp/fzf test')
    (1..100).each { |i| FileUtils.touch("/tmp/fzf-test/#{i}") }
    ['no~such~user', '/tmp/fzf test/foobar', '~/.fzf-home'].each do |f|
      FileUtils.touch(File.expand_path(f))
    end
    tmux.prepare
    tmux.send_keys 'cat /tmp/fzf-test/10**', :Tab
    tmux.until { |lines| lines.match_count > 0 }
    tmux.send_keys ' !d'
    tmux.until { |lines| lines.match_count == 2 }
    tmux.send_keys :Tab, :Tab
    tmux.until { |lines| lines.select_count == 2 }
    tmux.send_keys :Enter
    tmux.until(true) do |lines|
      lines[-1].include?('/tmp/fzf-test/10') &&
        lines[-1].include?('/tmp/fzf-test/100')
    end

    # ~USERNAME**<TAB>
    tmux.send_keys 'C-u'
    tmux.send_keys "cat ~#{ENV['USER']}**", :Tab
    tmux.until { |lines| lines.match_count > 0 }
    tmux.send_keys "'.fzf-home"
    tmux.until { |lines| lines.count { |l| l.include?('.fzf-home') } > 1 }
    tmux.send_keys :Enter
    tmux.until(true) do |lines|
      lines[-1] =~ %r{cat .*/\.fzf-home}
    end

    # ~INVALID_USERNAME**<TAB>
    tmux.send_keys 'C-u'
    tmux.send_keys 'cat ~such**', :Tab
    tmux.until(true) { |lines| lines.any_include?('no~such~user') }
    tmux.send_keys :Enter
    tmux.until(true) { |lines| lines[-1].end_with?('no~such~user') }

    # /tmp/fzf\ test**<TAB>
    tmux.send_keys 'C-u'
    tmux.send_keys 'cat /tmp/fzf\ test/**', :Tab
    tmux.until { |lines| lines.match_count > 0 }
    tmux.send_keys 'foobar$'
    tmux.until { |lines| lines.match_count == 1 }
    tmux.send_keys :Enter
    tmux.until(true) { |lines| lines[-1].end_with?('/tmp/fzf\ test/foobar') }