more error handling work and cleanup, more stable now

This commit is contained in:
John Bintz 2012-03-15 16:07:43 -04:00
parent cc753a10fd
commit cb222198ce
6 changed files with 35 additions and 13 deletions

View File

@ -116,7 +116,14 @@ module Flowerbox
end end
def cleanup! def cleanup!
browsers.values.each(&:close) browsers.values.each do |browser|
begin
browser.close
rescue Errno::ECONNREFUSED => e
puts "Browser already closed."
end
end
@browsers = {} @browsers = {}
end end
end end

View File

@ -20,6 +20,7 @@ module Flowerbox::Reporter
puts result.name.join(" - ").foreground(:red) puts result.name.join(" - ").foreground(:red)
result.failures.each do |failure| result.failures.each do |failure|
puts " " + failure.message.foreground(:red) + " [" + failure.runners.join(',') + "] " + path_for(failure) puts " " + failure.message.foreground(:red) + " [" + failure.runners.join(',') + "] " + path_for(failure)
puts failure.stack.join("\n").foreground(:red) if failure.exception?
end end
end end

View File

@ -13,7 +13,13 @@ module Flowerbox::Result
end end
def file def file
first_local_stack[%r{\(([^:]+\:\d+)}, 1] file = first_local_stack
if file['__F__']
file[%r{^.*__F__/([^:]+:\d+)}, 1]
else
file[%r{\(([^:]+\:\d+)}, 1]
end
end end
def runner def runner
@ -24,10 +30,18 @@ module Flowerbox::Result
@runners ||= [ runner ] @runners ||= [ runner ]
end end
def stack
@data['stack']
end
def first_local_stack def first_local_stack
@data['stack'][1..-1].find do |line| @first_local_stack ||= stack[1..-1].find do |line|
!system_files.any? { |file| line[%r{\(#{file}}] } !system_files.any? { |file| line[%r{\(#{file}}] }
end || @data['stack'][1] || '' end || stack[1] || ''
end
def exception?
stack[0][%r{^.+Error: }]
end end
end end
end end

View File

@ -1,10 +1,6 @@
module Flowerbox::Result::FileInfo module Flowerbox::Result::FileInfo
def translated_file def translated_file
@translated_file ||= if actual_file_base = filename[%r{\.tmp/sprockets(.*)}, 1] @translated_file ||= filename
Dir[actual_file_base + "*"].first
else
filename
end
end end
def file_translated? def file_translated?
@ -12,7 +8,7 @@ module Flowerbox::Result::FileInfo
end end
def filename def filename
file.to_s.split(":").first file.to_s.split(":").first || 'unknown'
end end
def line_number def line_number
@ -20,7 +16,7 @@ module Flowerbox::Result::FileInfo
@line_number = file.to_s.split(":")[1] @line_number = file.to_s.split(":")[1]
@line_number = "~#{@line_number}" if file_translated? @line_number = "~#{@line_number}" if file_translated?
@line_number @line_number ||= "0"
end end
alias :line :line_number alias :line :line_number

View File

@ -23,6 +23,8 @@ module Flowerbox::Run
runner_envs.each(&:cleanup) runner_envs.each(&:cleanup)
result_set.exitstatus result_set.exitstatus
rescue Flowerbox::Runner::Base::RunnerDiedError
255
end end
end end
end end

View File

@ -7,6 +7,8 @@ module Flowerbox
MAX_COUNT = 50 MAX_COUNT = 50
class RunnerDiedError < StandardError ; end
def initialize def initialize
@results = ResultSet.new @results = ResultSet.new
end end
@ -18,9 +20,9 @@ module Flowerbox
end end
if !finished? if !finished?
puts "Something died hard. Here are the tests that did get run before Flowerbox died.".foreground(:red)
puts tests.flatten.join("\n").foreground(:red) puts tests.flatten.join("\n").foreground(:red)
cleanup raise RunnerDiedError.new
exit 1
end end
end end