From c0b432f7b4086c415d798d23970a3f5a4471af32 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Sat, 17 Jan 2015 06:12:57 +0900 Subject: Fix Travis-CI build --- .travis.yml | 24 +++++++++++++++--------- test/test_go.rb | 21 +++++++++++++++------ 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/.travis.yml b/.travis.yml index 38961904..9943ca61 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,19 +1,25 @@ language: ruby -rvm: - - "2.1.1" -before_script: | - sudo apt-get install -y tmux libncurses-dev lib32ncurses5-dev +install: +- sudo apt-get install -y libncurses-dev lib32ncurses5-dev +- sudo add-apt-repository -y ppa:pi-rho/dev +- sudo apt-get update +- sudo apt-get install -y tmux=1.9a-1~ppa1~p +script: | export GOROOT=~/go1.4 export GOPATH=~/go + export FZF_BASE=~/go/src/github.com/junegunn/fzf mkdir -p ~/go/src/github.com/junegunn - ln -s $(pwd) ~/go/src/github.com/junegunn/fzf + ln -s $(pwd) $FZF_BASE - curl https://storage.googleapis.com/golang/go1.4.linux-amd64.tar.gz | tar -xz + curl https://storage.googleapis.com/golang/go1.4.1.linux-amd64.tar.gz | tar -xz mv go $GOROOT - cd $GOROOT/src && GOARCH=386 ./make.bash + cd $GOROOT/src + GOARCH=386 ./make.bash - cd ~/go/src/github.com/junegunn/fzf/src && make install && cd .. && - yes | ./install && tmux + cd $FZF_BASE/src && make install && + cd $FZF_BASE/bin && ln -sf fzf-linux_amd64 fzf-$(./fzf --version)-linux_amd64 && + cd $FZF_BASE && yes | ./install && + tmux new "rake test > out && touch ok" && cat out && [ -e ok ] diff --git a/test/test_go.rb b/test/test_go.rb index de8fac7d..a499a92f 100644 --- a/test/test_go.rb +++ b/test/test_go.rb @@ -10,6 +10,7 @@ class Tmux def initialize shell = 'bash' @win = go("new-window -P -F '#I' 'bash --rcfile ~/.fzf.#{shell}'").first + @lines = `tput lines`.chomp.to_i end def self.current @@ -25,7 +26,7 @@ class Tmux end def close timeout = 1 - send_keys 'C-c', 'C-u', 'C-d' + send_keys 'C-c', 'C-u', 'exit', :Enter wait(timeout) { closed? } end @@ -41,7 +42,7 @@ class Tmux def capture go("capture-pane -t #{win} \\; save-buffer #{TEMPNAME}") raise "Window not found" if $?.exitstatus != 0 - File.read(TEMPNAME).split($/) + File.read(TEMPNAME).split($/)[0, @lines] end def until timeout = 1 @@ -54,7 +55,15 @@ private until yield waited += 0.1 sleep 0.1 - raise "timeout" if waited > timeout + if waited > timeout + hl = '=' * 10 + puts hl + capture.each_with_index do |line, idx| + puts [idx.to_s.rjust(2), line].join(': ') + end + puts hl + raise "timeout" + end end end @@ -85,7 +94,7 @@ class TestGoFZF < MiniTest::Unit::TestCase def test_vanilla tmux.send_keys "seq 1 100000 | fzf > #{tempname}", :Enter - tmux.until { |lines| lines.last =~ /^>/ && lines[-2] =~ /^ 100000/ } + tmux.until(10) { |lines| lines.last =~ /^>/ && lines[-2] =~ /^ 100000/ } lines = tmux.capture assert_equal ' 2', lines[-4] assert_equal '> 1', lines[-3] @@ -94,7 +103,7 @@ class TestGoFZF < MiniTest::Unit::TestCase # Testing basic key bindings tmux.send_keys '99', 'C-a', '1', 'C-f', '3', 'C-b', 'C-h', 'C-u', 'C-e', 'C-y', 'C-k', 'Tab', 'BTab' - tmux.until { |lines| lines.last == '> 391' } + tmux.until { |lines| lines[-2] == ' 856/100000' } lines = tmux.capture assert_equal '> 1391', lines[-4] assert_equal ' 391', lines[-3] @@ -117,7 +126,7 @@ class TestGoFZF < MiniTest::Unit::TestCase def test_fzf_prompt tmux.send_keys "fzf -q 'foo bar foo-bar'", :Enter - tmux.until { |lines| lines.last =~ /foo-bar/ } + tmux.until { |lines| lines.last =~ /^>/ } # CTRL-A tmux.send_keys "C-A", "(" -- cgit v1.2.3