run_loop 1.0.5 → 1.0.6

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: cccd2b346e9cf04b773256ff464776244f9f0cf3
4
- data.tar.gz: 5671b7936e49ab9fdf2d4b01d1dd4bf4c88436b2
3
+ metadata.gz: 554b2d4bd16ba7167682bbf0fed420a025891bd5
4
+ data.tar.gz: 007adf5ed0d635d2dc992061fe0d88e3c155bd18
5
5
  SHA512:
6
- metadata.gz: 04783915dfab3e7f116577d755d3ff259d065de769fa24de9c6bea21c269914ecbb67e1a9f713e236a0b6ae21a95769af89da95db8613a9c14665dfbdcecd7de
7
- data.tar.gz: 5860bc671dc8ea4a89f8fcf4446feb2d0b083253e2ef0e7ce629069c7c1aee28f560e53fe20174b99c63b9bd0e9df7e35568cc60c3c2ed82115075287de45a20
6
+ metadata.gz: e0b0cdf8084fe02fa929eeff7dc5d995ea8d1083479705e4147aa90b600102b73302922090be7f3f03b9bddb694f49dcd2e2b0f7f96c565d4a710336eae088d8
7
+ data.tar.gz: 08c478594dcd4d7bfaccec0217ff38c68e10e1346ff60bf6fc3c1c10ef43cad6c8d897a9b6a5314a5065c69931b1288124010f96f82682513c17f99afc7624a6
data/lib/run_loop.rb CHANGED
@@ -4,3 +4,4 @@ require 'run_loop/xctools'
4
4
  require 'run_loop/plist_buddy'
5
5
  require 'run_loop/sim_control'
6
6
  require 'run_loop/device'
7
+ require 'run_loop/instruments'
data/lib/run_loop/core.rb CHANGED
@@ -84,11 +84,12 @@ module RunLoop
84
84
 
85
85
  def self.run_with_options(options)
86
86
  before = Time.now
87
- ensure_instruments_not_running!
88
87
 
89
88
  sim_control ||= options[:sim_control] || RunLoop::SimControl.new
90
89
  xctools ||= options[:xctools] || sim_control.xctools
91
90
 
91
+ RunLoop::Instruments.new.kill_instruments(xctools)
92
+
92
93
  if self.simulator_target?(options, sim_control)
93
94
  # @todo only enable accessibility on the targeted simulator
94
95
  sim_control.enable_accessibility_on_sims({:verbose => true})
@@ -505,20 +506,9 @@ module RunLoop
505
506
 
506
507
  end
507
508
 
509
+ # @deprecated 1.0.5
508
510
  def self.pids_for_run_loop(run_loop, &block)
509
- results_dir = run_loop[:results_dir]
510
- udid = run_loop[:udid]
511
- instruments_prefix = instruments_command_prefix(udid, results_dir)
512
-
513
- pids_str = `ps x -o pid,command | grep -v grep | grep "#{instruments_prefix.gsub(%Q["], %Q[\\"])}" | awk '{printf "%s,", $1}'`
514
- pids = pids_str.split(',').map { |pid| pid.to_i }
515
- if block_given?
516
- pids.each do |pid|
517
- block.call(pid)
518
- end
519
- else
520
- pids
521
- end
511
+ RunLoop::Instruments.new.instruments_pids(&block)
522
512
  end
523
513
 
524
514
  def self.instruments_command_prefix(udid, results_dir_trace)
@@ -591,22 +581,18 @@ module RunLoop
591
581
  end
592
582
  end
593
583
 
584
+ # @deprecated 1.0.5
594
585
  def self.ensure_instruments_not_running!
595
- instruments_pids.each do |pid|
596
- if ENV['DEBUG']=='1'
597
- puts "Found instruments #{pid}. Killing..."
598
- end
599
- `kill -9 #{pid} && wait #{pid} &> /dev/null`
600
- end
586
+ RunLoop::Instruments.new.kill_instruments
601
587
  end
