run_loop 1.2.8 → 1.2.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 253c24d7121ffc84824a1d3e7a5e3c79d14dfcd8
4
- data.tar.gz: d22bc4efbace3cbcd82e3ab023515984beff9618
3
+ metadata.gz: 2231305525deb7ff8eef39cab42f66a592e0618d
4
+ data.tar.gz: e02a550f4dfd50652a406e75ec7f8b5075393c7b
5
5
  SHA512:
6
- metadata.gz: 716a2225ff8d2ff978b28852d803c84ba97ac05a75a0ce74a714f910ef35317f9322f4818c8812f88b72bafcda6542e3df1a82c87dfe73137e8737a687aeb61f
7
- data.tar.gz: 2750db0951ae73dd859fac716b138ffd02972e42f2e1aec600f9faf4bb10addf7e19d334488fed3f59f3476aacbbb87f080bf8eca81a4263166fa2f3c58262e6
6
+ metadata.gz: f2e693f21f81754350213e4e331d5c400639d59ce135b1c63419f1e6cc585bbdf1af916b09f49ae83bee725b5b6b62ff911a9bfc26541d1ebffc23eb0e1598f4
7
+ data.tar.gz: 11c87e9d511a1e1ece647b493a24c604c0916d50f302166d80dbc126d92aa70b42eb1c7078ae90beaa0e1354c62c8b93d03cf59d08dbb4b8c75e5735bdf49615
data/lib/run_loop/core.rb CHANGED
@@ -178,15 +178,12 @@ module RunLoop
178
178
  end
179
179
 
180
180
  # Compute udid and bundle_dir / bundle_id from options and target depending on Xcode version
181
- udid, bundle_dir_or_bundle_id = udid_and_bundle_for_launcher(device_target, options, xctools)
181
+ udid, bundle_dir_or_bundle_id = self.udid_and_bundle_for_launcher(device_target, options, sim_control)
182
182
 
183
183
  args = options.fetch(:args, [])
184
184
 
185
185
  log_file ||= File.join(results_dir, 'run_loop.out')
186
186
 
187
- after = Time.now
188
- RunLoop::Logging.log_debug(logger, "Preparation took #{after-before} seconds")
189
-
190
187
  discovered_options =
191
188
  {
192
189
  :udid => udid,
@@ -226,7 +223,10 @@ module RunLoop
226
223
  :log_file => log_file,
227
224
  :results_dir => results_dir}
228
225
 
229
- uia_timeout = options[:uia_timeout] || (ENV['UIA_TIMEOUT'] && ENV['UIA_TIMEOUT'].to_f) || 10
226
+ uia_timeout = options[:uia_timeout] || RunLoop::Environment.uia_timeout || 10
227
+
228
+ after = Time.now
229
+ RunLoop::Logging.log_debug(logger, "Preparation took #{after-before} seconds")
230
230
 
231
231
  before = Time.now
232
232
  begin
@@ -355,8 +355,10 @@ module RunLoop
355
355
  end
356
356
  end
357
357
 
358
- def self.udid_and_bundle_for_launcher(device_target, options, xctools=RunLoop::XCTools.new)
359
- bundle_dir_or_bundle_id = options[:app] || ENV['BUNDLE_ID']|| ENV['APP_BUNDLE_PATH'] || ENV['APP']
358
+ def self.udid_and_bundle_for_launcher(device_target, options, sim_control=RunLoop::SimControl.new)
359
+ xctools = sim_control.xctools
360
+
361
+ bundle_dir_or_bundle_id = options[:app] || RunLoop::Environment.bundle_id || RunLoop::Environment.path_to_app_bundle
360
362
 
361
363
  unless bundle_dir_or_bundle_id
362
364
  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)'
@@ -370,7 +372,7 @@ module RunLoop
370
372
  end
371
373
  udid = device_target
372
374
 
373
- unless /simulator/i.match(device_target)
375
+ unless self.simulator_target?(options, sim_control)
374
376
  bundle_dir_or_bundle_id = options[:bundle_id] if options[:bundle_id]
375
377
  end
376
378
  else
@@ -474,6 +476,8 @@ module RunLoop
474
476
  end
475
477
 
476
478
  def self.read_response(run_loop, expected_index, empty_file_timeout=10, search_for_property='index')
479
+ debug_read = RunLoop::Environment.debug_read?
480
+
477
481
  log_file = run_loop[:log_file]
