lib/calabash-cucumber/launch/simulator_helper.rb in testautoi-0.9.135 vs lib/calabash-cucumber/launch/simulator_helper.rb in testautoi-0.9.142

- old
+ new

@@ -17,10 +17,14 @@ DEFAULT_SIM_WAIT = 30 DEFAULT_SIM_RETRY = 2 + # Load environment variable for showing full console output + # If not env var set then we use true; i.e. output to console in full + FULL_CONSOLE_OUTPUT = ENV['CALABASH_FULL_CONSOLE_OUTPUT'] == 'false' ? false : true + def self.relaunch(path, sdk = nil, version = 'iphone', args = nil) app_bundle_path = app_bundle_or_raise(path) ensure_connectivity(app_bundle_path, sdk, version, args) @@ -174,16 +178,22 @@ begin max_retry_count = (ENV['MAX_CONNECT_RETRY'] || DEFAULT_SIM_RETRY).to_i timeout = (ENV['CONNECT_TIMEOUT'] || DEFAULT_SIM_WAIT).to_i retry_count = 0 connected = false - puts "Waiting at most #{timeout} seconds for simulator (CONNECT_TIMEOUT)" - puts "Retrying at most #{max_retry_count} times (MAX_CONNECT_RETRY)" + + if FULL_CONSOLE_OUTPUT + puts "Waiting at most #{timeout} seconds for simulator (CONNECT_TIMEOUT)" + puts "Retrying at most #{max_retry_count} times (MAX_CONNECT_RETRY)" + end + until connected do raise "MAX_RETRIES" if retry_count == max_retry_count retry_count += 1 - puts "(#{retry_count}.) Start Simulator #{sdk}, #{version}, for #{app_bundle_path}" + if FULL_CONSOLE_OUTPUT + puts "(#{retry_count}.) Start Simulator #{sdk}, #{version}, for #{app_bundle_path}" + end begin Timeout::timeout(timeout, TimeoutErr) do simulator = launch(app_bundle_path, sdk, version, args) until connected begin @@ -194,11 +204,13 @@ sleep(post_connect_sleep) unless post_connect_sleep <= 0 end if connected server_version = get_version if server_version - p server_version + if FULL_CONSOLE_OUTPUT + p server_version + end unless version_check(server_version) msgs = ["You're running an older version of Calabash server with a newer client", "Client:#{Calabash::Cucumber::VERSION}", "Server:#{server_version}", "Minimum server version #{Calabash::Cucumber::FRAMEWORK_VERSION}", @@ -239,11 +251,13 @@ simulator end def self.ping_app url = URI.parse(ENV['DEVICE_ENDPOINT']|| "http://localhost:37265/") - puts "Ping #{url}..." + if FULL_CONSOLE_OUTPUT + puts "Ping #{url}..." + end http = Net::HTTP.new(url.host, url.port) res = http.start do |sess| sess.request Net::HTTP::Get.new url.path end status = res.code @@ -258,10 +272,12 @@ def self.get_version endpoint = ENV['DEVICE_ENDPOINT']|| "http://localhost:37265" endpoint += "/" unless endpoint.end_with? "/" url = URI.parse("#{endpoint}version") - puts "Fetch version #{url}..." + if FULL_CONSOLE_OUTPUT + puts "Fetch version #{url}..." + end begin body = Net::HTTP.get_response(url).body res = JSON.parse(body) if res['iOS_version'] @ios_version = res['iOS_version']