motion-calabash 0.9.160 → 0.9.160.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/motion/project/calabash.rb +1 -1
- data/motion-calabash.gemspec +1 -1
- data/scripts/launch.rb +281 -54
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69d5a5633079bf4dcf584074416372d824c24f65
|
4
|
+
data.tar.gz: d0ecfba809c637c9e761f4b3b46ec3991ce3ecaa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e52523aa8e0a00c000c216cf3cc7aadf9e4b992b9cc570fbe35776ed7cf5f8e0b882832d5b37d697e228da2a6b3fb1ecd111a41db71efd786c8de5901c7a39b
|
7
|
+
data.tar.gz: 65a209bedd6949f609933f99380b3a8f48cb8ab73a0a2dd6ce1608c6b8b7cee9679b6999c0b38b9dcae45f9f5714566ad1295ed5b6de199cdb851f6da03ddc2f
|
@@ -34,7 +34,7 @@ namespace 'calabash' do
|
|
34
34
|
|
35
35
|
# Retrieve optional Calabash args.
|
36
36
|
def gather_calabash_env
|
37
|
-
sdk = ENV['target'] || ENV['sdk'] || ENV['SDK_VERSION'] || "
|
37
|
+
sdk = ENV['target'] || ENV['sdk'] || ENV['SDK_VERSION'] || "7.0" #Calabash env vars
|
38
38
|
major = sdk[0]
|
39
39
|
os = ENV['os'] || ENV['OS']
|
40
40
|
if os.nil?
|
data/motion-calabash.gemspec
CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.author = 'Karl Krukow'
|
8
8
|
s.email = 'karl.krukow@xamarin.com'
|
9
9
|
s.homepage = 'http://www.xamarin.com'
|
10
|
-
s.version = '0.9.160'
|
10
|
+
s.version = '0.9.160.1'
|
11
11
|
s.summary = %q{Calabash support for RubyMotion}
|
12
12
|
s.description = %q{This linkes-in calabash for iOS}
|
13
13
|
s.files = ["lib/framework/libcalabashuni-0.9.160.a"].concat(`git ls-files`.split("\n"))
|
data/scripts/launch.rb
CHANGED
@@ -23,36 +23,59 @@
|
|
23
23
|
|
24
24
|
require 'calabash-cucumber/launch/simulator_helper'
|
25
25
|
require 'sim_launcher'
|
26
|
+
require 'calabash-cucumber/device'
|
26
27
|
require 'run_loop'
|
28
|
+
require 'cfpropertylist'
|
27
29
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
# of your production target.
|
33
|
-
#APP_BUNDLE_PATH = "~/Library/Developer/Xcode/DerivedData/??/Build/Products/Calabash-iphonesimulator/??.app"
|
34
|
-
#
|
30
|
+
class Calabash::Cucumber::Launcher
|
31
|
+
attr_accessor :run_loop
|
32
|
+
attr_accessor :device
|
33
|
+
attr_accessor :launch_args
|
35
34
|
|
35
|
+
@@launcher = nil
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
end
|
37
|
+
class StartError < RuntimeError
|
38
|
+
attr_accessor :error
|
40
39
|
|
41
|
-
def
|
42
|
-
|
43
|
-
end
|
40
|
+
def initialize(err)
|
41
|
+
self.error= err
|
42
|
+
end
|
44
43
|
|
44
|
+
def to_s
|
45
|
+
"#{super.to_s}: #{error}"
|
46
|
+
end
|
47
|
+
end
|
45
48
|
|
46
|
-
class
|
47
|
-
end
|
49
|
+
class CalabashLauncherTimeoutErr < Timeout::Error
|
50
|
+
end
|
48
51
|
|
49
|
-
|
50
|
-
|
52
|
+
def self.launcher
|
53
|
+
@@launcher ||= Launcher.new
|
54
|
+
end
|
51
55
|
|
52
|
-
def
|
53
|
-
|
56
|
+
def self.launcher_if_used
|
57
|
+
@@launcher
|
58
|
+
end
|
59
|
+
|
60
|
+
def initialize
|
61
|
+
@@launcher = self
|
62
|
+
end
|
63
|
+
|
64
|
+
def ios_major_version
|
65
|
+
return nil if device.nil? or device.ios_version.nil?
|
66
|
+
device.ios_major_version
|
67
|
+
end
|
68
|
+
|
69
|
+
def ios_version
|
70
|
+
return nil if device.nil?
|
71
|
+
device.ios_version
|
72
|
+
end
|
54
73
|
|
55
|
-
|
74
|
+
def reset_app_jail(sdk=nil, path=nil)
|
75
|
+
sdk ||= sdk_version || SimLauncher::SdkDetector.new().latest_sdk_version
|
76
|
+
path ||= Calabash::Cucumber::SimulatorHelper.app_bundle_or_raise(app_path)
|
77
|
+
|
78
|
+
app = File.basename(path)
|
56
79
|
bundle = `find "#{ENV['HOME']}/Library/Application Support/iPhone Simulator/#{sdk}/Applications/" -type d -depth 2 -name "#{app}" | head -n 1`
|
57
80
|
return if bundle.empty? # Assuming we're already clean
|
58
81
|
|
@@ -62,22 +85,172 @@ class MotionLauncher
|
|
62
85
|
end
|
63
86
|
end
|
64
87
|
|
65
|
-
def
|
66
|
-
|
67
|
-
|
88
|
+
def default_launch_args
|
89
|
+
# APP_BUNDLE_PATH
|
90
|
+
# BUNDLE_ID
|
91
|
+
# APP (unifies APP_BUNDLE_PATH, BUNDLE_ID)
|
92
|
+
# DEVICE_TARGET
|
93
|
+
# SDK_VERSION
|
94
|
+
# RESET_BETWEEN_SCENARIOS
|
95
|
+
# DEVICE
|
96
|
+
# NO_LAUNCH
|
97
|
+
# NO_STOP
|
98
|
+
|
99
|
+
args = {
|
100
|
+
:launch_method => default_launch_method,
|
101
|
+
:reset => reset_between_scenarios?,
|
102
|
+
:bundle_id => ENV['BUNDLE_ID'],
|
103
|
+
:device => device_env,
|
104
|
+
:no_stop => calabash_no_stop?,
|
105
|
+
:no_launch => calabash_no_launch?,
|
106
|
+
:sdk_version => sdk_version
|
107
|
+
}
|
108
|
+
|
109
|
+
#:device_target will be set
|
110
|
+
|
111
|
+
if run_with_instruments?(args) && !simulator_target?
|
112
|
+
device_tgt = ENV['DEVICE_TARGET']
|
113
|
+
if detect_connected_device? && (device_tgt.nil? || device_tgt.downcase == 'device')
|
114
|
+
device_tgt = RunLoop::Core.detect_connected_device
|
115
|
+
end
|
116
|
+
|
117
|
+
if device_tgt
|
118
|
+
args[:device_target] = args[:udid] = device_tgt
|
119
|
+
else
|
120
|
+
args[:device_target] = 'simulator'
|
121
|
+
end
|
122
|
+
else
|
123
|
+
args[:device_target] = 'simulator'
|
68
124
|
end
|
69
|
-
|
70
|
-
|
71
|
-
|
125
|
+
|
126
|
+
|
127
|
+
args
|
128
|
+
end
|
129
|
+
|
130
|
+
def detect_connected_device?
|
131
|
+
return ENV['DETECT_CONNECTED_DEVICE'] != '0'
|
132
|
+
end
|
133
|
+
|
134
|
+
def default_launch_method
|
135
|
+
return :instruments unless sdk_version || use_instruments_env?
|
136
|
+
return :instruments if sdk_version.start_with?('7') # Only instruments supported for iOS7+
|
137
|
+
sim_detector = SimLauncher::SdkDetector.new()
|
138
|
+
available = sim_detector.available_sdk_versions.reject { |v| v.start_with?('7') }
|
139
|
+
if available.include?(sdk_version)
|
140
|
+
:sim_launcher
|
141
|
+
else
|
142
|
+
:instruments
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
def relaunch(args={})
|
147
|
+
RunLoop.stop(run_loop) if run_loop
|
148
|
+
|
149
|
+
args = default_launch_args.merge(args)
|
150
|
+
|
151
|
+
args[:app] = args[:app] || args[:bundle_id] || app_path || detect_app_bundle_from_args(args)
|
152
|
+
|
153
|
+
|
154
|
+
if args[:app]
|
155
|
+
if File.directory?(args[:app])
|
156
|
+
args[:app] = File.expand_path(args[:app])
|
157
|
+
else
|
158
|
+
# args[:app] is not a directory so must be a bundle id
|
159
|
+
if args[:device_target] == 'simulator' ## bundle id set, but simulator target
|
160
|
+
args[:app] = app_path || detect_app_bundle_from_args(args)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
unless args[:app]
|
166
|
+
if args[:device_target]=='simulator'
|
167
|
+
device_xamarin_build_dir = 'iPhoneSimulator'
|
168
|
+
else
|
169
|
+
device_xamarin_build_dir = 'iPhone'
|
170
|
+
end
|
171
|
+
args[:app] = Calabash::Cucumber::SimulatorHelper.app_bundle_or_raise(app_path, device_xamarin_build_dir)
|
172
|
+
end
|
173
|
+
|
174
|
+
args[:bundle_id] ||= detect_bundle_id_from_app_bundle(args)
|
175
|
+
|
176
|
+
args[:device] ||= detect_device_from_args(args)
|
177
|
+
|
178
|
+
|
179
|
+
reset_app_jail if args[:reset]
|
180
|
+
|
181
|
+
if run_with_instruments?(args)
|
182
|
+
self.run_loop = new_run_loop(args)
|
72
183
|
else
|
73
|
-
|
184
|
+
# run with sim launcher
|
185
|
+
sdk = sdk_version || SimLauncher::SdkDetector.new().available_sdk_versions.reverse.find { |x| !x.start_with?('7') }
|
74
186
|
path = Calabash::Cucumber::SimulatorHelper.app_bundle_or_raise(app_path)
|
75
|
-
|
76
|
-
|
187
|
+
Calabash::Cucumber::SimulatorHelper.relaunch(path, sdk, args[:device].to_s, args)
|
188
|
+
end
|
189
|
+
self.launch_args = args
|
190
|
+
ensure_connectivity
|
191
|
+
end
|
192
|
+
|
193
|
+
def detect_device_from_args(args)
|
194
|
+
if args[:app] && File.directory?(args[:app])
|
195
|
+
# Derive bundle id from bundle_dir
|
196
|
+
plist_as_hash = info_plist_from_bundle_path(args[:app])
|
197
|
+
if plist_as_hash
|
198
|
+
device_family = plist_as_hash['UIDeviceFamily']
|
199
|
+
if device_family
|
200
|
+
first_device = device_family.first
|
201
|
+
if first_device == 2
|
202
|
+
return 'ipad'
|
203
|
+
else
|
204
|
+
return 'iphone'
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end
|
208
|
+
else
|
209
|
+
args[:app]
|
210
|
+
end
|
211
|
+
|
212
|
+
|
213
|
+
end
|
214
|
+
|
215
|
+
def detect_app_bundle_from_args(args)
|
216
|
+
if args[:device_target]=='simulator'
|
217
|
+
device_xamarin_build_dir = 'iPhoneSimulator'
|
218
|
+
else
|
219
|
+
device_xamarin_build_dir = 'iPhone'
|
220
|
+
end
|
221
|
+
Calabash::Cucumber::SimulatorHelper.detect_app_bundle(nil, device_xamarin_build_dir)
|
222
|
+
end
|
223
|
+
|
224
|
+
def detect_bundle_id_from_app_bundle(args)
|
225
|
+
if args[:app] && File.directory?(args[:app])
|
226
|
+
# Derive bundle id from bundle_dir
|
227
|
+
plist_as_hash = info_plist_from_bundle_path(args[:app])
|
228
|
+
if plist_as_hash
|
229
|
+
plist_as_hash['CFBundleIdentifier']
|
77
230
|
end
|
78
|
-
|
231
|
+
else
|
232
|
+
args[:app]
|
79
233
|
end
|
234
|
+
end
|
80
235
|
|
236
|
+
def info_plist_from_bundle_path(bundle_path)
|
237
|
+
plist_path = File.join(bundle_path, 'Info.plist')
|
238
|
+
info_plist_as_hash(plist_path) if File.exist?(plist_path)
|
239
|
+
end
|
240
|
+
|
241
|
+
def new_run_loop(args)
|
242
|
+
last_err = nil
|
243
|
+
3.times do
|
244
|
+
begin
|
245
|
+
return RunLoop.run(args)
|
246
|
+
rescue RunLoop::TimeoutError => e
|
247
|
+
last_err = e
|
248
|
+
if ENV['CALABASH_FULL_CONSOLE_OUTPUT'] == '1'
|
249
|
+
puts "retrying run loop..."
|
250
|
+
end
|
251
|
+
end
|
252
|
+
end
|
253
|
+
raise StartError.new(last_err)
|
81
254
|
end
|
82
255
|
|
83
256
|
def ensure_connectivity
|
@@ -86,12 +259,14 @@ class MotionLauncher
|
|
86
259
|
timeout = (ENV['CONNECT_TIMEOUT'] || 30).to_i
|
87
260
|
retry_count = 0
|
88
261
|
connected = false
|
89
|
-
|
262
|
+
if ENV['CALABASH_FULL_CONSOLE_OUTPUT'] == '1'
|
263
|
+
puts "Waiting for App to be ready"
|
264
|
+
end
|
90
265
|
until connected do
|
91
266
|
raise "MAX_RETRIES" if retry_count == max_retry_count
|
92
267
|
retry_count += 1
|
93
268
|
begin
|
94
|
-
Timeout::timeout(timeout,
|
269
|
+
Timeout::timeout(timeout, CalabashLauncherTimeoutErr) do
|
95
270
|
until connected
|
96
271
|
begin
|
97
272
|
connected = (ping_app == '200')
|
@@ -104,11 +279,11 @@ class MotionLauncher
|
|
104
279
|
end
|
105
280
|
end
|
106
281
|
end
|
107
|
-
rescue
|
282
|
+
rescue CalabashLauncherTimeoutErr => e
|
108
283
|
puts "Timed out...Retry.."
|
109
284
|
end
|
110
285
|
end
|
111
|
-
rescue e
|
286
|
+
rescue RuntimeError => e
|
112
287
|
p e
|
113
288
|
msg = "Unable to make connection to Calabash Server at #{ENV['DEVICE_ENDPOINT']|| "http://localhost:37265/"}\n"
|
114
289
|
msg << "Make sure you don't have a firewall blocking traffic to #{ENV['DEVICE_ENDPOINT']|| "http://localhost:37265/"}.\n"
|
@@ -121,7 +296,7 @@ class MotionLauncher
|
|
121
296
|
|
122
297
|
http = Net::HTTP.new(url.host, url.port)
|
123
298
|
res = http.start do |sess|
|
124
|
-
sess.request Net::HTTP::Get.new "version"
|
299
|
+
sess.request Net::HTTP::Get.new(ENV['CALABASH_VERSION_PATH'] || "version")
|
125
300
|
end
|
126
301
|
status = res.code
|
127
302
|
begin
|
@@ -130,6 +305,11 @@ class MotionLauncher
|
|
130
305
|
|
131
306
|
end
|
132
307
|
|
308
|
+
if status == '200'
|
309
|
+
version_body = JSON.parse(res.body)
|
310
|
+
self.device = Calabash::Cucumber::Device.new(url, version_body)
|
311
|
+
end
|
312
|
+
|
133
313
|
status
|
134
314
|
end
|
135
315
|
|
@@ -137,10 +317,6 @@ class MotionLauncher
|
|
137
317
|
RunLoop.stop(run_loop)
|
138
318
|
end
|
139
319
|
|
140
|
-
def app_path
|
141
|
-
ENV['APP_BUNDLE_PATH'] || (defined?(APP_BUNDLE_PATH) && APP_BUNDLE_PATH)
|
142
|
-
end
|
143
|
-
|
144
320
|
def calabash_notify(world)
|
145
321
|
if world.respond_to?(:on_launch)
|
146
322
|
world.on_launch
|
@@ -148,24 +324,75 @@ class MotionLauncher
|
|
148
324
|
end
|
149
325
|
|
150
326
|
|
151
|
-
|
327
|
+
def info_plist_as_hash(plist_path)
|
328
|
+
unless File.exist?(plist_path)
|
329
|
+
raise "Unable to find Info.plist: #{plist_path}"
|
330
|
+
end
|
331
|
+
parsedplist = CFPropertyList::List.new(:file => plist_path)
|
332
|
+
CFPropertyList.native_types(parsedplist.value)
|
333
|
+
end
|
152
334
|
|
153
|
-
|
154
|
-
|
155
|
-
|
335
|
+
def detect_bundle_id
|
336
|
+
begin
|
337
|
+
bundle_path = Calabash::Cucumber::SimulatorHelper.app_bundle_or_raise(app_path)
|
338
|
+
plist_path = File.join(bundle_path, 'Info.plist')
|
339
|
+
info_plist_as_hash(plist_path)['CFBundleIdentifier']
|
340
|
+
rescue => e
|
341
|
+
raise "Unable to automatically find bundle id. Please set BUNDLE_ID environment variable. #{e}"
|
342
|
+
end
|
343
|
+
end
|
156
344
|
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
@launcher.calabash_notify(self)
|
161
|
-
end
|
345
|
+
def calabash_no_stop?
|
346
|
+
calabash_no_launch? or ENV['NO_STOP']=="1"
|
347
|
+
end
|
162
348
|
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
349
|
+
def calabash_no_launch?
|
350
|
+
ENV['NO_LAUNCH']=='1'
|
351
|
+
end
|
352
|
+
|
353
|
+
def device_target?
|
354
|
+
(ENV['DEVICE_TARGET'] != nil) && (not simulator_target?)
|
355
|
+
end
|
356
|
+
|
357
|
+
def simulator_target?
|
358
|
+
ENV['DEVICE_TARGET'] == 'simulator'
|
359
|
+
end
|
360
|
+
|
361
|
+
def sdk_version
|
362
|
+
ENV['SDK_VERSION']
|
363
|
+
end
|
364
|
+
|
365
|
+
def use_instruments_env?
|
366
|
+
ENV['LAUNCH_VIA'] == 'instruments'
|
367
|
+
end
|
368
|
+
|
369
|
+
def reset_between_scenarios?
|
370
|
+
ENV['RESET_BETWEEN_SCENARIOS']=="1"
|
371
|
+
end
|
372
|
+
|
373
|
+
def device_env
|
374
|
+
ENV['DEVICE']
|
375
|
+
end
|
376
|
+
|
377
|
+
def app_path
|
378
|
+
ENV['APP_BUNDLE_PATH'] || (defined?(APP_BUNDLE_PATH) && APP_BUNDLE_PATH) || ENV['APP']
|
379
|
+
end
|
380
|
+
|
381
|
+
def run_with_instruments?(args)
|
382
|
+
args[:launch_method] == :instruments
|
383
|
+
end
|
384
|
+
|
385
|
+
def active?
|
386
|
+
not run_loop.nil?
|
387
|
+
end
|
388
|
+
|
389
|
+
def inspect
|
390
|
+
msg = ["#{self.class}: Launch Method #{launch_args[:launch_method]}"]
|
391
|
+
if run_with_instruments?(self.launch_args) && self.run_loop
|
392
|
+
msg << "Log file: #{self.run_loop[:log_file]}"
|
169
393
|
end
|
394
|
+
msg.join("\n")
|
170
395
|
end
|
396
|
+
|
397
|
+
|
171
398
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: motion-calabash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.160
|
4
|
+
version: 0.9.160.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Karl Krukow
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-10-
|
11
|
+
date: 2013-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: calabash-cucumber
|