From 63ffe1469231aa2aa720332a76568efe2c22e7ea Mon Sep 17 00:00:00 2001 From: John Bintz Date: Wed, 21 Mar 2012 17:36:17 -0400 Subject: [PATCH] fixes for when browsers die --- lib/assets/javascripts/flowerbox.js.coffee | 2 ++ lib/flowerbox.rb | 4 +++- lib/flowerbox/result/failure_message.rb | 2 +- lib/flowerbox/runner/base.rb | 4 ++++ lib/flowerbox/runner/selenium.rb | 11 ++++++++++- lib/flowerbox/server.rb | 1 + 6 files changed, 21 insertions(+), 3 deletions(-) diff --git a/lib/assets/javascripts/flowerbox.js.coffee b/lib/assets/javascripts/flowerbox.js.coffee index cfe100c..ebbd648 100644 --- a/lib/assets/javascripts/flowerbox.js.coffee +++ b/lib/assets/javascripts/flowerbox.js.coffee @@ -19,6 +19,8 @@ Flowerbox = started: false done: false + xhrObjects: {} + onQueueStateChange: -> queueRunner: (failsafe = 5) -> diff --git a/lib/flowerbox.rb b/lib/flowerbox.rb index 1e767fe..48734f3 100644 --- a/lib/flowerbox.rb +++ b/lib/flowerbox.rb @@ -63,7 +63,9 @@ module Flowerbox begin browser.close rescue Errno::ECONNREFUSED => e - puts "Browser already closed." + puts "Browser already closed.".foreground(:yellow) + rescue ::Selenium::WebDriver::Error::UnknownError => e + puts "Unknown browser error, pushing past it to close...".foreground(:yellow) end end diff --git a/lib/flowerbox/result/failure_message.rb b/lib/flowerbox/result/failure_message.rb index 0f4f036..8f9b379 100644 --- a/lib/flowerbox/result/failure_message.rb +++ b/lib/flowerbox/result/failure_message.rb @@ -48,7 +48,7 @@ module Flowerbox::Result end def first_local_stack - @first_local_stack ||= stack[1..-1].find do |line| + @first_local_stack ||= (stack[1..-1] || []).find do |line| !system_files.any? { |file| line[%r{\(#{file}}] } end || stack[1] || '' end diff --git a/lib/flowerbox/runner/base.rb b/lib/flowerbox/runner/base.rb index e63ee9d..84e1167 100644 --- a/lib/flowerbox/runner/base.rb +++ b/lib/flowerbox/runner/base.rb @@ -78,6 +78,10 @@ module Flowerbox end @results + rescue ExecJS::RuntimeError => e + puts e.message.foreground(:red) + + raise RunnerDiedError.new end def configured? diff --git a/lib/flowerbox/runner/selenium.rb b/lib/flowerbox/runner/selenium.rb index 602668b..fc19017 100644 --- a/lib/flowerbox/runner/selenium.rb +++ b/lib/flowerbox/runner/selenium.rb @@ -21,7 +21,16 @@ module Flowerbox def run(sprockets, spec_files, options) super do - browser.navigate.to "http://localhost:#{server.port}/" + navigate = Proc.new { browser.navigate.to "http://localhost:#{server.port}/" } + + begin + navigate.call + rescue ::Selenium::WebDriver::Error::UnknownError => e + puts "Browser communication error, reopening all browsers...".foreground(:yellow) + Flowerbox.cleanup! + + navigate.call + end ensure_alive end diff --git a/lib/flowerbox/server.rb b/lib/flowerbox/server.rb index 7ed22af..2dba072 100644 --- a/lib/flowerbox/server.rb +++ b/lib/flowerbox/server.rb @@ -3,6 +3,7 @@ require 'net/http' require 'socket' require 'rack/builder' require 'thin' +require 'eventmachine' module Flowerbox class Server