run_loop 2.7.1 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e1989b341a39a627304c44e4b912659b994186853eea0f29fa0a1a8ff0a9e90d
4
- data.tar.gz: e093957dfc2a9e06b19db6087c712ca028c6fc1649c40d4277bbb821e17ecda1
3
+ metadata.gz: 2a3873b92b4c8568a495fcc27d0941944c51c970c9bad153a633b7968ea21434
4
+ data.tar.gz: 7cb0715ea157c79ab0f134611eb119d0fa1bedfa271d8fbbf7a09ac35a1810ed
5
5
  SHA512:
6
- metadata.gz: d1ae59bba8863b365a444bb7192768cce5a9792bbbc5e2b74aa5bcdea1e8382f17d3718e1bab0b8133b5dbad6e7a012ea3d2417758b3eb6354e6441aed83d36c
7
- data.tar.gz: 6607359f51ea568f3f582f37abaaa720c1236650655c0451813dd35a71a8070c17d9d2c98cacbb3902c19d6dadda8889a07b858f1b5de493a7bcd4843d69634f
6
+ metadata.gz: 29d727bad338610ce8d3e3cb28e6a3c5f0fbfd75a537768b016463970b934b987d977e6f707366d6a76797a0887db3c5a5c0567c6f20944874657915d5b77ec7
7
+ data.tar.gz: 824e82af5b89ba3b00f4aba551e63cd7e576576c282ee10119196e3d744efde52376fba4f8fb2705be5cce06ada5d1299734243baee873cc63dcca1b6d075ff9
@@ -34,7 +34,6 @@ require "run_loop/detect_aut/errors"
34
34
  require "run_loop/detect_aut/xamarin_studio"
35
35
  require "run_loop/detect_aut/xcode"
36
36
  require "run_loop/detect_aut/detect"
37
- require 'run_loop/sim_control'
38
37
  require 'run_loop/device'
39
38
  require 'run_loop/instruments'
40
39
  require 'run_loop/lipo'
@@ -202,43 +201,6 @@ Please quit the Instruments.app and try again.)
202
201
  FileUtils.cp(pngs, dest) if pngs and pngs.length > 0
203
202
  end
204
203
 
205
- # @!visibility private
206
- #
207
- # @deprecated since 2.1.2
208
- def self.default_script_for_uia_strategy(uia_strategy)
209
- self.deprecated("2.1.2", "Replaced by methods in RunLoop::Core")
210
- case uia_strategy
211
- when :preferences
212
- Core.script_for_key(:run_loop_fast_uia)
213
- when :host
214
- Core.script_for_key(:run_loop_host)
215
- when :shared_element
216
- Core.script_for_key(:run_loop_shared_element)
217
- else
218
- Core.script_for_key(:run_loop_basic)
219
- end
220
- end
221
-
222
- # @!visibility private
223
- #
224
- # @deprecated since 2.1.2
225
- def self.validate_script(script)
226
- self.deprecated("2.1.2", "Replaced by methods in RunLoop::Core")
227
- if script.is_a?(String)
228
- unless File.exist?(script)
229
- raise "Unable to find file: #{script}"
230
- end
231
- elsif script.is_a?(Symbol)
232
- script = Core.script_for_key(script)
233
- unless script
234
- raise "Unknown script for symbol: #{script}. Options: #{Core::SCRIPTS.keys.join(', ')}"
235
- end
236
- else
237
- raise "Script must be a symbol or path: #{script}"
238
- end
239
- script
240
- end
241
-
242
204
  def self.log_info(*args)
243
205
  RunLoop::Logging.log_info(*args)
244
206
  end
@@ -16,7 +16,21 @@ module RunLoop
16
16
  @path = File.expand_path(app_bundle_path)
17
17
 
18
18
  if !App.valid?(app_bundle_path)
19
- raise ArgumentError,
19
+ if App.cached_app_on_simulator?(app_bundle_path)
20
+ raise RuntimeError, %Q{
21
+ App is "cached" on the simulator.
22
+
23
+ #{app_bundle_path}
24
+
25
+ This can happen if there was an incomplete install or uninstall.
26
+
27
+ Try manually deleting the application data container and relaunching the simulator.
28
+
29
+ $ rm -r #{File.dirname(app_bundle_path)}
30
+ $ run-loop simctl manage-processes
31
+ }
32
+ else
33
+ raise ArgumentError,
20
34
  %Q{App does not exist at path or is not an app bundle.
21
35
 
22
36
  #{app_bundle_path}
@@ -28,6 +42,7 @@ Bundle must:
28
42
  3. contain an Info.plist,
29
43
  4. and the app binary (CFBundleExecutable) must exist
30
44
  }
45
+ end
31
46
  end
32
47
  end
33
48
 
@@ -71,6 +86,19 @@ Bundle must:
71
86
  true
