Skip to content
Myr

Run rubocop --auto-correct --disable-uncorrectable (#1967)

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

authored by Jack Bates · committed by GitHub · parent 15e2952 · Browse files · 4 files+347 added−320 removed
This commit

State

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

Trailers

  • Co-authored-by: Junegunn Choi <junegunn.c@gmail.com>

Diff stats

4 files+347 added−320 removed

  • tests:+307 added−308 removed
  • other:+40 added−12 removed

4 files+347 added−320 removed

modified:src/update_assets.rb+14 added-12 removed
1#!/usr/bin/env ruby2# frozen_string_literal: true34# http://www.rubydoc.info/github/rest-client/rest-client/RestClient5require 'rest_client'6require 'json'78if ARGV.length < 38 puts "usage: #$0 <token> <version> <files...>"9 puts "usage: #{$PROGRAM_NAME} <token> <version> <files...>"10 exit 111end1213token, version, *files = ARGV13base = "https://api.github.com/repos/junegunn/fzf-bin/releases"14base = 'https://api.github.com/repos/junegunn/fzf-bin/releases'1516# List releases16rels = JSON.parse(RestClient.get(base, :authorization => "token #{token}"))17rels = JSON.parse(RestClient.get(base, authorization: "token #{token}"))18rel = rels.find { |r| r['tag_name'] == version }19unless rel20 puts "#{version} not found"21 exit 122end2324# List assets24assets = Hash[rel['assets'].map { |a| a.values_at *%w[name id] }]25assets = Hash[rel['assets'].map { |a| a.values_at('name', 'id') }]2626files.select { |f| File.exists? f }.map do |file|27files.select { |f| File.exist?(f) }.map do |file|28 Thread.new do28 name = File.basename file29 name = File.basename(file)3030 if asset_id = assets[name]31 if asset_id = assets[name] # rubocop:todo Lint/AssignmentInCondition32 puts "#{name} found. Deleting asset id #{asset_id}."32 RestClient.delete "#{base}/assets/#{asset_id}",33 :authorization => "token #{token}"33 RestClient.delete("#{base}/assets/#{asset_id}",34 authorization: "token #{token}")35 else36 puts "#{name} not found"37 end3839 puts "Uploading #{name}"40 RestClient.post(40 "#{base.sub 'api', 'uploads'}/#{rel['id']}/assets?name=#{name}",41 "#{base.sub('api', 'uploads')}/#{rel['id']}/assets?name=#{name}",42 File.read(file),42 :authorization => "token #{token}",43 :content_type => "application/octet-stream")43 authorization: "token #{token}",44 content_type: 'application/octet-stream'45 )46 end47end.each(&:join)
modified:test/test_go.rb+307 added-308 removed
1#!/usr/bin/env ruby2# encoding: utf-82# frozen_string_literal: true35# rubocop:disable Metrics/LineLength6# rubocop:disable Metrics/MethodLength74require 'minitest/autorun'5require 'fileutils'6require 'English'7require 'shellwords'
32 unmodified lines
40def wait41 since = Time.now42 while Time.now - since < DEFAULT_TIMEOUT43 return if yield48 sleep 0.054445 sleep(0.05)46 end47 raise 'timeout'48end49
3 unmodified lines
53 @bash ||=54 begin55 bashrc = '/tmp/fzf.bash'56 File.open(bashrc, 'w') do |f|60 f.puts(ERB.new(TEMPLATE).result(binding))57 f.puts ERB.new(TEMPLATE).result(binding)58 end5960 "bash --rcfile #{bashrc}"61 end
5 unmodified lines
67 zdotdir = '/tmp/fzf-zsh'68 FileUtils.rm_rf(zdotdir)69 FileUtils.mkdir_p(zdotdir)70 File.open("#{zdotdir}/.zshrc", 'w') do |f|74 f.puts(ERB.new(TEMPLATE).result(binding))71 f.puts ERB.new(TEMPLATE).result(binding)72 end73 "ZDOTDIR=#{zdotdir} zsh"74 end75 end
11 unmodified lines
87 @win = go(%W[new-window -d -P -F #I #{Shell.send(shell)}]).first88 go(%W[set-window-option -t #{@win} pane-base-index 0])89 return unless shell == :fish9094 send_keys('function fish_prompt; end; clear', :Enter)91 send_keys 'function fish_prompt; end; clear', :Enter92 self.until(&:empty?)93 end9495 def kill
23 unmodified lines
119 lines = capture120 class << lines121 def counts122 lazy126 .map { |l| l.scan %r{^. ([0-9]+)\/([0-9]+)( \(([0-9]+)\))?} }123 .map { |l| l.scan(%r{^. ([0-9]+)\/([0-9]+)( \(([0-9]+)\))?}) }124 .reject(&:empty?)125 .first&.first&.map(&:to_i)&.values_at(0, 1, 3) || [0, 0, 0]126 end127
10 unmodified lines
138 end139140 def any_include?(val)141 method = val.is_a?(Regexp) ? :match : :include?145 select { |line| line.send method, val }.first142 find { |line| line.send(method, val) }143 end144 end145 yield(lines).tap do |ok|146 send_keys 'C-l' if refresh && !ok
24 unmodified lines
171172 private173174 def go(args)178 IO.popen(['tmux'] + args) { |io| io.readlines(chomp: true) }175 IO.popen(%w[tmux] + args) { |io| io.readlines(chomp: true) }176 end177end178179class TestBase < Minitest::Test
4 unmodified lines
184 def tempname185 @temp_suffix ||= 0186 [TEMPNAME,187 caller_locations.map(&:label).find { |l| l =~ /^test_/ },191 @temp_suffix].join '-'188 @temp_suffix].join('-')189 end190191 def writelines(path, lines)195 File.unlink path while File.exist? path192 File.unlink(path) while File.exist?(path)193 File.open(path, 'w') { |f| f << lines.join($INPUT_RECORD_SEPARATOR) + $INPUT_RECORD_SEPARATOR }194 end195196 def readonce197 wait { File.exist?(tempname) }198 File.read(tempname)199 ensure203 File.unlink tempname while File.exist?(tempname)200 File.unlink(tempname) while File.exist?(tempname)201 @temp_suffix += 1202 tmux.prepare203 end204
10 unmodified lines
215 when String, Numeric216 o.to_s217 end218 end.compact222 "#{FZF} #{opts.join ' '}"219 "#{FZF} #{opts.join(' ')}"220 end221end222223class TestGoFZF < TestBase
17 unmodified lines
241242 # Testing basic key bindings243 tmux.send_keys '99', 'C-a', '1', 'C-f', '3', 'C-b', 'C-h', 'C-u', 'C-e', 'C-y', 'C-k', 'Tab', 'BTab'244 tmux.until do |lines|248 '> 3910' == lines[-4] &&249 ' 391' == lines[-3] &&250 ' 856/100000' == lines[-2] &&251 '> 391' == lines[-1]245 lines[-4] == '> 3910' &&246 lines[-3] == ' 391' &&247 lines[-2] == ' 856/100000' &&248 lines[-1] == '> 391'249 end250251 tmux.send_keys :Enter252 assert_equal '3910', readonce.chomp
91 unmodified lines
344 tmux.until { |lines| lines.last == '> --///baz' }345 end346347 def test_multi_order351 tmux.send_keys "seq 1 10 | #{fzf :multi}", :Enter348 tmux.send_keys "seq 1 10 | #{fzf(:multi)}", :Enter349 tmux.until { |lines| lines.last =~ /^>/ }350351 tmux.send_keys :Tab, :Up, :Up, :Tab, :Tab, :Tab, # 3, 2352 'C-K', 'C-K', 'C-K', 'C-K', :BTab, :BTab, # 5, 6353 :PgUp, 'C-J', :Down, :Tab, :Tab # 8, 7357 tmux.until { |lines| lines[-2].include? '(6)' }354 tmux.until { |lines| lines[-2].include?('(6)') }355 tmux.send_keys 'C-M'356 assert_equal %w[3 2 5 6 8 7], readonce.split($INPUT_RECORD_SEPARATOR)357 end358
59 unmodified lines
418 def test_with_nth419 [true, false].each do |multi|420 tmux.send_keys "(echo ' 1st 2nd 3rd/';421 echo ' first second third/') |425 #{fzf multi && :multi, :x, :nth, 2, :with_nth, '2,-1,1'}",422 #{fzf(multi && :multi, :x, :nth, 2, :with_nth, '2,-1,1')}",423 :Enter424 tmux.until { |lines| lines[-2].include?('2/2') }425426 # Transformed list
17 unmodified lines
444 end445446 def test_scroll447 [true, false].each do |rev|451 tmux.send_keys "seq 1 100 | #{fzf rev && :reverse}", :Enter452 tmux.until { |lines| lines.include? ' 100/100' }448 tmux.send_keys "seq 1 100 | #{fzf(rev && :reverse)}", :Enter449 tmux.until { |lines| lines.include?(' 100/100') }450 tmux.send_keys(*Array.new(110) { rev ? :Down : :Up })454 tmux.until { |lines| lines.include? '> 100' }451 tmux.until { |lines| lines.include?('> 100') }452 tmux.send_keys :Enter453 assert_equal '100', readonce.chomp454 end455 end456457 def test_select_1461 tmux.send_keys "seq 1 100 | #{fzf :with_nth, '..,..', :print_query, :q, 5555, :'1'}", :Enter458 tmux.send_keys "seq 1 100 | #{fzf(:with_nth, '..,..', :print_query, :q, 5555, :'1')}", :Enter459 assert_equal %w[5555 55], readonce.split($INPUT_RECORD_SEPARATOR)460 end461462 def test_exit_0466 tmux.send_keys "seq 1 100 | #{fzf :with_nth, '..,..', :print_query, :q, 555_555, :'0'}", :Enter467 assert_equal ['555555'], readonce.split($INPUT_RECORD_SEPARATOR)463 tmux.send_keys "seq 1 100 | #{fzf(:with_nth, '..,..', :print_query, :q, 555_555, :'0')}", :Enter464 assert_equal %w[555555], readonce.split($INPUT_RECORD_SEPARATOR)465 end466467 def test_select_1_exit_0_fail468 [:'0', :'1', %i[1 0]].each do |opt|472 tmux.send_keys "seq 1 100 | #{fzf :print_query, :multi, :q, 5, *opt}", :Enter469 tmux.send_keys "seq 1 100 | #{fzf(:print_query, :multi, :q, 5, *opt)}", :Enter470 tmux.until { |lines| lines.last =~ /^> 5/ }471 tmux.send_keys :BTab, :BTab, :BTab472 tmux.until { |lines| lines[-2].include?('(3)') }473 tmux.send_keys :Enter
1 unmodified line
475 end476 end477478 def test_query_unicode482 tmux.paste "(echo abc; echo $'\\352\\260\\200\\353\\202\\230\\353\\213\\244') | #{fzf :query, "$'\\352\\260\\200\\353\\213\\244'"}"483 tmux.until { |lines| lines[-2].include? '1/2' }479 tmux.paste "(echo abc; echo $'\\352\\260\\200\\353\\202\\230\\353\\213\\244') | #{fzf(:query, "$'\\352\\260\\200\\353\\213\\244'")}"480 tmux.until { |lines| lines[-2].include?('1/2') }481 tmux.send_keys :Enter485 assert_equal ['가나다'], readonce.split($INPUT_RECORD_SEPARATOR)482 assert_equal %w[가나다], readonce.split($INPUT_RECORD_SEPARATOR)483 end484485 def test_sync489 tmux.send_keys "seq 1 100 | #{fzf! :multi} | awk '{print $1 $1}' | #{fzf :sync}", :Enter486 tmux.send_keys "seq 1 100 | #{fzf!(:multi)} | awk '{print $1 $1}' | #{fzf(:sync)}", :Enter487 tmux.until { |lines| lines[-1] == '>' }488 tmux.send_keys 9489 tmux.until { |lines| lines[-2] == ' 19/100' }490 tmux.send_keys :BTab, :BTab, :BTab491 tmux.until { |lines| lines[-2].include?('(3)') }492 tmux.send_keys :Enter493 tmux.until { |lines| lines[-1] == '>' }494 tmux.send_keys 'C-K', :Enter498 assert_equal ['9090'], readonce.split($INPUT_RECORD_SEPARATOR)495 assert_equal %w[9090], readonce.split($INPUT_RECORD_SEPARATOR)496 end497498 def test_tac502 tmux.send_keys "seq 1 1000 | #{fzf :tac, :multi}", :Enter503 tmux.until { |lines| lines[-2].include? '1000/1000' }499 tmux.send_keys "seq 1 1000 | #{fzf(:tac, :multi)}", :Enter500 tmux.until { |lines| lines[-2].include?('1000/1000') }501 tmux.send_keys :BTab, :BTab, :BTab502 tmux.until { |lines| lines[-2].include?('(3)') }503 tmux.send_keys :Enter504 assert_equal %w[1000 999 998], readonce.split($INPUT_RECORD_SEPARATOR)505 end506507 def test_tac_sort511 tmux.send_keys "seq 1 1000 | #{fzf :tac, :multi}", :Enter512 tmux.until { |lines| lines[-2].include? '1000/1000' }508 tmux.send_keys "seq 1 1000 | #{fzf(:tac, :multi)}", :Enter509 tmux.until { |lines| lines[-2].include?('1000/1000') }510 tmux.send_keys '99'514 tmux.until { |lines| lines[-2].include? '28/1000' }511 tmux.until { |lines| lines[-2].include?('28/1000') }512 tmux.send_keys :BTab, :BTab, :BTab513 tmux.until { |lines| lines[-2].include?('(3)') }514 tmux.send_keys :Enter515 assert_equal %w[99 999 998], readonce.split($INPUT_RECORD_SEPARATOR)516 end517518 def test_tac_nosort522 tmux.send_keys "seq 1 1000 | #{fzf :tac, :no_sort, :multi}", :Enter523 tmux.until { |lines| lines[-2].include? '1000/1000' }519 tmux.send_keys "seq 1 1000 | #{fzf(:tac, :no_sort, :multi)}", :Enter520 tmux.until { |lines| lines[-2].include?('1000/1000') }521 tmux.send_keys '00'525 tmux.until { |lines| lines[-2].include? '10/1000' }522 tmux.until { |lines| lines[-2].include?('10/1000') }523 tmux.send_keys :BTab, :BTab, :BTab524 tmux.until { |lines| lines[-2].include?('(3)') }525 tmux.send_keys :Enter526 assert_equal %w[1000 900 800], readonce.split($INPUT_RECORD_SEPARATOR)527 end528529 def test_expect530 test = lambda do |key, feed, expected = key|534 tmux.send_keys "seq 1 100 | #{fzf :expect, key}; sync", :Enter535 tmux.until { |lines| lines[-2].include? '100/100' }531 tmux.send_keys "seq 1 100 | #{fzf(:expect, key)}; sync", :Enter532 tmux.until { |lines| lines[-2].include?('100/100') }533 tmux.send_keys '55'537 tmux.until { |lines| lines[-2].include? '1/100' }534 tmux.until { |lines| lines[-2].include?('1/100') }535 tmux.send_keys(*feed)536 tmux.prepare537 assert_equal [expected, '55'], readonce.split($INPUT_RECORD_SEPARATOR)538 end542 test.call 'ctrl-t', 'C-T'543 test.call 'ctrl-t', 'Enter', ''544 test.call 'alt-c', %i[Escape c]545 test.call 'f1', 'f1'546 test.call 'f2', 'f2'547 test.call 'f3', 'f3'548 test.call 'f2,f4', 'f2', 'f2'549 test.call 'f2,f4', 'f4', 'f4'550 test.call 'alt-/', %i[Escape /]539 test.call('ctrl-t', 'C-T')540 test.call('ctrl-t', 'Enter', '')541 test.call('alt-c', %i[Escape c])542 test.call('f1', 'f1')543 test.call('f2', 'f2')544 test.call('f3', 'f3')545 test.call('f2,f4', 'f2', 'f2')546 test.call('f2,f4', 'f4', 'f4')547 test.call('alt-/', %i[Escape /])548 %w[f5 f6 f7 f8 f9 f10].each do |key|552 test.call 'f5,f6,f7,f8,f9,f10', key, key549 test.call('f5,f6,f7,f8,f9,f10', key, key)550 end554 test.call '@', '@'551 test.call('@', '@')552 end553554 def test_expect_print_query558 tmux.send_keys "seq 1 100 | #{fzf '--expect=alt-z', :print_query}", :Enter559 tmux.until { |lines| lines[-2].include? '100/100' }555 tmux.send_keys "seq 1 100 | #{fzf('--expect=alt-z', :print_query)}", :Enter556 tmux.until { |lines| lines[-2].include?('100/100') }557 tmux.send_keys '55'561 tmux.until { |lines| lines[-2].include? '1/100' }558 tmux.until { |lines| lines[-2].include?('1/100') }559 tmux.send_keys :Escape, :z563 assert_equal ['55', 'alt-z', '55'], readonce.split($INPUT_RECORD_SEPARATOR)560 assert_equal %w[55 alt-z 55], readonce.split($INPUT_RECORD_SEPARATOR)561 end562563 def test_expect_printable_character_print_query567 tmux.send_keys "seq 1 100 | #{fzf '--expect=z --print-query'}", :Enter568 tmux.until { |lines| lines[-2].include? '100/100' }564 tmux.send_keys "seq 1 100 | #{fzf('--expect=z --print-query')}", :Enter565 tmux.until { |lines| lines[-2].include?('100/100') }566 tmux.send_keys '55'570 tmux.until { |lines| lines[-2].include? '1/100' }567 tmux.until { |lines| lines[-2].include?('1/100') }568 tmux.send_keys 'z'569 assert_equal %w[55 z 55], readonce.split($INPUT_RECORD_SEPARATOR)570 end571572 def test_expect_print_query_select_1576 tmux.send_keys "seq 1 100 | #{fzf '-q55 -1 --expect=alt-z --print-query'}", :Enter573 tmux.send_keys "seq 1 100 | #{fzf('-q55 -1 --expect=alt-z --print-query')}", :Enter574 assert_equal ['55', '', '55'], readonce.split($INPUT_RECORD_SEPARATOR)575 end576577 def test_toggle_sort578 ['--toggle-sort=ctrl-r', '--bind=ctrl-r:toggle-sort'].each do |opt|582 tmux.send_keys "seq 1 111 | #{fzf "-m +s --tac #{opt} -q11"}", :Enter583 tmux.until { |lines| lines[-3].include? '> 111' }579 tmux.send_keys "seq 1 111 | #{fzf("-m +s --tac #{opt} -q11")}", :Enter580 tmux.until { |lines| lines[-3].include?('> 111') }581 tmux.send_keys :Tab585 tmux.until { |lines| lines[-2].include? '4/111 -S (1)' }582 tmux.until { |lines| lines[-2].include?('4/111 -S (1)') }583 tmux.send_keys 'C-R'587 tmux.until { |lines| lines[-3].include? '> 11' }584 tmux.until { |lines| lines[-3].include?('> 11') }585 tmux.send_keys :Tab589 tmux.until { |lines| lines[-2].include? '4/111 +S (2)' }586 tmux.until { |lines| lines[-2].include?('4/111 +S (2)') }587 tmux.send_keys :Enter588 assert_equal %w[111 11], readonce.split($INPUT_RECORD_SEPARATOR)589 end590 end591592 def test_unicode_case596 writelines tempname, %w[строКА1 СТРОКА2 строка3 Строка4]593 writelines(tempname, %w[строКА1 СТРОКА2 строка3 Строка4])594 assert_equal %w[СТРОКА2 Строка4], `#{FZF} -fС < #{tempname}`.split($INPUT_RECORD_SEPARATOR)595 assert_equal %w[строКА1 СТРОКА2 строка3 Строка4], `#{FZF} -fс < #{tempname}`.split($INPUT_RECORD_SEPARATOR)596 end597
3 unmodified lines
601 -----foobar---602 ----foobar--603 -------foobar-604 ]608 writelines tempname, input605 writelines(tempname, input)606607 assert_equal input, `#{FZF} -ffoobar --tiebreak=index < #{tempname}`.split($INPUT_RECORD_SEPARATOR)608609 by_length = %w[
24 unmodified lines
634 assert_equal input, `#{FZF} -f"!z" -x --tiebreak end < #{tempname}`.split($INPUT_RECORD_SEPARATOR)635 end636637 def test_tiebreak_index_begin641 writelines tempname, [642 'xoxxxxxoxx',643 'xoxxxxxox',644 'xxoxxxoxx',645 'xxxoxoxxx',646 'xxxxoxox',647 ' xxoxoxxx'648 ]638 writelines(tempname, [639 'xoxxxxxoxx',640 'xoxxxxxox',641 'xxoxxxoxx',642 'xxxoxoxxx',643 'xxxxoxox',644 ' xxoxoxxx'645 ])646647 assert_equal [648 'xxxxoxox',649 ' xxoxoxxx',
33 unmodified lines
683 ], `#{FZF} -foo --tiebreak=begin,length < #{tempname}`.split($INPUT_RECORD_SEPARATOR)684 end685686 def test_tiebreak_begin_algo_v2690 writelines tempname, [691 'baz foo bar',692 'foo bar baz'693 ]687 writelines(tempname, [688 'baz foo bar',689 'foo bar baz'690 ])691 assert_equal [692 'foo bar baz',693 'baz foo bar'694 ], `#{FZF} -fbar --tiebreak=begin --algo=v2 < #{tempname}`.split($INPUT_RECORD_SEPARATOR)695 end696697 def test_tiebreak_end701 writelines tempname, [702 'xoxxxxxxxx',703 'xxoxxxxxxx',704 'xxxoxxxxxx',705 'xxxxoxxxx',706 'xxxxxoxxx',707 ' xxxxoxxx'708 ]698 writelines(tempname, [699 'xoxxxxxxxx',700 'xxoxxxxxxx',701 'xxxoxxxxxx',702 'xxxxoxxxx',703 'xxxxxoxxx',704 ' xxxxoxxx'705 ])706707 assert_equal [708 ' xxxxoxxx',709 'xxxxoxxxx',
28 unmodified lines
738 123:hello739 12345:he740 1234567:h741 ]745 writelines tempname, input742 writelines(tempname, input)743744 output = %w[745 1:hell746 12345:he
6 unmodified lines
753 assert_equal output, `#{FZF} -fh -n2 -d: < #{tempname}`.split($INPUT_RECORD_SEPARATOR)754 end755756 def test_invalid_cache760 tmux.send_keys "(echo d; echo D; echo x) | #{fzf '-q d'}", :Enter761 tmux.until { |lines| lines[-2].include? '2/3' }757 tmux.send_keys "(echo d; echo D; echo x) | #{fzf('-q d')}", :Enter758 tmux.until { |lines| lines[-2].include?('2/3') }759 tmux.send_keys :BSpace763 tmux.until { |lines| lines[-2].include? '3/3' }760 tmux.until { |lines| lines[-2].include?('3/3') }761 tmux.send_keys :D765 tmux.until { |lines| lines[-2].include? '1/3' }762 tmux.until { |lines| lines[-2].include?('1/3') }763 tmux.send_keys :Enter764 end765766 def test_invalid_cache_query_type
32 unmodified lines
799 assert_equal 1, `echo Foo bar | #{FZF} -x -f "foo Fbar" | wc -l`.to_i800 end801802 def test_bind806 tmux.send_keys "seq 1 1000 | #{fzf '-m --bind=ctrl-j:accept,u:up,T:toggle-up,t:toggle'}", :Enter807 tmux.until { |lines| lines[-2].end_with? '/1000' }803 tmux.send_keys "seq 1 1000 | #{fzf('-m --bind=ctrl-j:accept,u:up,T:toggle-up,t:toggle')}", :Enter804 tmux.until { |lines| lines[-2].end_with?('/1000') }805 tmux.send_keys 'uuu', 'TTT', 'tt', 'uu', 'ttt', 'C-j'806 assert_equal %w[4 5 6 9], readonce.split($INPUT_RECORD_SEPARATOR)807 end808809 def test_bind_print_query813 tmux.send_keys "seq 1 1000 | #{fzf '-m --bind=ctrl-j:print-query'}", :Enter814 tmux.until { |lines| lines[-2].end_with? '/1000' }810 tmux.send_keys "seq 1 1000 | #{fzf('-m --bind=ctrl-j:print-query')}", :Enter811 tmux.until { |lines| lines[-2].end_with?('/1000') }812 tmux.send_keys 'print-my-query', 'C-j'813 assert_equal %w[print-my-query], readonce.split($INPUT_RECORD_SEPARATOR)814 end815816 def test_bind_replace_query820 tmux.send_keys "seq 1 1000 | #{fzf '--print-query --bind=ctrl-j:replace-query'}", :Enter817 tmux.send_keys "seq 1 1000 | #{fzf('--print-query --bind=ctrl-j:replace-query')}", :Enter818 tmux.send_keys '1'822 tmux.until { |lines| lines[-2].end_with? '272/1000' }819 tmux.until { |lines| lines[-2].end_with?('272/1000') }820 tmux.send_keys 'C-k', 'C-j'824 tmux.until { |lines| lines[-2].end_with? '29/1000' }825 tmux.until { |lines| lines[-1].end_with? '> 10' }821 tmux.until { |lines| lines[-2].end_with?('29/1000') }822 tmux.until { |lines| lines[-1].end_with?('> 10') }823 end824825 def test_long_line826 data = '.' * 256 * 1024
5 unmodified lines
832833 def test_read0834 lines = `find .`.split($INPUT_RECORD_SEPARATOR)835 assert_equal lines.last, `find . | #{FZF} -e -f "^#{lines.last}$"`.chomp839 assert_equal(836 assert_equal \837 lines.last,838 `find . -print0 | #{FZF} --read0 -e -f "^#{lines.last}$"`.chomp842 )839 end840841 def test_select_all_deselect_all_toggle_all846 tmux.send_keys "seq 100 | #{fzf '--bind ctrl-a:select-all,ctrl-d:deselect-all,ctrl-t:toggle-all --multi'}", :Enter847 tmux.until { |lines| lines[-2].include? '100/100' }842 tmux.send_keys "seq 100 | #{fzf('--bind ctrl-a:select-all,ctrl-d:deselect-all,ctrl-t:toggle-all --multi')}", :Enter843 tmux.until { |lines| lines[-2].include?('100/100') }844 tmux.send_keys :BTab, :BTab, :BTab849 tmux.until { |lines| lines[-2].include? '(3)' }845 tmux.until { |lines| lines[-2].include?('(3)') }846 tmux.send_keys 'C-t'851 tmux.until { |lines| lines[-2].include? '(97)' }847 tmux.until { |lines| lines[-2].include?('(97)') }848 tmux.send_keys 'C-a'853 tmux.until { |lines| lines[-2].include? '(100)' }849 tmux.until { |lines| lines[-2].include?('(100)') }850 tmux.send_keys :Tab, :Tab855 tmux.until { |lines| lines[-2].include? '(98)' }851 tmux.until { |lines| lines[-2].include?('(98)') }852 tmux.send_keys '100'853 tmux.until { |lines| lines.match_count == 1 }854 tmux.send_keys 'C-d'859 tmux.until { |lines| lines[-2].include? '(97)' }855 tmux.until { |lines| lines[-2].include?('(97)') }856 tmux.send_keys 'C-u'857 tmux.until { |lines| lines.match_count == 100 }858 tmux.send_keys 'C-d'863 tmux.until { |lines| !lines[-2].include? '(' }859 tmux.until { |lines| !lines[-2].include?('(') }860 tmux.send_keys :BTab, :BTab865 tmux.until { |lines| lines[-2].include? '(2)' }861 tmux.until { |lines| lines[-2].include?('(2)') }862 tmux.send_keys 0867 tmux.until { |lines| lines[-2].include? '10/100' }863 tmux.until { |lines| lines[-2].include?('10/100') }864 tmux.send_keys 'C-a'869 tmux.until { |lines| lines[-2].include? '(12)' }865 tmux.until { |lines| lines[-2].include?('(12)') }866 tmux.send_keys :Enter867 assert_equal %w[1 2 10 20 30 40 50 60 70 80 90 100],868 readonce.split($INPUT_RECORD_SEPARATOR)869 end
2 unmodified lines
872 history_file = '/tmp/fzf-test-history'873874 # History with limited number of entries875 begin880 File.unlink history_file881 rescue876 File.unlink(history_file)877 rescue StandardError878 nil879 end880 opts = "--history=#{history_file} --history-size=4"881 input = %w[00 11 22 33 44].map { |e| e + $INPUT_RECORD_SEPARATOR }882 input.each do |keys|887 tmux.send_keys "seq 100 | #{fzf opts}", :Enter888 tmux.until { |lines| lines[-2].include? '100/100' }883 tmux.send_keys "seq 100 | #{fzf(opts)}", :Enter884 tmux.until { |lines| lines[-2].include?('100/100') }885 tmux.send_keys keys890 tmux.until { |lines| lines[-2].include? '1/100' }886 tmux.until { |lines| lines[-2].include?('1/100') }887 tmux.send_keys :Enter888 readonce889 end890 assert_equal input[1..-1], File.readlines(history_file)891892 # Update history entries (not changed on disk)897 tmux.send_keys "seq 100 | #{fzf opts}", :Enter898 tmux.until { |lines| lines[-2].include? '100/100' }893 tmux.send_keys "seq 100 | #{fzf(opts)}", :Enter894 tmux.until { |lines| lines[-2].include?('100/100') }895 tmux.send_keys 'C-p'900 tmux.until { |lines| lines[-1].end_with? '> 44' }896 tmux.until { |lines| lines[-1].end_with?('> 44') }897 tmux.send_keys 'C-p'902 tmux.until { |lines| lines[-1].end_with? '> 33' }898 tmux.until { |lines| lines[-1].end_with?('> 33') }899 tmux.send_keys :BSpace904 tmux.until { |lines| lines[-1].end_with? '> 3' }900 tmux.until { |lines| lines[-1].end_with?('> 3') }901 tmux.send_keys 1906 tmux.until { |lines| lines[-1].end_with? '> 31' }902 tmux.until { |lines| lines[-1].end_with?('> 31') }903 tmux.send_keys 'C-p'908 tmux.until { |lines| lines[-1].end_with? '> 22' }904 tmux.until { |lines| lines[-1].end_with?('> 22') }905 tmux.send_keys 'C-n'910 tmux.until { |lines| lines[-1].end_with? '> 31' }906 tmux.until { |lines| lines[-1].end_with?('> 31') }907 tmux.send_keys 0912 tmux.until { |lines| lines[-1].end_with? '> 310' }908 tmux.until { |lines| lines[-1].end_with?('> 310') }909 tmux.send_keys :Enter910 readonce911 assert_equal %w[22 33 44 310].map { |e| e + $INPUT_RECORD_SEPARATOR }, File.readlines(history_file)912913 # Respect --bind option918 tmux.send_keys "seq 100 | #{fzf opts + ' --bind ctrl-p:next-history,ctrl-n:previous-history'}", :Enter919 tmux.until { |lines| lines[-2].include? '100/100' }914 tmux.send_keys "seq 100 | #{fzf(opts + ' --bind ctrl-p:next-history,ctrl-n:previous-history')}", :Enter915 tmux.until { |lines| lines[-2].include?('100/100') }916 tmux.send_keys 'C-n', 'C-n', 'C-n', 'C-n', 'C-p'917 tmux.until { |lines| lines[-1].end_with?('33') }918 tmux.send_keys :Enter919 ensure924 File.unlink history_file920 File.unlink(history_file)921 end922923 def test_execute924 output = '/tmp/fzf-test-execute'925 opts = %[--bind "alt-a:execute(echo /{}/ >> #{output}),alt-b:execute[echo /{}{}/ >> #{output}],C:execute:echo /{}{}{}/ >> #{output}"]930 wait = ->(exp) { tmux.until { |lines| lines[-2].include? exp } }931 writelines tempname, %w[foo'bar foo"bar foo$bar]932 tmux.send_keys "cat #{tempname} | #{fzf opts}; sync", :Enter926 wait = ->(exp) { tmux.until { |lines| lines[-2].include?(exp) } }927 writelines(tempname, %w[foo'bar foo"bar foo$bar])928 tmux.send_keys "cat #{tempname} | #{fzf(opts)}; sync", :Enter929 wait['3/3']930 tmux.send_keys :Escape, :a931 wait['/3']932 tmux.send_keys :Escape, :a
19 unmodified lines
952 /foo$barfoo$barfoo$bar/],953 File.readlines(output).map(&:chomp)954 ensure955 begin960 File.unlink output961 rescue956 File.unlink(output)957 rescue StandardError958 nil959 end960 end961962 def test_execute_multi963 output = '/tmp/fzf-test-execute-multi'964 opts = %[--multi --bind "alt-a:execute-multi(echo {}/{+} >> #{output}; sync)"]969 writelines tempname, %w[foo'bar foo"bar foo$bar foobar]970 tmux.send_keys "cat #{tempname} | #{fzf opts}", :Enter971 tmux.until { |lines| lines[-2].include? '4/4' }965 writelines(tempname, %w[foo'bar foo"bar foo$bar foobar])966 tmux.send_keys "cat #{tempname} | #{fzf(opts)}", :Enter967 tmux.until { |lines| lines[-2].include?('4/4') }968 tmux.send_keys :Escape, :a973 tmux.until { |lines| lines[-2].include? '/4' }969 tmux.until { |lines| lines[-2].include?('/4') }970 tmux.send_keys :BTab, :BTab, :BTab971 tmux.send_keys :Escape, :a976 tmux.until { |lines| lines[-2].include? '/4' }972 tmux.until { |lines| lines[-2].include?('/4') }973 tmux.send_keys :Tab, :Tab974 tmux.send_keys :Escape, :a979 tmux.until { |lines| lines[-2].include? '/4' }975 tmux.until { |lines| lines[-2].include?('/4') }976 tmux.send_keys :Enter977 tmux.prepare978 readonce979 assert_equal [%(foo'bar/foo'bar),
1 unmodified line
981 %(foo'bar foo"bar foobar/foo'bar foo"bar foobar)],982 File.readlines(output).map(&:chomp)983 ensure984 begin989 File.unlink output990 rescue985 File.unlink(output)986 rescue StandardError987 nil988 end989 end990991 def test_execute_plus_flag992 output = tempname + '.tmp'993 begin998 File.unlink output999 rescue994 File.unlink(output)995 rescue StandardError996 nil997 end1002 writelines tempname, ['foo bar', '123 456']998 writelines(tempname, ['foo bar', '123 456'])9991000 tmux.send_keys "cat #{tempname} | #{FZF} --multi --bind 'x:execute-silent(echo {+}/{}/{+2}/{2} >> #{output})'", :Enter10011002 execute = lambda do1003 tmux.send_keys 'x', 'y'1008 tmux.until { |lines| lines[-2].include? '0/2' }1004 tmux.until { |lines| lines[-2].include?('0/2') }1005 tmux.send_keys :BSpace1010 tmux.until { |lines| lines[-2].include? '2/2' }1006 tmux.until { |lines| lines[-2].include?('2/2') }1007 end10081013 tmux.until { |lines| lines[-2].include? '2/2' }1009 tmux.until { |lines| lines[-2].include?('2/2') }1010 execute.call10111012 tmux.send_keys :Up1013 tmux.send_keys :Tab
10 unmodified lines
1024 %(foo bar/foo bar/bar/bar),1025 %(123 456/foo bar/456/bar),1026 %(123 456 foo bar/foo bar/456 bar/bar)1027 ], File.readlines(output).map(&:chomp)1032 rescue1028 rescue StandardError1029 begin1034 File.unlink output1035 rescue1030 File.unlink(output)1031 rescue StandardError1032 nil1033 end1034 end10351036 def test_execute_shell1037 # Custom script to use as $SHELL1038 output = tempname + '.out'1039 begin1044 File.unlink output1045 rescue1040 File.unlink(output)1041 rescue StandardError1042 nil1043 end1048 writelines tempname,1049 ['#!/usr/bin/env bash', "echo $1 / $2 > #{output}", 'sync']1050 system "chmod +x #{tempname}"1044 writelines(tempname,1045 ['#!/usr/bin/env bash', "echo $1 / $2 > #{output}", 'sync'])1046 system("chmod +x #{tempname}")10471048 tmux.send_keys "echo foo | SHELL=#{tempname} fzf --bind 'enter:execute:{}bar'", :Enter1053 tmux.until { |lines| lines[-2].include? '1/1' }1049 tmux.until { |lines| lines[-2].include?('1/1') }1050 tmux.send_keys :Enter1055 tmux.until { |lines| lines[-2].include? '1/1' }1051 tmux.until { |lines| lines[-2].include?('1/1') }1052 tmux.send_keys 'C-c'1053 tmux.prepare1054 assert_equal ["-c / 'foo'bar"], File.readlines(output).map(&:chomp)1055 ensure1056 begin1061 File.unlink output1062 rescue1057 File.unlink(output)1058 rescue StandardError1059 nil1060 end1061 end10621063 def test_cycle1068 tmux.send_keys "seq 8 | #{fzf :cycle}", :Enter1069 tmux.until { |lines| lines[-2].include? '8/8' }1064 tmux.send_keys "seq 8 | #{fzf(:cycle)}", :Enter1065 tmux.until { |lines| lines[-2].include?('8/8') }1066 tmux.send_keys :Down1071 tmux.until { |lines| lines[-10].start_with? '>' }1067 tmux.until { |lines| lines[-10].start_with?('>') }1068 tmux.send_keys :Down1073 tmux.until { |lines| lines[-9].start_with? '>' }1069 tmux.until { |lines| lines[-9].start_with?('>') }1070 tmux.send_keys :Up1075 tmux.until { |lines| lines[-10].start_with? '>' }1071 tmux.until { |lines| lines[-10].start_with?('>') }1072 tmux.send_keys :PgUp1077 tmux.until { |lines| lines[-10].start_with? '>' }1073 tmux.until { |lines| lines[-10].start_with?('>') }1074 tmux.send_keys :Up1079 tmux.until { |lines| lines[-3].start_with? '>' }1075 tmux.until { |lines| lines[-3].start_with?('>') }1076 tmux.send_keys :PgDn1081 tmux.until { |lines| lines[-3].start_with? '>' }1077 tmux.until { |lines| lines[-3].start_with?('>') }1078 tmux.send_keys :Down1083 tmux.until { |lines| lines[-10].start_with? '>' }1079 tmux.until { |lines| lines[-10].start_with?('>') }1080 end10811082 def test_header_lines1087 tmux.send_keys "seq 100 | #{fzf '--header-lines=10 -q 5'}", :Enter1083 tmux.send_keys "seq 100 | #{fzf('--header-lines=10 -q 5')}", :Enter1084 2.times do1085 tmux.until do |lines|1086 lines[-2].include?('/90') &&1087 lines[-3] == ' 1' &&
6 unmodified lines
1094 assert_equal '50', readonce.chomp1095 end10961097 def test_header_lines_reverse1102 tmux.send_keys "seq 100 | #{fzf '--header-lines=10 -q 5 --reverse'}", :Enter1098 tmux.send_keys "seq 100 | #{fzf('--header-lines=10 -q 5 --reverse')}", :Enter1099 2.times do1100 tmux.until do |lines|1101 lines[1].include?('/90') &&1102 lines[2] == ' 1' &&
6 unmodified lines
1109 assert_equal '50', readonce.chomp1110 end11111112 def test_header_lines_reverse_list1117 tmux.send_keys "seq 100 | #{fzf '--header-lines=10 -q 5 --layout=reverse-list'}", :Enter1113 tmux.send_keys "seq 100 | #{fzf('--header-lines=10 -q 5 --layout=reverse-list')}", :Enter1114 2.times do1115 tmux.until do |lines|1116 lines[0] == '> 50' &&1117 lines[-4] == ' 2' &&
6 unmodified lines
1124 assert_equal '50', readonce.chomp1125 end11261127 def test_header_lines_overflow1132 tmux.send_keys "seq 100 | #{fzf '--header-lines=200'}", :Enter1128 tmux.send_keys "seq 100 | #{fzf('--header-lines=200')}", :Enter1129 tmux.until do |lines|1130 lines[-2].include?('0/0') &&1131 lines[-3].include?(' 1')1132 end
1 unmodified line
1134 assert_equal '', readonce.chomp1135 end11361137 def test_header_lines_with_nth1142 tmux.send_keys "seq 100 | #{fzf '--header-lines 5 --with-nth 1,1,1,1,1'}", :Enter1138 tmux.send_keys "seq 100 | #{fzf('--header-lines 5 --with-nth 1,1,1,1,1')}", :Enter1139 tmux.until do |lines|1140 lines[-2].include?('95/95') &&1141 lines[-3] == ' 11111' &&1142 lines[-7] == ' 55555' &&
3 unmodified lines
1146 assert_equal '6', readonce.chomp1147 end11481149 def test_header1154 tmux.send_keys "seq 100 | #{fzf "--header \"$(head -5 #{FILE})\""}", :Enter1150 tmux.send_keys "seq 100 | #{fzf("--header \"$(head -5 #{FILE})\"")}", :Enter1151 header = File.readlines(FILE).take(5).map(&:strip)1152 tmux.until do |lines|1153 lines[-2].include?('100/100') &&1154 lines[-7..-3].map(&:strip) == header &&
1 unmodified line
1156 end1157 end11581159 def test_header_reverse1164 tmux.send_keys "seq 100 | #{fzf "--header \"$(head -5 #{FILE})\" --reverse"}", :Enter1160 tmux.send_keys "seq 100 | #{fzf("--header \"$(head -5 #{FILE})\" --reverse")}", :Enter1161 header = File.readlines(FILE).take(5).map(&:strip)1162 tmux.until do |lines|1163 lines[1].include?('100/100') &&1164 lines[2..6].map(&:strip) == header &&
1 unmodified line
1166 end1167 end11681169 def test_header_reverse_list1174 tmux.send_keys "seq 100 | #{fzf "--header \"$(head -5 #{FILE})\" --layout=reverse-list"}", :Enter1170 tmux.send_keys "seq 100 | #{fzf("--header \"$(head -5 #{FILE})\" --layout=reverse-list")}", :Enter1171 header = File.readlines(FILE).take(5).map(&:strip)1172 tmux.until do |lines|1173 lines[-2].include?('100/100') &&1174 lines[-7..-3].map(&:strip) == header &&
1 unmodified line
1176 end1177 end11781179 def test_header_and_header_lines1184 tmux.send_keys "seq 100 | #{fzf "--header-lines 10 --header \"$(head -5 #{FILE})\""}", :Enter1180 tmux.send_keys "seq 100 | #{fzf("--header-lines 10 --header \"$(head -5 #{FILE})\"")}", :Enter1181 header = File.readlines(FILE).take(5).map(&:strip)1182 tmux.until do |lines|1183 lines[-2].include?('90/90') &&1184 lines[-7...-2].map(&:strip) == header &&
1 unmodified line
1186 end1187 end11881189 def test_header_and_header_lines_reverse1194 tmux.send_keys "seq 100 | #{fzf "--reverse --header-lines 10 --header \"$(head -5 #{FILE})\""}", :Enter1190 tmux.send_keys "seq 100 | #{fzf("--reverse --header-lines 10 --header \"$(head -5 #{FILE})\"")}", :Enter1191 header = File.readlines(FILE).take(5).map(&:strip)1192 tmux.until do |lines|1193 lines[1].include?('90/90') &&1194 lines[2...7].map(&:strip) == header &&
1 unmodified line
1196 end1197 end11981199 def test_header_and_header_lines_reverse_list1204 tmux.send_keys "seq 100 | #{fzf "--layout=reverse-list --header-lines 10 --header \"$(head -5 #{FILE})\""}", :Enter1200 tmux.send_keys "seq 100 | #{fzf("--layout=reverse-list --header-lines 10 --header \"$(head -5 #{FILE})\"")}", :Enter1201 header = File.readlines(FILE).take(5).map(&:strip)1202 tmux.until do |lines|1203 lines[-2].include?('90/90') &&1204 lines[-7...-2].map(&:strip) == header &&
1 unmodified line
1206 end1207 end12081209 def test_cancel1214 tmux.send_keys "seq 10 | #{fzf '--bind 2:cancel'}", :Enter1210 tmux.send_keys "seq 10 | #{fzf('--bind 2:cancel')}", :Enter1211 tmux.until { |lines| lines[-2].include?('10/10') }1212 tmux.send_keys '123'1213 tmux.until { |lines| lines[-1] == '> 3' && lines[-2].include?('1/10') }1214 tmux.send_keys 'C-y', 'C-y'
4 unmodified lines
1219 tmux.prepare1220 end12211222 def test_margin1227 tmux.send_keys "yes | head -1000 | #{fzf '--margin 5,3'}", :Enter1223 tmux.send_keys "yes | head -1000 | #{fzf('--margin 5,3')}", :Enter1224 tmux.until { |lines| lines[4] == '' && lines[5] == ' y' }1225 tmux.send_keys :Enter1226 end12271228 def test_margin_reverse1233 tmux.send_keys "seq 1000 | #{fzf '--margin 7,5 --reverse'}", :Enter1229 tmux.send_keys "seq 1000 | #{fzf('--margin 7,5 --reverse')}", :Enter1230 tmux.until { |lines| lines[1 + 7] == ' 1000/1000' }1231 tmux.send_keys :Enter1232 end12331234 def test_margin_reverse_list1239 tmux.send_keys "yes | head -1000 | #{fzf '--margin 5,3 --layout=reverse-list'}", :Enter1235 tmux.send_keys "yes | head -1000 | #{fzf('--margin 5,3 --layout=reverse-list')}", :Enter1236 tmux.until { |lines| lines[4] == '' && lines[5] == ' > y' }1237 tmux.send_keys :Enter1238 end12391240 def test_tabstop1245 writelines tempname, ["f\too\tba\tr\tbaz\tbarfooq\tux"]1241 writelines(tempname, %W[f\too\tba\tr\tbaz\tbarfooq\tux])1242 {1243 1 => '> f oo ba r baz barfooq ux',1244 2 => '> f oo ba r baz barfooq ux',1245 3 => '> f oo ba r baz barfooq ux',
6 unmodified lines
1252 }.each do |ts, exp|1253 tmux.prepare1254 tmux.send_keys %(cat #{tempname} | fzf --tabstop=#{ts}), :Enter1255 tmux.until(true) do |lines|1260 exp.start_with? lines[-3].to_s.strip.sub(/\.\.$/, '')1256 exp.start_with?(lines[-3].to_s.strip.sub(/\.\.$/, ''))1257 end1258 tmux.send_keys :Enter1259 end1260 end12611262 def test_with_nth_basic1267 writelines tempname, ['hello world ', 'byebye']1268 assert_equal(1263 writelines(tempname, ['hello world ', 'byebye'])1264 assert_equal \1265 'hello world ',1266 `#{FZF} -f"^he hehe" -x -n 2.. --with-nth 2,1,1 < #{tempname}`.chomp1271 )1267 end12681269 def test_with_nth_ansi1275 writelines tempname, ["\x1b[33mhello \x1b[34;1mworld\x1b[m ", 'byebye']1276 assert_equal(1270 writelines(tempname, ["\x1b[33mhello \x1b[34;1mworld\x1b[m ", 'byebye'])1271 assert_equal \1272 'hello world ',1273 `#{FZF} -f"^he hehe" -x -n 2.. --with-nth 2,1,1 --ansi < #{tempname}`.chomp1279 )1274 end12751276 def test_with_nth_no_ansi1277 src = "\x1b[33mhello \x1b[34;1mworld\x1b[m "1284 writelines tempname, [src, 'byebye']1285 assert_equal(1278 writelines(tempname, [src, 'byebye'])1279 assert_equal \1280 src,1281 `#{FZF} -fhehe -x -n 2.. --with-nth 2,1,1 --no-ansi < #{tempname}`.chomp1288 )1282 end12831284 def test_exit_0_exit_code1285 `echo foo | #{FZF} -q bar -0`
21 unmodified lines
1307 { '99' => '0', '999' => '1' }.each do |query, status|1308 tmux.send_keys "seq 100 | #{FZF} -q #{query}; echo --$?--", :Enter1309 tmux.until { |lines| lines[-2] =~ %r{ [10]/100} }1310 tmux.send_keys :Enter1318 tmux.until { |lines| lines.last.include? "--#{status}--" }1311 tmux.until { |lines| lines.last.include?("--#{status}--") }1312 end1313 end13141315 def test_default_extended
13 unmodified lines
1329 `seq 10 | #{FZF} -f '1 | !1'`.lines.map(&:chomp)1330 end13311332 def test_hscroll_off1340 writelines tempname, ['=' * 10_000 + '0123456789']1333 writelines(tempname, ['=' * 10_000 + '0123456789'])1334 [0, 3, 6].each do |off|1335 tmux.prepare1336 tmux.send_keys "#{FZF} --hscroll-off=#{off} -q 0 < #{tempname}", :Enter1337 tmux.until { |lines| lines[-3].end_with?((0..off).to_a.join + '..') }1338 tmux.send_keys '9'1346 tmux.until { |lines| lines[-3].end_with? '789' }1339 tmux.until { |lines| lines[-3].end_with?('789') }1340 tmux.send_keys :Enter1341 end1342 end1343
7 unmodified lines
1351 tmux.send_keys :Enter1352 end13531354 def test_jump1362 tmux.send_keys "seq 1000 | #{fzf "--multi --jump-labels 12345 --bind 'ctrl-j:jump'"}", :Enter1355 tmux.send_keys "seq 1000 | #{fzf("--multi --jump-labels 12345 --bind 'ctrl-j:jump'")}", :Enter1356 tmux.until { |lines| lines[-2] == ' 1000/1000' }1357 tmux.send_keys 'C-j'1358 tmux.until { |lines| lines[-7] == '5 5' }1359 tmux.until { |lines| lines[-8] == ' 6' }
19 unmodified lines
1379 assert_equal %w[5 2 1], readonce.split($INPUT_RECORD_SEPARATOR)1380 end13811382 def test_jump_accept1390 tmux.send_keys "seq 1000 | #{fzf "--multi --jump-labels 12345 --bind 'ctrl-j:jump-accept'"}", :Enter1383 tmux.send_keys "seq 1000 | #{fzf("--multi --jump-labels 12345 --bind 'ctrl-j:jump-accept'")}", :Enter1384 tmux.until { |lines| lines[-2] == ' 1000/1000' }1385 tmux.send_keys 'C-j'1386 tmux.until { |lines| lines[-7] == '5 5' }1387 tmux.send_keys '3'
1 unmodified line
1389 end13901391 def test_pointer1392 pointer = '>>'1400 tmux.send_keys "seq 10 | #{fzf "--pointer '#{pointer}'"}", :Enter1393 tmux.send_keys "seq 10 | #{fzf("--pointer '#{pointer}'")}", :Enter1394 tmux.until { |lines| lines[-2] == ' 10/10' }1395 lines = tmux.capture1396 # Assert that specified pointer is displayed1397 assert_equal "#{pointer} 1", lines[-3]1398 end13991400 def test_pointer_with_jump1401 pointer = '>>'1409 tmux.send_keys "seq 10 | #{fzf "--multi --jump-labels 12345 --bind 'ctrl-j:jump' --pointer '#{pointer}'"}", :Enter1402 tmux.send_keys "seq 10 | #{fzf("--multi --jump-labels 12345 --bind 'ctrl-j:jump' --pointer '#{pointer}'")}", :Enter1403 tmux.until { |lines| lines[-2] == ' 10/10' }1404 tmux.send_keys 'C-j'1405 # Correctly padded jump label should appear1406 tmux.until { |lines| lines[-7] == '5 5' }
5 unmodified lines
1412 end14131414 def test_marker1415 marker = '>>'1423 tmux.send_keys "seq 10 | #{fzf "--multi --marker '#{marker}'"}", :Enter1416 tmux.send_keys "seq 10 | #{fzf("--multi --marker '#{marker}'")}", :Enter1417 tmux.until { |lines| lines[-2] == ' 10/10' }1418 tmux.send_keys :BTab1419 lines = tmux.capture1420 # Assert that specified marker is displayed
11 unmodified lines
1432 tmux.until { |lines| !lines[1].include?(' {555-555}') }1433 tmux.send_keys '?'1434 tmux.until { |lines| lines[1].include?(' {555-555}') }1435 tmux.send_keys :BSpace1443 tmux.until { |lines| lines[-2].start_with? ' 28/1000' }1436 tmux.until { |lines| lines[-2].start_with?(' 28/1000') }1437 tmux.send_keys 'foobar'1438 tmux.until { |lines| !lines[1].include?('{') }1439 tmux.send_keys 'C-u'1440 tmux.until { |lines| lines.match_count == 1000 }
20 unmodified lines
1461 end14621463 def test_preview_size_01464 begin1472 File.unlink tempname1473 rescue1465 File.unlink(tempname)1466 rescue StandardError1467 nil1468 end1469 tmux.send_keys %(seq 100 | #{FZF} --reverse --preview 'echo {} >> #{tempname}; echo ' --preview-window 0), :Enter1470 tmux.until { |lines| lines.item_count == 100 && lines[1] == ' 100/100' && lines[2] == '> 1' }1478 tmux.until { |_| %w[1] == File.readlines(tempname).map(&:chomp) }1471 tmux.until { |_| File.readlines(tempname).map(&:chomp) == %w[1] }1472 tmux.send_keys :Down1473 tmux.until { |lines| lines[3] == '> 2' }1481 tmux.until { |_| %w[1 2] == File.readlines(tempname).map(&:chomp) }1474 tmux.until { |_| File.readlines(tempname).map(&:chomp) == %w[1 2] }1475 tmux.send_keys :Down1476 tmux.until { |lines| lines[4] == '> 3' }1484 tmux.until { |_| %w[1 2 3] == File.readlines(tempname).map(&:chomp) }1477 tmux.until { |_| File.readlines(tempname).map(&:chomp) == %w[1 2 3] }1478 end14791480 def test_preview_flags1481 tmux.send_keys %(seq 10 | sed 's/^/:: /; s/$/ /' |
43 unmodified lines
1525 tmux.send_keys "seq 10 | fzf --no-clear --inline-info --height 5 > #{tempname}", :Enter1526 prompt = '> < 10/10'1527 tmux.until { |lines| lines[-1] == prompt }1528 tmux.send_keys :Enter1536 tmux.until { |_| %w[1] == File.readlines(tempname).map(&:chomp) }1529 tmux.until { |_| File.readlines(tempname).map(&:chomp) == %w[1] }1530 tmux.until { |lines| lines[-1] == prompt }1531 end15321533 def test_info_hidden
15 unmodified lines
1549 tmux.send_keys :Enter1550 end15511552 def test_accept_non_empty1560 tmux.send_keys %(seq 1000 | #{fzf '--print-query --bind enter:accept-non-empty'}), :Enter1553 tmux.send_keys %(seq 1000 | #{fzf('--print-query --bind enter:accept-non-empty')}), :Enter1554 tmux.until { |lines| lines.match_count == 1000 }1555 tmux.send_keys 'foo'1563 tmux.until { |lines| lines[-2].include? '0/1000' }1556 tmux.until { |lines| lines[-2].include?('0/1000') }1557 # fzf doesn't exit since there's no selection1558 tmux.send_keys :Enter1566 tmux.until { |lines| lines[-2].include? '0/1000' }1559 tmux.until { |lines| lines[-2].include?('0/1000') }1560 tmux.send_keys 'C-u'1568 tmux.until { |lines| lines[-2].include? '1000/1000' }1561 tmux.until { |lines| lines[-2].include?('1000/1000') }1562 tmux.send_keys '999'1570 tmux.until { |lines| lines[-2].include? '1/1000' }1563 tmux.until { |lines| lines[-2].include?('1/1000') }1564 tmux.send_keys :Enter1565 assert_equal %w[999 999], readonce.split($INPUT_RECORD_SEPARATOR)1566 end15671568 def test_accept_non_empty_with_multi_selection1576 tmux.send_keys %(seq 1000 | #{fzf '-m --print-query --bind enter:accept-non-empty'}), :Enter1569 tmux.send_keys %(seq 1000 | #{fzf('-m --print-query --bind enter:accept-non-empty')}), :Enter1570 tmux.until { |lines| lines.match_count == 1000 }1571 tmux.send_keys :Tab1579 tmux.until { |lines| lines[-2].include? '1000/1000 (1)' }1572 tmux.until { |lines| lines[-2].include?('1000/1000 (1)') }1573 tmux.send_keys 'foo'1581 tmux.until { |lines| lines[-2].include? '0/1000' }1574 tmux.until { |lines| lines[-2].include?('0/1000') }1575 # fzf will exit in this case even though there's no match for the current query1576 tmux.send_keys :Enter1577 assert_equal %w[foo 1], readonce.split($INPUT_RECORD_SEPARATOR)1578 end15791580 def test_accept_non_empty_with_empty_list1588 tmux.send_keys %(: | #{fzf '-q foo --print-query --bind enter:accept-non-empty'}), :Enter1581 tmux.send_keys %(: | #{fzf('-q foo --print-query --bind enter:accept-non-empty')}), :Enter1582 tmux.until { |lines| lines[-2].strip == '0/0' }1583 tmux.send_keys :Enter1584 # fzf will exit anyway since input list is empty1585 assert_equal %w[foo], readonce.split($INPUT_RECORD_SEPARATOR)1586 end15871588 def test_preview_update_on_select1596 tmux.send_keys(%(seq 10 | fzf -m --preview 'echo {+}' --bind a:toggle-all),1597 :Enter)1589 tmux.send_keys %(seq 10 | fzf -m --preview 'echo {+}' --bind a:toggle-all),1590 :Enter1591 tmux.until { |lines| lines.item_count == 10 }1592 tmux.send_keys 'a'1600 tmux.until { |lines| lines.any? { |line| line.include? '1 2 3 4 5' } }1593 tmux.until { |lines| lines.any? { |line| line.include?('1 2 3 4 5') } }1594 tmux.send_keys 'a'1602 tmux.until { |lines| lines.none? { |line| line.include? '1 2 3 4 5' } }1595 tmux.until { |lines| lines.none? { |line| line.include?('1 2 3 4 5') } }1596 end15971598 def test_escaped_meta_characters1606 input = <<~EOF1607 foo^bar1608 foo$bar1609 foo!bar1610 foo'bar1611 foo bar1612 bar foo1613 EOF1614 writelines tempname, input.lines.map(&:chomp)1599 input = [1600 'foo^bar',1601 'foo$bar',1602 'foo!bar',1603 "foo'bar",1604 'foo bar',1605 'bar foo'1606 ]1607 writelines(tempname, input)16081616 assert_equal input.lines.count, `#{FZF} -f'foo bar' < #{tempname}`.lines.count1617 assert_equal input.lines.count - 1, `#{FZF} -f'^foo bar$' < #{tempname}`.lines.count1609 assert_equal input.length, `#{FZF} -f'foo bar' < #{tempname}`.lines.length1610 assert_equal input.length - 1, `#{FZF} -f'^foo bar$' < #{tempname}`.lines.length1611 assert_equal ['foo bar'], `#{FZF} -f'foo\\ bar' < #{tempname}`.lines.map(&:chomp)1612 assert_equal ['foo bar'], `#{FZF} -f'^foo\\ bar$' < #{tempname}`.lines.map(&:chomp)1620 assert_equal input.lines.count - 1, `#{FZF} -f'!^foo\\ bar$' < #{tempname}`.lines.count1613 assert_equal input.length - 1, `#{FZF} -f'!^foo\\ bar$' < #{tempname}`.lines.length1614 end16151616 def test_inverse_only_search_should_not_sort_the_result1617 # Filter1625 assert_equal(%w[aaaaa b ccc],1626 `printf '%s\n' aaaaa b ccc BAD | #{FZF} -f '!bad'`.lines.map(&:chomp))1618 assert_equal %w[aaaaa b ccc],1619 `printf '%s\n' aaaaa b ccc BAD | #{FZF} -f '!bad'`.lines.map(&:chomp)16201621 # Interactive1629 tmux.send_keys(%[printf '%s\n' aaaaa b ccc BAD | #{FZF} -q '!bad'], :Enter)1622 tmux.send_keys %(printf '%s\n' aaaaa b ccc BAD | #{FZF} -q '!bad'), :Enter1623 tmux.until { |lines| lines.item_count == 4 && lines.match_count == 3 }1624 tmux.until { |lines| lines[-3] == '> aaaaa' }1625 tmux.until { |lines| lines[-4] == ' b' }1626 tmux.until { |lines| lines[-5] == ' ccc' }1627 end16281629 def test_preview_correct_tab_width_after_ansi_reset_code1637 writelines tempname, ["\x1b[31m+\x1b[m\t\x1b[32mgreen"]1630 writelines(tempname, ["\x1b[31m+\x1b[m\t\x1b[32mgreen"])1631 tmux.send_keys "#{FZF} --preview 'cat #{tempname}'", :Enter1632 tmux.until { |lines| lines[1].include?('+ green') }1633 end1634
21 unmodified lines
1656 end16571658 def test_reload_even_when_theres_no_match1659 tmux.send_keys %(: | #{FZF} --bind 'space:reload(seq 10)'), :Enter1667 tmux.until { |lines| lines.item_count.zero? }1660 tmux.until { |lines| lines.item_count == 0 }1661 tmux.send_keys :Space1662 tmux.until { |lines| lines.item_count == 10 }1663 end1664
5 unmodified lines
1670 end16711672 def test_clear_query1673 tmux.send_keys %(: | #{FZF} --query foo --bind space:clear-query), :Enter1681 tmux.until { |lines| lines.item_count.zero? }1674 tmux.until { |lines| lines.item_count == 0 }1675 tmux.until { |lines| lines.last.include?('> foo') }1676 tmux.send_keys 'C-a', 'bar'1677 tmux.until { |lines| lines.last.include?('> barfoo') }1678 tmux.send_keys :Space
5 unmodified lines
1684 tmux.until { |lines| lines.match_count == 100 }1685 tmux.send_keys :Tab1686 tmux.until { |lines| lines[-2].include?('(1)') }1687 tmux.send_keys 'foo'1695 tmux.until { |lines| lines.match_count.zero? }1688 tmux.until { |lines| lines.match_count == 0 }1689 tmux.until { |lines| lines[-2].include?('(1)') }1690 tmux.send_keys :Space1698 tmux.until { |lines| lines.match_count.zero? }1691 tmux.until { |lines| lines.match_count == 0 }1692 tmux.until { |lines| !lines[-2].include?('(1)') }1693 end16941695 def test_backward_delete_char_eof1703 tmux.send_keys "seq 1000 | #{fzf "--bind 'bs:backward-delete-char/eof'"}", :Enter1696 tmux.send_keys "seq 1000 | #{fzf("--bind 'bs:backward-delete-char/eof'")}", :Enter1697 tmux.until { |lines| lines[-2] == ' 1000/1000' }1698 tmux.send_keys '11'1699 tmux.until { |lines| lines[-1] == '> 11' }1700 tmux.send_keys :BSpace
5 unmodified lines
1706 end17071708 def test_strip_xterm_osc_sequence1709 %W[\x07 \x1b\\].each do |esc|1717 writelines tempname, [%(printf $1"\e]4;3;rgb:aa/bb/cc#{esc} "$2)]1710 writelines(tempname, [%(printf $1"\e]4;3;rgb:aa/bb/cc#{esc} "$2)])1711 File.chmod(0o755, tempname)1712 tmux.prepare1720 tmux.send_keys(1713 tmux.send_keys \1714 %(echo foo bar | #{FZF} --preview '#{tempname} {2} {1}'), :Enter1722 )17151716 tmux.until { |lines| lines.any_include?('bar foo') }1717 tmux.send_keys :Enter1718 end1719 end17201721 def test_keep_right1729 tmux.send_keys("seq 10000 | #{FZF} --read0 --keep-right", :Enter)1722 tmux.send_keys "seq 10000 | #{FZF} --read0 --keep-right", :Enter1723 tmux.until { |lines| lines.any_include?('9999 10000') }1724 end1725end17261727module TestShell1728 def setup1736 @tmux = Tmux.new shell1729 @tmux = Tmux.new(shell)1730 tmux.prepare1731 end17321733 def teardown
12 unmodified lines
1746 tmux.prepare1747 end17481749 def test_ctrl_t1757 set_var 'FZF_CTRL_T_COMMAND', 'seq 100'1750 set_var('FZF_CTRL_T_COMMAND', 'seq 100')17511752 retries do1753 tmux.prepare1754 tmux.send_keys 'C-t'1755 tmux.until { |lines| lines.item_count == 100 }1756 end1757 tmux.send_keys :Tab, :Tab, :Tab1765 tmux.until { |lines| lines.any_include? ' (3)' }1758 tmux.until { |lines| lines.any_include?(' (3)') }1759 tmux.send_keys :Enter1767 tmux.until { |lines| lines.any_include? '1 2 3' }1760 tmux.until { |lines| lines.any_include?('1 2 3') }1761 tmux.send_keys 'C-c'1762 end17631764 def test_ctrl_t_unicode1772 writelines tempname, ['fzf-unicode 테스트1', 'fzf-unicode 테스트2']1773 set_var 'FZF_CTRL_T_COMMAND', "cat #{tempname}"1765 writelines(tempname, ['fzf-unicode 테스트1', 'fzf-unicode 테스트2'])1766 set_var('FZF_CTRL_T_COMMAND', "cat #{tempname}")17671768 retries do1769 tmux.prepare1770 tmux.send_keys 'echo ', 'C-t'
24 unmodified lines
1795 def test_alt_c1796 lines = retries do1797 tmux.prepare1798 tmux.send_keys :Escape, :c1806 tmux.until { |lines| lines.match_count.positive? }1799 tmux.until { |lines| lines.match_count > 0 }1800 end1808 expected = lines.reverse.select { |l| l.start_with? '>' }.first[2..-1]1801 expected = lines.reverse.find { |l| l.start_with?('>') }[2..-1]1802 tmux.send_keys :Enter1803 tmux.prepare1804 tmux.send_keys :pwd, :Enter1805 tmux.until { |lines| lines[-1].end_with?(expected) }1806 end18071808 def test_alt_c_command1816 set_var 'FZF_ALT_C_COMMAND', 'echo /tmp'1809 set_var('FZF_ALT_C_COMMAND', 'echo /tmp')18101811 tmux.prepare1812 tmux.send_keys 'cd /', :Enter1813
5 unmodified lines
1819 tmux.send_keys :Enter18201821 tmux.prepare1822 tmux.send_keys :pwd, :Enter1830 tmux.until { |lines| lines[-1].end_with? '/tmp' }1823 tmux.until { |lines| lines[-1].end_with?('/tmp') }1824 end18251826 def test_ctrl_r1827 tmux.prepare1835 tmux.send_keys 'echo 1st', :Enter; tmux.prepare1836 tmux.send_keys 'echo 2nd', :Enter; tmux.prepare1837 tmux.send_keys 'echo 3d', :Enter; tmux.prepare1838 3.times { tmux.send_keys 'echo 3rd', :Enter; tmux.prepare }1828 tmux.send_keys 'echo 1st', :Enter1829 tmux.prepare1830 tmux.send_keys 'echo 2nd', :Enter1831 tmux.prepare1832 tmux.send_keys 'echo 3d', :Enter1833 tmux.prepare1834 3.times do1835 tmux.send_keys 'echo 3rd', :Enter1836 tmux.prepare1837 end1838 tmux.send_keys 'echo 4th', :Enter1839 retries do1840 tmux.prepare1841 tmux.send_keys 'C-r'1843 tmux.until { |lines| lines.match_count.positive? }1842 tmux.until { |lines| lines.match_count > 0 }1843 end1844 tmux.send_keys 'e3d'1845 # Duplicates removed: 3d (1) + 3rd (1) => 2 matches1846 tmux.until { |lines| lines.match_count == 2 }1848 tmux.until { |lines| lines[-3].end_with? 'echo 3d' }1847 tmux.until { |lines| lines[-3].end_with?('echo 3d') }1848 tmux.send_keys 'C-r'1850 tmux.until { |lines| lines[-3].end_with? 'echo 3rd' }1849 tmux.until { |lines| lines[-3].end_with?('echo 3rd') }1850 tmux.send_keys :Enter1851 tmux.until { |lines| lines[-1] == 'echo 3rd' }1852 tmux.send_keys :Enter1853 tmux.until { |lines| lines[-1] == '3rd' }1854 end18551856 def test_ctrl_r_multiline1857 tmux.send_keys 'echo "foo', :Enter, 'bar"', :Enter1859 tmux.until { |lines| lines[-2..-1] == ['foo', 'bar'] }1858 tmux.until { |lines| lines[-2..-1] == %w[foo bar] }1859 retries do1860 tmux.prepare1861 tmux.send_keys 'C-r'1862 tmux.until { |lines| lines[-1] == '>' }1863 end1864 tmux.send_keys 'foo bar'1866 tmux.until { |lines| lines[-3].end_with? 'bar"' }1865 tmux.until { |lines| lines[-3].end_with?('bar"') }1866 tmux.send_keys :Enter1868 tmux.until { |lines| lines[-1].end_with? 'bar"' }1867 tmux.until { |lines| lines[-1].end_with?('bar"') }1868 tmux.send_keys :Enter1870 tmux.until { |lines| lines[-2..-1] == ['foo', 'bar'] }1869 tmux.until { |lines| lines[-2..-1] == %w[foo bar] }1870 end18711872 def test_ctrl_r_abort1874 skip "doesn't restore the original line when search is aborted pre Bash 4" if shell == :bash && /(?<= version )\d+/.match(`#{Shell.bash} --version`).to_s.to_i < 41873 skip("doesn't restore the original line when search is aborted pre Bash 4") if shell == :bash && /(?<= version )\d+/.match(`#{Shell.bash} --version`).to_s.to_i < 41874 %w[foo ' "].each do |query|1875 retries do1876 tmux.prepare1878 tmux.send_keys(:Space, 'C-e', 'C-u', query)1879 tmux.until { |lines| lines[-1].start_with? query }1877 tmux.send_keys :Space, 'C-e', 'C-u', query1878 tmux.until { |lines| lines[-1].start_with?(query) }1879 tmux.send_keys 'C-r'1880 tmux.until { |lines| lines[-1] == "> #{query}" }1881 end1882 tmux.send_keys 'C-g'1884 tmux.until { |lines| lines[-1].start_with? query }1883 tmux.until { |lines| lines[-1].start_with?(query) }1884 end1885 end18861887 def retries(times = 3)1888 (times - 1).times do1889 begin1890 return yield1892 rescue RuntimeError1891 rescue RuntimeError # rubocop:todo Lint/SuppressedException1892 end1893 end1894 yield1895 end1896end18971898module CompletionTest1899 def test_file_completion1901 FileUtils.mkdir_p '/tmp/fzf-test'1902 FileUtils.mkdir_p '/tmp/fzf test'1903 (1..100).each { |i| FileUtils.touch "/tmp/fzf-test/#{i}" }1900 FileUtils.mkdir_p('/tmp/fzf-test')1901 FileUtils.mkdir_p('/tmp/fzf test')1902 (1..100).each { |i| FileUtils.touch("/tmp/fzf-test/#{i}") }1903 ['no~such~user', '/tmp/fzf test/foobar', '~/.fzf-home'].each do |f|1905 FileUtils.touch File.expand_path(f)1904 FileUtils.touch(File.expand_path(f))1905 end1906 tmux.prepare1907 tmux.send_keys 'cat /tmp/fzf-test/10**', :Tab1909 tmux.until { |lines| lines.match_count.positive? }1908 tmux.until { |lines| lines.match_count > 0 }1909 tmux.send_keys ' !d'1910 tmux.until { |lines| lines.match_count == 2 }1911 tmux.send_keys :Tab, :Tab1912 tmux.until { |lines| lines.select_count == 2 }
5 unmodified lines
19181919 # ~USERNAME**<TAB>1920 tmux.send_keys 'C-u'1921 tmux.send_keys "cat ~#{ENV['USER']}**", :Tab1923 tmux.until { |lines| lines.match_count.positive? }1922 tmux.until { |lines| lines.match_count > 0 }1923 tmux.send_keys "'.fzf-home"1925 tmux.until { |lines| lines.select { |l| l.include? '.fzf-home' }.count > 1 }1924 tmux.until { |lines| lines.count { |l| l.include?('.fzf-home') } > 1 }1925 tmux.send_keys :Enter1926 tmux.until(true) do |lines|1927 lines[-1].end_with?('.fzf-home')1928 end19291930 # ~INVALID_USERNAME**<TAB>1931 tmux.send_keys 'C-u'1932 tmux.send_keys 'cat ~such**', :Tab1934 tmux.until(true) { |lines| lines.any_include? 'no~such~user' }1933 tmux.until(true) { |lines| lines.any_include?('no~such~user') }1934 tmux.send_keys :Enter1935 tmux.until(true) { |lines| lines[-1].end_with?('no~such~user') }19361937 # /tmp/fzf\ test**<TAB>1938 tmux.send_keys 'C-u'1939 tmux.send_keys 'cat /tmp/fzf\ test/**', :Tab1941 tmux.until { |lines| lines.match_count.positive? }1940 tmux.until { |lines| lines.match_count > 0 }1941 tmux.send_keys 'foobar$'1942 tmux.until { |lines| lines.match_count == 1 }1943 tmux.send_keys :Enter1944 tmux.until(true) { |lines| lines[-1].end_with?('/tmp/fzf\ test/foobar') }19451946 # Should include hidden files1948 (1..100).each { |i| FileUtils.touch "/tmp/fzf-test/.hidden-#{i}" }1947 (1..100).each { |i| FileUtils.touch("/tmp/fzf-test/.hidden-#{i}") }1948 tmux.send_keys 'C-u'1949 tmux.send_keys 'cat /tmp/fzf-test/hidden**', :Tab1950 tmux.until(true) { |lines| lines.match_count == 100 && lines.any_include?('/tmp/fzf-test/.hidden-') }1951 tmux.send_keys :Enter1952 ensure1953 ['/tmp/fzf-test', '/tmp/fzf test', '~/.fzf-home', 'no~such~user'].each do |f|1955 FileUtils.rm_rf File.expand_path(f)1954 FileUtils.rm_rf(File.expand_path(f))1955 end1956 end19571958 def test_file_completion_root1959 tmux.send_keys 'ls /**', :Tab1961 tmux.until { |lines| lines.match_count.positive? }1960 tmux.until { |lines| lines.match_count > 0 }1961 tmux.send_keys :Enter1962 end19631964 def test_dir_completion1965 (1..100).each do |idx|1967 FileUtils.mkdir_p "/tmp/fzf-test/d#{idx}"1966 FileUtils.mkdir_p("/tmp/fzf-test/d#{idx}")1967 end1969 FileUtils.touch '/tmp/fzf-test/d55/xxx'1968 FileUtils.touch('/tmp/fzf-test/d55/xxx')1969 tmux.prepare1970 tmux.send_keys 'cd /tmp/fzf-test/**', :Tab1972 tmux.until { |lines| lines.match_count.positive? }1971 tmux.until { |lines| lines.match_count > 0 }1972 tmux.send_keys :Tab, :Tab # Tab does not work here1973 tmux.send_keys 551974 tmux.until { |lines| lines.match_count == 1 }1975 tmux.send_keys :Enter
15 unmodified lines
1991 end19921993 def test_process_completion1994 tmux.send_keys 'sleep 12345 &', :Enter1996 lines = tmux.until { |lines| lines[-1].start_with? '[1]' }1995 lines = tmux.until { |lines| lines[-1].start_with?('[1]') }1996 pid = lines[-1].split.last1997 tmux.prepare1998 tmux.send_keys 'C-L'1999 tmux.send_keys 'kill ', :Tab2001 tmux.until { |lines| lines.match_count.positive? }2000 tmux.until { |lines| lines.match_count > 0 }2001 tmux.send_keys 'sleep12345'2003 tmux.until { |lines| lines.any_include? 'sleep 12345' }2002 tmux.until { |lines| lines.any_include?('sleep 12345') }2003 tmux.send_keys :Enter2005 tmux.until(true) { |lines| lines[-1].include? "kill #{pid}" }2004 tmux.until(true) { |lines| lines[-1].include?("kill #{pid}") }2005 ensure2006 if pid2007 begin2009 Process.kill 'KILL', pid.to_i2010 rescue2008 Process.kill('KILL', pid.to_i)2009 rescue StandardError2010 nil2011 end2012 end2013 end
16 unmodified lines
2030 # Using tmux2031 tmux.send_keys 'unset FZFFOOBR**', :Tab2032 tmux.until { |lines| lines.match_count == 1 }2033 tmux.send_keys :Enter2035 tmux.until { |lines| lines[-1].include? 'unset FZFFOOBAR' }2034 tmux.until { |lines| lines[-1].include?('unset FZFFOOBAR') }2035 tmux.send_keys 'C-c'20362037 # FZF_TMUX=12038 new_shell2039 tmux.focus2040 tmux.send_keys 'unset FZFFOOBR**', :Tab2041 tmux.until { |lines| lines.match_count == 1 }2042 tmux.send_keys :Enter2044 tmux.until { |lines| lines[-1].include? 'unset FZFFOOBAR' }2043 tmux.until { |lines| lines[-1].include?('unset FZFFOOBAR') }2044 end20452046 def test_file_completion_unicode2048 FileUtils.mkdir_p '/tmp/fzf-test'2047 FileUtils.mkdir_p('/tmp/fzf-test')2048 tmux.paste "cd /tmp/fzf-test; echo -n test3 > $'fzf-unicode \\355\\205\\214\\354\\212\\244\\355\\212\\2701'; echo -n test4 > $'fzf-unicode \\355\\205\\214\\354\\212\\244\\355\\212\\2702'"2049 tmux.prepare2050 tmux.send_keys 'cat fzf-unicode**', :Tab2051 tmux.until { |lines| lines.match_count == 2 }
11 unmodified lines
2063 tmux.send_keys :Tab2064 tmux.until { |lines| lines.select_count == 2 }20652066 tmux.send_keys :Enter2068 tmux.until(true) { |lines| lines.any_include? 'cat' }2067 tmux.until(true) { |lines| lines.any_include?('cat') }2068 tmux.send_keys :Enter2070 tmux.until { |lines| lines[-1].include? 'test3test4' }2069 tmux.until { |lines| lines[-1].include?('test3test4') }2070 end20712072 def test_custom_completion_api2073 tmux.send_keys 'eval "_fzf$(declare -f _comprun)"', :Enter
33 unmodified lines
2107 tmux.paste 'touch /tmp/foo; _fzf_completion_loader=1'2108 tmux.paste '_completion_loader() { complete -o default fake; }'2109 tmux.paste 'complete -F _fzf_path_completion -o default -o bashdefault fake'2110 tmux.send_keys 'fake /tmp/foo**', :Tab2112 tmux.until { |lines| lines.match_count.positive? }2111 tmux.until { |lines| lines.match_count > 0 }2112 tmux.send_keys 'C-c'21132114 tmux.prepare2115 tmux.send_keys 'fake /tmp/foo'2117 tmux.send_keys :Tab , 'C-u'2116 tmux.send_keys :Tab, 'C-u'21172118 tmux.prepare2119 tmux.send_keys 'fake /tmp/foo**', :Tab2121 tmux.until { |lines| lines.match_count.positive? }2120 tmux.until { |lines| lines.match_count > 0 }2121 end2122end21232124class TestZsh < TestBase
88 unmodified lines
added:.rubocop.yml+24 added
modified:.travis.yml+2 added