run_loop 1.0.3 → 1.0.4

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
  SHA1:
3
- metadata.gz: 2de16f5cb3f91a4a5d0cf8f056a4a128d0cb906a
4
- data.tar.gz: 58244f2475fa2ea431e18022545e02498d86dc4a
3
+ metadata.gz: 6b20bf3d2f01e6535a4ff815c863d8028fb6a4fe
4
+ data.tar.gz: 88633d7185f47b0775e926b6b584da840ef01195
5
5
  SHA512:
6
- metadata.gz: 4bd98dcee58d56074c95ada808a4fe0b19a05bf8ece5f8c5fedfd9d55119bf8e5bdee8831b5f7b50471053aea2bc676af682cbabe18a653479b19677890a9f2f
7
- data.tar.gz: da03c9b79b3435b11fc832268ddd8bb72e05e9e52f9b3a0bd3070b2470be53a32cb6ffa1fe41d32f59ab8ba48326054512f9a892475d4f9bc25fb16394b39a47
6
+ metadata.gz: 319d9b03f85ec315e71446a9a7ffbe4f82407f85c1e440995d9b79c5058074f66682a54623cb327b20eb3b323ca6d8f867f81cc0fce6cb03618a778d6e0b906f
7
+ data.tar.gz: f7efe08c5cd8655f2ca8352a6b45985bbe1dffc0263a18af8294120d93b0ff17ae10e1f44707778f7fa51700c376eac9bf592832aafe13efcec0d654c458b86c
data/lib/run_loop/core.rb CHANGED
@@ -168,9 +168,9 @@ module RunLoop
168
168
 
169
169
  log_header("Starting on #{device_target} App: #{bundle_dir_or_bundle_id}")
170
170
  cmd_str = cmd.join(' ')
171
- if ENV['DEBUG']
172
- log(cmd_str)
173
- end
171
+
172
+ log(cmd_str) if ENV['DEBUG'] == '1'
173
+
174
174
  if !jruby? && RUBY_VERSION && RUBY_VERSION.start_with?('1.8')
175
175
  pid = fork do
176
176
  exec(cmd_str)
@@ -251,7 +251,7 @@ module RunLoop
251
251
  end
252
252
  end
253
253
  rescue TimeoutError => e
254
- if ENV['DEBUG']
254
+ if ENV['DEBUG'] == '1'
255
255
  puts "Failed to launch."
256
256
  puts "#{e}: #{e && e.message}"
257
257
  if raw_lldb_output
@@ -329,6 +329,21 @@ module RunLoop
329
329
  `/usr/libexec/PlistBuddy -c "Print :CFBundleExecutable" "#{info_plist}"`.strip
330
330
  end
331
331
 
332
+ # Returns the a default simulator to target. This default needs to be one
333
+ # that installed by default in the current Xcode version.
334
+ #
335
+ # For historical reasons, the most recent non-64b SDK should be used.
336
+ #
337
+ # @param [RunLoop::XCTools] xcode_tools Used to detect the current xcode
338
+ # version.
339
+ def self.default_simulator(xcode_tools=RunLoop::XCTools.new)
340
+ if xcode_tools.xcode_version_gte_6?
341
+ 'iPhone 5 (8.0 Simulator)'
342
+ else
343
+ 'iPhone Retina (4-inch) - Simulator - iOS 7.1'
344
+ end
345
+ end
346
+
332
347
  def self.udid_and_bundle_for_launcher(device_target, options, xctools=RunLoop::XCTools.new)
333
348
  bundle_dir_or_bundle_id = options[:app] || ENV['BUNDLE_ID']|| ENV['APP_BUNDLE_PATH'] || ENV['APP']
334
349
 
@@ -340,12 +355,7 @@ module RunLoop
340
355
 
341
356
  if xctools.xcode_version_gte_51?
342
357
  if device_target.nil? || device_target.empty? || device_target == 'simulator'
343
- if xctools.xcode_version_gte_6?
344
- # the simulator can be either the textual name or the UDID (directory name)
345
- device_target = 'iPhone 5 (8.0 Simulator)'
346
- else
347
- device_target = 'iPhone Retina (4-inch) - Simulator - iOS 7.1'
348
- end
358
+ device_target = self.default_simulator(xctools)
349
359
  end
350
360
  udid = device_target
351
361
 
@@ -382,7 +392,7 @@ module RunLoop
382
392
  end
383
393
 
384
394
  # @deprecated 1.0.0 replaced with Xctools#version
385
- def self.xcode_version(xctools=XCTools.new)
395
+ def self.xcode_version(xctools=RunLoop::XCTools.new)
386
396
  xctools.xcode_version.to_s
387
397
  end
388
398
 
@@ -521,7 +531,7 @@ module RunLoop
521
531
  end
522
532
 
523
533
 
524
- def self.instruments_command(options, xctools=XCTools.new)
534
+ def self.instruments_command(options, xctools=RunLoop::XCTools.new)
525
535
  udid = options[:udid]
526
536
  results_dir_trace = options[:results_dir_trace]
527
537
  bundle_dir_or_bundle_id = options[:bundle_dir_or_bundle_id]
@@ -552,7 +562,7 @@ module RunLoop
552
562
  candidate
553
563
  end
554
564
 
555
- def self.default_tracetemplate(xctools=XCTools.new)
565
+ def self.default_tracetemplate(xctools=RunLoop::XCTools.new)
556
566
  templates = xctools.instruments :templates
557
567
  if xctools.xcode_version_gte_6?