478
482
  initial_offset = run_loop[:initial_offset] || 0
479
483
  offset = initial_offset
@@ -499,7 +503,7 @@ module RunLoop
499
503
  raise RunLoop::TimeoutError.new('Exception while running script')
500
504
  end
501
505
  index_if_found = output.index(START_DELIMITER)
502
- if ENV['DEBUG_READ']=='1'
506
+ if debug_read
503
507
  puts output.gsub('*', '')
504
508
  puts "Size #{size}"
505
509
  puts "offset #{offset}"
@@ -521,7 +525,7 @@ module RunLoop
521
525
  json = rest[0..index_of_json]
522
526
 
523
527
 
524
- if ENV['DEBUG_READ']=='1'
528
+ if debug_read
525
529
  puts "Index #{index_if_found}, Size: #{size} Offset #{offset}"
526
530
 
527
531
  puts ("parse #{json}")
@@ -529,7 +533,7 @@ module RunLoop
529
533
 
530
534
  offset = offset + json.size
531
535
  parsed_result = JSON.parse(json)
532
- if ENV['DEBUG_READ']=='1'
536
+ if debug_read
533
537
  p parsed_result
534
538
  end
535
539
  json_index_if_present = parsed_result[search_for_property]
@@ -552,7 +556,7 @@ module RunLoop
552
556
  RunLoop::Instruments.new.instruments_pids(&block)
553
557
  end
554
558
 
555
- def self.automation_template(xctools, candidate = ENV['TRACE_TEMPLATE'])
559
+ def self.automation_template(xctools, candidate = RunLoop::Environment.trace_template)
556
560
  unless candidate && File.exist?(candidate)
557
561
  candidate = default_tracetemplate xctools
558
562
  end
@@ -12,8 +12,51 @@ module RunLoop
12
12
  ENV['DEBUG'] == '1'
13
13
  end
14
14
 
15
+ # Returns true if read debugging is enabled.
16
+ def self.debug_read?
17
+ ENV['DEBUG_READ'] == '1'
18
+ end
19
+
20
+ # Returns true if we are running on the XTC
15
21
  def self.xtc?
16
22
  ENV['XAMARIN_TEST_CLOUD'] == '1'
17
23
  end
24
+
25
+ # Returns the value of TRACE_TEMPLATE; the Instruments template to use
26
+ # during testing.
27
+ def self.trace_template
28
+ ENV['TRACE_TEMPLATE']
29
+ end
30
+
31
+ # Returns the value of UIA_TIMEOUT. Use this control how long to wait
32
+ # for instruments to launch and attach to your application.
33
+ #
34
+ # Non-empty values are converted to a float.
35
+ def self.uia_timeout
36
+ timeout = ENV['UIA_TIMEOUT']
37
+ timeout ? timeout.to_f : nil
38
+ end
39
+
40
+ # Returns the value of BUNDLE_ID
41
+ def self.bundle_id
42
+ ENV['BUNDLE_ID']
43
+ end
44
+
45
+ # Returns to the path to the app bundle (simulator builds).
46
+ #
47
+ # Both APP_BUNDLE_PATH and APP are checked and in that order.
48
+ #
49
+ # Use of APP_BUNDLE_PATH is deprecated and will be removed.
50
+ def self.path_to_app_bundle
51
+ ENV['APP_BUNDLE_PATH'] || ENV['APP']
52
+ end
53
+
54
+ # Returns the value of DEVELOPER_DIR
55
+ #
56
+ # @note Never call this directly. Always create an XCTool instance
57
+ # and allow it to derive the path to the Xcode toolchain.
58
+ def self.developer_dir
59
+ ENV['DEVELOPER_DIR']
60
+ end
18
61
  end
19
62
  end
@@ -910,6 +910,7 @@ module RunLoop
910
910
  out = stdout.read.strip
911
911
  err = stderr.read.strip
912
912
  if ENV['DEBUG_UNIX_CALLS'] == '1'
913
+ cmd = "xcrun simctl erase #{udid}"
913
914
  puts "#{cmd} => stdout: '#{out}' | stderr: '#{err}'"
914
915
  end
915
916
  wait_thr.value.success?
@@ -986,17 +987,19 @@ module RunLoop
986
987
  # base sdk version.
987
988
  # @see #simctl_list
988
989
  def simctl_list_devices
