calabash-cucumber 0.9.109 → 0.9.110

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,12 +8,15 @@ module Calabash
8
8
 
9
9
  module SimulatorHelper
10
10
 
11
+ class TimeoutErr < RuntimeError
12
+ end
13
+
11
14
  DERIVED_DATA = File.expand_path("~/Library/Developer/Xcode/DerivedData")
12
15
  DEFAULT_DERIVED_DATA_INFO = File.expand_path("#{DERIVED_DATA}/*/info.plist")
13
16
 
14
- DEFAULT_SIM_WAIT = 15
17
+ DEFAULT_SIM_WAIT = 30
15
18
 
16
- MAX_PING_ATTEMPTS = 5
19
+ DEFAULT_SIM_RETRY = 2
17
20
 
18
21
  def self.relaunch(path, sdk = nil, version = 'iphone')
19
22
 
@@ -168,47 +171,59 @@ module Calabash
168
171
 
169
172
  def self.ensure_connectivity(app_bundle_path, sdk, version)
170
173
  begin
174
+ max_retry_count = (ENV['MAX_CONNECT_RETRY'] || DEFAULT_SIM_RETRY).to_i
171
175
  timeout = (ENV['CONNECT_TIMEOUT'] || DEFAULT_SIM_WAIT).to_i
172
- max_ping = (ENV['MAX_PING_ATTEMPTS'] || MAX_PING_ATTEMPTS).to_i
173
- Timeout::timeout(timeout) do
174
- connected = false
175
- until connected
176
- simulator = launch(app_bundle_path, sdk, version)
177
- num_pings = 0
178
- until connected or (num_pings == max_ping)
179
- begin
180
- connected = (ping_app == '405')
181
- post_connect_sleep = (ENV['POST_START_BREAK'] || "2").to_f
182
- sleep(post_connect_sleep) unless post_connect_sleep <= 0
183
- server_version = get_version
184
- if server_version
185
- unless version_check(server_version)
186
- msgs = ["You're running an older version of Calabash server with a newer client",
187
- "Client:#{Calabash::Cucumber::VERSION}",
188
- "Server:#{server_version}",
189
- "Minimum server version #{Calabash::Cucumber::FRAMEWORK_VERSION}",
190
- "Update recommended:",
191
- "https://github.com/calabash/calabash-ios/wiki/B1-Updating-your-Calabash-iOS-version"
192
- ]
193
-
194
- raise msgs.join("\n")
176
+ retry_count = 0
177
+ connected = false
178
+ puts "Waiting at most #{timeout} seconds for simulator (CONNECT_TIMEOUT)"
179
+ puts "Retrying at most #{max_retry_count} times (MAX_CONNECT_RETRY)"
180
+ until connected do
181
+ raise "MAX_RETRIES" if retry_count == max_retry_count
182
+ retry_count += 1
183
+ puts "(#{retry_count}.) Start Simulator #{sdk}, #{version}, for #{app_bundle_path}"
184
+ begin
185
+ Timeout::timeout(timeout, TimeoutErr) do
186
+ simulator = launch(app_bundle_path, sdk, version)
187
+ until connected
188
+ begin
189
+ connected = (ping_app == '405')
190
+ if ENV['POST_START_BREAK']
191
+ puts "Environment var POST_START_BREAK is deprecated and should no longer be necessary."
192
+ post_connect_sleep = (ENV['POST_START_BREAK'] || "2").to_f
193
+ sleep(post_connect_sleep) unless post_connect_sleep <= 0
195
194
  end
196
- else
197
- connected = false
195
+ if connected
196
+ server_version = get_version
197
+ if server_version
198
+ unless version_check(server_version)
199
+ msgs = ["You're running an older version of Calabash server with a newer client",
200
+ "Client:#{Calabash::Cucumber::VERSION}",
201
+ "Server:#{server_version}",
202
+ "Minimum server version #{Calabash::Cucumber::FRAMEWORK_VERSION}",
203
+ "Update recommended:",
204
+ "https://github.com/calabash/calabash-ios/wiki/B1-Updating-your-Calabash-iOS-version"
205
+ ]
206
+ raise msgs.join("\n")
207
+ end
208
+ else
209
+ connected = false
210
+ end
211
+ end
212
+ rescue Exception => e
213
+
214
+ ensure
215
+ sleep 1 unless connected
198
216
  end
199
- rescue Exception => e
200
- p e if num_pings > 2
201
- ensure
202
- num_pings += 1
203
- sleep 1 unless connected
204
217
  end
205
218
  end
219
+ rescue TimeoutErr => e
220
+ puts "Timed out..."
206
221
  end
207
222
  end
208
223
  rescue
209
224
  msg = "Unable to make connection to Calabash Server at #{ENV['DEVICE_ENDPOINT']|| "http://localhost:37265/"}\n"
210
225
  msg << "Make sure you've' linked correctly with calabash.framework and set Other Linker Flags.\n"
211
- msg << "See: http://github.com/calabash/calabash-ios"
226
+ msg << "Make sure you don't have a firewall blocking traffic to #{ENV['DEVICE_ENDPOINT']|| "http://localhost:37265/"}.\n"
212
227
  raise msg
213
228
  end
214
229
  end
@@ -239,7 +254,7 @@ module Calabash
239
254
 
240
255
  def self.get_version
241
256
  endpoint = ENV['DEVICE_ENDPOINT']|| "http://localhost:37265"
242
- endpoint += "/" unless endpoint.end_with?"/"
257
+ endpoint += "/" unless endpoint.end_with? "/"
243
258
  url = URI.parse("#{endpoint}version")
244
259
 
245
260
  puts "Fetch version #{url}..."
@@ -1,6 +1,6 @@
1
1
  module Calabash
2
2
  module Cucumber
3
- VERSION = "0.9.109"
4
- FRAMEWORK_VERSION = "0.9.109"
3
+ VERSION = "0.9.110"
4
+ FRAMEWORK_VERSION = "0.9.110"
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: calabash-cucumber
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.109
4
+ version: 0.9.110
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-11 00:00:00.000000000 Z
12
+ date: 2012-10-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: cucumber