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
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 = {}
end
end

View File

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

View File

@ -13,7 +13,13 @@ module Flowerbox::Result
end
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
def runner
@ -24,10 +30,18 @@ module Flowerbox::Result
@runners ||= [ runner ]
end
def stack
@data['stack']
end
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}}] }
end || @data['stack'][1] || ''
end || stack[1] || ''
end
def exception?
stack[0][%r{^.+Error: }]
end
end
end

View File

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

View File

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

View File

@ -7,6 +7,8 @@ module Flowerbox
MAX_COUNT = 50
class RunnerDiedError < StandardError ; end
def initialize
@results = ResultSet.new
end
@ -18,9 +20,9 @@ module Flowerbox
end
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)
cleanup
exit 1
raise RunnerDiedError.new
end
end