72
87
  end
73
88
 
89
+ # @!visibility private
90
+ #
91
+ # Starting in Xcode 10 betas, this can happen if there was an incomplete
92
+ # install or uninstall.
93
+ def self.cached_app_on_simulator?(app_bundle_path)
94
+ return false if Dir[File.join(app_bundle_path, "**/*")].length != 2
95
+ return false if !app_bundle_path[RunLoop::Regex::CORE_SIMULATOR_UDID_REGEX]
96
+ [File.join(app_bundle_path, "Info.plist"),
97
+ File.join(app_bundle_path, "Icon.png")].all? do |file|
98
+ File.exist?(file)
99
+ end
100
+ end
101
+
74
102
  # Returns the Info.plist path.
75
103
  # @raise [RuntimeError] If there is no Info.plist.
76
104
  def info_plist_path
@@ -128,6 +156,14 @@ Bundle must:
128
156
  version
129
157
  end
130
158
 
159
+ # @!visibility private
160
+ # Return the fingerprint of the linked server
161
+ def calabash_server_id
162
+ name = plist_buddy.plist_read("CFBundleExecutable", info_plist_path)
163
+ app_executable = File.join(self.path, name)
164
+ strings(app_executable).server_id
165
+ end
166
+
131
167
  # @!visibility private
132
168
  def codesign_info
133
169
  RunLoop::Codesign.info(path)
@@ -0,0 +1,71 @@
1
+
2
+ module RunLoop
3
+ module CLI
4
+
5
+ require 'thor'
6
+ class IDM < Thor
7
+
8
+ require "run_loop"
9
+ require "run_loop/cli/errors"
10
+ require "run_loop/shell"
11
+ include RunLoop::Shell
12
+
13
+ require "run_loop/regex"
14
+
15
+ desc "install app [OPTIONS]", "Installs an app on a device."
16
+
17
+ method_option "device",
18
+ :desc => 'The simulator UDID or name.',
19
+ :aliases => "-d",
20
+ :required => false,
21
+ :type => :string
22
+
23
+ method_option "debug",
24
+ :desc => "Enable debug logging.",
25
+ :aliases => "-v",
26
+ :required => false,
27
+ :default => false,
28
+ :type => :boolean
29
+
30
+ method_option "force",
31
+ :desc => "Force a re-install the existing app",
32
+ :aliases => "-f",
33
+ :required => false,
34
+ :default => false,
35
+ :type => :boolean
36
+
37
+ def install(app)
38
+ extension = File.extname(app)
39
+ if extension == ".app"
40
+ app_instance = RunLoop::App.new(app)
41
+ else
42
+ app_instance = RunLoop::Ipa.new(app)
43
+ end
44
+
45
+ xcode = RunLoop::Xcode.new
46
+ simctl = RunLoop::Simctl.new
47
+ instruments = RunLoop::Instruments.new
48
+
49
+ detect_options = {}
50
+
51
+ device = options[:device]
52
+ if !device
53
+ detect_options[:device] = "device"
54
+ else
55
+ detect_options[:device] = device
56
+ end
57
+
58
+ device = RunLoop::Device.detect_device(detect_options, xcode,
59
+ simctl, instruments)
60
+
61
+ idm = RunLoop::PhysicalDevice::IOSDeviceManager.new(device)
62
+
63
+ if options[:force]
64
+ idm.install_app(app_instance)
65
+ else
66
+ idm.ensure_newest_installed(app_instance)
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
@@ -250,7 +250,7 @@ module RunLoop
250
250
  if device_from_options.nil?
251
251
  default_name = RunLoop::Core.default_simulator
252
252
  device = simulators.find do |sim|
253
- sim.instruments_identifier(xcode) == default_name
253
+ sim.instruments_identifier == default_name
254
254
  end
255
255
 
256
256
  if device.nil?
@@ -260,7 +260,7 @@ module RunLoop
260
260
  else
261
261
  device = simulators.find do |sim|
262
262
  sim.udid == device_from_options ||
263
- sim.instruments_identifier(xcode) == device_from_options
263
+ sim.instruments_identifier == device_from_options
264
264
  end
265
265
 
266
266
  if device.nil?
@@ -319,44 +319,20 @@ Logfile: #{log_file}
319
319
  # @param [RunLoop::Xcode] xcode Used to detect the current xcode
320
320
  # version.
321
321
  def self.default_simulator(xcode=RunLoop::Xcode.new)
