Dump screen content on test failure

This commit is contained in:
Junegunn Choi 2015-05-10 03:25:14 +09:00
parent 207aa07891
commit 683abb86ef

View File

@ -111,6 +111,7 @@ class Tmux
def until pane = 0 def until pane = 0
lines = nil lines = nil
begin
wait do wait do
lines = capture(pane) lines = capture(pane)
class << lines class << lines
@ -120,6 +121,13 @@ class Tmux
end end
yield lines yield lines
end end
rescue Exception
puts $!.backtrace
puts '>' * 80
puts lines
puts '<' * 80
raise
end
lines lines
end end
@ -527,7 +535,7 @@ module TestShell
def test_ctrl_t def test_ctrl_t
tmux.prepare tmux.prepare
tmux.send_keys 'C-t', pane: 0 tmux.send_keys 'C-t', pane: 0
lines = tmux.until(1) { |lines| lines.item_count > 0 } lines = tmux.until(1) { |lines| lines.item_count > 1 }
expected = lines.values_at(-3, -4).map { |line| line[2..-1] }.join(' ') expected = lines.values_at(-3, -4).map { |line| line[2..-1] }.join(' ')
tmux.send_keys :BTab, :BTab, :Enter, pane: 1 tmux.send_keys :BTab, :BTab, :Enter, pane: 1
tmux.until(0) { |lines| lines[-1].include? expected } tmux.until(0) { |lines| lines[-1].include? expected }
@ -536,7 +544,7 @@ module TestShell
# FZF_TMUX=0 # FZF_TMUX=0
new_shell new_shell
tmux.send_keys 'C-t', pane: 0 tmux.send_keys 'C-t', pane: 0
lines = tmux.until(0) { |lines| lines.item_count > 0 } lines = tmux.until(0) { |lines| lines.item_count > 1 }
expected = lines.values_at(-3, -4).map { |line| line[2..-1] }.join(' ') expected = lines.values_at(-3, -4).map { |line| line[2..-1] }.join(' ')
tmux.send_keys :BTab, :BTab, :Enter, pane: 0 tmux.send_keys :BTab, :BTab, :Enter, pane: 0
tmux.until(0) { |lines| lines[-1].include? expected } tmux.until(0) { |lines| lines[-1].include? expected }