558
568
  templates.delete_if do |name|
@@ -164,9 +164,14 @@ module RunLoop
164
164
  end
165
165
  end
166
166
 
167
- # Resets the simulator content and settings. It is analogous to touching
168
- # the menu item _for every simulator_, regardless of SDK.
167
+ # Resets the simulator content and settings.
169
168
  #
169
+ # In Xcode < 6, it is analogous to touching the menu item _for every
170
+ # simulator_, regardless of SDK.
171
+ #
172
+ # In Xcode 6, the default is the same; the content and settings for every
173
+ # simulator is erased. However, in Xcode 6 it is possible to pass
174
+ # a `:sim_udid` as a option to erase an individual simulator.
170
175
  #
171
176
  # On Xcode 5, it works by deleting the following directories:
172
177
  #
@@ -190,10 +195,13 @@ module RunLoop
190
195
  # gem features` that require the simulator be launched repeated and you are
191
196
  # tired of your editor losing focus. :) **NOTE:** This option is ignored
192
197
  # in Xcode 6.
198
+ # @option opts [String] :sim_udid (nil) The udid of the simulator to reset.
199
+ # **NOTE:** This option is ignored in Xcode < 6.
193
200
  def reset_sim_content_and_settings(opts={})
194
201
  default_opts = {:post_quit_wait => 1.0,
195
202
  :post_launch_wait => 3.0,
196
- :hide_after => false}
203
+ :hide_after => false,
204
+ :sim_udid => nil}
197
205
  merged_opts = default_opts.merge(opts)
198
206
 
199
207
  quit_sim(merged_opts)
@@ -202,7 +210,7 @@ module RunLoop
202
210
  # Very bad things will happen. Unlike Xcode < 6, the re-launching the
203
211
  # simulator will _not_ recreate the SDK (aka Devices) directories.
204
212
  if xcode_version_gte_6?
205
- simctl_reset
213
+ simctl_reset(merged_opts[:sim_udid])
206
214
  else
207
215
  sim_lib_path = File.join(sim_app_support_dir, 'Library')
208
216
  FileUtils.rm_rf(sim_lib_path)
@@ -783,21 +791,20 @@ module RunLoop
783
791
  end
784
792
 
785
793
  # @!visibility private
786
- # Uses the `simctl erase` command to reset the content and settings on _all_
787
- # simulators.
788
- #
789
- # @todo Should this reset _every_ simulator or just the targeted simulator?
790
- # It is very slow to reset every simulator and if we are trying to respond
791
- # to RESET_BETWEEN_SCENARIOS we probably want to erase just the current
792
- # simulator.
794
+ # Uses the `simctl erase` command to reset a simulator content and settings.
795
+ # If no `sim_udid` is nil, _all_ simulators are reset.
793
796
  #
794
- # @note This is an Xcode 6 only method. Will raise an error if called on
797
+ # # @note This is an Xcode 6 only method. It will raise an error if called on
795
798
  # Xcode < 6.
796
799
  #
797
800
  # @note This method will quit the simulator.
798
801
  #
802
+ # @param [String] sim_udid The udid of the simulator that will be reset.
803
+ # If sim_udid is nil, _all_ simulators will be reset.
799
804
  # @raise [RuntimeError] If called on Xcode < 6.
800
- def simctl_reset
805
+ # @raise [RuntimeError] If `sim_udid` is not a valid simulator udid. Valid
806
+ # simulator udids are determined by calling `simctl list`.
807
+ def simctl_reset(sim_udid = nil)
801
808
  unless xcode_version_gte_6?
802
809
  raise RuntimeError, 'this method is only available on Xcode >= 6'
803
810
  end
@@ -805,19 +812,33 @@ module RunLoop
805
812
  quit_sim
806
813
 
807
814
  sim_details = sim_details(:udid)
808
- res = []
809
- sim_details.each_key do |key|
810
- cmd = "xcrun simctl erase #{key}"
811
- Open3.popen3(cmd) do |_, stdout, stderr, _|
815
+
816
+ simctl_erase = lambda { |udid|
817
+ cmd = "xcrun simctl erase #{udid}"
818
+ Open3.popen3(cmd) do |_, stdout, stderr, wait_thr|
812
819
  out = stdout.read.strip
813
820
  err = stderr.read.strip
814
821
  if ENV['DEBUG_UNIX_CALLS'] == '1'
815
822
  puts "#{cmd} => stdout: '#{out}' | stderr: '#{err}'"
816
823
  end
817
- res << err.empty?
824
+ wait_thr.value.success?
825
+ end
826
+ }
827
+
828
+ # Call erase on all simulators
829
+ if sim_udid.nil?
830
+ res = []
831
+ sim_details.each_key do |key|
832
+ res << simctl_erase.call(key)
833
+ end
834
+ res.all?
835
+ else
836
+ if sim_details[sim_udid]
837
+ simctl_erase.call(sim_udid)
838
+ else
839
+ raise "Could not find simulator with udid '#{sim_udid}'"
818
840
  end
819
841
  end
820
- res.all?
821
842
  end
822
843
 
823
844
  # @!visibility private
@@ -1,5 +1,5 @@
1
1
  module RunLoop
2
- VERSION = '1.0.3'
2
+ VERSION = '1.0.4'
3
3
 
4
4
  # A model of a software release version that can be used to compare two versions.
5
5
  #
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: run_loop
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karl Krukow
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-16 00:00:00.000000000 Z
11
+ date: 2014-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor