diff --git a/lib/flowerbox.rb b/lib/flowerbox.rb index 8c9caa2..fcd2294 100644 --- a/lib/flowerbox.rb +++ b/lib/flowerbox.rb @@ -21,7 +21,7 @@ module Flowerbox require 'flowerbox/rails/engine' end - CACHE_DIR = '.tmp-sprockets' + CACHE_DIR = 'tmp/sprockets' class << self attr_writer :reporters @@ -115,6 +115,10 @@ module Flowerbox break if env.transplant(dir) end end + + def cache_dir + File.join(CACHE_DIR, Flowerbox.test_environment.name) + end end end diff --git a/lib/flowerbox/reporter/console_base.rb b/lib/flowerbox/reporter/console_base.rb index 7d1fdbe..de167d9 100644 --- a/lib/flowerbox/reporter/console_base.rb +++ b/lib/flowerbox/reporter/console_base.rb @@ -20,7 +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? + puts failure.filtered_stack.join("\n").foreground(:red) if failure.exception? end end diff --git a/lib/flowerbox/reporter/verbose.rb b/lib/flowerbox/reporter/verbose.rb index 6cf2b32..02f8e71 100644 --- a/lib/flowerbox/reporter/verbose.rb +++ b/lib/flowerbox/reporter/verbose.rb @@ -12,6 +12,8 @@ module Flowerbox::Reporter if result.name result.name.each_with_index do |name, index| if @name_stack[index] != name + @name_stack = [] + if name != result.name.last message = name else diff --git a/lib/flowerbox/result/failure_message.rb b/lib/flowerbox/result/failure_message.rb index 6dc5c2a..d5ba474 100644 --- a/lib/flowerbox/result/failure_message.rb +++ b/lib/flowerbox/result/failure_message.rb @@ -34,6 +34,14 @@ module Flowerbox::Result @data['stack'] || [] end + def filtered_stack + stack.collect do |line| + line.gsub(%r{\.coffee:(\d+)}) do |_| + ".coffee:~#{($1.to_i * 0.67 + 1).to_i}" + end + end + end + def first_local_stack @first_local_stack ||= stack[1..-1].find do |line| !system_files.any? { |file| line[%r{\(#{file}}] } diff --git a/lib/flowerbox/runner/base.rb b/lib/flowerbox/runner/base.rb index 4ccedfc..e63ee9d 100644 --- a/lib/flowerbox/runner/base.rb +++ b/lib/flowerbox/runner/base.rb @@ -57,7 +57,20 @@ module Flowerbox puts "Flowerbox running your #{Flowerbox.test_environment.name} tests on #{console_name}..." - server.start + attempts = 3 + + while true + begin + server.start + + break + rescue Flowerbox::Server::ServerDiedError + attempts -= 1 + raise RunnerDiedError.new if attempts == 0 + + Flowerbox.server = nil + end + end yield diff --git a/lib/flowerbox/server.rb b/lib/flowerbox/server.rb index 2e64e27..7ed22af 100644 --- a/lib/flowerbox/server.rb +++ b/lib/flowerbox/server.rb @@ -8,6 +8,8 @@ module Flowerbox class Server attr_reader :options + class ServerDiedError < StandardError ; end + def initialize(options = {}) @options = { :logging => false }.merge(options || {}) end @@ -39,7 +41,7 @@ module Flowerbox sleep 0.1 end - raise StandardError.new("Server died") if !@server_thread[:server].running? + raise ServerDiedError.new if !@server_thread[:server].running? end def stop diff --git a/lib/flowerbox/sprockets_handler.rb b/lib/flowerbox/sprockets_handler.rb index a0bb219..a716f10 100644 --- a/lib/flowerbox/sprockets_handler.rb +++ b/lib/flowerbox/sprockets_handler.rb @@ -39,7 +39,7 @@ module Flowerbox return @environment if @environment @environment = Sprockets::Environment.new - @environment.cache = Sprockets::Cache::FileStore.new(Flowerbox::CACHE_DIR) + @environment.cache = Sprockets::Cache::FileStore.new(Flowerbox.cache_dir) self.class.gem_asset_paths.each { |path| append_path(path) } options[:asset_paths].each { |path| append_path(path) }