run_loop 0.0.19 → 0.0.20
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 +4 -4
- data/lib/run_loop/core.rb +64 -26
- data/lib/run_loop/version.rb +1 -1
- data/scripts/calabash_script_uia.js +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be6623163af4dc2e54253b91dc9ac4009576ae25
|
4
|
+
data.tar.gz: 922198cf53cf9177a755e22468b4c857e486f520
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd0b3bd9704d93aa20438ffb7d39f402f2dc5406186f0f31c4ea04c4c88d09562670f8d700d6e6d85d24d3e2d4225c492178431e95bba8b728d926da67b5caea
|
7
|
+
data.tar.gz: 6aeb1107fd78c2f4bb2fe2c0bc155571cb0637bfe75bcb06022b51247f7ba4b5e574d1883a64e2f2e253e27a43710ce66c61abc1b39c8c81e94619a527fe4bcc
|
data/lib/run_loop/core.rb
CHANGED
@@ -30,16 +30,28 @@ module RunLoop
|
|
30
30
|
File.join(scripts_path, SCRIPTS[key])
|
31
31
|
end
|
32
32
|
|
33
|
+
def self.detect_connected_device
|
34
|
+
begin
|
35
|
+
Timeout::timeout(1, TimeoutError) do
|
36
|
+
return `#{File.join(scripts_path, 'udidetect')}`.chomp
|
37
|
+
end
|
38
|
+
rescue TimeoutError => e
|
39
|
+
`killall udidetect &> /dev/null`
|
40
|
+
end
|
41
|
+
nil
|
42
|
+
end
|
43
|
+
|
33
44
|
def self.run_with_options(options)
|
45
|
+
before = Time.now
|
34
46
|
ensure_instruments_not_running!
|
35
47
|
|
36
|
-
|
37
|
-
|
38
|
-
|
48
|
+
device_target = options[:udid] || options[:device_target] || detect_connected_device || 'simulator'
|
49
|
+
if device_target && device_target.to_s.downcase == 'device'
|
50
|
+
device_target = detect_connected_device
|
51
|
+
end
|
39
52
|
|
40
53
|
log_file = options[:log_path]
|
41
|
-
|
42
|
-
|
54
|
+
timeout = options[:timeout] || 15
|
43
55
|
|
44
56
|
results_dir = options[:results_dir] || Dir.mktmpdir("run_loop")
|
45
57
|
results_dir_trace = File.join(results_dir, "trace")
|
@@ -64,15 +76,25 @@ module RunLoop
|
|
64
76
|
File.open(script, "w") { |file| file.puts code }
|
65
77
|
|
66
78
|
|
67
|
-
bundle_dir_or_bundle_id = options[:app] || ENV['BUNDLE_ID']|| ENV['APP_BUNDLE_PATH']
|
79
|
+
bundle_dir_or_bundle_id = options[:app] || ENV['BUNDLE_ID']|| ENV['APP_BUNDLE_PATH'] || ENV['APP']
|
68
80
|
|
69
81
|
unless bundle_dir_or_bundle_id
|
70
|
-
raise 'key :app or environment variable APP_BUNDLE_PATH or
|
82
|
+
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)'
|
71
83
|
end
|
72
84
|
|
73
|
-
|
74
|
-
|
75
|
-
|
85
|
+
|
86
|
+
udid = nil
|
87
|
+
|
88
|
+
if device_target == 'simulator'
|
89
|
+
|
90
|
+
unless File.exist?(bundle_dir_or_bundle_id)
|
91
|
+
raise "Unable to find app in directory #{bundle_dir_or_bundle_id} when trying to launch simulator"
|
92
|
+
end
|
93
|
+
|
94
|
+
|
95
|
+
device = options[:device] || :iphone
|
96
|
+
device = device && device.to_sym
|
97
|
+
|
76
98
|
plistbuddy="/usr/libexec/PlistBuddy"
|
77
99
|
plistfile="#{bundle_dir_or_bundle_id}/Info.plist"
|
78
100
|
if device == :iphone
|
@@ -84,27 +106,33 @@ module RunLoop
|
|
84
106
|
system("#{plistbuddy} -c 'Add :UIDeviceFamily array' '#{plistfile}'")
|
85
107
|
system("#{plistbuddy} -c 'Add :UIDeviceFamily:0 integer #{uidevicefamily}' '#{plistfile}'")
|
86
108
|
else
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
udid = `#{File.join(scripts_path, 'udidetect')}`.chomp
|
91
|
-
end
|
92
|
-
rescue TimeoutError => e
|
109
|
+
udid = device_target
|
110
|
+
bundle_dir_or_bundle_id = options[:bundle_id] if options[:bundle_id]
|
111
|
+
end
|
93
112
|
|
94
|
-
|
95
|
-
unless udid
|
96
|
-
raise "Unable to find connected device."
|
97
|
-
end
|
98
|
-
end
|
113
|
+
log_file ||= File.join(results_dir, 'run_loop.out')
|
99
114
|
|
115
|
+
if ENV['DEBUG']=='1'
|
116
|
+
p options
|
117
|
+
puts "device_target=#{device_target}"
|
118
|
+
puts "udid=#{udid}"
|
119
|
+
puts "bundle_dir_or_bundle_id=#{bundle_dir_or_bundle_id}"
|
120
|
+
puts "script=#{script}"
|
121
|
+
puts "log_file=#{log_file}"
|
100
122
|
end
|
101
123
|
|
102
|
-
|
124
|
+
after = Time.now
|
125
|
+
|
126
|
+
if ENV['DEBUG']=='1'
|
127
|
+
puts "Preparation took #{after-before} seconds"
|
128
|
+
|
129
|
+
end
|
103
130
|
|
104
131
|
cmd = instruments_command(udid, results_dir_trace, bundle_dir_or_bundle_id, results_dir, script, log_file)
|
105
132
|
|
133
|
+
|
106
134
|
pid = fork do
|
107
|
-
log_header("Starting App: #{bundle_dir_or_bundle_id}")
|
135
|
+
log_header("Starting on #{device_target} App: #{bundle_dir_or_bundle_id}")
|
108
136
|
cmd_str = cmd.join(" ")
|
109
137
|
if ENV['DEBUG']
|
110
138
|
log(cmd_str)
|
@@ -121,6 +149,7 @@ module RunLoop
|
|
121
149
|
run_loop = {:pid => pid, :udid => udid, :app => bundle_dir_or_bundle_id, :repl_path => repl_path, :log_file => log_file, :results_dir => results_dir}
|
122
150
|
|
123
151
|
#read_response(run_loop,0)
|
152
|
+
before = Time.now
|
124
153
|
begin
|
125
154
|
Timeout::timeout(timeout, TimeoutError) do
|
126
155
|
read_response(run_loop, 0)
|
@@ -129,6 +158,12 @@ module RunLoop
|
|
129
158
|
raise TimeoutError, "Time out waiting for UIAutomation run-loop to Start. \n Logfile #{log_file} \n #{File.read(log_file)}"
|
130
159
|
end
|
131
160
|
|
161
|
+
after = Time.now()
|
162
|
+
|
163
|
+
if ENV['DEBUG']=='1'
|
164
|
+
puts "Launching took #{after-before} seconds"
|
165
|
+
end
|
166
|
+
|
132
167
|
run_loop
|
133
168
|
end
|
134
169
|
|
@@ -158,6 +193,7 @@ module RunLoop
|
|
158
193
|
end
|
159
194
|
|
160
195
|
def self.read_response(run_loop, expected_index)
|
196
|
+
|
161
197
|
log_file = run_loop[:log_file]
|
162
198
|
initial_offset = run_loop[:initial_offset] || 0
|
163
199
|
offset = initial_offset
|
@@ -165,7 +201,7 @@ module RunLoop
|
|
165
201
|
result = nil
|
166
202
|
loop do
|
167
203
|
unless File.exist?(log_file) && File.size?(log_file)
|
168
|
-
sleep(0.
|
204
|
+
sleep(0.2)
|
169
205
|
next
|
170
206
|
end
|
171
207
|
|
@@ -288,8 +324,10 @@ module RunLoop
|
|
288
324
|
|
289
325
|
def self.ensure_instruments_not_running!
|
290
326
|
if instruments_running?
|
291
|
-
|
292
|
-
|
327
|
+
if ENV['DEBUG']=='1'
|
328
|
+
puts "Killing instruments"
|
329
|
+
end
|
330
|
+
`killall -9 instruments > /dev/null 2>&1`
|
293
331
|
end
|
294
332
|
end
|
295
333
|
|
data/lib/run_loop/version.rb
CHANGED
@@ -21677,10 +21677,10 @@ calabash_script.core.calculate_swipe_to_offset = function calculate_swipe_to_off
|
|
21677
21677
|
var base_movement = function() {
|
21678
21678
|
var G__2931 = (new cljs.core.Keyword("\ufdd0'direction")).call(null, options);
|
21679
21679
|
if(cljs.core._EQ_.call(null, "\ufdd0'down", G__2931)) {
|
21680
|
-
return cljs.core.ObjMap.fromObject(["\ufdd0'x", "\ufdd0'y"], {"\ufdd0'x":x + cljs.core.get_in.call(null, calabash_script.core.swipe_delta, cljs.core.PersistentVector.fromArray(["\ufdd0'vertical", "\ufdd0'dx"], true)), "\ufdd0'y":y
|
21680
|
+
return cljs.core.ObjMap.fromObject(["\ufdd0'x", "\ufdd0'y"], {"\ufdd0'x":x + cljs.core.get_in.call(null, calabash_script.core.swipe_delta, cljs.core.PersistentVector.fromArray(["\ufdd0'vertical", "\ufdd0'dx"], true)), "\ufdd0'y":y + cljs.core.get_in.call(null, calabash_script.core.swipe_delta, cljs.core.PersistentVector.fromArray(["\ufdd0'vertical", "\ufdd0'dy"], true))})
|
21681
21681
|
}else {
|
21682
21682
|
if(cljs.core._EQ_.call(null, "\ufdd0'up", G__2931)) {
|
21683
|
-
return cljs.core.ObjMap.fromObject(["\ufdd0'x", "\ufdd0'y"], {"\ufdd0'x":x + cljs.core.get_in.call(null, calabash_script.core.swipe_delta, cljs.core.PersistentVector.fromArray(["\ufdd0'vertical", "\ufdd0'dx"], true)), "\ufdd0'y":y
|
21683
|
+
return cljs.core.ObjMap.fromObject(["\ufdd0'x", "\ufdd0'y"], {"\ufdd0'x":x + cljs.core.get_in.call(null, calabash_script.core.swipe_delta, cljs.core.PersistentVector.fromArray(["\ufdd0'vertical", "\ufdd0'dx"], true)), "\ufdd0'y":y - cljs.core.get_in.call(null, calabash_script.core.swipe_delta, cljs.core.PersistentVector.fromArray(["\ufdd0'vertical", "\ufdd0'dy"], true))})
|
21684
21684
|
}else {
|
21685
21685
|
if(cljs.core._EQ_.call(null, "\ufdd0'right", G__2931)) {
|
21686
21686
|
return cljs.core.ObjMap.fromObject(["\ufdd0'x", "\ufdd0'y"], {"\ufdd0'x":x + cljs.core.get_in.call(null, calabash_script.core.swipe_delta, cljs.core.PersistentVector.fromArray(["\ufdd0'horizontal", "\ufdd0'dx"], true)), "\ufdd0'y":y + cljs.core.get_in.call(null, calabash_script.core.swipe_delta, cljs.core.PersistentVector.fromArray(["\ufdd0'horizontal", "\ufdd0'dy"], true))})
|
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: 0.0.
|
4
|
+
version: 0.0.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Karl Krukow
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-09-
|
11
|
+
date: 2013-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|