run_loop 0.0.8 → 0.0.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.
- data/lib/run_loop/core.rb +19 -15
- data/lib/run_loop/version.rb +1 -1
- metadata +2 -2
data/lib/run_loop/core.rb
CHANGED
@@ -30,6 +30,7 @@ module RunLoop
|
|
30
30
|
def self.run_with_options(options)
|
31
31
|
|
32
32
|
device = options[:device] || :iphone
|
33
|
+
udid = options[:udid]
|
33
34
|
|
34
35
|
|
35
36
|
results_dir = options[:results_dir] || Dir.mktmpdir("run_loop")
|
@@ -74,7 +75,6 @@ module RunLoop
|
|
74
75
|
system("#{plistbuddy} -c 'Add :UIDeviceFamily array' '#{plistfile}'")
|
75
76
|
system("#{plistbuddy} -c 'Add :UIDeviceFamily:0 integer #{uidevicefamily}' '#{plistfile}'")
|
76
77
|
else
|
77
|
-
udid = options[:udid]
|
78
78
|
unless udid
|
79
79
|
begin
|
80
80
|
Timeout::timeout(3, TimeoutError) do
|
@@ -109,7 +109,7 @@ module RunLoop
|
|
109
109
|
f.write pid
|
110
110
|
end
|
111
111
|
|
112
|
-
run_loop = {:pid => pid, :repl_path => repl_path, :log_file => log_file, :results_dir => results_dir}
|
112
|
+
run_loop = {:pid => pid, :udid => udid, :app => bundle_dir_or_bundle_id, :repl_path => repl_path, :log_file => log_file, :results_dir => results_dir}
|
113
113
|
|
114
114
|
#read_response(run_loop,0)
|
115
115
|
begin
|
@@ -203,7 +203,11 @@ module RunLoop
|
|
203
203
|
end
|
204
204
|
|
205
205
|
def self.pids_for_run_loop(run_loop, &block)
|
206
|
-
|
206
|
+
results_dir = run_loop[:results_dir]
|
207
|
+
udid = run_loop[:udid]
|
208
|
+
instruments_prefix = instruments_command_prefix(udid, results_dir)
|
209
|
+
|
210
|
+
pids_str = `ps x -o pid,command | grep -v grep | grep "#{instruments_prefix}" | awk '{printf "%s,", $1}'`
|
207
211
|
pids = pids_str.split(",").map { |pid| pid.to_i }
|
208
212
|
if block_given?
|
209
213
|
pids.each do |pid|
|
@@ -214,22 +218,27 @@ module RunLoop
|
|
214
218
|
end
|
215
219
|
end
|
216
220
|
|
217
|
-
|
218
|
-
def self.instruments_command(udid, results_dir_trace, bundle_dir_or_bundle_id, results_dir, script, log_file)
|
221
|
+
def self.instruments_command_prefix(udid,results_dir_trace)
|
219
222
|
instruments_path = 'instruments'
|
220
223
|
if udid
|
221
224
|
instruments_path = "#{instruments_path} -w #{udid}"
|
222
225
|
end
|
226
|
+
instruments_path << " -D \"#{results_dir_trace}\""
|
227
|
+
instruments_path
|
228
|
+
end
|
229
|
+
|
230
|
+
|
231
|
+
def self.instruments_command(udid, results_dir_trace, bundle_dir_or_bundle_id, results_dir, script, log_file)
|
232
|
+
instruments_prefix = instruments_command_prefix(udid, results_dir_trace)
|
223
233
|
cmd = [
|
224
|
-
|
225
|
-
"-D", results_dir_trace,
|
234
|
+
instruments_prefix,
|
226
235
|
"-t", automation_template,
|
227
236
|
"\"#{bundle_dir_or_bundle_id}\"",
|
228
237
|
"-e", "UIARESULTSPATH", results_dir,
|
229
238
|
"-e", "UIASCRIPT", script
|
230
239
|
]
|
231
240
|
if log_file
|
232
|
-
|
241
|
+
cmd << "&> #{log_file}"
|
233
242
|
end
|
234
243
|
cmd
|
235
244
|
end
|
@@ -287,26 +296,21 @@ module RunLoop
|
|
287
296
|
|
288
297
|
def self.stop(run_loop, out=Dir.pwd)
|
289
298
|
results_dir = run_loop[:results_dir]
|
299
|
+
udid = run_loop[:udid]
|
300
|
+
instruments_prefix = Core.instruments_command_prefix(udid, results_dir)
|
290
301
|
pid = run_loop[:pid] || IO.read(File.join(results_dir, "run_loop.pid"))
|
291
302
|
dest = out
|
292
303
|
|
293
|
-
if pid
|
294
|
-
Process.kill('TERM', pid.to_i)
|
295
|
-
end
|
296
|
-
|
297
304
|
Core.pids_for_run_loop(run_loop) do |pid|
|
298
305
|
Process.kill('TERM', pid.to_i)
|
299
306
|
end
|
300
307
|
|
301
|
-
sleep(1)
|
302
|
-
|
303
308
|
FileUtils.mkdir_p(dest)
|
304
309
|
pngs = Dir.glob(File.join(results_dir, "Run 1", "*.png"))
|
305
310
|
FileUtils.cp(pngs, dest) if pngs and pngs.length > 0
|
306
311
|
end
|
307
312
|
|
308
313
|
|
309
|
-
|
310
314
|
def self.validate_script(options)
|
311
315
|
script = options[:script]
|
312
316
|
if script
|
data/lib/run_loop/version.rb
CHANGED
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: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-04-
|
12
|
+
date: 2013-04-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|