322
-
323
- if xcode.version_gte_94?
324
- "iPhone 8 (11.4)"
325
- elsif xcode.version_gte_93?
326
- "iPhone 8 (11.3)"
327
- elsif xcode.version_gte_92?
328
- "iPhone 8 (11.2)"
329
- elsif xcode.version_gte_91?
330
- "iPhone 8 (11.1)"
331
- elsif xcode.version_gte_90?
332
- "iPhone 8 (11.0)"
333
- elsif xcode.version_gte_83?
334
- "iPhone 7 (10.3)"
335
- elsif xcode.version_gte_82?
336
- "iPhone 7 (10.2)"
337
- elsif xcode.version_gte_81?
338
- "iPhone 7 (10.1)"
339
- elsif xcode.version_gte_8?
340
- "iPhone 7 (10.0)"
341
- elsif xcode.version_gte_73?
342
- "iPhone 6s (9.3)"
343
- elsif xcode.version_gte_72?
344
- "iPhone 6s (9.2)"
345
- elsif xcode.version_gte_71?
346
- "iPhone 6s (9.1)"
347
- elsif xcode.version_gte_7?
348
- "iPhone 5s (9.0)"
349
- elsif xcode.version_gte_64?
350
- "iPhone 5s (8.4 Simulator)"
351
- elsif xcode.version_gte_63?
352
- "iPhone 5s (8.3 Simulator)"
353
- elsif xcode.version_gte_62?
354
- "iPhone 5s (8.2 Simulator)"
355
- elsif xcode.version_gte_61?
356
- "iPhone 5s (8.1 Simulator)"
322
+ version = xcode.version
323
+ xcode_major = version.major
324
+ xcode_minor = version.minor
325
+ major = xcode_major + 2
326
+ minor = xcode_minor
327
+
328
+ # Early major Xcode beta releases do not have new hardware model numbers
329
+ if xcode.beta? && xcode_major == 10
330
+ model = xcode_major - 2
357
331
  else
358
- "iPhone 5s (8.0 Simulator)"
332
+ model = xcode_major - 1
359
333
  end
334
+
335
+ "iPhone #{model} (#{major}.#{minor})"
360
336
  end
361
337
 
362
338
  def self.create_uia_pipe(repl_path)
@@ -574,125 +550,10 @@ $ xcrun instruments -s templates
574
550
  ])
575
551
  end
576
552
 
577
- # @deprecated 2.1.0
578
- # Replaced with Device.detect_physical_device_on_usb
579
- def self.detect_connected_device
580
- begin
581
- Timeout::timeout(1, RunLoop::TimeoutError) do
582
- return `#{File.join(SCRIPTS_PATH, 'udidetect')}`.chomp
583
- end
584
- rescue RunLoop::TimeoutError => _
585
- `killall udidetect &> /dev/null`
586
- end
587
- nil
588
- end
589
-
590
- # @deprecated 2.1.0
591
- # @!visibility private
592
- # Are we targeting a simulator?
593
- #
594
- # @note The behavior of this method is different than the corresponding
595
- # method in Calabash::Cucumber::Launcher method. If
596
- # `:device_target => {nil | ''}`, then the calabash-ios method returns
597
- # _false_. I am basing run-loop's behavior off the behavior in
598
- # `self.udid_and_bundle_for_launcher`
599
- #
600
- # @see {Core::RunLoop.udid_and_bundle_for_launcher}
601
- #
602
- # @todo sim_control argument is no longer necessary and can be removed.
603
- def self.simulator_target?(run_options, sim_control=nil)
604
- # TODO Enable deprecation warning
605
- # RunLoop.deprecated("2.1.0", "No replacement")
606
- value = run_options[:device_target]
607
-
608
- # Match the behavior of udid_and_bundle_for_launcher.
609
- return true if value.nil? or value == ''
610
-
611
- # 5.1 <= Xcode < 7.0
612
- return true if value.downcase.include?('simulator')
613
-
614
- # Not a physical device.
615
- return false if value[DEVICE_UDID_REGEX, 0] != nil
616
-
617
- # Check for named simulators and Xcode >= 7.0 simulators.
618
- simctl = run_options[:sim_control] || run_options[:simctl] || RunLoop::Simctl.new
619
- xcode = run_options[:xcode] || RunLoop::Xcode.new
620
- simulator = simctl.simulators.find do |sim|
621
- [
622
- sim.instruments_identifier(xcode) == value,
623
- sim.udid == value,
624
- sim.name == value
625
- ].any?
626
- end
627
- !simulator.nil?
628
- end
629
-
630
- # @!visibility private
631
- # @deprecated 2.1.0
632
- #
633
- # Do not call this method.
634
- def self.udid_and_bundle_for_launcher(device_target, options, simctl=RunLoop::Simctl.new)
635
- RunLoop.deprecated("2.1.0", "No replacement")
636
- xcode = RunLoop::Xcode.new
637
-
638
- bundle_dir_or_bundle_id = options[:app] || RunLoop::Environment.bundle_id || RunLoop::Environment.path_to_app_bundle
639
-
640
- unless bundle_dir_or_bundle_id
641
- raise 'key :app or environment variable APP_BUNDLE_PATH, BUNDLE_ID or APP must be specified as path to app bundle (simulator) or bundle id (device)'
642
- end
643
-
644
- if device_target.nil? || device_target.empty? || device_target == 'simulator'
645
- device_target = self.default_simulator(xcode)
646
- end
647
- udid = device_target
648
-
649
- unless self.simulator_target?(options)
650
- bundle_dir_or_bundle_id = options[:bundle_id] if options[:bundle_id]
651
- end
652
- return udid, bundle_dir_or_bundle_id
653
- end
654
-
655
- # @deprecated 1.0.5
656
- def self.ensure_instruments_not_running!
657
- RunLoop::Instruments.new.kill_instruments
658
- end
659
-
660
553
  def self.instruments_running?
