still fllailing away
This commit is contained in:
parent
7a7c5debc4
commit
fe51eda8a3
@ -7,6 +7,7 @@ class Flowerbox::CLI < Thor
|
|||||||
desc "test DIR", "Run the specs found in spec dir, loading spec_helper.rb for configuration details"
|
desc "test DIR", "Run the specs found in spec dir, loading spec_helper.rb for configuration details"
|
||||||
method_options :pwd => :string
|
method_options :pwd => :string
|
||||||
method_options :runners => :string
|
method_options :runners => :string
|
||||||
|
method_options :verbose => false
|
||||||
def test(dir)
|
def test(dir)
|
||||||
Dir.chdir(pwd) do
|
Dir.chdir(pwd) do
|
||||||
exit Flowerbox.run(dir, options)
|
exit Flowerbox.run(dir, options)
|
||||||
|
@ -23,4 +23,5 @@ Gem::Specification.new do |gem|
|
|||||||
gem.add_dependency 'thor'
|
gem.add_dependency 'thor'
|
||||||
gem.add_dependency 'selenium-webdriver'
|
gem.add_dependency 'selenium-webdriver'
|
||||||
gem.add_dependency 'sinatra'
|
gem.add_dependency 'sinatra'
|
||||||
|
gem.add_dependency 'rainbow'
|
||||||
end
|
end
|
||||||
|
@ -12,13 +12,7 @@ class jasmine.FlowerboxReporter
|
|||||||
Flowerbox.fail() if Flowerbox.fail?
|
Flowerbox.fail() if Flowerbox.fail?
|
||||||
|
|
||||||
reportSpecResults: (spec) ->
|
reportSpecResults: (spec) ->
|
||||||
failures = []
|
Flowerbox.contact("finish_test", spec.description, spec.results())
|
||||||
|
|
||||||
for result in spec.results().getItems()
|
|
||||||
if result.type == 'expect' && !result.passed_
|
|
||||||
failures.push(result)
|
|
||||||
|
|
||||||
Flowerbox.contact("finish_test", spec.description, failures)
|
|
||||||
reportRunnerResults: (runner) ->
|
reportRunnerResults: (runner) ->
|
||||||
Flowerbox.contact("results", (new Date().getTime()) - @time)
|
Flowerbox.contact("results", (new Date().getTime()) - @time)
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
require "flowerbox/version"
|
require "flowerbox/version"
|
||||||
require 'flowerbox-delivery'
|
require 'flowerbox-delivery'
|
||||||
|
require 'rainbow'
|
||||||
|
|
||||||
module Flowerbox
|
module Flowerbox
|
||||||
autoload :Runner, 'flowerbox/runner'
|
autoload :Runner, 'flowerbox/runner'
|
||||||
@ -15,7 +16,9 @@ module Flowerbox
|
|||||||
autoload :TestEnvironment, 'flowerbox/test_environment'
|
autoload :TestEnvironment, 'flowerbox/test_environment'
|
||||||
|
|
||||||
module TestEnvironment
|
module TestEnvironment
|
||||||
|
autoload :Base, 'flowerbox/test_environment/base'
|
||||||
autoload :Jasmine, 'flowerbox/test_environment/jasmine'
|
autoload :Jasmine, 'flowerbox/test_environment/jasmine'
|
||||||
|
autoload :Cucumber, 'flowerbox/test_environment/cucumber'
|
||||||
end
|
end
|
||||||
|
|
||||||
autoload :Rack, 'flowerbox/rack'
|
autoload :Rack, 'flowerbox/rack'
|
||||||
@ -23,6 +26,8 @@ module Flowerbox
|
|||||||
autoload :ResultSet, 'flowerbox/result_set'
|
autoload :ResultSet, 'flowerbox/result_set'
|
||||||
autoload :GatheredResult, 'flowerbox/gathered_result'
|
autoload :GatheredResult, 'flowerbox/gathered_result'
|
||||||
autoload :Result, 'flowerbox/result'
|
autoload :Result, 'flowerbox/result'
|
||||||
|
autoload :BaseResult, 'flowerbox/base_result'
|
||||||
|
autoload :Success, 'flowerbox/success'
|
||||||
autoload :Failure, 'flowerbox/failure'
|
autoload :Failure, 'flowerbox/failure'
|
||||||
autoload :Exception, 'flowerbox/exception'
|
autoload :Exception, 'flowerbox/exception'
|
||||||
|
|
||||||
@ -77,7 +82,7 @@ module Flowerbox
|
|||||||
result_set = ResultSet.new
|
result_set = ResultSet.new
|
||||||
|
|
||||||
Flowerbox.runner_environment.each do |env|
|
Flowerbox.runner_environment.each do |env|
|
||||||
result_set << env.run(build_sprockets_for(dir), spec_files_for(dir))
|
result_set << env.run(build_sprockets_for(dir), spec_files_for(dir), options)
|
||||||
end
|
end
|
||||||
|
|
||||||
result_set.print
|
result_set.print
|
||||||
|
18
lib/flowerbox/base_result.rb
Normal file
18
lib/flowerbox/base_result.rb
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
module Flowerbox
|
||||||
|
class BaseResult < Result
|
||||||
|
attr_reader :name, :message, :file
|
||||||
|
|
||||||
|
def initialize(name, message, file = nil)
|
||||||
|
@name, @message, @file = name, message, file
|
||||||
|
end
|
||||||
|
|
||||||
|
def ==(other)
|
||||||
|
@name == other.name && @message == other.message
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_s
|
||||||
|
"#{message} [#{runners.join(',')}] (#{translated_file}:#{line_number})"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -1,17 +1,7 @@
|
|||||||
module Flowerbox
|
module Flowerbox
|
||||||
class Failure < Result
|
class Failure < BaseResult
|
||||||
attr_reader :name, :message, :file
|
def print_progress
|
||||||
|
print "F".foreground(:red)
|
||||||
def initialize(name, message, file)
|
|
||||||
@name, @message, @file = name, message, file
|
|
||||||
end
|
|
||||||
|
|
||||||
def ==(other)
|
|
||||||
@name == other.name && @message == other.message
|
|
||||||
end
|
|
||||||
|
|
||||||
def to_s
|
|
||||||
"#{message} [#{runners.join(',')}] (#{file})"
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -14,6 +14,18 @@ module Flowerbox
|
|||||||
@results ||= []
|
@results ||= []
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def successes
|
||||||
|
results.find_all(&:success?)
|
||||||
|
end
|
||||||
|
|
||||||
|
def failures
|
||||||
|
results.reject(&:success?)
|
||||||
|
end
|
||||||
|
|
||||||
|
def success?
|
||||||
|
@results.all?(&:success?)
|
||||||
|
end
|
||||||
|
|
||||||
def print
|
def print
|
||||||
puts name.join(' ')
|
puts name.join(' ')
|
||||||
|
|
||||||
|
@ -24,6 +24,10 @@ module Flowerbox
|
|||||||
end
|
end
|
||||||
|
|
||||||
empty_post '/results' do
|
empty_post '/results' do
|
||||||
|
p "made it"
|
||||||
|
|
||||||
|
p data
|
||||||
|
|
||||||
runner.finish!(data.flatten.first)
|
runner.finish!(data.flatten.first)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -32,7 +36,7 @@ module Flowerbox
|
|||||||
end
|
end
|
||||||
|
|
||||||
empty_post '/finish_test' do
|
empty_post '/finish_test' do
|
||||||
runner.add_failures(data.flatten[1..-1])
|
runner.add_results(data.flatten[1..-1])
|
||||||
end
|
end
|
||||||
|
|
||||||
empty_post '/log' do
|
empty_post '/log' do
|
||||||
|
@ -1,8 +1,46 @@
|
|||||||
module Flowerbox
|
module Flowerbox
|
||||||
class Result
|
class Result
|
||||||
|
def <=>(other)
|
||||||
|
result = self.name.length <=> other.name.length
|
||||||
|
|
||||||
|
if result == 0
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
result
|
||||||
|
end
|
||||||
|
|
||||||
def runners
|
def runners
|
||||||
@runners ||= []
|
@runners ||= []
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def translated_file
|
||||||
|
@translated_file ||= if actual_file_base = filename[%r{\.tmp/sprockets(.*)}, 1]
|
||||||
|
Dir[actual_file_base + "*"].first
|
||||||
|
else
|
||||||
|
filename
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def file_translated?
|
||||||
|
translated_file != filename
|
||||||
|
end
|
||||||
|
|
||||||
|
def filename
|
||||||
|
file.split(":").first
|
||||||
|
end
|
||||||
|
|
||||||
|
def line_number
|
||||||
|
return @line_number if @line_number
|
||||||
|
|
||||||
|
@line_number = file.split(":").last
|
||||||
|
@line_number = "~#{@line_number}" if file_translated?
|
||||||
|
@line_number
|
||||||
|
end
|
||||||
|
|
||||||
|
def success?
|
||||||
|
false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -2,14 +2,19 @@ module Flowerbox
|
|||||||
class ResultSet
|
class ResultSet
|
||||||
attr_reader :results, :options
|
attr_reader :results, :options
|
||||||
|
|
||||||
def self.from_failures(failures, options)
|
attr_accessor :time
|
||||||
results = failures.collect do |result_data|
|
|
||||||
if name = result_data.first['splitName']
|
def self.from_results(results, options)
|
||||||
result_data.collect do |failure|
|
results = results['items_'].collect do |result|
|
||||||
Failure.new(name, failure['message'], failure['trace']['stack'].first)
|
if name = result['splitName']
|
||||||
|
case result['passed_']
|
||||||
|
when true
|
||||||
|
Success.new(name, result['message'])
|
||||||
|
else
|
||||||
|
Failure.new(name, result['message'], result['trace']['stack'].first)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
Exception.new(result_data.first['trace']['stack'])
|
Exception.new(result.first['trace']['stack'])
|
||||||
end
|
end
|
||||||
end.flatten
|
end.flatten
|
||||||
|
|
||||||
@ -18,6 +23,10 @@ module Flowerbox
|
|||||||
new(results, options)
|
new(results, options)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.for(runner)
|
||||||
|
new(results, :runner => runner)
|
||||||
|
end
|
||||||
|
|
||||||
def initialize(results = [], options = {})
|
def initialize(results = [], options = {})
|
||||||
@results, @options = results, options
|
@results, @options = results, options
|
||||||
end
|
end
|
||||||
@ -38,6 +47,20 @@ module Flowerbox
|
|||||||
|
|
||||||
def print
|
def print
|
||||||
gathered_results.each(&:print)
|
gathered_results.each(&:print)
|
||||||
|
|
||||||
|
puts "#{total_tests} total, #{total_failures} failures, #{time} secs."
|
||||||
|
end
|
||||||
|
|
||||||
|
def total_tests
|
||||||
|
results.length
|
||||||
|
end
|
||||||
|
|
||||||
|
def total_failures
|
||||||
|
results.reject(&:success?).length
|
||||||
|
end
|
||||||
|
|
||||||
|
def print_progress
|
||||||
|
@results.each { |result| result.print_progress ; $stdout.flush }
|
||||||
end
|
end
|
||||||
|
|
||||||
def gathered_results
|
def gathered_results
|
||||||
|
@ -1,15 +1,18 @@
|
|||||||
module Flowerbox
|
module Flowerbox
|
||||||
module Runner
|
module Runner
|
||||||
class Base
|
class Base
|
||||||
attr_reader :sprockets, :spec_files
|
attr_reader :sprockets, :spec_files, :options
|
||||||
|
|
||||||
attr_accessor :time, :results
|
attr_accessor :results
|
||||||
|
|
||||||
def run(sprockets, spec_files)
|
def initialize
|
||||||
@sprockets = sprockets
|
@results = ResultSet.new
|
||||||
@spec_files = spec_files
|
end
|
||||||
|
|
||||||
puts "Flowerbox running your #{Flowerbox.test_environment.name} tests on #{name}..."
|
def run(sprockets, spec_files, options)
|
||||||
|
@sprockets, @spec_files, @options = sprockets, spec_files, options
|
||||||
|
|
||||||
|
puts "Flowerbox running your #{Flowerbox.test_environment.name} tests on #{console_name}..."
|
||||||
|
|
||||||
server.start
|
server.start
|
||||||
|
|
||||||
@ -17,9 +20,10 @@ module Flowerbox
|
|||||||
|
|
||||||
server.stop
|
server.stop
|
||||||
|
|
||||||
|
puts
|
||||||
puts
|
puts
|
||||||
|
|
||||||
ResultSet.from_failures(failures, :runner => name, :time => time)
|
@results
|
||||||
end
|
end
|
||||||
|
|
||||||
def type
|
def type
|
||||||
@ -30,6 +34,11 @@ module Flowerbox
|
|||||||
Flowerbox.test_environment.start_for(self)
|
Flowerbox.test_environment.start_for(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def time=(time)
|
||||||
|
p time
|
||||||
|
@results.time = time
|
||||||
|
end
|
||||||
|
|
||||||
def server
|
def server
|
||||||
return @server if @server
|
return @server if @server
|
||||||
|
|
||||||
@ -55,16 +64,12 @@ module Flowerbox
|
|||||||
@failures ||= []
|
@failures ||= []
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_failures(test_failures)
|
def add_results(test_results)
|
||||||
if test_failures.length == 0
|
results = result_set_from_test_results(test_results)
|
||||||
print '.'
|
|
||||||
else
|
|
||||||
print 'F'
|
|
||||||
end
|
|
||||||
|
|
||||||
$stdout.flush
|
results.print_progress
|
||||||
|
|
||||||
failures << test_failures
|
@results << results
|
||||||
end
|
end
|
||||||
|
|
||||||
def total_count
|
def total_count
|
||||||
@ -84,6 +89,11 @@ module Flowerbox
|
|||||||
def finished?
|
def finished?
|
||||||
@finished
|
@finished
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def result_set_from_test_results(test_results)
|
||||||
|
ResultSet.from_results(test_results.first, options.merge(:runner => name))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -3,6 +3,15 @@ class Flowerbox::Runner::Chrome < Flowerbox::Runner::Selenium
|
|||||||
"Chrome"
|
"Chrome"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def console_name
|
||||||
|
"C".foreground('#4f97d1') +
|
||||||
|
"h".foreground('#ec5244') +
|
||||||
|
"r".foreground('#fdd901') +
|
||||||
|
"o".foreground('#4f97d1') +
|
||||||
|
"m".foreground('#5cb15b') +
|
||||||
|
"e".foreground('#ec5244')
|
||||||
|
end
|
||||||
|
|
||||||
def browser
|
def browser
|
||||||
:chrome
|
:chrome
|
||||||
end
|
end
|
||||||
|
@ -3,6 +3,10 @@ class Flowerbox::Runner::Firefox < Flowerbox::Runner::Selenium
|
|||||||
"Firefox"
|
"Firefox"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def console_name
|
||||||
|
"Firefox".foreground('#d0450b')
|
||||||
|
end
|
||||||
|
|
||||||
def browser
|
def browser
|
||||||
:firefox
|
:firefox
|
||||||
end
|
end
|
||||||
|
@ -6,14 +6,21 @@ module Flowerbox
|
|||||||
module Runner
|
module Runner
|
||||||
class Node < Base
|
class Node < Base
|
||||||
def name
|
def name
|
||||||
"Node.js"
|
"node.js"
|
||||||
|
end
|
||||||
|
|
||||||
|
def console_name
|
||||||
|
"n".foreground(:white) +
|
||||||
|
"o".foreground('#8cc84b') +
|
||||||
|
"de".foreground(:white) +
|
||||||
|
".js".foreground('#8cc84b')
|
||||||
end
|
end
|
||||||
|
|
||||||
def type
|
def type
|
||||||
:node
|
:node
|
||||||
end
|
end
|
||||||
|
|
||||||
def run(sprockets, spec_files)
|
def run(sprockets, spec_files, options)
|
||||||
super do
|
super do
|
||||||
begin
|
begin
|
||||||
file = File.join(Dir.pwd, ".node-tmp.#{Time.now.to_i}.js")
|
file = File.join(Dir.pwd, ".node-tmp.#{Time.now.to_i}.js")
|
||||||
|
@ -13,13 +13,15 @@ module Flowerbox
|
|||||||
:selenium
|
:selenium
|
||||||
end
|
end
|
||||||
|
|
||||||
def run(sprockets, spec_files)
|
def run(sprockets, spec_files, options)
|
||||||
super do
|
super do
|
||||||
begin
|
begin
|
||||||
selenium = ::Selenium::WebDriver.for(browser)
|
selenium = ::Selenium::WebDriver.for(browser)
|
||||||
|
|
||||||
selenium.navigate.to "http://localhost:#{server.port}/"
|
selenium.navigate.to "http://localhost:#{server.port}/"
|
||||||
|
|
||||||
|
sleep 10
|
||||||
|
|
||||||
@count = 0
|
@count = 0
|
||||||
|
|
||||||
while @count < MAX_COUNT && !finished?
|
while @count < MAX_COUNT && !finished?
|
||||||
|
12
lib/flowerbox/success.rb
Normal file
12
lib/flowerbox/success.rb
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
module Flowerbox
|
||||||
|
class Success < BaseResult
|
||||||
|
def print_progress
|
||||||
|
print ".".foreground(:green)
|
||||||
|
end
|
||||||
|
|
||||||
|
def success?
|
||||||
|
true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
14
lib/flowerbox/test_environment/base.rb
Normal file
14
lib/flowerbox/test_environment/base.rb
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
module Flowerbox
|
||||||
|
module TestEnvironment
|
||||||
|
class Base
|
||||||
|
def name
|
||||||
|
self.class.name.split("::").last
|
||||||
|
end
|
||||||
|
|
||||||
|
def reporters
|
||||||
|
@reporters ||= []
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
34
lib/flowerbox/test_environment/cucumber.rb
Normal file
34
lib/flowerbox/test_environment/cucumber.rb
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
module Flowerbox
|
||||||
|
module TestEnvironment
|
||||||
|
class Cucumber
|
||||||
|
def inject_into(sprockets)
|
||||||
|
@sprockets = sprockets
|
||||||
|
|
||||||
|
@sprockets.add('cucumber.js')
|
||||||
|
end
|
||||||
|
|
||||||
|
def start_for(runner)
|
||||||
|
@sprockets.add("flowerbox/cucumber")
|
||||||
|
@sprockets.add("flowerbox/cucumber/#{runner.type}")
|
||||||
|
|
||||||
|
runner.spec_files.each { |file| @sprockets.add(file) }
|
||||||
|
|
||||||
|
<<-JS
|
||||||
|
if (typeof context != 'undefined' && typeof jasmine == 'undefined') {
|
||||||
|
jasmine = context.jasmine;
|
||||||
|
}
|
||||||
|
|
||||||
|
jasmine.getEnv().addReporter(new jasmine.FlowerboxReporter());
|
||||||
|
#{jasmine_reporters.join("\n")}
|
||||||
|
jasmine.getEnv().execute();
|
||||||
|
JS
|
||||||
|
end
|
||||||
|
|
||||||
|
def jasmine_reporters
|
||||||
|
reporters.collect { |reporter| %{jasmine.getEnv().addReporter(new jasmine.#{reporter}());} }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
@ -2,10 +2,7 @@ require 'jasmine-core'
|
|||||||
|
|
||||||
module Flowerbox
|
module Flowerbox
|
||||||
module TestEnvironment
|
module TestEnvironment
|
||||||
class Jasmine
|
class Jasmine < Base
|
||||||
def name
|
|
||||||
self.class.name.split("::").last
|
|
||||||
end
|
|
||||||
|
|
||||||
def inject_into(sprockets)
|
def inject_into(sprockets)
|
||||||
@sprockets = sprockets
|
@sprockets = sprockets
|
||||||
@ -22,20 +19,15 @@ module Flowerbox
|
|||||||
|
|
||||||
runner.spec_files.each { |file| @sprockets.add(file) }
|
runner.spec_files.each { |file| @sprockets.add(file) }
|
||||||
|
|
||||||
case runner.type
|
|
||||||
when :node
|
|
||||||
<<-JS
|
<<-JS
|
||||||
var jasmine = context.jasmine;
|
if (typeof context != 'undefined' && typeof jasmine == 'undefined') {
|
||||||
|
jasmine = context.jasmine;
|
||||||
|
}
|
||||||
|
|
||||||
|
jasmine.getEnv().addReporter(new jasmine.FlowerboxReporter());
|
||||||
#{jasmine_reporters.join("\n")}
|
#{jasmine_reporters.join("\n")}
|
||||||
jasmine.getEnv().execute();
|
jasmine.getEnv().execute();
|
||||||
JS
|
JS
|
||||||
when :selenium
|
|
||||||
<<-JS
|
|
||||||
jasmine.getEnv().addReporter(new jasmine.FlowerboxReporter());
|
|
||||||
jasmine.getEnv().execute();
|
|
||||||
JS
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def jasmine_reporters
|
def jasmine_reporters
|
||||||
@ -43,7 +35,7 @@ JS
|
|||||||
end
|
end
|
||||||
|
|
||||||
def reporters
|
def reporters
|
||||||
@reporters ||= [ 'FlowerboxReporter' ]
|
@reporters ||= []
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
4818
vendor/assets/javascripts/cucumber.js
vendored
Normal file
4818
vendor/assets/javascripts/cucumber.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user