Skip to content
Myr

Test refactoring

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

authored by Junegunn Choi · committed by Junegunn Choi · parent 8973207 · Browse files · 1 file+9 added−29 removed
This commit

State

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

Diff stats

1 file+9 added−29 removed

  • tests:+9 added−29 removed

1 file+9 added−29 removed

modified:test/test_go.rb+9 added-29 removed
70 unmodified lines
71 self.until { |lines| lines.empty? }72 end73 end7475 def closed?76 !go("list-window -F '#I'").include?(win)77 end7879 def close80 wait do81 send_keys 'C-c', 'C-u', 'exit', :Enter82 closed?83 end84 end8575 def kill76 go("kill-window -t #{win} 2> /dev/null")77 end78
61 unmodified lines
140 TEMPNAME = '/tmp/output'141142 attr_reader :tmux143144 def tempname145 [TEMPNAME,146 caller_locations.map(&:label).find { |l| l =~ /^test_/ }].join '-'147 end148149 def setup150 ENV.delete 'FZF_DEFAULT_OPTS'151 ENV.delete 'FZF_DEFAULT_COMMAND'158 File.unlink TEMPNAME while File.exists?(TEMPNAME)152 end153154 def readonce162 wait { File.exists?(TEMPNAME) }163 File.read(TEMPNAME)155 wait { File.exists?(tempname) }156 File.read(tempname)157 ensure165 File.unlink TEMPNAME while File.exists?(TEMPNAME)158 File.unlink tempname while File.exists?(tempname)159 end160161 def fzf(*opts)169 fzf!(*opts) + " > #{TEMPNAME}.tmp; mv #{TEMPNAME}.tmp #{TEMPNAME}"162 fzf!(*opts) + " > #{tempname}.tmp; mv #{tempname}.tmp #{tempname}"163 end164165 def fzf!(*opts)166 opts = opts.map { |o|
39 unmodified lines
206 assert_equal ' 856/100000', lines[-2]207 assert_equal '> 391', lines[-1]208209 tmux.send_keys :Enter217 tmux.close210 assert_equal '1391', readonce.chomp211 end212213 def test_fzf_default_command214 tmux.send_keys "FZF_DEFAULT_COMMAND='echo hello' #{fzf}", :Enter215 tmux.until { |lines| lines.last =~ /^>/ }216217 tmux.send_keys :Enter226 tmux.close218 assert_equal 'hello', readonce.chomp219 end220221 def test_key_bindings
58 unmodified lines
280281 # CTRL-M282 tmux.send_keys "C-M"283 tmux.until { |lines| lines.last !~ /^>/ }293 tmux.close284 end285286 def test_multi_order287 tmux.send_keys "seq 1 10 | #{fzf :multi}", :Enter
4 unmodified lines
292 :PgUp, 'C-J', :Down, :Tab, :Tab # 8, 7293 tmux.until { |lines| lines[-2].include? '(6)' }294 tmux.send_keys "C-M"295 assert_equal %w[3 2 5 6 8 7], readonce.split($/)306 tmux.close296 end297298 def test_with_nth299 [true, false].each do |multi|
142 unmodified lines
442 end443 end444445 def test_unicode_case457 tempname = TEMPNAME + Time.now.to_f.to_s446 writelines tempname, %w[строКА1 СТРОКА2 строка3 Строка4]447 assert_equal %w[СТРОКА2 Строка4], `cat #{tempname} | #{FZF} -fС`.split($/)448 assert_equal %w[строКА1 СТРОКА2 строка3 Строка4], `cat #{tempname} | #{FZF} -fс`.split($/)461 rescue462 File.unlink tempname449 end450451 def test_tiebreak466 tempname = TEMPNAME + Time.now.to_f.to_s452 input = %w[453 --foobar--------454 -----foobar---455 ----foobar--
28 unmodified lines
484 --foobar--------485 ], `cat #{tempname} | #{FZF} -ffoobar --tiebreak end`.split($/)486487 assert_equal input, `cat #{tempname} | #{FZF} -f"!z" -x --tiebreak end`.split($/)503 rescue504 File.unlink tempname488 end489490 def test_invalid_cache491 tmux.send_keys "(echo d; echo D; echo x) | #{fzf '-q d'}", :Enter
17 unmodified lines
509 assert_equal %w[4 5 6 9], readonce.split($/)510 end511512 def test_long_line530 tempname = TEMPNAME + Time.now.to_f.to_s513 data = '.' * 256 * 1024514 File.open(tempname, 'w') do |f|515 f << data516 end517 assert_equal data, `cat #{tempname} | #{FZF} -f .`.chomp536 ensure537 File.unlink tempname518 end519520 def test_null521 lines = `find .`.split($/)
287 unmodified lines