989
- cmd = 'xcrun simctl list devices'
990
- Open3.popen3(cmd) do |_, stdout, stderr, _|
990
+ args = 'simctl list devices'.split(' ')
991
+ Open3.popen3('xcrun', *args) do |_, stdout, stderr, _|
991
992
  out = stdout.read.strip
992
993
  err = stderr.read.strip
993
994
  if ENV['DEBUG_UNIX_CALLS'] == '1'
995
+ cmd = "xcrun #{args.join(' ')}"
994
996
  puts "#{cmd} => stdout: '#{out}' | stderr: '#{err}'"
995
997
  end
996
998
 
997
999
  current_sdk = nil
998
1000
  res = {}
999
1001
  out.split("\n").each do |line|
1002
+
1000
1003
  possible_sdk = line[/(\d\.\d(\.\d)?)/,0]
1001
1004
  if possible_sdk
1002
1005
  current_sdk = possible_sdk
@@ -1004,11 +1007,19 @@ module RunLoop
1004
1007
  next
1005
1008
  end
1006
1009
 
1010
+ unavailable_skd = line[/Unavailable/, 0]
1011
+ if unavailable_skd
1012
+ current_sdk = nil
1013
+ next
1014
+ end
1015
+
1007
1016
  if current_sdk
1008
- name = line.split('(').first.strip
1009
- udid = line[XCODE_6_SIM_UDID_REGEX,0]
1010
- state = line[/(Booted|Shutdown)/,0]
1011
- res[current_sdk] << {:name => name, :udid => udid, :state => state}
1017
+ unless line[/unavailable/,0]
1018
+ name = line.split('(').first.strip
1019
+ udid = line[XCODE_6_SIM_UDID_REGEX,0]
1020
+ state = line[/(Booted|Shutdown)/,0]
1021
+ res[current_sdk] << {:name => name, :udid => udid, :state => state}
1022
+ end
1012
1023
  end
1013
1024
  end
1014
1025
  res
@@ -1038,11 +1049,12 @@ module RunLoop
1038
1049
  def simctl_list_runtimes
1039
1050
  # The 'com.apple.CoreSimulator.SimRuntime.iOS-7-0' is the runtime-id,
1040
1051
  # which can be used to create devices.
1041
- cmd = 'xcrun simctl list runtimes'
1042
- Open3.popen3(cmd) do |_, stdout, stderr, _|
1052
+ args = 'simctl list runtimes'.split(' ')
1053
+ Open3.popen3('xcrun', *args) do |_, stdout, stderr, _|
1043
1054
  out = stdout.read.strip
1044
1055
  err = stderr.read.strip
1045
1056
  if ENV['DEBUG_UNIX_CALLS'] == '1'
1057
+ cmd = "xcrun #{args.join(' ')}"
1046
1058
  puts "#{cmd} => stdout: '#{out}' | stderr: '#{err}'"
1047
1059
  end
1048
1060
  # Ex.
@@ -1,5 +1,5 @@
1
1
  module RunLoop
2
- VERSION = '1.2.8'
2
+ VERSION = '1.2.9'
3
3
 
4
4
  # A model of a software release version that can be used to compare two versions.
5
5
  #
@@ -125,8 +125,8 @@ module RunLoop
125
125
  # @return [String] path to current developer directory
126
126
  def xcode_developer_dir
127
127
  @xcode_developer_dir ||=
128
- if ENV['DEVELOPER_DIR']
129
- ENV['DEVELOPER_DIR']
128
+ if RunLoop::Environment.developer_dir
129
+ RunLoop::Environment.developer_dir
130
130
  else
131
131
  # fall back to xcode-select
132
132
  `xcode-select --print-path`.chomp
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.2.8
4
+ version: 1.2.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karl Krukow
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-06 00:00:00.000000000 Z
11
+ date: 2015-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -255,7 +255,6 @@ files:
255
255
  - lib/run_loop/simctl/bridge.rb
256
256
  - lib/run_loop/version.rb
257
257
  - lib/run_loop/xctools.rb
258
- - scripts/calabash-uia-min.js
259
258
  - scripts/calabash.lldb.erb
260
259
  - scripts/calabash_script_uia.js
261
260
  - scripts/json2-min.js
@@ -288,7 +287,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
288
287
  version: '0'
289
288
  requirements: []
290
289
  rubyforge_project:
