fix some multi-threaded and reporting issues
This commit is contained in:
parent
32eb3eb401
commit
6c685d740e
@ -38,6 +38,7 @@ class jasmine.FlowerboxReporter
|
|||||||
for item in spec.results().items_
|
for item in spec.results().items_
|
||||||
if !item.passed_
|
if !item.passed_
|
||||||
result.status = Flowerbox.Result.FAILURE
|
result.status = Flowerbox.Result.FAILURE
|
||||||
|
|
||||||
stack = item.trace.stack || []
|
stack = item.trace.stack || []
|
||||||
if stack.constructor != Array
|
if stack.constructor != Array
|
||||||
stack = stack.split("\n")
|
stack = stack.split("\n")
|
||||||
|
@ -5,11 +5,13 @@ jasmine.Spec.beforeAddMatcherResult().push ->
|
|||||||
lol.wut
|
lol.wut
|
||||||
catch e
|
catch e
|
||||||
if e.stack
|
if e.stack
|
||||||
file = switch Flowerbox.environment
|
file = switch Flowerbox.environment.toLowerCase()
|
||||||
when 'firefox'
|
when 'firefox'
|
||||||
e.stack.split("\n")[3]
|
e.stack.split("\n")[3]
|
||||||
when 'chrome'
|
when 'chrome'
|
||||||
e.stack.split("\n")[4]
|
e.stack.split("\n")[4]
|
||||||
|
else
|
||||||
|
'unknown:0'
|
||||||
|
|
||||||
@trace = { stack: [ file ] }
|
@trace = { stack: [ @message, file ] }
|
||||||
|
|
||||||
|
@ -2,46 +2,20 @@ require "flowerbox/version"
|
|||||||
require 'rainbow'
|
require 'rainbow'
|
||||||
|
|
||||||
module Flowerbox
|
module Flowerbox
|
||||||
module CoreExt
|
require 'flowerbox/core_ext/module'
|
||||||
autoload :Module, 'flowerbox/core_ext/module'
|
|
||||||
end
|
|
||||||
|
|
||||||
autoload :Runner, 'flowerbox/runner'
|
require 'flowerbox/runner'
|
||||||
autoload :Task, 'flowerbox/task'
|
|
||||||
|
|
||||||
module Run
|
require 'flowerbox/run/base'
|
||||||
autoload :Base, 'flowerbox/run/base'
|
require 'flowerbox/run/test'
|
||||||
autoload :Test, 'flowerbox/run/test'
|
require 'flowerbox/run/debug'
|
||||||
autoload :Debug, 'flowerbox/run/debug'
|
|
||||||
end
|
|
||||||
|
|
||||||
module Runner
|
require 'flowerbox/test_environment'
|
||||||
autoload :Node, 'flowerbox/runner/node'
|
require 'flowerbox/result'
|
||||||
autoload :Selenium, 'flowerbox/runner/selenium'
|
require 'flowerbox/result_set'
|
||||||
autoload :Firefox, 'flowerbox/runner/firefox'
|
require 'flowerbox/gathered_result'
|
||||||
autoload :Chrome, 'flowerbox/runner/chrome'
|
|
||||||
autoload :Base, 'flowerbox/runner/base'
|
|
||||||
end
|
|
||||||
|
|
||||||
autoload :TestEnvironment, 'flowerbox/test_environment'
|
require 'flowerbox/reporter'
|
||||||
|
|
||||||
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'
|
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
attr_writer :reporters
|
attr_writer :reporters
|
||||||
@ -87,7 +61,7 @@ module Flowerbox
|
|||||||
Pathname(File.expand_path('../..', __FILE__))
|
Pathname(File.expand_path('../..', __FILE__))
|
||||||
end
|
end
|
||||||
|
|
||||||
attr_accessor :test_environment, :runner_environment, :bare_coffeescript
|
attr_accessor :test_environment, :runner_environment, :bare_coffeescript, :server
|
||||||
|
|
||||||
def configure
|
def configure
|
||||||
yield self
|
yield self
|
||||||
|
@ -2,11 +2,12 @@ module Flowerbox
|
|||||||
module Reporter
|
module Reporter
|
||||||
extend Flowerbox::CoreExt::Module
|
extend Flowerbox::CoreExt::Module
|
||||||
|
|
||||||
autoload :Base, 'flowerbox/reporter/base'
|
require 'flowerbox/reporter/file_display'
|
||||||
autoload :ConsoleBase, 'flowerbox/reporter/console_base'
|
|
||||||
autoload :Verbose, 'flowerbox/reporter/verbose'
|
require 'flowerbox/reporter/base'
|
||||||
autoload :Progress, 'flowerbox/reporter/progress'
|
require 'flowerbox/reporter/console_base'
|
||||||
autoload :FileDisplay, 'flowerbox/reporter/file_display'
|
require 'flowerbox/reporter/verbose'
|
||||||
|
require 'flowerbox/reporter/progress'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -10,12 +10,12 @@ module Flowerbox
|
|||||||
extend Flowerbox::CoreExt::Module
|
extend Flowerbox::CoreExt::Module
|
||||||
end
|
end
|
||||||
|
|
||||||
autoload :Base, 'flowerbox/result/base'
|
require 'flowerbox/result/base'
|
||||||
autoload :Exception, 'flowerbox/result/exception'
|
require 'flowerbox/result/exception'
|
||||||
autoload :Failure, 'flowerbox/result/failure'
|
require 'flowerbox/result/failure'
|
||||||
autoload :Pending, 'flowerbox/result/pending'
|
require 'flowerbox/result/pending'
|
||||||
autoload :FailureMessage, 'flowerbox/result/failure_message'
|
require 'flowerbox/result/failure_message'
|
||||||
autoload :FileInfo, 'flowerbox/result/file_info'
|
require 'flowerbox/result/file_info'
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
def for(test_env, type)
|
def for(test_env, type)
|
||||||
|
@ -3,6 +3,7 @@ require 'forwardable'
|
|||||||
module Flowerbox
|
module Flowerbox
|
||||||
module Result
|
module Result
|
||||||
class Base
|
class Base
|
||||||
|
require 'flowerbox/result/file_info'
|
||||||
include Flowerbox::Result::FileInfo
|
include Flowerbox::Result::FileInfo
|
||||||
|
|
||||||
extend Forwardable
|
extend Forwardable
|
||||||
|
@ -33,6 +33,8 @@ module Flowerbox::Run
|
|||||||
end
|
end
|
||||||
|
|
||||||
def sprockets
|
def sprockets
|
||||||
|
require 'flowerbox/sprockets_handler'
|
||||||
|
|
||||||
Flowerbox::SprocketsHandler.new(
|
Flowerbox::SprocketsHandler.new(
|
||||||
:asset_paths => [
|
:asset_paths => [
|
||||||
Flowerbox.path.join("lib/assets/javascripts"),
|
Flowerbox.path.join("lib/assets/javascripts"),
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
module Flowerbox::Run
|
module Flowerbox::Run
|
||||||
class Test < Base
|
class Test < Base
|
||||||
|
require 'flowerbox/runner/base'
|
||||||
|
|
||||||
def execute
|
def execute
|
||||||
prep!
|
prep!
|
||||||
|
|
||||||
|
@ -1,6 +1,12 @@
|
|||||||
module Flowerbox
|
module Flowerbox
|
||||||
module Runner
|
module Runner
|
||||||
extend Flowerbox::CoreExt::Module
|
extend Flowerbox::CoreExt::Module
|
||||||
|
|
||||||
|
def self.find_constant(string)
|
||||||
|
require "flowerbox/runner/#{string}"
|
||||||
|
|
||||||
|
super
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
require 'thread'
|
||||||
|
|
||||||
module Flowerbox
|
module Flowerbox
|
||||||
module Runner
|
module Runner
|
||||||
class Base
|
class Base
|
||||||
@ -9,6 +11,10 @@ module Flowerbox
|
|||||||
|
|
||||||
class RunnerDiedError < StandardError ; end
|
class RunnerDiedError < StandardError ; end
|
||||||
|
|
||||||
|
def self.mutex
|
||||||
|
@mutex ||= Mutex.new
|
||||||
|
end
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@results = ResultSet.new
|
@results = ResultSet.new
|
||||||
@started = false
|
@started = false
|
||||||
@ -40,18 +46,20 @@ module Flowerbox
|
|||||||
end
|
end
|
||||||
|
|
||||||
def run(*args)
|
def run(*args)
|
||||||
setup(*args)
|
self.class.mutex.synchronize do
|
||||||
|
setup(*args)
|
||||||
|
|
||||||
@count = 0
|
@count = 0
|
||||||
@timer_running = true
|
@timer_running = true
|
||||||
|
|
||||||
puts "Flowerbox running your #{Flowerbox.test_environment.name} tests on #{console_name}..."
|
puts "Flowerbox running your #{Flowerbox.test_environment.name} tests on #{console_name}..."
|
||||||
|
|
||||||
server.start
|
server.start
|
||||||
|
|
||||||
yield
|
yield
|
||||||
|
|
||||||
server.stop
|
server.stop
|
||||||
|
end
|
||||||
|
|
||||||
@results
|
@results
|
||||||
end
|
end
|
||||||
@ -100,17 +108,20 @@ module Flowerbox
|
|||||||
end
|
end
|
||||||
|
|
||||||
def server
|
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 = { :app => Flowerbox::Rack }
|
||||||
server_options[:logging] = true if options[:verbose_server]
|
server_options[:logging] = true if options[:verbose_server]
|
||||||
server_options[:port] = Flowerbox.port
|
server_options[:port] = Flowerbox.port
|
||||||
|
|
||||||
@server = Flowerbox::Server.new(server_options)
|
Flowerbox.server = Flowerbox::Server.new(server_options)
|
||||||
Flowerbox::Rack.runner = self
|
|
||||||
Flowerbox::Rack.sprockets = @sprockets
|
|
||||||
|
|
||||||
@server
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def log(message)
|
def log(message)
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
require 'flowerbox/runner/selenium'
|
||||||
|
|
||||||
class Flowerbox::Runner::Chrome < Flowerbox::Runner::Selenium
|
class Flowerbox::Runner::Chrome < Flowerbox::Runner::Selenium
|
||||||
def name
|
def name
|
||||||
"Chrome"
|
"Chrome"
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
require 'flowerbox/runner/selenium'
|
||||||
|
|
||||||
class Flowerbox::Runner::Firefox < Flowerbox::Runner::Selenium
|
class Flowerbox::Runner::Firefox < Flowerbox::Runner::Selenium
|
||||||
def name
|
def name
|
||||||
"Firefox"
|
"Firefox"
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
require 'tempfile'
|
require 'tempfile'
|
||||||
require 'json'
|
require 'json'
|
||||||
|
require 'flowerbox/runner/base'
|
||||||
|
|
||||||
module Flowerbox
|
module Flowerbox
|
||||||
module Runner
|
module Runner
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
require 'selenium-webdriver'
|
require 'selenium-webdriver'
|
||||||
|
require 'flowerbox/runner/base'
|
||||||
|
|
||||||
module Flowerbox
|
module Flowerbox
|
||||||
module Runner
|
module Runner
|
||||||
|
@ -18,6 +18,8 @@ module Flowerbox
|
|||||||
def initialize(options)
|
def initialize(options)
|
||||||
@options = options
|
@options = options
|
||||||
|
|
||||||
|
require 'flowerbox/unique_asset_list'
|
||||||
|
|
||||||
@files = Flowerbox::UniqueAssetList.new
|
@files = Flowerbox::UniqueAssetList.new
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@ module Flowerbox
|
|||||||
|
|
||||||
class << self
|
class << self
|
||||||
def for(env)
|
def for(env)
|
||||||
|
require "flowerbox/test_environment/#{env}"
|
||||||
|
|
||||||
find_constant(env).new
|
find_constant(env).new
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
require 'flowerbox/test_environment/base'
|
||||||
|
|
||||||
module Flowerbox
|
module Flowerbox
|
||||||
module TestEnvironment
|
module TestEnvironment
|
||||||
class Cucumber < Base
|
class Cucumber < Base
|
||||||
@ -12,6 +14,8 @@ module Flowerbox
|
|||||||
def inject_into(sprockets)
|
def inject_into(sprockets)
|
||||||
super
|
super
|
||||||
|
|
||||||
|
require 'flowerbox/tilt/feature_template'
|
||||||
|
|
||||||
@sprockets.register_engine('.feature', Flowerbox::Tilt::FeatureTemplate)
|
@sprockets.register_engine('.feature', Flowerbox::Tilt::FeatureTemplate)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -84,9 +88,3 @@ JS
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
module Flowerbox
|
|
||||||
module Tilt
|
|
||||||
autoload :FeatureTemplate, 'flowerbox/tilt/feature_template'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
require 'flowerbox/test_environment/base'
|
||||||
require 'jasmine-core'
|
require 'jasmine-core'
|
||||||
|
|
||||||
module Flowerbox
|
module Flowerbox
|
||||||
|
@ -1,21 +1,23 @@
|
|||||||
require 'tilt'
|
require 'tilt'
|
||||||
|
|
||||||
module Flowerbox::Tilt
|
module Flowerbox
|
||||||
class FeatureTemplate < Tilt::Template
|
module Tilt
|
||||||
self.default_mime_type = 'application/javascript'
|
class FeatureTemplate < ::Tilt::Template
|
||||||
|
self.default_mime_type = 'application/javascript'
|
||||||
|
|
||||||
def prepare; end
|
def prepare; end
|
||||||
|
|
||||||
def evaluate(scope, locals, &block)
|
def evaluate(scope, locals, &block)
|
||||||
<<-JS
|
<<-JS
|
||||||
Flowerbox.Cucumber.Features = Flowerbox.Cucumber.Features || [];
|
Flowerbox.Cucumber.Features = Flowerbox.Cucumber.Features || [];
|
||||||
|
|
||||||
Flowerbox.Cucumber.Features.push("#{escaped_data}");
|
Flowerbox.Cucumber.Features.push("#{escaped_data}");
|
||||||
JS
|
JS
|
||||||
end
|
end
|
||||||
|
|
||||||
def escaped_data
|
def escaped_data
|
||||||
data.gsub("\n", "\\n").gsub('"', '\\"')
|
data.gsub("\n", "\\n").gsub('"', '\\"')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user