Skip to content
Myr

Fix Travis CI build

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

tcell build is commented out as it doesn't reliably respond to tmux send-keys.

authored by Junegunn Choi · committed by Junegunn Choi · parent e5e75ef · Browse files · 2 files+274 added−210 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+274 added−210 removed

  • tests:+272 added−205 removed
  • other:+2 added−5 removed

2 files+274 added−210 removed

modified:test/test_go.rb+272 added-205 removed
1#!/usr/bin/env ruby2# encoding: utf-83# frozen_string_literal: true45# rubocop:disable Metrics/LineLength6# rubocop:disable Metrics/MethodLength78require 'minitest/autorun'9require 'fileutils'10require 'English'11require 'shellwords'1213DEFAULT_TIMEOUT = 201415FILE = File.expand_path(__FILE__)
1 unmodified line
17Dir.chdir base18FZF = "FZF_DEFAULT_OPTS= FZF_DEFAULT_COMMAND= #{base}/bin/fzf"1920class NilClass15 def include? str21 def include?(_str)22 false23 end2419 def start_with? str25 def start_with?(_str)26 false27 end2823 def end_with? str29 def end_with?(_str)30 false31 end32end33
32 unmodified lines
66 TEMPNAME = '/tmp/fzf-test.txt'6768 attr_reader :win6964 def initialize shell = :bash70 def initialize(shell = :bash)71 @win =72 case shell73 when :bash74 go("new-window -d -P -F '#I' '#{Shell.unsets + Shell.bash}'").first
6 unmodified lines
81 end82 go("set-window-option -t #{@win} pane-base-index 0")83 @lines = `tput lines`.chomp.to_i8479 if shell == :fish80 send_keys('function fish_prompt; end; clear', :Enter)81 self.until { |lines| lines.empty? }82 end85 return unless shell == :fish86 send_keys('function fish_prompt; end; clear', :Enter)87 self.until(&:empty?)88 end8990 def kill91 go("kill-window -t #{win} 2> /dev/null")92 end9389 def send_keys *args94 def send_keys(*args)95 target =96 if args.last.is_a?(Hash)97 hash = args.pop98 go("select-window -t #{win}")99 "#{win}.#{hash[:pane]}"100 else101 win102 end98 args = args.map { |a| %{"#{a}"} }.join ' '99 go("send-keys -t #{target} #{args}")103 enum = (args + [nil]).each_cons(2)104 loop do105 pair = enum.next106 if pair.first == :Escape107 arg = pair.compact.map { |key| %("#{key}") }.join(' ')108 go(%(send-keys -t #{target} #{arg}))109 enum.next if pair.last110 else111 go(%(send-keys -t #{target} "#{pair.first}"))112 end113 break unless pair.last114 end115 end116102 def paste str103 %x[tmux setb '#{str.gsub("'", "'\\''")}' \\; pasteb -t #{win} \\; send-keys -t #{win} Enter]117 def paste(str)118 `tmux setb '#{str.gsub("'", "'\\''")}' \\; pasteb -t #{win} \\; send-keys -t #{win} Enter`119 end120106 def capture pane = 0107 File.unlink TEMPNAME while File.exists? TEMPNAME121 def capture(pane = 0)122 File.unlink TEMPNAME while File.exist? TEMPNAME123 wait do124 go("capture-pane -t #{win}.#{pane} \\; save-buffer #{TEMPNAME} 2> /dev/null")110 $?.exitstatus == 0125 $CHILD_STATUS.exitstatus.zero?126 end112 File.read(TEMPNAME).split($/)[0, @lines].reverse.drop_while(&:empty?).reverse127 File.read(TEMPNAME).split($INPUT_RECORD_SEPARATOR)[0, @lines].reverse.drop_while(&:empty?).reverse128 end129115 def until refresh = false, pane = 0130 def until(refresh = false, pane = 0)131 lines = nil132 begin133 wait do134 lines = capture(pane)135 class << lines136 def counts122 self.lazy123 .map { |l| l.scan /^. ([0-9]+)\/([0-9]+)( \(([0-9]+)\))?/ }137 lazy138 .map { |l| l.scan %r{^. ([0-9]+)\/([0-9]+)( \(([0-9]+)\))?} }139 .reject(&:empty?)140 .first&.first&.map(&:to_i)&.values_at(0, 1, 3) || [0, 0, 0]141 end142
8 unmodified lines
151 def select_count152 counts[2]153 end154140 def any_include? val155 def any_include?(val)156 method = val.is_a?(Regexp) ? :match : :include?142 self.select { |line| line.send method, val }.first157 select { |line| line.send method, val }.first158 end159 end160 yield(lines).tap do |ok|161 send_keys 'C-l' if refresh && !ok162 end163 end149 rescue Exception150 puts $!.backtrace164 rescue StandardError165 puts $ERROR_INFO.backtrace166 puts '>' * 80167 puts lines168 puts '<' * 80169 raise
4 unmodified lines
174 def prepare175 tries = 0176 begin177 self.until do |lines|163 self.send_keys 'C-u', 'hello'178 send_keys 'C-u', 'hello'179 lines[-1].end_with?('hello')180 end166 rescue Exception181 rescue StandardError182 (tries += 1) < 5 ? retry : raise183 end169 self.send_keys 'C-u'184 send_keys 'C-u'185 end171private172 def go *args173 %x[tmux #{args.join ' '}].split($/)186187 private188189 def go(*args)190 `tmux #{args.join ' '}`.split($INPUT_RECORD_SEPARATOR)191 end192end193194class TestBase < Minitest::Test
7 unmodified lines
202 caller_locations.map(&:label).find { |l| l =~ /^test_/ },203 @temp_suffix].join '-'204 end205189 def writelines path, lines190 File.unlink path while File.exists? path191 File.open(path, 'w') { |f| f << lines.join($/) + $/ }206 def writelines(path, lines)207 File.unlink path while File.exist? path208 File.open(path, 'w') { |f| f << lines.join($INPUT_RECORD_SEPARATOR) + $INPUT_RECORD_SEPARATOR }209 end210211 def readonce195 wait { File.exists?(tempname) }212 wait { File.exist?(tempname) }213 File.read(tempname)214 ensure198 File.unlink tempname while File.exists?(tempname)215 File.unlink tempname while File.exist?(tempname)216 @temp_suffix += 1217 tmux.prepare218 end219
1 unmodified line
221 fzf!(*opts) + " > #{tempname}.tmp; mv #{tempname}.tmp #{tempname}"222 end223224 def fzf!(*opts)208 opts = opts.map { |o|225 opts = opts.map do |o|226 case o227 when Symbol228 o = o.to_s212 o.length > 1 ? "--#{o.gsub('_', '-')}" : "-#{o}"229 o.length > 1 ? "--#{o.tr('_', '-')}" : "-#{o}"230 when String, Numeric231 o.to_s215 else216 nil232 end218 }.compact233 end.compact234 "#{FZF} #{opts.join ' '}"235 end236end237
47 unmodified lines
285 tmux.send_keys "#{FZF} -q 'foo bar foo-bar'", :Enter286 tmux.until { |lines| lines.last =~ /^>/ }287288 # CTRL-A274 tmux.send_keys "C-A", "("289 tmux.send_keys 'C-A', '('290 tmux.until { |lines| lines.last == '> (foo bar foo-bar' }291292 # META-F278 tmux.send_keys :Escape, :f, ")"293 tmux.send_keys :Escape, :f, ')'294 tmux.until { |lines| lines.last == '> (foo) bar foo-bar' }295296 # CTRL-B282 tmux.send_keys "C-B", "var"297 tmux.send_keys 'C-B', 'var'298 tmux.until { |lines| lines.last == '> (foovar) bar foo-bar' }299300 # Left, CTRL-D286 tmux.send_keys :Left, :Left, "C-D"301 tmux.send_keys :Left, :Left, 'C-D'302 tmux.until { |lines| lines.last == '> (foovr) bar foo-bar' }303304 # META-BS305 tmux.send_keys :Escape, :BSpace306 tmux.until { |lines| lines.last == '> (r) bar foo-bar' }307308 # CTRL-Y294 tmux.send_keys "C-Y", "C-Y"309 tmux.send_keys 'C-Y', 'C-Y'310 tmux.until { |lines| lines.last == '> (foovfoovr) bar foo-bar' }311312 # META-B313 tmux.send_keys :Escape, :b, :Space, :Space
7 unmodified lines
321 tmux.send_keys 'C-H', :BSpace322 tmux.until { |lines| lines.last == '> ( fovfoovr) bar foo-bar' }323324 # CTRL-E310 tmux.send_keys "C-E", 'baz'325 tmux.send_keys 'C-E', 'baz'326 tmux.until { |lines| lines.last == '> ( fovfoovr) bar foo-barbaz' }327328 # CTRL-U314 tmux.send_keys "C-U"329 tmux.send_keys 'C-U'330 tmux.until { |lines| lines.last == '>' }331332 # CTRL-Y318 tmux.send_keys "C-Y"333 tmux.send_keys 'C-Y'334 tmux.until { |lines| lines.last == '> ( fovfoovr) bar foo-barbaz' }335336 # CTRL-W322 tmux.send_keys "C-W", "bar-foo"337 tmux.send_keys 'C-W', 'bar-foo'338 tmux.until { |lines| lines.last == '> ( fovfoovr) bar bar-foo' }339340 # META-D326 tmux.send_keys :Escape, :b, :Escape, :b, :Escape, :d, "C-A", "C-Y"341 tmux.send_keys :Escape, :b, :Escape, :b, :Escape, :d, 'C-A', 'C-Y'342 tmux.until { |lines| lines.last == '> bar( fovfoovr) bar -foo' }343344 # CTRL-M330 tmux.send_keys "C-M"345 tmux.send_keys 'C-M'346 tmux.until { |lines| lines.last !~ /^>/ }347 end348349 def test_file_word
16 unmodified lines
366 tmux.send_keys :Tab, :Up, :Up, :Tab, :Tab, :Tab, # 3, 2367 'C-K', 'C-K', 'C-K', 'C-K', :BTab, :BTab, # 5, 6368 :PgUp, 'C-J', :Down, :Tab, :Tab # 8, 7369 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($/)370 tmux.send_keys 'C-M'371 assert_equal %w[3 2 5 6 8 7], readonce.split($INPUT_RECORD_SEPARATOR)372 end373374 def test_with_nth375 [true, false].each do |multi|376 tmux.send_keys "(echo ' 1st 2nd 3rd/';377 echo ' first second third/') |378 #{fzf multi && :multi, :x, :nth, 2, :with_nth, '2,-1,1'}",364 :Enter379 :Enter380 tmux.until { |lines| lines[-2].include?('2/2') }381382 # Transformed list383 lines = tmux.capture
4 unmodified lines
388 if multi389 tmux.send_keys :BTab, :BTab390 tmux.until { |lines| lines[-2].include?('(2)') }391 tmux.send_keys :Enter377 assert_equal [' 1st 2nd 3rd/', ' first second third/'], readonce.split($/)392 assert_equal [' 1st 2nd 3rd/', ' first second third/'], readonce.split($INPUT_RECORD_SEPARATOR)393 else394 tmux.send_keys '^', '3'395 tmux.until { |lines| lines[-2].include?('1/2') }396 tmux.send_keys :Enter382 assert_equal [' 1st 2nd 3rd/'], readonce.split($/)397 assert_equal [' 1st 2nd 3rd/'], readonce.split($INPUT_RECORD_SEPARATOR)398 end399 end400 end401402 def test_scroll403 [true, false].each do |rev|404 tmux.send_keys "seq 1 100 | #{fzf rev && :reverse}", :Enter405 tmux.until { |lines| lines.include? ' 100/100' }391 tmux.send_keys *110.times.map { rev ? :Down : :Up }406 tmux.send_keys(*Array.new(110) { rev ? :Down : :Up })407 tmux.until { |lines| lines.include? '> 100' }408 tmux.send_keys :Enter409 assert_equal '100', readonce.chomp410 end411 end412413 def test_select_1414 tmux.send_keys "seq 1 100 | #{fzf :with_nth, '..,..', :print_query, :q, 5555, :'1'}", :Enter400 assert_equal ['5555', '55'], readonce.split($/)415 assert_equal %w[5555 55], readonce.split($INPUT_RECORD_SEPARATOR)416 end417418 def test_exit_0404 tmux.send_keys "seq 1 100 | #{fzf :with_nth, '..,..', :print_query, :q, 555555, :'0'}", :Enter405 assert_equal ['555555'], readonce.split($/)419 tmux.send_keys "seq 1 100 | #{fzf :with_nth, '..,..', :print_query, :q, 555_555, :'0'}", :Enter420 assert_equal ['555555'], readonce.split($INPUT_RECORD_SEPARATOR)421 end422423 def test_select_1_exit_0_fail409 [:'0', :'1', [:'1', :'0']].each do |opt|424 [:'0', :'1', %i[1 0]].each do |opt|425 tmux.send_keys "seq 1 100 | #{fzf :print_query, :multi, :q, 5, *opt}", :Enter426 tmux.until { |lines| lines.last =~ /^> 5/ }427 tmux.send_keys :BTab, :BTab, :BTab428 tmux.until { |lines| lines[-2].include?('(3)') }429 tmux.send_keys :Enter415 assert_equal ['5', '5', '50', '51'], readonce.split($/)430 assert_equal %w[5 5 50 51], readonce.split($INPUT_RECORD_SEPARATOR)431 end432 end433434 def test_query_unicode435 tmux.paste "(echo abc; echo 가나다) | #{fzf :query, '가다'}"436 tmux.until { |lines| lines[-2].include? '1/2' }437 tmux.send_keys :Enter423 assert_equal ['가나다'], readonce.split($/)438 assert_equal ['가나다'], readonce.split($INPUT_RECORD_SEPARATOR)439 end440441 def test_sync442 tmux.send_keys "seq 1 100 | #{fzf! :multi} | awk '{print \\$1 \\$1}' | #{fzf :sync}", :Enter
4 unmodified lines
447 tmux.until { |lines| lines[-2].include?('(3)') }448 tmux.send_keys :Enter449 tmux.until { |lines| lines[-1] == '>' }450 tmux.send_keys 'C-K', :Enter436 assert_equal ['9090'], readonce.split($/)451 assert_equal ['9090'], readonce.split($INPUT_RECORD_SEPARATOR)452 end453454 def test_tac455 tmux.send_keys "seq 1 1000 | #{fzf :tac, :multi}", :Enter456 tmux.until { |lines| lines[-2].include? '1000/1000' }457 tmux.send_keys :BTab, :BTab, :BTab458 tmux.until { |lines| lines[-2].include?('(3)') }459 tmux.send_keys :Enter445 assert_equal %w[1000 999 998], readonce.split($/)460 assert_equal %w[1000 999 998], readonce.split($INPUT_RECORD_SEPARATOR)461 end462463 def test_tac_sort464 tmux.send_keys "seq 1 1000 | #{fzf :tac, :multi}", :Enter
2 unmodified lines
467 tmux.until { |lines| lines[-2].include? '28/1000' }468 tmux.send_keys :BTab, :BTab, :BTab469 tmux.until { |lines| lines[-2].include?('(3)') }470 tmux.send_keys :Enter456 assert_equal %w[99 999 998], readonce.split($/)471 assert_equal %w[99 999 998], readonce.split($INPUT_RECORD_SEPARATOR)472 end473474 def test_tac_nosort475 tmux.send_keys "seq 1 1000 | #{fzf :tac, :no_sort, :multi}", :Enter
2 unmodified lines
478 tmux.until { |lines| lines[-2].include? '10/1000' }479 tmux.send_keys :BTab, :BTab, :BTab480 tmux.until { |lines| lines[-2].include?('(3)') }481 tmux.send_keys :Enter467 assert_equal %w[1000 900 800], readonce.split($/)482 assert_equal %w[1000 900 800], readonce.split($INPUT_RECORD_SEPARATOR)483 end484485 def test_expect486 test = lambda do |key, feed, expected = key|487 tmux.send_keys "seq 1 100 | #{fzf :expect, key}; sync", :Enter488 tmux.until { |lines| lines[-2].include? '100/100' }489 tmux.send_keys '55'490 tmux.until { |lines| lines[-2].include? '1/100' }476 tmux.send_keys *feed491 tmux.send_keys(*feed)492 tmux.prepare478 assert_equal [expected, '55'], readonce.split($/)493 assert_equal [expected, '55'], readonce.split($INPUT_RECORD_SEPARATOR)494 end495 test.call 'ctrl-t', 'C-T'496 test.call 'ctrl-t', 'Enter', ''482 test.call 'alt-c', [:Escape, :c]497 test.call 'alt-c', %i[Escape c]498 test.call 'f1', 'f1'499 test.call 'f2', 'f2'500 test.call 'f3', 'f3'501 test.call 'f2,f4', 'f2', 'f2'502 test.call 'f2,f4', 'f4', 'f4'488 test.call 'alt-/', [:Escape, :/]503 test.call 'alt-/', %i[Escape /]504 %w[f5 f6 f7 f8 f9 f10].each do |key|505 test.call 'f5,f6,f7,f8,f9,f10', key, key506 end507 test.call '@', '@'
4 unmodified lines
512 tmux.until { |lines| lines[-2].include? '100/100' }513 tmux.send_keys '55'514 tmux.until { |lines| lines[-2].include? '1/100' }515 tmux.send_keys :Escape, :z501 assert_equal ['55', 'alt-z', '55'], readonce.split($/)516 assert_equal ['55', 'alt-z', '55'], readonce.split($INPUT_RECORD_SEPARATOR)517 end518519 def test_expect_printable_character_print_query520 tmux.send_keys "seq 1 100 | #{fzf '--expect=z --print-query'}", :Enter521 tmux.until { |lines| lines[-2].include? '100/100' }522 tmux.send_keys '55'523 tmux.until { |lines| lines[-2].include? '1/100' }524 tmux.send_keys 'z'510 assert_equal ['55', 'z', '55'], readonce.split($/)525 assert_equal %w[55 z 55], readonce.split($INPUT_RECORD_SEPARATOR)526 end527528 def test_expect_print_query_select_1529 tmux.send_keys "seq 1 100 | #{fzf '-q55 -1 --expect=alt-z --print-query'}", :Enter515 assert_equal ['55', '', '55'], readonce.split($/)530 assert_equal ['55', '', '55'], readonce.split($INPUT_RECORD_SEPARATOR)531 end532533 def test_toggle_sort534 ['--toggle-sort=ctrl-r', '--bind=ctrl-r:toggle-sort'].each do |opt|
5 unmodified lines
540 tmux.until { |lines| lines[-3].include? '> 11' }541 tmux.send_keys :Tab542 tmux.until { |lines| lines[-2].include? '4/111 +S (2)' }543 tmux.send_keys :Enter529 assert_equal ['111', '11'], readonce.split($/)544 assert_equal %w[111 11], readonce.split($INPUT_RECORD_SEPARATOR)545 end546 end547548 def test_unicode_case549 writelines tempname, %w[строКА1 СТРОКА2 строка3 Строка4]535 assert_equal %w[СТРОКА2 Строка4], `#{FZF} -fС < #{tempname}`.split($/)536 assert_equal %w[строКА1 СТРОКА2 строка3 Строка4], `#{FZF} -fс < #{tempname}`.split($/)550 assert_equal %w[СТРОКА2 Строка4], `#{FZF} -fС < #{tempname}`.split($INPUT_RECORD_SEPARATOR)551 assert_equal %w[строКА1 СТРОКА2 строка3 Строка4], `#{FZF} -fс < #{tempname}`.split($INPUT_RECORD_SEPARATOR)552 end553554 def test_tiebreak555 input = %w[
3 unmodified lines
559 -------foobar-560 ]561 writelines tempname, input562548 assert_equal input, `#{FZF} -ffoobar --tiebreak=index < #{tempname}`.split($/)563 assert_equal input, `#{FZF} -ffoobar --tiebreak=index < #{tempname}`.split($INPUT_RECORD_SEPARATOR)564565 by_length = %w[566 ----foobar--567 -----foobar---568 -------foobar-569 --foobar--------570 ]556 assert_equal by_length, `#{FZF} -ffoobar < #{tempname}`.split($/)557 assert_equal by_length, `#{FZF} -ffoobar --tiebreak=length < #{tempname}`.split($/)571 assert_equal by_length, `#{FZF} -ffoobar < #{tempname}`.split($INPUT_RECORD_SEPARATOR)572 assert_equal by_length, `#{FZF} -ffoobar --tiebreak=length < #{tempname}`.split($INPUT_RECORD_SEPARATOR)573574 by_begin = %w[575 --foobar--------576 ----foobar--577 -----foobar---578 -------foobar-579 ]565 assert_equal by_begin, `#{FZF} -ffoobar --tiebreak=begin < #{tempname}`.split($/)566 assert_equal by_begin, `#{FZF} -f"!z foobar" -x --tiebreak begin < #{tempname}`.split($/)580 assert_equal by_begin, `#{FZF} -ffoobar --tiebreak=begin < #{tempname}`.split($INPUT_RECORD_SEPARATOR)581 assert_equal by_begin, `#{FZF} -f"!z foobar" -x --tiebreak begin < #{tempname}`.split($INPUT_RECORD_SEPARATOR)582583 assert_equal %w[584 -------foobar-585 ----foobar--586 -----foobar---587 --foobar--------573 ], `#{FZF} -ffoobar --tiebreak end < #{tempname}`.split($/)588 ], `#{FZF} -ffoobar --tiebreak end < #{tempname}`.split($INPUT_RECORD_SEPARATOR)589575 assert_equal input, `#{FZF} -f"!z" -x --tiebreak end < #{tempname}`.split($/)590 assert_equal input, `#{FZF} -f"!z" -x --tiebreak end < #{tempname}`.split($INPUT_RECORD_SEPARATOR)591 end592593 def test_tiebreak_index_begin594 writelines tempname, [
1 unmodified line
596 'xoxxxxxox',597 'xxoxxxoxx',598 'xxxoxoxxx',599 'xxxxoxox',585 ' xxoxoxxx',600 ' xxoxoxxx'601 ]602603 assert_equal [604 'xxxxoxox',605 ' xxoxoxxx',606 'xxxoxoxxx',607 'xxoxxxoxx',608 'xoxxxxxox',594 'xoxxxxxoxx',595 ], `#{FZF} -foo < #{tempname}`.split($/)609 'xoxxxxxoxx'610 ], `#{FZF} -foo < #{tempname}`.split($INPUT_RECORD_SEPARATOR)611612 assert_equal [613 'xxxoxoxxx',614 'xxxxoxox',615 ' xxoxoxxx',616 'xxoxxxoxx',617 'xoxxxxxoxx',603 'xoxxxxxox',604 ], `#{FZF} -foo --tiebreak=index < #{tempname}`.split($/)618 'xoxxxxxox'619 ], `#{FZF} -foo --tiebreak=index < #{tempname}`.split($INPUT_RECORD_SEPARATOR)620621 # Note that --tiebreak=begin is now based on the first occurrence of the622 # first character on the pattern623 assert_equal [
1 unmodified line
625 'xxxoxoxxx',626 'xxxxoxox',627 'xxoxxxoxx',628 'xoxxxxxoxx',614 'xoxxxxxox',615 ], `#{FZF} -foo --tiebreak=begin < #{tempname}`.split($/)629 'xoxxxxxox'630 ], `#{FZF} -foo --tiebreak=begin < #{tempname}`.split($INPUT_RECORD_SEPARATOR)631632 assert_equal [633 ' xxoxoxxx',634 'xxxoxoxxx',635 'xxxxoxox',636 'xxoxxxoxx',637 'xoxxxxxox',623 'xoxxxxxoxx',624 ], `#{FZF} -foo --tiebreak=begin,length < #{tempname}`.split($/)638 'xoxxxxxoxx'639 ], `#{FZF} -foo --tiebreak=begin,length < #{tempname}`.split($INPUT_RECORD_SEPARATOR)640 end641642 def test_tiebreak_begin_algo_v2643 writelines tempname, [644 'baz foo bar',630 'foo bar baz',645 'foo bar baz'646 ]647 assert_equal [648 'foo bar baz',634 'baz foo bar',635 ], `#{FZF} -fbar --tiebreak=begin --algo=v2 < #{tempname}`.split($/)649 'baz foo bar'650 ], `#{FZF} -fbar --tiebreak=begin --algo=v2 < #{tempname}`.split($INPUT_RECORD_SEPARATOR)651 end652653 def test_tiebreak_end654 writelines tempname, [
1 unmodified line
656 'xxoxxxxxxx',657 'xxxoxxxxxx',658 'xxxxoxxxx',659 'xxxxxoxxx',645 ' xxxxoxxx',660 ' xxxxoxxx'661 ]662663 assert_equal [664 ' xxxxoxxx',665 'xxxxoxxxx',666 'xxxxxoxxx',667 'xoxxxxxxxx',668 'xxoxxxxxxx',654 'xxxoxxxxxx',655 ], `#{FZF} -fo < #{tempname}`.split($/)669 'xxxoxxxxxx'670 ], `#{FZF} -fo < #{tempname}`.split($INPUT_RECORD_SEPARATOR)671672 assert_equal [673 'xxxxxoxxx',674 ' xxxxoxxx',675 'xxxxoxxxx',676 'xxxoxxxxxx',677 'xxoxxxxxxx',663 'xoxxxxxxxx',664 ], `#{FZF} -fo --tiebreak=end < #{tempname}`.split($/)678 'xoxxxxxxxx'679 ], `#{FZF} -fo --tiebreak=end < #{tempname}`.split($INPUT_RECORD_SEPARATOR)680681 assert_equal [682 'xxxxxoxxx',683 ' xxxxoxxx',684 'xxxxoxxxx',685 'xxxoxxxxxx',686 'xxoxxxxxxx',672 'xoxxxxxxxx',673 ], `#{FZF} -fo --tiebreak=end,length,begin < #{tempname}`.split($/)687 'xoxxxxxxxx'688 ], `#{FZF} -fo --tiebreak=end,length,begin < #{tempname}`.split($INPUT_RECORD_SEPARATOR)689 end690691 def test_tiebreak_length_with_nth692 input = %w[
9 unmodified lines
702 12345:he703 123:hello704 1234567:h705 ]691 assert_equal output, `#{FZF} -fh < #{tempname}`.split($/)706 assert_equal output, `#{FZF} -fh < #{tempname}`.split($INPUT_RECORD_SEPARATOR)707708 # Since 0.16.8, --nth doesn't affect --tiebreak694 assert_equal output, `#{FZF} -fh -n2 -d: < #{tempname}`.split($/)709 assert_equal output, `#{FZF} -fh -n2 -d: < #{tempname}`.split($INPUT_RECORD_SEPARATOR)710 end711712 def test_invalid_cache713 tmux.send_keys "(echo d; echo D; echo x) | #{fzf '-q d'}", :Enter
9 unmodified lines
723 assert_equal 1, `echo Foo bar | #{FZF} -x -f "foo Fbar" | wc -l`.to_i724 end725726 def test_bind712 tmux.send_keys "seq 1 1000 | #{713 fzf '-m --bind=ctrl-j:accept,u:up,T:toggle-up,t:toggle'}", :Enter727 tmux.send_keys "seq 1 1000 | #{fzf '-m --bind=ctrl-j:accept,u:up,T:toggle-up,t:toggle'}", :Enter728 tmux.until { |lines| lines[-2].end_with? '/1000' }729 tmux.send_keys 'uuu', 'TTT', 'tt', 'uu', 'ttt', 'C-j'716 assert_equal %w[4 5 6 9], readonce.split($/)730 assert_equal %w[4 5 6 9], readonce.split($INPUT_RECORD_SEPARATOR)731 end732733 def test_bind_print_query734 tmux.send_keys "seq 1 1000 | #{fzf '-m --bind=ctrl-j:print-query'}", :Enter735 tmux.until { |lines| lines[-2].end_with? '/1000' }736 tmux.send_keys 'print-my-query', 'C-j'723 assert_equal %w[print-my-query], readonce.split($/)737 assert_equal %w[print-my-query], readonce.split($INPUT_RECORD_SEPARATOR)738 end739740 def test_long_line741 data = '.' * 256 * 1024
3 unmodified lines
745 assert_equal data, `#{FZF} -f . < #{tempname}`.chomp746 end747748 def test_read0735 lines = `find .`.split($/)749 lines = `find .`.split($INPUT_RECORD_SEPARATOR)750 assert_equal lines.last, `find . | #{FZF} -e -f "^#{lines.last}$"`.chomp751 assert_equal(752 lines.last,737 assert_equal lines.last, `find . -print0 | #{FZF} --read0 -e -f "^#{lines.last}$"`.chomp753 `find . -print0 | #{FZF} --read0 -e -f "^#{lines.last}$"`.chomp754 )755 end756757 def test_select_all_deselect_all_toggle_all758 tmux.send_keys "seq 100 | #{fzf '--bind ctrl-a:select-all,ctrl-d:deselect-all,ctrl-t:toggle-all --multi'}", :Enter
14 unmodified lines
773 tmux.until { |lines| lines[-2].include? '10/100' }774 tmux.send_keys 'C-a'775 tmux.until { |lines| lines[-2].include? '(12)' }776 tmux.send_keys :Enter760 assert_equal %w[2 1 10 20 30 40 50 60 70 80 90 100], readonce.split($/)777 assert_equal %w[2 1 10 20 30 40 50 60 70 80 90 100],778 readonce.split($INPUT_RECORD_SEPARATOR)779 end780781 def test_history782 history_file = '/tmp/fzf-test-history'783784 # History with limited number of entries785 begin767 File.unlink history_file rescue nil786 File.unlink history_file787 rescue788 nil789 end790 opts = "--history=#{history_file} --history-size=4"769 input = %w[00 11 22 33 44].map { |e| e + $/ }791 input = %w[00 11 22 33 44].map { |e| e + $INPUT_RECORD_SEPARATOR }792 input.each do |keys|793 tmux.send_keys "seq 100 | #{fzf opts}", :Enter794 tmux.until { |lines| lines[-2].include? '100/100' }795 tmux.send_keys keys
21 unmodified lines
817 tmux.send_keys 0818 tmux.until { |lines| lines[-1].end_with? '> 310' }819 tmux.send_keys :Enter820 readonce799 assert_equal %w[22 33 44 310].map { |e| e + $/ }, File.readlines(history_file)821 assert_equal %w[22 33 44 310].map { |e| e + $INPUT_RECORD_SEPARATOR }, File.readlines(history_file)822823 # Respect --bind option824 tmux.send_keys "seq 100 | #{fzf opts + ' --bind ctrl-p:next-history,ctrl-n:previous-history'}", :Enter825 tmux.until { |lines| lines[-2].include? '100/100' }
6 unmodified lines
832833 def test_execute834 output = '/tmp/fzf-test-execute'835 opts = %[--bind \\"alt-a:execute(echo [{}] >> #{output}),alt-b:execute[echo /{}{}/ >> #{output}],C:execute:echo /{}{}{}/ >> #{output}\\"]814 wait = lambda { |exp| tmux.until { |lines| lines[-2].include? exp } }836 wait = ->(exp) { tmux.until { |lines| lines[-2].include? exp } }837 writelines tempname, %w[foo'bar foo"bar foo$bar]838 tmux.send_keys "cat #{tempname} | #{fzf opts}; sync", :Enter839 wait['3/3']840 tmux.send_keys :Escape, :a
18 unmodified lines
859 readonce860 assert_equal %w[[foo'bar] [foo'bar]861 /foo"barfoo"bar/ /foo"barfoo"bar/862 /foo$barfoo$barfoo$bar/],841 File.readlines(output).map(&:chomp)863 File.readlines(output).map(&:chomp)864 ensure865 begin843 File.unlink output rescue nil866 File.unlink output867 rescue868 nil869 end870 end871872 def test_execute_multi873 output = '/tmp/fzf-test-execute-multi'
11 unmodified lines
885 tmux.until { |lines| lines[-2].include? '/4' }886 tmux.send_keys :Enter887 tmux.prepare888 readonce863 assert_equal [%[foo'bar/foo'bar],864 %[foo'bar foo"bar foo$bar/foo'bar foo"bar foo$bar],865 %[foo'bar foo"bar foobar/foo'bar foo"bar foobar]],866 File.readlines(output).map(&:chomp)889 assert_equal [%(foo'bar/foo'bar),890 %(foo'bar foo"bar foo$bar/foo'bar foo"bar foo$bar),891 %(foo'bar foo"bar foobar/foo'bar foo"bar foobar)],892 File.readlines(output).map(&:chomp)893 ensure894 begin868 File.unlink output rescue nil895 File.unlink output896 rescue897 nil898 end899 end900901 def test_execute_plus_flag872 output = tempname + ".tmp"873 File.unlink output rescue nil874 writelines tempname, ["foo bar", "123 456"]902 output = tempname + '.tmp'903 begin904 File.unlink output905 rescue906 nil907 end908 writelines tempname, ['foo bar', '123 456']909876 tmux.send_keys "cat #{tempname} | #{FZF} --multi --bind 'x:execute(echo {+}/{}/{+2}/{2} >> #{output})'", :Enter910 tmux.send_keys "cat #{tempname} | #{FZF} --multi --bind 'x:execute-silent(echo {+}/{}/{+2}/{2} >> #{output})'", :Enter911912 execute = lambda do913 tmux.send_keys 'x', 'y'914 tmux.until { |lines| lines[-2].include? '0/2' }
15 unmodified lines
930 tmux.prepare931 readonce932933 assert_equal [900 %[foo bar/foo bar/bar/bar],901 %[123 456/foo bar/456/bar],902 %[123 456 foo bar/foo bar/456 bar/bar]934 %(foo bar/foo bar/bar/bar),935 %(123 456/foo bar/456/bar),936 %(123 456 foo bar/foo bar/456 bar/bar)937 ], File.readlines(output).map(&:chomp)938 rescue939 begin905 File.unlink output rescue nil940 File.unlink output941 rescue942 nil943 end944 end945946 def test_execute_shell947 # Custom script to use as $SHELL948 output = tempname + '.out'911 File.unlink output rescue nil912 writelines tempname, ['#!/usr/bin/env bash', "echo $1 / $2 > #{output}", "sync"]949 begin950 File.unlink output951 rescue952 nil953 end954 writelines tempname,955 ['#!/usr/bin/env bash', "echo $1 / $2 > #{output}", 'sync']956 system "chmod +x #{tempname}"957958 tmux.send_keys "echo foo | SHELL=#{tempname} fzf --bind 'enter:execute:{}bar'", :Enter959 tmux.until { |lines| lines[-2].include? '1/1' }
2 unmodified lines
962 tmux.send_keys 'C-c'963 tmux.prepare964 assert_equal ["-c / 'foo'bar"], File.readlines(output).map(&:chomp)965 ensure966 begin923 File.unlink output rescue nil967 File.unlink output968 rescue969 nil970 end971 end972973 def test_cycle974 tmux.send_keys "seq 8 | #{fzf :cycle}", :Enter
18 unmodified lines
993 tmux.send_keys "seq 100 | #{fzf '--header-lines=10 -q 5'}", :Enter994 2.times do995 tmux.until do |lines|996 lines[-2].include?('/90') &&950 lines[-3] == ' 1' &&951 lines[-4] == ' 2' &&952 lines[-13] == '> 50'997 lines[-3] == ' 1' &&998 lines[-4] == ' 2' &&999 lines[-13] == '> 50'1000 end1001 tmux.send_keys :Down1002 end1003 tmux.send_keys :Enter
4 unmodified lines
1008 tmux.send_keys "seq 100 | #{fzf '--header-lines=10 -q 5 --reverse'}", :Enter1009 2.times do1010 tmux.until do |lines|1011 lines[1].include?('/90') &&965 lines[2] == ' 1' &&966 lines[3] == ' 2' &&967 lines[12] == '> 50'1012 lines[2] == ' 1' &&1013 lines[3] == ' 2' &&1014 lines[12] == '> 50'1015 end1016 tmux.send_keys :Up1017 end1018 tmux.send_keys :Enter
3 unmodified lines
1022 def test_header_lines_overflow1023 tmux.send_keys "seq 100 | #{fzf '--header-lines=200'}", :Enter1024 tmux.until do |lines|1025 lines[-2].include?('0/0') &&979 lines[-3].include?(' 1')1026 lines[-3].include?(' 1')1027 end1028 tmux.send_keys :Enter1029 assert_equal '', readonce.chomp1030 end10311032 def test_header_lines_with_nth986 tmux.send_keys "seq 100 | #{fzf "--header-lines 5 --with-nth 1,1,1,1,1"}", :Enter1033 tmux.send_keys "seq 100 | #{fzf '--header-lines 5 --with-nth 1,1,1,1,1'}", :Enter1034 tmux.until do |lines|1035 lines[-2].include?('95/95') &&989 lines[-3] == ' 11111' &&990 lines[-7] == ' 55555' &&991 lines[-8] == '> 66666'1036 lines[-3] == ' 11111' &&1037 lines[-7] == ' 55555' &&1038 lines[-8] == '> 66666'1039 end1040 tmux.send_keys :Enter1041 assert_equal '6', readonce.chomp1042 end
2 unmodified lines
1045 tmux.send_keys "seq 100 | #{fzf "--header \\\"\\$(head -5 #{FILE})\\\""}", :Enter1046 header = File.readlines(FILE).take(5).map(&:strip)1047 tmux.until do |lines|1048 lines[-2].include?('100/100') &&1002 lines[-7..-3].map(&:strip) == header1049 lines[-7..-3].map(&:strip) == header1050 end1051 end10521053 def test_header_reverse1054 tmux.send_keys "seq 100 | #{fzf "--header=\\\"\\$(head -5 #{FILE})\\\" --reverse"}", :Enter1055 header = File.readlines(FILE).take(5).map(&:strip)1056 tmux.until do |lines|1057 lines[1].include?('100/100') &&1011 lines[2..6].map(&:strip) == header1058 lines[2..6].map(&:strip) == header1059 end1060 end10611062 def test_header_and_header_lines1063 tmux.send_keys "seq 100 | #{fzf "--header-lines 10 --header \\\"\\$(head -5 #{FILE})\\\""}", :Enter1064 header = File.readlines(FILE).take(5).map(&:strip)1065 tmux.until do |lines|1066 lines[-2].include?('90/90') &&1020 lines[-7...-2].map(&:strip) == header &&1021 lines[-17...-7].map(&:strip) == (1..10).map(&:to_s).reverse1067 lines[-7...-2].map(&:strip) == header &&1068 lines[-17...-7].map(&:strip) == (1..10).map(&:to_s).reverse1069 end1070 end10711072 def test_header_and_header_lines_reverse1073 tmux.send_keys "seq 100 | #{fzf "--reverse --header-lines 10 --header \\\"\\$(head -5 #{FILE})\\\""}", :Enter1074 header = File.readlines(FILE).take(5).map(&:strip)1075 tmux.until do |lines|1076 lines[1].include?('90/90') &&1030 lines[2...7].map(&:strip) == header &&1031 lines[7...17].map(&:strip) == (1..10).map(&:to_s)1077 lines[2...7].map(&:strip) == header &&1078 lines[7...17].map(&:strip) == (1..10).map(&:to_s)1079 end1080 end10811082 def test_cancel1036 tmux.send_keys "seq 10 | #{fzf "--bind 2:cancel"}", :Enter1083 tmux.send_keys "seq 10 | #{fzf '--bind 2:cancel'}", :Enter1084 tmux.until { |lines| lines[-2].include?('10/10') }1085 tmux.send_keys '123'1086 tmux.until { |lines| lines[-1] == '> 3' && lines[-2].include?('1/10') }1087 tmux.send_keys 'C-y', 'C-y'
4 unmodified lines
1092 tmux.prepare1093 end10941095 def test_margin1049 tmux.send_keys "yes | head -1000 | #{fzf "--margin 5,3"}", :Enter1096 tmux.send_keys "yes | head -1000 | #{fzf '--margin 5,3'}", :Enter1097 tmux.until { |lines| lines[4] == '' && lines[5] == ' y' }1098 tmux.send_keys :Enter1099 end11001101 def test_margin_reverse1055 tmux.send_keys "seq 1000 | #{fzf "--margin 7,5 --reverse"}", :Enter1102 tmux.send_keys "seq 1000 | #{fzf '--margin 7,5 --reverse'}", :Enter1103 tmux.until { |lines| lines[1 + 7] == ' 1000/1000' }1104 tmux.send_keys :Enter1105 end1106
7 unmodified lines
1114 5 => '> f oo ba r baz barfooq ux',1115 6 => '> f oo ba r baz barfooq ux',1116 7 => '> f oo ba r baz barfooq ux',1117 8 => '> f oo ba r baz barfooq ux',1071 9 => '> f oo ba r baz barfooq ux',1118 9 => '> f oo ba r baz barfooq ux'1119 }.each do |ts, exp|1120 tmux.prepare1074 tmux.send_keys %[cat #{tempname} | fzf --tabstop=#{ts}], :Enter1075 tmux.until(true) { |lines| exp.start_with? lines[-3].to_s.strip.sub(/\.\.$/, '') }1121 tmux.send_keys %(cat #{tempname} | fzf --tabstop=#{ts}), :Enter1122 tmux.until(true) do |lines|1123 exp.start_with? lines[-3].to_s.strip.sub(/\.\.$/, '')1124 end1125 tmux.send_keys :Enter1126 end1127 end11281080 def test_with_nth1129 def test_with_nth_basic1130 writelines tempname, ['hello world ', 'byebye']1131 assert_equal(1132 'hello world ',1082 assert_equal 'hello world ', `#{FZF} -f"^he hehe" -x -n 2.. --with-nth 2,1,1 < #{tempname}`.chomp1133 `#{FZF} -f"^he hehe" -x -n 2.. --with-nth 2,1,1 < #{tempname}`.chomp1134 )1135 end11361137 def test_with_nth_ansi1138 writelines tempname, ["\x1b[33mhello \x1b[34;1mworld\x1b[m ", 'byebye']1139 assert_equal(1140 'hello world ',1087 assert_equal 'hello world ', `#{FZF} -f"^he hehe" -x -n 2.. --with-nth 2,1,1 --ansi < #{tempname}`.chomp1141 `#{FZF} -f"^he hehe" -x -n 2.. --with-nth 2,1,1 --ansi < #{tempname}`.chomp1142 )1143 end11441145 def test_with_nth_no_ansi1146 src = "\x1b[33mhello \x1b[34;1mworld\x1b[m "1147 writelines tempname, [src, 'byebye']1148 assert_equal(1149 src,1093 assert_equal src, `#{FZF} -fhehe -x -n 2.. --with-nth 2,1,1 --no-ansi < #{tempname}`.chomp1150 `#{FZF} -fhehe -x -n 2.. --with-nth 2,1,1 --no-ansi < #{tempname}`.chomp1151 )1152 end11531154 def test_exit_0_exit_code1155 `echo foo | #{FZF} -q bar -0`1098 assert_equal 1, $?.exitstatus1156 assert_equal 1, $CHILD_STATUS.exitstatus1157 end11581159 def test_invalid_option1160 lines = `#{FZF} --foobar 2>&1`1103 assert_equal 2, $?.exitstatus1161 assert_equal 2, $CHILD_STATUS.exitstatus1162 assert lines.include?('unknown option: --foobar'), lines1163 end11641165 def test_filter_exitstatus1166 # filter / streaming filter1109 ["", "--no-sort"].each do |opts|1167 ['', '--no-sort'].each do |opts|1168 assert `echo foo | #{FZF} -f foo #{opts}`.include?('foo')1111 assert_equal 0, $?.exitstatus1169 assert_equal 0, $CHILD_STATUS.exitstatus11701171 assert `echo foo | #{FZF} -f bar #{opts}`.empty?1114 assert_equal 1, $?.exitstatus1172 assert_equal 1, $CHILD_STATUS.exitstatus1173 end1174 end11751176 def test_exitstatus_empty
18 unmodified lines
11951196 def test_or_operator1197 assert_equal %w[1 5 10], `seq 10 | #{FZF} -f "1 | 5"`.lines.map(&:chomp)1198 assert_equal %w[1 10 2 3 4 5 6 7 8 9],1141 `seq 10 | #{FZF} -f '1 | !1'`.lines.map(&:chomp)1199 `seq 10 | #{FZF} -f '1 | !1'`.lines.map(&:chomp)1200 end12011202 def test_hscroll_off1145 writelines tempname, ['=' * 10000 + '0123456789']1203 writelines tempname, ['=' * 10_000 + '0123456789']1204 [0, 3, 6].each do |off|1205 tmux.prepare1206 tmux.send_keys "#{FZF} --hscroll-off=#{off} -q 0 < #{tempname}", :Enter1207 tmux.until { |lines| lines[-3].end_with?((0..off).to_a.join + '..') }
37 unmodified lines
1245 tmux.until { |lines| lines[-3] == '> 1' }1246 tmux.send_keys :Tab1247 tmux.until { |lines| lines[-3] == '>>1' }1248 tmux.send_keys :Enter1191 assert_equal %w[5 2 1], readonce.split($/)1249 assert_equal %w[5 2 1], readonce.split($INPUT_RECORD_SEPARATOR)1250 end12511252 def test_jump_accept1253 tmux.send_keys "seq 1000 | #{fzf "--multi --jump-labels 12345 --bind 'ctrl-j:jump-accept'"}", :Enter
4 unmodified lines
1258 assert_equal '3', readonce.chomp1259 end12601261 def test_preview1204 tmux.send_keys %[seq 1000 | sed s/^2$// | #{FZF} -m --preview 'sleep 0.2; echo {{}-{+}}' --bind ?:toggle-preview], :Enter1262 tmux.send_keys %(seq 1000 | sed s/^2$// | #{FZF} -m --preview 'sleep 0.2; echo {{}-{+}}' --bind ?:toggle-preview), :Enter1263 tmux.until { |lines| lines[1].include?(' {1-1}') }1264 tmux.send_keys :Up1265 tmux.until { |lines| lines[1].include?(' {-}') }1266 tmux.send_keys '555'
19 unmodified lines
1286 tmux.until { |lines| lines[1].include?(' {5-1 3 4}') }1287 end12881289 def test_preview_hidden1232 tmux.send_keys %[seq 1000 | #{FZF} --preview 'echo {{}-{}}' --preview-window down:1:hidden --bind ?:toggle-preview], :Enter1290 tmux.send_keys %(seq 1000 | #{FZF} --preview 'echo {{}-{}}' --preview-window down:1:hidden --bind ?:toggle-preview), :Enter1291 tmux.until { |lines| lines[-1] == '>' }1292 tmux.send_keys '?'1293 tmux.until { |lines| lines[-2].include?(' {1-1}') }1294 tmux.send_keys '555'
2 unmodified lines
1297 tmux.until { |lines| lines[-1] == '> 555' }1298 end12991300 def test_preview_size_01243 File.unlink tempname rescue nil1244 tmux.send_keys %[seq 100 | #{FZF} --reverse --preview 'echo {} >> #{tempname}; echo ' --preview-window 0], :Enter1301 begin1302 File.unlink tempname1303 rescue1304 nil1305 end1306 tmux.send_keys %(seq 100 | #{FZF} --reverse --preview 'echo {} >> #{tempname}; echo ' --preview-window 0), :Enter1307 tmux.until { |lines| lines.item_count == 100 && lines[1] == ' 100/100' && lines[2] == '> 1' }1246 tmux.until { |_| %w[1] == File.readlines(tempname).map(&:chomp) }1308 tmux.until { |_| %w[1] == File.readlines(tempname).map(&:chomp) }1309 tmux.send_keys :Down1310 tmux.until { |lines| lines[3] == '> 2' }1249 tmux.until { |_| %w[1 2] == File.readlines(tempname).map(&:chomp) }1311 tmux.until { |_| %w[1 2] == File.readlines(tempname).map(&:chomp) }1312 tmux.send_keys :Down1313 tmux.until { |lines| lines[4] == '> 3' }1252 tmux.until { |_| %w[1 2 3] == File.readlines(tempname).map(&:chomp) }1314 tmux.until { |_| %w[1 2 3] == File.readlines(tempname).map(&:chomp) }1315 end13161317 def test_no_clear1318 tmux.send_keys "seq 10 | fzf --no-clear --inline-info --height 5 > #{tempname}", :Enter
4 unmodified lines
1323 tmux.until { |lines| lines[-1] == prompt }1324 end13251326 def test_change_top1265 tmux.send_keys %[seq 1000 | #{FZF} --bind change:top], :Enter1327 tmux.send_keys %(seq 1000 | #{FZF} --bind change:top), :Enter1328 tmux.until { |lines| lines.match_count == 1000 }1329 tmux.send_keys :Up1330 tmux.until { |lines| lines[-4] == '> 2' }1331 tmux.send_keys 1
11 unmodified lines
1343 tmux.until { |lines| lines.item_count == 10 }1344 tmux.send_keys 'a'1345 tmux.until { |lines| lines.any? { |line| line.include? '1 2 3 4 5' } }1346 tmux.send_keys 'a'1285 tmux.until { |lines| !lines.any? { |line| line.include? '1 2 3 4 5' } }1347 tmux.until { |lines| lines.none? { |line| line.include? '1 2 3 4 5' } }1348 end1349end13501351module TestShell
4 unmodified lines
1356 def teardown1357 @tmux.kill1358 end13591298 def set_var name, val1360 def set_var(name, val)1361 tmux.prepare1362 tmux.send_keys "export #{name}='#{val}'", :Enter1363 tmux.prepare1364 end13651304 def unset_var name1366 def unset_var(name)1367 tmux.prepare1368 tmux.send_keys "unset #{name}", :Enter1369 tmux.prepare1370 end13711372 def test_ctrl_t1311 set_var "FZF_CTRL_T_COMMAND", "seq 100"1373 set_var 'FZF_CTRL_T_COMMAND', 'seq 100'13741313 lines = retries do1375 retries do1376 tmux.prepare1377 tmux.send_keys 'C-t'1378 tmux.until { |lines| lines.item_count == 100 }1379 end
5 unmodified lines
1385 end13861387 def test_ctrl_t_unicode1388 writelines tempname, ['fzf-unicode 테스트1', 'fzf-unicode 테스트2']1327 set_var "FZF_CTRL_T_COMMAND", "cat #{tempname}"1389 set_var 'FZF_CTRL_T_COMMAND', "cat #{tempname}"13901391 retries do1392 tmux.prepare1393 tmux.send_keys 'echo ', 'C-t'
15 unmodified lines
1409 tmux.send_keys :Tab1410 tmux.until { |lines| lines.select_count == 2 }14111412 tmux.send_keys :Enter1351 tmux.until { |lines| lines.any_include? /echo.*fzf-unicode.*1.*fzf-unicode.*2/ }1413 tmux.until { |lines| lines.any_include?(/echo.*fzf-unicode.*1.*fzf-unicode.*2/) }1414 tmux.send_keys :Enter1353 tmux.until { |lines| lines.any_include? /^fzf-unicode.*1.*fzf-unicode.*2/ }1415 tmux.until { |lines| lines.any_include?(/^fzf-unicode.*1.*fzf-unicode.*2/) }1416 end14171418 def test_alt_c1419 lines = retries do1420 tmux.prepare1421 tmux.send_keys :Escape, :c1360 tmux.until { |lines| lines.item_count > 0 }1422 tmux.until { |lines| lines.item_count.positive? }1423 end1424 expected = lines.reverse.select { |l| l.start_with? '>' }.first[2..-1]1425 tmux.send_keys :Enter1426 tmux.prepare
9 unmodified lines
14361437 retries do1438 tmux.prepare1439 tmux.send_keys :Escape, :c1378 lines = tmux.until { |lines| lines.item_count == 1 }1440 tmux.until { |lines| lines.item_count == 1 }1441 end1442 tmux.send_keys :Enter14431444 tmux.prepare
10 unmodified lines
1455 tmux.send_keys 'echo 4th', :Enter1456 retries do1457 tmux.prepare1458 tmux.send_keys 'C-r'1397 tmux.until { |lines| lines.item_count > 0 }1459 tmux.until { |lines| lines.item_count.positive? }1460 end1461 tmux.send_keys 'C-r'1462 tmux.send_keys '3d'1463 tmux.until { |lines| lines[-3].end_with? 'echo 3rd' }
2 unmodified lines
1466 tmux.send_keys :Enter1467 tmux.until { |lines| lines[-1] == '3rd' }1468 end14691408 def retries times = 3, &block1409 (times - 1).times do |t|1470 def retries(times = 3)1471 (times - 1).times do1472 begin1411 return block.call1473 return yield1474 rescue RuntimeError1475 end1476 end1415 block.call1477 yield1478 end1479end14801481module CompletionTest
5 unmodified lines
1487 FileUtils.touch File.expand_path(f)1488 end1489 tmux.prepare1490 tmux.send_keys 'cat /tmp/fzf-test/10**', :Tab1429 tmux.until { |lines| lines.item_count > 0 }1491 tmux.until { |lines| lines.item_count.positive? }1492 tmux.send_keys ' !d'1493 tmux.until { |lines| lines.match_count == 2 }1494 tmux.send_keys :Tab, :Tab1495 tmux.until { |lines| lines.select_count == 2 }1496 tmux.send_keys :Enter1497 tmux.until(true) do |lines|1498 lines[-1].include?('/tmp/fzf-test/10') &&1437 lines[-1].include?('/tmp/fzf-test/100')1499 lines[-1].include?('/tmp/fzf-test/100')1500 end15011502 # ~USERNAME**<TAB>1503 tmux.send_keys 'C-u'1504 tmux.send_keys "cat ~#{ENV['USER']}**", :Tab1443 tmux.until { |lines| lines.item_count > 0 }1505 tmux.until { |lines| lines.item_count.positive? }1506 tmux.send_keys "'.fzf-home"1507 tmux.until { |lines| lines.select { |l| l.include? '.fzf-home' }.count > 1 }1508 tmux.send_keys :Enter1509 tmux.until(true) do |lines|
1 unmodified line
1511 end15121513 # ~INVALID_USERNAME**<TAB>1514 tmux.send_keys 'C-u'1453 tmux.send_keys "cat ~such**", :Tab1515 tmux.send_keys 'cat ~such**', :Tab1516 tmux.until(true) { |lines| lines.any_include? 'no~such~user' }1517 tmux.send_keys :Enter1518 tmux.until(true) { |lines| lines[-1].end_with?('no~such~user') }15191520 # /tmp/fzf\ test**<TAB>1521 tmux.send_keys 'C-u'1522 tmux.send_keys 'cat /tmp/fzf\ test/**', :Tab1461 tmux.until { |lines| lines.item_count > 0 }1523 tmux.until { |lines| lines.item_count.positive? }1524 tmux.send_keys 'foobar$'1525 tmux.until { |lines| lines.match_count == 1 }1526 tmux.send_keys :Enter1527 tmux.until(true) { |lines| lines[-1].end_with?('/tmp/fzf\ test/foobar') }
11 unmodified lines
1539 end15401541 def test_file_completion_root1542 tmux.send_keys 'ls /**', :Tab1481 tmux.until { |lines| lines.item_count > 0 }1543 tmux.until { |lines| lines.item_count.positive? }1544 tmux.send_keys :Enter1545 end15461547 def test_dir_completion
2 unmodified lines
1550 end1551 FileUtils.touch '/tmp/fzf-test/d55/xxx'1552 tmux.prepare1553 tmux.send_keys 'cd /tmp/fzf-test/**', :Tab1492 tmux.until { |lines| lines.item_count > 0 }1554 tmux.until { |lines| lines.item_count.positive? }1555 tmux.send_keys :Tab, :Tab # Tab does not work here1556 tmux.send_keys 551557 tmux.until { |lines| lines.match_count == 1 }1558 tmux.send_keys :Enter
20 unmodified lines
1579 pid = lines[-1].split.last1580 tmux.prepare1581 tmux.send_keys 'C-L'1582 tmux.send_keys 'kill ', :Tab1521 tmux.until { |lines| lines.item_count > 0 }1583 tmux.until { |lines| lines.item_count.positive? }1584 tmux.send_keys 'sleep12345'1585 tmux.until { |lines| lines.any_include? 'sleep 12345' }1586 tmux.send_keys :Enter1587 tmux.until(true) { |lines| lines[-1].include? "kill #{pid}" }1588 ensure1589 if pid1590 begin1527 Process.kill 'KILL', pid.to_i rescue nil if pid1591 Process.kill 'KILL', pid.to_i1592 rescue1593 nil1594 end1595 end1596 end15971598 def test_custom_completion1599 tmux.send_keys '_fzf_compgen_path() { echo "\$1"; seq 10; }', :Enter
2 unmodified lines
1602 tmux.until { |lines| lines.item_count == 11 }1603 tmux.send_keys :Tab, :Tab, :Tab1604 tmux.until { |lines| lines.select_count == 3 }1605 tmux.send_keys :Enter1538 tmux.until(true) { |lines| lines[-1] == "ls /tmp 1 2" }1606 tmux.until(true) { |lines| lines[-1] == 'ls /tmp 1 2' }1607 end16081609 def test_unset_completion1610 tmux.send_keys 'export FZFFOOBAR=BAZ', :Enter
77 unmodified lines
16881689 def new_shell1690 tmux.send_keys 'env FZF_TMUX=1 fish', :Enter1691 tmux.send_keys 'function fish_prompt; end; clear', :Enter1624 tmux.until { |lines| lines.empty? }1692 tmux.until(&:empty?)1693 end16941627 def set_var name, val1695 def set_var(name, val)1696 tmux.prepare1697 tmux.send_keys "set -g #{name} '#{val}'", :Enter1698 tmux.prepare1699 end
2 unmodified lines
1702 super1703 @tmux = Tmux.new :fish1704 end1705end1638
modified:.travis.yml+2 added-5 removed