fix some multi-threaded and reporting issues

This commit is contained in:
John Bintz 2012-03-16 13:47:52 -04:00
parent 32eb3eb401
commit 6c685d740e
19 changed files with 89 additions and 78 deletions

View File

@ -38,6 +38,7 @@ class jasmine.FlowerboxReporter
for item in spec.results().items_
if !item.passed_
result.status = Flowerbox.Result.FAILURE
stack = item.trace.stack || []
if stack.constructor != Array
stack = stack.split("\n")

View File

@ -5,11 +5,13 @@ jasmine.Spec.beforeAddMatcherResult().push ->
lol.wut
catch e
if e.stack
file = switch Flowerbox.environment
file = switch Flowerbox.environment.toLowerCase()
when 'firefox'
e.stack.split("\n")[3]
when 'chrome'
e.stack.split("\n")[4]
else
'unknown:0'
@trace = { stack: [ file ] }
@trace = { stack: [ @message, file ] }

View File

@ -2,46 +2,20 @@ require "flowerbox/version"
require 'rainbow'
module Flowerbox
module CoreExt
autoload :Module, 'flowerbox/core_ext/module'
end
require 'flowerbox/core_ext/module'
autoload :Runner, 'flowerbox/runner'
autoload :Task, 'flowerbox/task'
require 'flowerbox/runner'
module Run
autoload :Base, 'flowerbox/run/base'
autoload :Test, 'flowerbox/run/test'
autoload :Debug, 'flowerbox/run/debug'
end
require 'flowerbox/run/base'
require 'flowerbox/run/test'
require 'flowerbox/run/debug'
module Runner
autoload :Node, 'flowerbox/runner/node'
autoload :Selenium, 'flowerbox/runner/selenium'
autoload :Firefox, 'flowerbox/runner/firefox'
autoload :Chrome, 'flowerbox/runner/chrome'
autoload :Base, 'flowerbox/runner/base'
end
require 'flowerbox/test_environment'
require 'flowerbox/result'
require 'flowerbox/result_set'
require 'flowerbox/gathered_result'
autoload :TestEnvironment, 'flowerbox/test_environment'
module TestEnvironment
autoload :Base, 'flowerbox/test_environment/base'
autoload :Jasmine, 'flowerbox/test_environment/jasmine'
autoload :Cucumber, 'flowerbox/test_environment/cucumber'
end
autoload :Rack, 'flowerbox/rack'
autoload :ResultSet, 'flowerbox/result_set'
autoload :GatheredResult, 'flowerbox/gathered_result'
autoload :Result, 'flowerbox/result'
autoload :Reporter, 'flowerbox/reporter'
autoload :Server, 'flowerbox/server'
autoload :UniqueAssetList, 'flowerbox/unique_asset_list'
autoload :SprocketsHandler, 'flowerbox/sprockets_handler'
require 'flowerbox/reporter'
class << self
attr_writer :reporters
@ -87,7 +61,7 @@ module Flowerbox
Pathname(File.expand_path('../..', __FILE__))
end
attr_accessor :test_environment, :runner_environment, :bare_coffeescript
attr_accessor :test_environment, :runner_environment, :bare_coffeescript, :server
def configure
yield self

View File

@ -2,11 +2,12 @@ module Flowerbox
module Reporter
extend Flowerbox::CoreExt::Module
autoload :Base, 'flowerbox/reporter/base'
autoload :ConsoleBase, 'flowerbox/reporter/console_base'
autoload :Verbose, 'flowerbox/reporter/verbose'
autoload :Progress, 'flowerbox/reporter/progress'
autoload :FileDisplay, 'flowerbox/reporter/file_display'
require 'flowerbox/reporter/file_display'
require 'flowerbox/reporter/base'
require 'flowerbox/reporter/console_base'
require 'flowerbox/reporter/verbose'
require 'flowerbox/reporter/progress'
end
end

View File

@ -10,12 +10,12 @@ module Flowerbox
extend Flowerbox::CoreExt::Module
end
autoload :Base, 'flowerbox/result/base'
autoload :Exception, 'flowerbox/result/exception'
autoload :Failure, 'flowerbox/result/failure'
autoload :Pending, 'flowerbox/result/pending'
autoload :FailureMessage, 'flowerbox/result/failure_message'
autoload :FileInfo, 'flowerbox/result/file_info'
require 'flowerbox/result/base'
require 'flowerbox/result/exception'
require 'flowerbox/result/failure'
require 'flowerbox/result/pending'
require 'flowerbox/result/failure_message'
require 'flowerbox/result/file_info'
class << self
def for(test_env, type)

