diff --git a/calabash-cucumber/features-skeleton/support/01_launch.rb b/calabash-cucumber/features-skeleton/support/01_launch.rb index a8c4688ee..b8809078c 100644 --- a/calabash-cucumber/features-skeleton/support/01_launch.rb +++ b/calabash-cucumber/features-skeleton/support/01_launch.rb @@ -42,5 +42,7 @@ at_exit do launcher = Calabash::Cucumber::Launcher.new - Calabash::Cucumber::SimulatorHelper.stop unless launcher.calabash_no_stop? + if launcher.simulator_target? + Calabash::Cucumber::SimulatorHelper.stop unless launcher.calabash_no_stop? + end end diff --git a/calabash-cucumber/lib/calabash-cucumber/core.rb b/calabash-cucumber/lib/calabash-cucumber/core.rb index 41f177170..78779df40 100644 --- a/calabash-cucumber/lib/calabash-cucumber/core.rb +++ b/calabash-cucumber/lib/calabash-cucumber/core.rb @@ -7,7 +7,10 @@ module Core DATA_PATH = File.expand_path(File.dirname(__FILE__)) CAL_HTTP_RETRY_COUNT=3 - RETRYABLE_ERRORS = [Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::ECONNABORTED, Errno::ETIMEDOUT] + RETRYABLE_ERRORS = [HTTPClient::TimeoutError, + HTTPClient::KeepAliveDisconnected, + Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::ECONNABORTED, + Errno::ETIMEDOUT] def macro(txt) if self.respond_to? :step @@ -466,10 +469,11 @@ def backdoor(sel, arg) def calabash_exit # Exiting the app shuts down the HTTP connection and generates ECONNREFUSED, + # or HTTPClient::KeepAliveDisconnected # which needs to be suppressed. begin - http({:method =>:post, :path => 'exit', :retryable_errors => RETRYABLE_ERRORS - [Errno::ECONNREFUSED]}) - rescue Errno::ECONNREFUSED + http({:method =>:post, :path => 'exit', :retryable_errors => RETRYABLE_ERRORS - [Errno::ECONNREFUSED,HTTPClient::KeepAliveDisconnected]}) + rescue Errno::ECONNREFUSED, HTTPClient::KeepAliveDisconnected [] end end @@ -548,6 +552,7 @@ def url_for(verb) end def make_http_request(options) + body = nil retryable_errors = options[:retryable_errors] || RETRYABLE_ERRORS CAL_HTTP_RETRY_COUNT.times do |count| @@ -561,29 +566,20 @@ def make_http_request(options) body = @http.get(options[:uri], options[:body]).body end break - rescue HTTPClient::TimeoutError, HTTPClient::KeepAliveDisconnected => e - if count < CAL_HTTP_RETRY_COUNT-1 - @http.reset_all - @http=nil - STDOUT.write "Waiting 5 secs before retry...\n" - sleep(5) - STDOUT.write "Retrying.. #{e.class}: (#{e})\n" - STDOUT.flush + rescue Exception => e - else - puts "Failing... #{e.class}" - raise e - end + if retryable_errors.include?(e) || retryable_errors.any?{|c| e.is_a?(c)} - rescue Exception => e - if retryable_errors.include?(e) if count < CAL_HTTP_RETRY_COUNT-1 - sleep(0.5) + if e.is_a?(HTTPClient::TimeoutError) + sleep(3) + else + sleep(0.5) + end @http.reset_all @http=nil STDOUT.write "Retrying.. #{e.class}: (#{e})\n" STDOUT.flush - else puts "Failing... #{e.class}" raise e diff --git a/calabash-cucumber/lib/calabash-cucumber/launcher.rb b/calabash-cucumber/lib/calabash-cucumber/launcher.rb index 1c7be85df..bc5b4a0d2 100644 --- a/calabash-cucumber/lib/calabash-cucumber/launcher.rb +++ b/calabash-cucumber/lib/calabash-cucumber/launcher.rb @@ -25,7 +25,7 @@ def calabash_no_launch? end def device_target? - ENV['DEVICE_TARGET'] == 'device' + (ENV['DEVICE_TARGET'] != nil) && (not simulator_target?) end def simulator_target? @@ -68,7 +68,10 @@ def relaunch(args={}) if device_target? default_args = {:app => ENV['BUNDLE_ID']} - default_args[:udid] = ENV['UDID_TARGET'] if ENV['UDID_TARGET'] + target = ENV['DEVICE_TARGET'] + if target != 'DEVICE' + default_args[:udid] = target + end self.run_loop = RunLoop.run(default_args.merge(args)) else diff --git a/calabash-cucumber/lib/calabash-cucumber/version.rb b/calabash-cucumber/lib/calabash-cucumber/version.rb index 82c090f84..7f59f2c3a 100644 --- a/calabash-cucumber/lib/calabash-cucumber/version.rb +++ b/calabash-cucumber/lib/calabash-cucumber/version.rb @@ -1,6 +1,6 @@ module Calabash module Cucumber - VERSION = '0.9.145.pre2' - FRAMEWORK_VERSION = '0.9.145.pre2' + VERSION = '0.9.145.pre3' + FRAMEWORK_VERSION = '0.9.145.pre3' end end