661
554
  RunLoop::Instruments.new.instruments_running?
662
555
  end
663
556
 
664
- # @deprecated 1.0.5
665
- def self.instruments_pids
666
- RunLoop::Instruments.new.instruments_pids
667
- end
668
-
669
- # @deprecated 1.0.0 replaced with Xctools#version
670
- def self.xcode_version(xcode=RunLoop::Xcode.new)
671
- xcode.version
672
- end
673
-
674
- # @deprecated since 1.0.0
675
- # still used extensively in calabash-ios launcher
676
- def self.above_or_eql_version?(target_version, xcode_version)
677
- if target_version.is_a?(RunLoop::Version)
678
- target = target_version
679
- else
680
- target = RunLoop::Version.new(target_version)
681
- end
682
-
683
- if xcode_version.is_a?(RunLoop::Version)
684
- xcode = xcode_version
685
- else
686
- xcode = RunLoop::Version.new(xcode_version)
687
- end
688
- target >= xcode
689
- end
690
-
691
- # @deprecated 1.0.5
692
- def self.pids_for_run_loop(run_loop, &block)
693
- RunLoop::Instruments.new.instruments_pids(&block)
694
- end
695
-
696
557
  private
697
558
 
698
559
  # @!visibility private
@@ -828,11 +689,6 @@ $ xcrun instruments -s templates
828
689
  core_sim.reset_app_sandbox
829
690
  end
830
691
 
831
- # @todo fix accessibility_enabled? so we don't have to quit the sim
832
- # SimControl#accessibility_enabled? is always false during Core#prepare_simulator
833
- # https://github.com/calabash/run_loop/issues/167
834
- simctl.ensure_accessibility(device)
835
-
836
692
  # Launches the simulator if the app is not installed.
837
693
  core_sim.install
838
694
 
@@ -122,7 +122,13 @@ class RunLoop::CoreSimulator
122
122
  ["pkd", false],
123
123
  ["KeychainSyncingOverIDSProxy", false],
124
124
  ["CloudKeychainProxy", false],
125
- ["aslmanager", false]
125
+ ["aslmanager", false],
126
+
127
+ # Processes from Xcode 10
128
+ ["diagnosticd", false],
129
+ ["syslogd", false],
130
+ ["mobiletimerd", false],
131
+ ["carkitd", false]
126
132
  ]
127
133
 
128
134
  # @!visibility private
@@ -424,6 +430,9 @@ class RunLoop::CoreSimulator
424
430
  '-CurrentDeviceUDID', device.udid,
425
431
  "-ConnectHardwareKeyboard", "0",
426
432
  "-DeviceBootTimeout", "120",
433
+ # Yes, this is the argument even though it is not spelled correctly
434
+ "-DetatchOnAppQuit", "0",
435
+ "-DetachOnWindowClose", "0",
427
436
  "LAUNCHED_BY_RUN_LOOP"]
428
437
 
429
438
  RunLoop.log_debug("Launching #{device} with:")
@@ -518,7 +527,12 @@ Could not launch #{app.bundle_identifier} on #{device} after trying #{tries} tim
518
527
 
519
528
  # Is this app installed?
520
529
  def app_is_installed?
521
- !installed_app_bundle_dir.nil?
530
+ if installed_app_bundle_dir ||
531
+ simctl.app_container(device, app.bundle_identifier)
532
+ true
533
+ else
534
+ false
535
+ end
522
536
  end
523
537
 
524
538
  # Resets the app sandbox.
@@ -600,13 +614,7 @@ Could not launch #{app.bundle_identifier} on #{device} after trying #{tries} tim
600
614
  # @return [String] A String suitable for searching for a pid, quitting, or
601
615
  # launching the current simulator.
602
616
  def sim_name
603
- @sim_name ||= begin
604
- if xcode.version_gte_7?
605
- "Simulator"
606
- else
607
- "iOS Simulator"
608
- end
609
- end
617
+ @sim_name ||= "Simulator"
610
618
  end
611
619
 
612
620
  # @!visibility private