diff --git a/lib/assets/javascripts/flowerbox.js.coffee b/lib/assets/javascripts/flowerbox.js.coffee index a72b7a3..cfe100c 100644 --- a/lib/assets/javascripts/flowerbox.js.coffee +++ b/lib/assets/javascripts/flowerbox.js.coffee @@ -21,7 +21,7 @@ Flowerbox = onQueueStateChange: -> - queueRunner: -> + queueRunner: (failsafe = 5) -> Flowerbox.onQueueStateChange("checking queue") if Flowerbox.contactQueue.length > 0 Flowerbox.started = true @@ -55,7 +55,10 @@ Flowerbox = xhr.abort() Flowerbox.onQueueStateChange("aborted #{url}, rerunning") Flowerbox.contactQueue.unshift(info) - Flowerbox.queueRunner() + + if failsafe > 0 + failsafe -= 1 + Flowerbox.queueRunner(failsafe) , Flowerbox.delay * 5 ) diff --git a/lib/assets/javascripts/flowerbox/cucumber.js.coffee b/lib/assets/javascripts/flowerbox/cucumber.js.coffee index 4de13eb..688b14c 100644 --- a/lib/assets/javascripts/flowerbox/cucumber.js.coffee +++ b/lib/assets/javascripts/flowerbox/cucumber.js.coffee @@ -17,16 +17,22 @@ Flowerbox.World = (code = null) -> Flowerbox.Matchers = toEqual: (expected) -> @message = "Expected #{@actual} #{@notMessage} equal #{expected}" - if typeof @actual == 'object' - for key, value of @actual - return false if expected[key] != value + result = null - for key, value of expected - return false if @actual[key] != value + if @actual? && expected? + switch (typeof @actual) + when 'object' + result = true + for key, value of @actual + result = false if expected[key] != value - true - else - @actual == expected + for key, value of expected + result = false if @actual[key] != value + + if result == null + result = (@actual == expected) + + result Flowerbox.World -> @assert = (what, message = 'failed') -> diff --git a/lib/assets/javascripts/flowerbox/cucumber/reporter.js.coffee b/lib/assets/javascripts/flowerbox/cucumber/reporter.js.coffee index 52bb46a..ded406e 100644 --- a/lib/assets/javascripts/flowerbox/cucumber/reporter.js.coffee +++ b/lib/assets/javascripts/flowerbox/cucumber/reporter.js.coffee @@ -39,7 +39,7 @@ class Flowerbox.Cucumber.Reporter when '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) diff --git a/lib/assets/javascripts/flowerbox/jasmine/reporter.js.coffee b/lib/assets/javascripts/flowerbox/jasmine/reporter.js.coffee index ef0c1be..3bb6a9d 100644 --- a/lib/assets/javascripts/flowerbox/jasmine/reporter.js.coffee +++ b/lib/assets/javascripts/flowerbox/jasmine/reporter.js.coffee @@ -4,7 +4,7 @@ class jasmine.FlowerboxReporter status: Flowerbox.Result.SUCCESS source: 'jasmine' name: spec.getSpecSplitName() - file: 'unknown:0' + file: "#{Flowerbox.UNKNOWN}:0" for key, value of overrides data[key] = value diff --git a/lib/assets/javascripts/flowerbox/jasmine/selenium.js.coffee b/lib/assets/javascripts/flowerbox/jasmine/selenium.js.coffee index ca85b80..fc6db02 100644 --- a/lib/assets/javascripts/flowerbox/jasmine/selenium.js.coffee +++ b/lib/assets/javascripts/flowerbox/jasmine/selenium.js.coffee @@ -11,7 +11,7 @@ jasmine.Spec.beforeAddMatcherResult().push -> when 'chrome' e.stack.split("\n")[4] else - 'unknown:0' + "#{Flowerbox.UNKNOWN}:0" @trace = { stack: [ @message, file ] } diff --git a/lib/flowerbox/rack.rb b/lib/flowerbox/rack.rb index d0dcf95..7d6f496 100644 --- a/lib/flowerbox/rack.rb +++ b/lib/flowerbox/rack.rb @@ -75,12 +75,6 @@ module Flowerbox runner.template end - - class << self - private - def setup_protetion(builder) - end - end end end diff --git a/lib/flowerbox/result/file_info.rb b/lib/flowerbox/result/file_info.rb index d41aafd..c988fee 100644 --- a/lib/flowerbox/result/file_info.rb +++ b/lib/flowerbox/result/file_info.rb @@ -1,28 +1,38 @@ module Flowerbox::Result::FileInfo + UNKNOWN = '__unknown__' + 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 def file_translated? - translated_file != filename + translated_file[%r{\.coffee$}] end def filename - file.to_s.split(":").first || 'unknown' + file.to_s.split(":").first || UNKNOWN end def line_number return @line_number if @line_number @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" end alias :line :line_number def translated_file_and_line - "#{translated_file.gsub(%r{^/}, '')}:#{line_number}" + "#{translated_file.gsub(%r{^#{Dir.pwd}/}, '')}:#{line_number}" end def system_files diff --git a/lib/flowerbox/result_set.rb b/lib/flowerbox/result_set.rb index f403754..a933b1e 100644 --- a/lib/flowerbox/result_set.rb +++ b/lib/flowerbox/result_set.rb @@ -41,7 +41,13 @@ module Flowerbox end def exitstatus - results.any?(&:failure?) ? 1 : 0 + if results.any?(&:failure?) + 1 + elsif results.any?(&:pending?) + 2 + else + 0 + end end def print(data = {}) diff --git a/lib/flowerbox/runner/base.rb b/lib/flowerbox/runner/base.rb index 2ad3802..4ccedfc 100644 --- a/lib/flowerbox/runner/base.rb +++ b/lib/flowerbox/runner/base.rb @@ -33,6 +33,9 @@ module Flowerbox if !finished? puts "Something died hard. Here are the tests that did get run before Flowerbox died.".foreground(:red) puts tests.flatten.join("\n").foreground(:red) + server.stop + Flowerbox.server = nil + raise RunnerDiedError.new end end diff --git a/lib/flowerbox/runner/chrome.rb b/lib/flowerbox/runner/chrome.rb index 25311bc..c9483b4 100644 --- a/lib/flowerbox/runner/chrome.rb +++ b/lib/flowerbox/runner/chrome.rb @@ -1,6 +1,7 @@ require 'flowerbox/runner/selenium' class Flowerbox::Runner::Chrome < Flowerbox::Runner::Selenium + def name "Chrome" end diff --git a/lib/flowerbox/runner/node.rb b/lib/flowerbox/runner/node.rb index aa3449b..f67a5e4 100644 --- a/lib/flowerbox/runner/node.rb +++ b/lib/flowerbox/runner/node.rb @@ -95,6 +95,7 @@ jsdom.env( if (!gotFlowerbox && context.Flowerbox) { context.Flowerbox.baseUrl = "http://localhost:#{server.port}/"; context.Flowerbox.environment = 'node'; + context.Flowerbox.UNKNOWN = '#{Flowerbox::Result::FileInfo::UNKNOWN}'; gotFlowerbox = true; } diff --git a/lib/flowerbox/runner/selenium.rb b/lib/flowerbox/runner/selenium.rb index e97d61d..e45334b 100644 --- a/lib/flowerbox/runner/selenium.rb +++ b/lib/flowerbox/runner/selenium.rb @@ -56,6 +56,7 @@ console.log = function(msg) { Flowerbox.onQueueStateChange = function(msg) { //document.getElementById('queue').innerHTML = document.getElementById('queue').innerHTML + "\\n" + msg; }; + Flowerbox.UNKNOWN = '#{Flowerbox::Result::FileInfo::UNKNOWN}'; var context = this; diff --git a/lib/flowerbox/test_environment/base.rb b/lib/flowerbox/test_environment/base.rb index bc8cc3a..26871e8 100644 --- a/lib/flowerbox/test_environment/base.rb +++ b/lib/flowerbox/test_environment/base.rb @@ -41,6 +41,10 @@ module Flowerbox def start runner.spec_files.each { |file| @sprockets.add(file) } end + + def actual_path_for(file) + @sprockets.asset_for(file, :bundle => false).pathname.to_s + end end end end