Fix Travis CI build

This commit is contained in:
Junegunn Choi 2015-01-29 17:37:35 +09:00
parent 47201c2c4d
commit e6a0de4094
2 changed files with 33 additions and 16 deletions

View File

@ -1,6 +1,7 @@
language: ruby language: ruby
install: install:
- sudo apt-get update
- sudo apt-get install -y libncurses-dev lib32ncurses5-dev - sudo apt-get install -y libncurses-dev lib32ncurses5-dev
- sudo add-apt-repository -y ppa:pi-rho/dev - sudo add-apt-repository -y ppa:pi-rho/dev
- sudo apt-get update - sudo apt-get update

View File

@ -38,7 +38,7 @@ class Tmux
attr_reader :win attr_reader :win
def initialize shell = 'bash' def initialize shell = 'bash'
@win = go("new-window -d -P -F '#I' 'PS1=FIN PROMPT_COMMAND= bash --rcfile ~/.fzf.#{shell}'").first @win = go("new-window -d -P -F '#I' 'PS1= PROMPT_COMMAND= bash --rcfile ~/.fzf.#{shell}'").first
@lines = `tput lines`.chomp.to_i @lines = `tput lines`.chomp.to_i
end end
@ -96,6 +96,7 @@ end
class TestGoFZF < MiniTest::Unit::TestCase class TestGoFZF < MiniTest::Unit::TestCase
include Temp include Temp
FIN = 'FIN'
TEMPNAME = '/tmp/output' TEMPNAME = '/tmp/output'
attr_reader :tmux attr_reader :tmux
@ -110,8 +111,23 @@ class TestGoFZF < MiniTest::Unit::TestCase
@tmux.kill @tmux.kill
end end
def fzf(*opts)
opts = opts.map { |o|
case o
when Symbol
o = o.to_s
o.length > 1 ? "--#{o.gsub('_', '-')}" : "-#{o}"
when String, Numeric
o.to_s
else
nil
end
}.compact
"fzf #{opts.join ' '} > #{TEMPNAME} && echo #{FIN}"
end
def test_vanilla def test_vanilla
tmux.send_keys "seq 1 100000 | fzf > #{TEMPNAME}", :Enter tmux.send_keys "seq 1 100000 | #{fzf}", :Enter
tmux.until(10) { |lines| lines.last =~ /^>/ && lines[-2] =~ /^ 100000/ } tmux.until(10) { |lines| lines.last =~ /^>/ && lines[-2] =~ /^ 100000/ }
lines = tmux.capture lines = tmux.capture
assert_equal ' 2', lines[-4] assert_equal ' 2', lines[-4]
@ -134,7 +150,7 @@ class TestGoFZF < MiniTest::Unit::TestCase
end end
def test_fzf_default_command def test_fzf_default_command
tmux.send_keys "FZF_DEFAULT_COMMAND='echo hello' fzf > #{TEMPNAME}", :Enter tmux.send_keys "FZF_DEFAULT_COMMAND='echo hello' #{fzf}", :Enter
tmux.until { |lines| lines.last =~ /^>/ } tmux.until { |lines| lines.last =~ /^>/ }
tmux.send_keys :Enter tmux.send_keys :Enter
@ -209,7 +225,7 @@ class TestGoFZF < MiniTest::Unit::TestCase
end end
def test_multi_order def test_multi_order
tmux.send_keys "seq 1 10 | fzf --multi > #{TEMPNAME}", :Enter tmux.send_keys "seq 1 10 | #{fzf :multi}", :Enter
tmux.until { |lines| lines.last =~ /^>/ } tmux.until { |lines| lines.last =~ /^>/ }
tmux.send_keys :Tab, :Up, :Up, :Tab, :Tab, :Tab, # 3, 2 tmux.send_keys :Tab, :Up, :Up, :Tab, :Tab, :Tab, # 3, 2
@ -217,7 +233,7 @@ class TestGoFZF < MiniTest::Unit::TestCase
:PgUp, 'C-J', :Down, :Tab, :Tab # 8, 7 :PgUp, 'C-J', :Down, :Tab, :Tab # 8, 7
tmux.until { |lines| lines[-2].include? '(6)' } tmux.until { |lines| lines[-2].include? '(6)' }
tmux.send_keys "C-M" tmux.send_keys "C-M"
tmux.until { |lines| lines[-1].include?('FIN') } tmux.until { |lines| lines[-1].include?(FIN) }
assert_equal %w[3 2 5 6 8 7], readonce.split($/) assert_equal %w[3 2 5 6 8 7], readonce.split($/)
tmux.close tmux.close
end end
@ -226,7 +242,7 @@ class TestGoFZF < MiniTest::Unit::TestCase
[true, false].each do |multi| [true, false].each do |multi|
tmux.send_keys "(echo ' 1st 2nd 3rd/'; tmux.send_keys "(echo ' 1st 2nd 3rd/';
echo ' first second third/') | echo ' first second third/') |
fzf #{"--multi" if multi} -x --nth 2 --with-nth 2,-1,1 > #{TEMPNAME}", #{fzf multi && :multi, :x, :nth, 2, :with_nth, '2,-1,1'}",
:Enter :Enter
tmux.until { |lines| lines[-2].include?('2/2') } tmux.until { |lines| lines[-2].include?('2/2') }
@ -238,13 +254,13 @@ class TestGoFZF < MiniTest::Unit::TestCase
# However, the output must not be transformed # However, the output must not be transformed
if multi if multi
tmux.send_keys :BTab, :BTab, :Enter tmux.send_keys :BTab, :BTab, :Enter
tmux.until { |lines| lines[-1].include?('FIN') } tmux.until { |lines| lines[-1].include?(FIN) }
assert_equal [' 1st 2nd 3rd/', ' first second third/'], readonce.split($/) assert_equal [' 1st 2nd 3rd/', ' first second third/'], readonce.split($/)
else else
tmux.send_keys '^', '3' tmux.send_keys '^', '3'
tmux.until { |lines| lines[-2].include?('1/2') } tmux.until { |lines| lines[-2].include?('1/2') }
tmux.send_keys :Enter tmux.send_keys :Enter
tmux.until { |lines| lines[-1].include?('FIN') } tmux.until { |lines| lines[-1].include?(FIN) }
assert_equal [' 1st 2nd 3rd/'], readonce.split($/) assert_equal [' 1st 2nd 3rd/'], readonce.split($/)
end end
end end
@ -252,33 +268,33 @@ class TestGoFZF < MiniTest::Unit::TestCase
def test_scroll def test_scroll
[true, false].each do |rev| [true, false].each do |rev|
tmux.send_keys "seq 1 100 | fzf #{'--reverse' if rev} > #{TEMPNAME}", :Enter tmux.send_keys "seq 1 100 | #{fzf rev && :reverse}", :Enter
tmux.until { |lines| lines.include? ' 100/100' } tmux.until { |lines| lines.include? ' 100/100' }
tmux.send_keys *110.times.map { rev ? :Down : :Up } tmux.send_keys *110.times.map { rev ? :Down : :Up }
tmux.until { |lines| lines.include? '> 100' } tmux.until { |lines| lines.include? '> 100' }
tmux.send_keys :Enter tmux.send_keys :Enter
tmux.until { |lines| lines[-1].include?('FIN') } tmux.until { |lines| lines[-1].include?(FIN) }
assert_equal '100', readonce.chomp assert_equal '100', readonce.chomp
end end
end end
def test_select_1 def test_select_1
tmux.send_keys "seq 1 100 | fzf --with-nth ..,.. --print-query -q 5555 -1 > #{TEMPNAME}", :Enter tmux.send_keys "seq 1 100 | #{fzf :with_nth, '..,..', :print_query, :q, 5555, :'1'}", :Enter
tmux.until { |lines| lines[-1].include?('FIN') } tmux.until { |lines| lines[-1].include?(FIN) }
assert_equal ['5555', '55'], readonce.split($/) assert_equal ['5555', '55'], readonce.split($/)
end end
def test_exit_0 def test_exit_0
tmux.send_keys "seq 1 100 | fzf --with-nth ..,.. --print-query -q 555555 -0 > #{TEMPNAME}", :Enter tmux.send_keys "seq 1 100 | #{fzf :with_nth, '..,..', :print_query, :q, 555555, :'0'}", :Enter
tmux.until { |lines| lines[-1].include?('FIN') } tmux.until { |lines| lines[-1].include?(FIN) }
assert_equal ['555555'], readonce.split($/) assert_equal ['555555'], readonce.split($/)
end end
def test_query_unicode def test_query_unicode
tmux.send_keys "(echo abc; echo 가나다) | fzf --query 가다 > #{TEMPNAME}", :Enter tmux.send_keys "(echo abc; echo 가나다) | #{fzf :query, '가다'}", :Enter
tmux.until { |lines| lines.last.start_with? '>' } tmux.until { |lines| lines.last.start_with? '>' }
tmux.send_keys :Enter tmux.send_keys :Enter
tmux.until { |lines| lines[-1].include?('FIN') } tmux.until { |lines| lines[-1].include?(FIN) }
assert_equal ['가나다'], readonce.split($/) assert_equal ['가나다'], readonce.split($/)
end end
end end