602
588
 
603
589
  def self.instruments_running?
604
- instruments_pids.size > 0
590
+ RunLoop::Instruments.new.instruments_running?
605
591
  end
606
592
 
593
+ # @deprecated 1.0.5
607
594
  def self.instruments_pids
608
- pids_str = `ps x -o pid,command | grep -v grep | grep "instruments" | awk '{printf "%s,", $1}'`.strip
609
- pids_str.split(',').map { |pid| pid.to_i }
595
+ RunLoop::Instruments.new.instruments_pids
610
596
  end
611
597
 
612
598
  # @todo This is a WIP
@@ -700,17 +686,11 @@ module RunLoop
700
686
  def self.stop(run_loop, out=Dir.pwd)
701
687
  return if run_loop.nil?
702
688
  results_dir = run_loop[:results_dir]
703
-
704
689
  dest = out
705
690
 
706
-
707
- Core.pids_for_run_loop(run_loop) do |pid|
708
- Process.kill('TERM', pid.to_i)
709
- end
710
-
691
+ RunLoop::Instruments.new.kill_instruments
711
692
 
712
693
  FileUtils.mkdir_p(dest)
713
-
714
694
  if results_dir
715
695
  pngs = Dir.glob(File.join(results_dir, 'Run 1', '*.png'))
716
696
  else
@@ -0,0 +1,57 @@
1
+ module RunLoop
2
+
3
+ # A class for interacting with the instruments command-line tool
4
+ #
5
+ # @note All instruments commands are run in the context of `xcrun`.
6
+ #
7
+ # @todo Detect Instruments.app is running and pop an alert.
8
+ # @todo Needs tests.
9
+ class Instruments
10
+
11
+ # @!visibility private
12
+ # $ ps x -o pid,command | grep -v grep | grep instruments
13
+ # 98081 sh -c xcrun instruments -w "43be3f89d9587e9468c24672777ff6241bd91124" < args >
14
+ # 98082 /Xcode/6.0.1/Xcode.app/Contents/Developer/usr/bin/instruments -w < args >
15
+ FIND_PIDS_CMD = 'ps x -o pid,comm | grep -v grep | grep instruments'
16
+
17
+ def grep_for_instruments_pids
18
+ ps_output = `#{FIND_PIDS_CMD}`.strip
19
+ lines = ps_output.lines("\n").map { |line| line.strip }
20
+ lines.map do |line|
21
+ tokens = line.strip.split(' ').map { |token| token.strip }
22
+ pid = tokens.fetch(0, nil)
23
+ process = tokens.fetch(1, nil)
24
+ if process and process[/\/usr\/bin\/instruments/, 0]
25
+ pid.to_i
26
+ else
27
+ nil
28
+ end
29
+ end.compact
30
+ end
31
+
32
+ def instruments_pids(&block)
33
+ pids = grep_for_instruments_pids
34
+ if block_given?
35
+ pids.each do |pid|
36
+ block.call(pid)
37
+ end
38
+ else
39
+ pids
40
+ end
41
+ end
42
+
43
+ def instruments_running?
44
+ instruments_pids.count > 0
45
+ end
46
+
47
+ def kill_instruments(xcode_tools = RunLoop::XCTools.new)
48
+ kill_signal = xcode_tools.xcode_version_gte_6? ? 'QUIT' : 'TERM'
49
+ instruments_pids do |pid|
50
+ if ENV['DEBUG'] == '1'
51
+ puts "Sending '#{kill_signal}' to instruments process '#{pid}'"
52
+ end
53
+ Process.kill(kill_signal, pid.to_i)
54
+ end
55
+ end
56
+ end
57
+ end
@@ -1,5 +1,5 @@
1
1
  module RunLoop
2
- VERSION = '1.0.5'
2
+ VERSION = '1.0.6'
3
3
 
4
4
  # A model of a software release version that can be used to compare two versions.
