a bunch of other changes

This commit is contained in:
John Bintz 2012-03-17 11:08:33 -04:00
parent be7fb0237b
commit f6cef98b39
13 changed files with 54 additions and 25 deletions

View File

@ -21,7 +21,7 @@ Flowerbox =
onQueueStateChange: -> onQueueStateChange: ->
queueRunner: -> queueRunner: (failsafe = 5) ->
Flowerbox.onQueueStateChange("checking queue") Flowerbox.onQueueStateChange("checking queue")
if Flowerbox.contactQueue.length > 0 if Flowerbox.contactQueue.length > 0
Flowerbox.started = true Flowerbox.started = true
@ -55,7 +55,10 @@ Flowerbox =
xhr.abort() xhr.abort()
Flowerbox.onQueueStateChange("aborted #{url}, rerunning") Flowerbox.onQueueStateChange("aborted #{url}, rerunning")
Flowerbox.contactQueue.unshift(info) Flowerbox.contactQueue.unshift(info)
Flowerbox.queueRunner()
if failsafe > 0
failsafe -= 1
Flowerbox.queueRunner(failsafe)
, Flowerbox.delay * 5 , Flowerbox.delay * 5
) )

View File

@ -17,16 +17,22 @@ Flowerbox.World = (code = null) ->
Flowerbox.Matchers = Flowerbox.Matchers =
toEqual: (expected) -> toEqual: (expected) ->
@message = "Expected #{@actual} #{@notMessage} equal #{expected}" @message = "Expected #{@actual} #{@notMessage} equal #{expected}"
if typeof @actual == 'object' result = null
for key, value of @actual
return false if expected[key] != value
for key, value of expected if @actual? && expected?
return false if @actual[key] != value switch (typeof @actual)
when 'object'
result = true
for key, value of @actual
result = false if expected[key] != value
true for key, value of expected
else result = false if @actual[key] != value
@actual == expected
if result == null
result = (@actual == expected)
result
Flowerbox.World -> Flowerbox.World ->
@assert = (what, message = 'failed') -> @assert = (what, message = 'failed') ->

View File

@ -39,7 +39,7 @@ class Flowerbox.Cucumber.Reporter
when 'StepResult' when 'StepResult'
stepResult = event.getPayloadItem('stepResult') stepResult = event.getPayloadItem('stepResult')
file = Flowerbox.Step.matchFile(@step.getName()) || "unknown:0" file = Flowerbox.Step.matchFile(@step.getName()) || "#{Flowerbox.UNKNOWN}:0"
result = new Flowerbox.Result(step_type: this.type(), source: 'cucumber', original_name: @step.getName(), name: this.nameParts(), file: file) result = new Flowerbox.Result(step_type: this.type(), source: 'cucumber', original_name: @step.getName(), name: this.nameParts(), file: file)

View File

@ -4,7 +4,7 @@ class jasmine.FlowerboxReporter
status: Flowerbox.Result.SUCCESS status: Flowerbox.Result.SUCCESS
source: 'jasmine' source: 'jasmine'
name: spec.getSpecSplitName() name: spec.getSpecSplitName()
file: 'unknown:0' file: "#{Flowerbox.UNKNOWN}:0"
for key, value of overrides for key, value of overrides
data[key] = value data[key] = value

View File

@ -11,7 +11,7 @@ jasmine.Spec.beforeAddMatcherResult().push ->
when 'chrome' when 'chrome'
e.stack.split("\n")[4] e.stack.split("\n")[4]
else else
'unknown:0' "#{Flowerbox.UNKNOWN}:0"
@trace = { stack: [ @message, file ] } @trace = { stack: [ @message, file ] }

View File

@ -75,12 +75,6 @@ module Flowerbox
runner.template runner.template
end end
class << self
private
def setup_protetion(builder)
end
end
end end
end end

View File

@ -1,28 +1,38 @@
module Flowerbox::Result::FileInfo module Flowerbox::Result::FileInfo
UNKNOWN = '__unknown__'
def translated_file def translated_file
@translated_file ||= filename return @translated_file if @translated_file
if filename == UNKNOWN
@translated_file = UNKNOWN
else
@translated_file = Flowerbox.test_environment.actual_path_for(filename)
end
@translated_file
end end
def file_translated? def file_translated?
translated_file != filename translated_file[%r{\.coffee$}]
end end
def filename def filename
file.to_s.split(":").first || 'unknown' file.to_s.split(":").first || UNKNOWN
end end
def line_number def line_number
return @line_number if @line_number return @line_number if @line_number
@line_number = file.to_s.split(":")[1] @line_number = file.to_s.split(":")[1]
@line_number = "~#{@line_number}" if file_translated? @line_number = "~#{(@line_number.to_i * 0.67).to_i}" if file_translated?
@line_number ||= "0" @line_number ||= "0"
end end
alias :line :line_number alias :line :line_number
def translated_file_and_line def translated_file_and_line
"#{translated_file.gsub(%r{^/}, '')}:#{line_number}" "#{translated_file.gsub(%r{^#{Dir.pwd}/}, '')}:#{line_number}"
end end
def system_files def system_files

View File

@ -41,7 +41,13 @@ module Flowerbox
end end
def exitstatus def exitstatus
results.any?(&:failure?) ? 1 : 0 if results.any?(&:failure?)
1
elsif results.any?(&:pending?)
2
else
0
end
end end
def print(data = {}) def print(data = {})

View File

@ -33,6 +33,9 @@ module Flowerbox
if !finished? if !finished?
puts "Something died hard. Here are the tests that did get run before Flowerbox died.".foreground(:red) puts "Something died hard. Here are the tests that did get run before Flowerbox died.".foreground(:red)
puts tests.flatten.join("\n").foreground(:red) puts tests.flatten.join("\n").foreground(:red)
server.stop
Flowerbox.server = nil
raise RunnerDiedError.new raise RunnerDiedError.new
end end
end end

View File

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

View File

@ -95,6 +95,7 @@ jsdom.env(
if (!gotFlowerbox && context.Flowerbox) { if (!gotFlowerbox && context.Flowerbox) {
context.Flowerbox.baseUrl = "http://localhost:#{server.port}/"; context.Flowerbox.baseUrl = "http://localhost:#{server.port}/";
context.Flowerbox.environment = 'node'; context.Flowerbox.environment = 'node';
context.Flowerbox.UNKNOWN = '#{Flowerbox::Result::FileInfo::UNKNOWN}';
gotFlowerbox = true; gotFlowerbox = true;
} }

View File

@ -56,6 +56,7 @@ console.log = function(msg) {
Flowerbox.onQueueStateChange = function(msg) { Flowerbox.onQueueStateChange = function(msg) {
//document.getElementById('queue').innerHTML = document.getElementById('queue').innerHTML + "\\n" + msg; //document.getElementById('queue').innerHTML = document.getElementById('queue').innerHTML + "\\n" + msg;
}; };
Flowerbox.UNKNOWN = '#{Flowerbox::Result::FileInfo::UNKNOWN}';
var context = this; var context = this;

View File

@ -41,6 +41,10 @@ module Flowerbox
def start def start
runner.spec_files.each { |file| @sprockets.add(file) } runner.spec_files.each { |file| @sprockets.add(file) }
end end
def actual_path_for(file)
@sprockets.asset_for(file, :bundle => false).pathname.to_s
end
end end
end end
end end