291
- rubygems_version: 2.2.2
290
+ rubygems_version: 2.4.5
292
291
  signing_key:
293
292
  specification_version: 4
294
293
  summary: Tools related to running Calabash iOS tests
@@ -1,7 +0,0 @@
1
- (function(){function m(){return h.frontMostApp()}function r(){return m().mainWindow()}function s(){return m().windows().toArray()}function n(){return m().keyboard()}function l(a,c){this.reason=a;this.a=c||"";this.message=this.toString()}function k(a){return!a||a instanceof UIAElementNil}function t(a,c){var b=c||[],e,d;if(k(a))return b;e=a.elements();for(var f=0,g=e.length;f<g;f+=1)d=e[f],b.push(d),t(d,b);return b}function q(a,c){for(var b=0,e=c.length;b<e;b+=1)a.push(c[b])}function u(a,c){var b=[];
2
- if(k(c))return b;c instanceof this[a]&&b.push(c);for(var e=c.elements(),d=0,f=e.length;d<f;d+=1)q(b,u(a,e[d]));return b}function x(a,c){var b=null;if(a instanceof Array){if(3===a.length){var e=a[0],b=a[1],d=a[2];if("string"==typeof d)if(-1==d.indexOf("'"))d="'"+d+"'";else if(-1==d.indexOf('"'))d='"'+d+'"';else throw new l("Escaping for filters not supported yet.");b=c.withPredicate(e+" "+b+" "+d);return!k(b)}return!1}for(e in a)if(a.hasOwnProperty(e))if(b=a[e],"marked"==e){if(c.name()!=b&&c.label()!=
3
- b&&(!c.value||c.value!=b))return!1}else if(b=c.withValueForKey(b,e),k(b))return!1;return!0}function v(a,c){if(c(a))return a;var b,e;if(k(a))return null;b=a.elements();for(var d=0,f=b.length;d<f;d+=1)if(e=b[d],v(e,c))return e;return null}function w(a){h.delay(a);return h}var g={},h=UIATarget.localTarget();h.setTimeout(0);l.prototype=error();l.prototype.toString=function(){var a="UIAutomationError[reason="+this.reason;0<this.a.length&&(a+=", details="+this.a);return a+"]"};g.sleep=w;g.query=function(a,
4
- c){if(!c)return g.query(a,s());c instanceof UIAElement&&(c=[c]);var b=c,e=null,d=null,f=[],p,h,k,l;p=0;for(k=a.length;p<k;p+=1){e=a[p];h=0;for(l=b.length;h<l;h+=1)d=b[h],"string"===typeof e?"*"===e||"view"==e||"UIAElement"===e?q(f,t(d,[d])):q(f,u(e,d)):x(e,d)&&f.push(d);b=f;f=[]}return b};g.keyboard_visible=function(){return!k(n())};g.keyboard_enter_text=function(a,c){if(!g.keyboard_visible())throw new l("Keyboard not visible");c=c||{};if(c.unsafe)return n().typeString(a),!0;var b=v(r(),function(a){return 1==
5
- a.hasKeyboardFocus()});if(k(b))return n().typeString(a),!0;var e=c.initial_text||"",d=new Date,f=c.timeout||60,h=n();do try{return h.typeString(a),!0}catch(m){UIALogger.logMessage("keyboard_enter_text failed: "+m),UIALogger.logMessage("keyboard_enter_text retrying with restore to: "+e),b.setValue(e)}while(!(new Date-d>=1E3*f));throw new l("Unable to enter text","text: "+a+" failed after retrying for "+f);};g.deactivate=function(a){h.deactivateAppForDuration(a)};g.tap_offset=function(a,c,b){b=b||{};
6
- return b.unsafe?function(){return c.apply(this,arguments)}:function(){var e=new Date,d=b.timeout||60,f=b.frequency||.1;do try{return c.apply(this,arguments)}catch(g){UIALogger.logMessage(a+"Error: "+g+". Arguments: "+arguments[0]+", "+arguments[1]),w(f)}while(!(new Date-e>=1E3*d));throw new l(a,"Arguments: "+arguments[0]+", "+arguments[1]);}}("tap_offset failed",function(a,c){h.tapWithOptions(a,c||{})},{timeout:60,frequency:.5});this.target=h;this.uia=g;g.app=m;g.window=r;g.windows=s;g.keyboard=n;
7
- g.alert=function(){return m().alert()}})();