5
5
  #
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: run_loop
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karl Krukow
@@ -14,182 +14,182 @@ dependencies:
14
14
  name: thor
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0.18'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.18'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: json
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.8'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.8'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: retriable
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: 1.3.3.1
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: 1.3.3.1
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: awesome_print
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: 1.2.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: 1.2.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: CFPropertyList
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: '2.2'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '2.2'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: bundler
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ~>
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
89
  version: '1.6'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ~>
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '1.6'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: travis
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ~>
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
103
  version: '1.7'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ~>
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '1.7'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rspec
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ~>
115
+ - - "~>"
116
116
  - !ruby/object:Gem::Version
117
117
  version: '3.0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ~>
122
+ - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: '3.0'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: rake
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - ~>
129
+ - - "~>"
130
130
  - !ruby/object:Gem::Version
131
131
  version: '10.3'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - ~>
136
+ - - "~>"
137
137
  - !ruby/object:Gem::Version
138
138
  version: '10.3'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: guard-rspec
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - ~>
143
+ - - "~>"
144
144
  - !ruby/object:Gem::Version
145
145
  version: '4.3'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - ~>
150
+ - - "~>"
151
151
  - !ruby/object:Gem::Version
152
152
  version: '4.3'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: guard-bundler
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
- - - ~>
157
+ - - "~>"
158
158
  - !ruby/object:Gem::Version
159
159
  version: '2.0'
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
- - - ~>
164
+ - - "~>"
165
165
  - !ruby/object:Gem::Version
166
166
  version: '2.0'
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: growl
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
- - - ~>
171
+ - - "~>"
172
172
  - !ruby/object:Gem::Version
173
173
  version: '1.0'
174
174
  type: :development
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
- - - ~>
178
+ - - "~>"
179
179
  - !ruby/object:Gem::Version
180
180
  version: '1.0'
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: rb-readline
183
183
  requirement: !ruby/object:Gem::Requirement
184
184
  requirements:
185
- - - ~>
185
+ - - "~>"
186
186
  - !ruby/object:Gem::Version
187
187
  version: '0.5'
188
188
  type: :development
189
189
  prerelease: false
190
190
  version_requirements: !ruby/object:Gem::Requirement
191
191
  requirements:
192
- - - ~>
192
+ - - "~>"
193
193
  - !ruby/object:Gem::Version
194
194
  version: '0.5'
195
195
  description: calabash-cucumber drives tests for native iOS apps. RunLoop provides
@@ -207,11 +207,11 @@ files:
207
207
  - lib/run_loop/cli.rb
208
208
  - lib/run_loop/core.rb
209
209
  - lib/run_loop/device.rb
210
+ - lib/run_loop/instruments.rb
210
211
  - lib/run_loop/plist_buddy.rb
211
212
  - lib/run_loop/sim_control.rb
212
213
  - lib/run_loop/version.rb
213
214
  - lib/run_loop/xctools.rb
214
- - scripts/calabash-uia-min.js
215
215
  - scripts/calabash.lldb.erb
216
216
  - scripts/calabash_script_uia.js
217
217
  - scripts/json2-min.js
@@ -232,17 +232,17 @@ require_paths:
232
232
  - lib
233
233
  required_ruby_version: !ruby/object:Gem::Requirement
234
234
  requirements:
235
- - - '>='
235
+ - - ">="
236
236
  - !ruby/object:Gem::Version
237
237
  version: '1.9'
238
238
  required_rubygems_version: !ruby/object:Gem::Requirement
239
239
  requirements:
240
- - - '>='
240
+ - - ">="
241
241
  - !ruby/object:Gem::Version
242
242
  version: '0'
243
243
  requirements: []
244
244
  rubyforge_project:
245
- rubygems_version: 2.4.1
245
+ rubygems_version: 2.3.0
246
246
  signing_key:
247
247
  specification_version: 4
248
248
  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()}})();