View File

@ -3,6 +3,7 @@ require 'forwardable'
module Flowerbox
module Result
class Base
require 'flowerbox/result/file_info'
include Flowerbox::Result::FileInfo
extend Forwardable

View File

@ -33,6 +33,8 @@ module Flowerbox::Run
end
def sprockets
require 'flowerbox/sprockets_handler'
Flowerbox::SprocketsHandler.new(
:asset_paths => [
Flowerbox.path.join("lib/assets/javascripts"),

View File

@ -1,5 +1,7 @@
module Flowerbox::Run
class Test < Base
require 'flowerbox/runner/base'
def execute
prep!

View File

@ -1,6 +1,12 @@
module Flowerbox
module Runner
extend Flowerbox::CoreExt::Module
def self.find_constant(string)
require "flowerbox/runner/#{string}"
super
end
end
end

View File

@ -1,3 +1,5 @@
require 'thread'
module Flowerbox
module Runner
class Base
@ -9,6 +11,10 @@ module Flowerbox
class RunnerDiedError < StandardError ; end
def self.mutex
@mutex ||= Mutex.new
end
def initialize
@results = ResultSet.new
@started = false
@ -40,6 +46,7 @@ module Flowerbox
end
def run(*args)
self.class.mutex.synchronize do
setup(*args)
@count = 0
@ -52,6 +59,7 @@ module Flowerbox
yield
server.stop
end
@results
end
@ -100,17 +108,20 @@ module Flowerbox
end
def server
return @server if @server
require 'flowerbox/rack'
Flowerbox::Rack.runner = self
Flowerbox::Rack.sprockets = @sprockets
return Flowerbox.server if Flowerbox.server
require 'flowerbox/server'
server_options = { :app => Flowerbox::Rack }
server_options[:logging] = true if options[:verbose_server]
server_options[:port] = Flowerbox.port
@server = Flowerbox::Server.new(server_options)
Flowerbox::Rack.runner = self
Flowerbox::Rack.sprockets = @sprockets
@server
Flowerbox.server = Flowerbox::Server.new(server_options)
end
def log(message)

View File

@ -1,3 +1,5 @@
require 'flowerbox/runner/selenium'
class Flowerbox::Runner::Chrome < Flowerbox::Runner::Selenium
def name
"Chrome"

View File

@ -1,3 +1,5 @@
require 'flowerbox/runner/selenium'
class Flowerbox::Runner::Firefox < Flowerbox::Runner::Selenium
def name
"Firefox"

View File

@ -1,5 +1,6 @@
require 'tempfile'
require 'json'
require 'flowerbox/runner/base'
module Flowerbox
module Runner

View File

@ -1,4 +1,5 @@
require 'selenium-webdriver'
require 'flowerbox/runner/base'
module Flowerbox
module Runner

View File

@ -18,6 +18,8 @@ module Flowerbox
def initialize(options)
@options = options
require 'flowerbox/unique_asset_list'
@files = Flowerbox::UniqueAssetList.new
end

View File

@ -4,6 +4,8 @@ module Flowerbox
class << self
def for(env)
require "flowerbox/test_environment/#{env}"
find_constant(env).new
end
end

View File

@ -1,3 +1,5 @@
require 'flowerbox/test_environment/base'
module Flowerbox
module TestEnvironment
class Cucumber < Base
@ -12,6 +14,8 @@ module Flowerbox
def inject_into(sprockets)
super
require 'flowerbox/tilt/feature_template'
@sprockets.register_engine('.feature', Flowerbox::Tilt::FeatureTemplate)
end
@ -84,9 +88,3 @@ JS
end
end
module Flowerbox
module Tilt
autoload :FeatureTemplate, 'flowerbox/tilt/feature_template'
end
end

View File

@ -1,3 +1,4 @@
require 'flowerbox/test_environment/base'
require 'jasmine-core'
module Flowerbox

View File

@ -1,7 +1,8 @@
require 'tilt'
module Flowerbox::Tilt
class FeatureTemplate < Tilt::Template
module Flowerbox
module Tilt
class FeatureTemplate < ::Tilt::Template
self.default_mime_type = 'application/javascript'
def prepare; end
@ -19,4 +20,5 @@ JS
end
end
end
end