run_loop 0.0.22 → 0.1.0.pre1
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 +18 -9
- data/lib/run_loop/version.rb +1 -1
- data/scripts/run_loop.js +50 -55
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a964878f5f254c2251799bb935534e9e42b68fdb
|
4
|
+
data.tar.gz: eee14a802d715caeb9758232d5a8e01e9a8d18ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc29867d1bcf79cb9b1e2c5dd1657840a76695b4f39ef5e3d0b3382bd2d4a89e94e0b8c6934969b6a3aa6764839a77023dbe5c667a94269e8b0423e480fc471c
|
7
|
+
data.tar.gz: 73aeac53bfa5316ace1ede7d475d31b2264d7fcd1b1d9d6c264f126ac8083e45162a5e6e9a1c27d534b30d1bef7cf38f78d916910ac3d2e5d1295ace317df13f
|
data/lib/run_loop/core.rb
CHANGED
@@ -148,21 +148,23 @@ module RunLoop
|
|
148
148
|
|
149
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}
|
150
150
|
|
151
|
-
#read_response(run_loop,0)
|
152
151
|
before = Time.now
|
153
152
|
begin
|
154
153
|
Timeout::timeout(timeout, TimeoutError) do
|
155
154
|
read_response(run_loop, 0)
|
156
155
|
end
|
157
156
|
rescue TimeoutError => e
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
157
|
+
if ENV['DEBUG']
|
158
|
+
puts "Failed to launch\n"
|
159
|
+
puts "reason=#{e}: #{e && e.message} "
|
160
|
+
puts "device_target=#{device_target}"
|
161
|
+
puts "udid=#{udid}"
|
162
|
+
puts "bundle_dir_or_bundle_id=#{bundle_dir_or_bundle_id}"
|
163
|
+
puts "script=#{script}"
|
164
|
+
puts "log_file=#{log_file}"
|
165
|
+
puts "timeout=#{timeout}"
|
166
|
+
puts "args=#{args}"
|
167
|
+
end
|
166
168
|
raise TimeoutError, "Time out waiting for UIAutomation run-loop to Start. \n Logfile #{log_file} \n\n #{File.read(log_file)}\n"
|
167
169
|
end
|
168
170
|
|
@@ -215,6 +217,10 @@ module RunLoop
|
|
215
217
|
|
216
218
|
size = File.size(log_file)
|
217
219
|
output = File.read(log_file, size-offset, offset)
|
220
|
+
|
221
|
+
if /AXError: Could not auto-register for pid status change/.match(output)
|
222
|
+
raise TimeoutError.new('AXError: Could not auto-register for pid status change')
|
223
|
+
end
|
218
224
|
index_if_found = output.index(START_DELIMITER)
|
219
225
|
if ENV['DEBUG_READ']=='1'
|
220
226
|
puts output.gsub("*", '')
|
@@ -246,6 +252,9 @@ module RunLoop
|
|
246
252
|
|
247
253
|
offset = offset + json.size
|
248
254
|
parsed_result = JSON.parse(json)
|
255
|
+
if ENV['DEBUG_READ']=='1'
|
256
|
+
p parsed_result
|
257
|
+
end
|
249
258
|
json_index_if_present = parsed_result['index']
|
250
259
|
if json_index_if_present && json_index_if_present == expected_index
|
251
260
|
result = parsed_result
|
data/lib/run_loop/version.rb
CHANGED
data/scripts/run_loop.js
CHANGED
@@ -147,26 +147,15 @@ if (typeof JSON !== 'object') {
|
|
147
147
|
}
|
148
148
|
}());
|
149
149
|
|
150
|
-
var commandPath = "$PATH";
|
151
|
-
if (!/\/$/.test(commandPath)) {
|
152
|
-
commandPath += "/";
|
153
|
-
}
|
154
|
-
commandPath += "repl-cmd.txt";
|
155
|
-
|
156
150
|
|
157
151
|
var _expectedIndex = 0,//expected index of next command
|
158
|
-
_actualIndex,//actual index of next command by reading commandPath
|
159
|
-
_index,//index of ':' char in command
|
152
|
+
_actualIndex=0,//actual index of next command by reading commandPath
|
160
153
|
_exp,//expression to be eval'ed
|
161
|
-
_result
|
162
|
-
_input,//command
|
163
|
-
_process;//host command process
|
154
|
+
_result;
|
164
155
|
|
165
156
|
var Log = (function () {
|
166
|
-
// According to Appium,
|
167
|
-
//16384 is the buffer size used by instruments
|
168
157
|
var forceFlush = [],
|
169
|
-
N =
|
158
|
+
N = 16384,
|
170
159
|
i = N;
|
171
160
|
while (i--) {
|
172
161
|
forceFlush[i] = "*";
|
@@ -179,17 +168,14 @@ var Log = (function () {
|
|
179
168
|
}
|
180
169
|
|
181
170
|
return {
|
182
|
-
result: function (status, data) {
|
171
|
+
result: function (status, data,flush) {
|
183
172
|
log_json({"status": status, "value": data, "index":_actualIndex})
|
184
|
-
if (
|
173
|
+
if (flush) {
|
185
174
|
UIALogger.logMessage(forceFlush);
|
186
175
|
}
|
187
176
|
},
|
188
177
|
output: function (msg) {
|
189
178
|
log_json({"output": msg,"last_index":_actualIndex});
|
190
|
-
if (forceFlush.length > 0) {
|
191
|
-
UIALogger.logMessage(forceFlush);
|
192
|
-
}
|
193
179
|
}
|
194
180
|
};
|
195
181
|
})();
|
@@ -217,8 +203,7 @@ function isLocationPrompt(alert) {
|
|
217
203
|
["Ja", /Darf (?:.)+ Ihren aktuellen Ort verwenden/]
|
218
204
|
],
|
219
205
|
ans, exp,
|
220
|
-
txt
|
221
|
-
txts;
|
206
|
+
txt;
|
222
207
|
|
223
208
|
txt = findAlertViewText(alert);
|
224
209
|
for (var i = 0; i < exps.length; i++) {
|
@@ -263,53 +248,63 @@ UIATarget.onAlert = function (alert) {
|
|
263
248
|
|
264
249
|
|
265
250
|
var target = null,
|
266
|
-
|
251
|
+
preferences = null,
|
252
|
+
__calabashRequest = "__calabashRequest",
|
253
|
+
__calabashResponse = "__calabashResponse",
|
254
|
+
_response = function(response) {
|
255
|
+
target.frontMostApp().setPreferencesValueForKey(response, __calabashResponse);
|
256
|
+
},
|
257
|
+
_success = function(result,index) {
|
258
|
+
_response({"status":'success', "value":result, "index": index});
|
267
259
|
|
260
|
+
},
|
261
|
+
_failure = function(err, index) {
|
262
|
+
_response({"status":'error',
|
263
|
+
"value":err.toString(),
|
264
|
+
"backtrace":(err.stack ? err.stack.toString() : ""),
|
265
|
+
"index":index});
|
266
|
+
};
|
268
267
|
|
268
|
+
UIATarget.localTarget().frontMostApp().setPreferencesValueForKey(null, __calabashResponse);
|
269
|
+
UIATarget.localTarget().frontMostApp().setPreferencesValueForKey(0, __calabashRequest);
|
270
|
+
|
271
|
+
Log.result('success',true,true);
|
269
272
|
|
270
273
|
while (true) {
|
271
274
|
target = UIATarget.localTarget();
|
272
|
-
host = target.host();
|
273
|
-
target.delay(0.2);
|
274
275
|
try {
|
275
|
-
|
276
|
-
[commandPath],
|
277
|
-
2);
|
278
|
-
|
276
|
+
preferences = target.frontMostApp().preferencesValueForKey(__calabashRequest);
|
279
277
|
} catch (e) {
|
280
|
-
Log.output("
|
278
|
+
Log.output("Unable to read preferences..."+ e.toString());
|
279
|
+
target.delay(0.5);
|
281
280
|
continue;
|
282
281
|
}
|
283
|
-
|
284
|
-
|
282
|
+
|
283
|
+
if (!preferences) {
|
284
|
+
target.delay(0.2);
|
285
|
+
continue;
|
285
286
|
}
|
286
|
-
else {
|
287
|
-
_input = _process.stdout;
|
288
|
-
try {
|
289
|
-
_index = _input.indexOf(":", 0);
|
290
|
-
if (_index > -1) {
|
291
|
-
_actualIndex = parseInt(_input.substring(0, _index), 10);
|
292
|
-
if (!isNaN(_actualIndex) && _actualIndex >= _expectedIndex) {
|
293
|
-
_exp = _input.substring(_index + 1, _input.length);
|
294
|
-
_result = eval(_exp);
|
295
|
-
}
|
296
|
-
else {//likely old command is lingering...
|
297
|
-
continue;
|
298
|
-
}
|
299
|
-
}
|
300
|
-
else {
|
301
|
-
continue;
|
302
|
-
}
|
303
287
|
|
288
|
+
_actualIndex = preferences['index'];
|
289
|
+
if (!isNaN(_actualIndex) && _actualIndex >= _expectedIndex) {
|
290
|
+
_exp = preferences['command'];
|
291
|
+
UIALogger.logMessage("index " + _actualIndex + " is command: "+ _exp);
|
292
|
+
target.frontMostApp().setPreferencesValueForKey(null, __calabashRequest);
|
293
|
+
try {
|
294
|
+
_result = eval(_exp);
|
295
|
+
UIALogger.logMessage("Success: "+ _result);
|
296
|
+
_success(_result, _actualIndex);
|
304
297
|
}
|
305
|
-
catch
|
306
|
-
|
307
|
-
|
308
|
-
continue;
|
298
|
+
catch(err) {
|
299
|
+
UIALogger.logMessage("Failure: "+ err.toString() + " " + (err.stack ? err.stack.toString() : ""));
|
300
|
+
_failure(err, _actualIndex);
|
309
301
|
}
|
302
|
+
}
|
303
|
+
else {//likely old command is lingering...
|
304
|
+
continue;
|
305
|
+
}
|
306
|
+
_expectedIndex++;
|
310
307
|
|
311
|
-
_expectedIndex++;
|
312
|
-
Log.result("success", _result);
|
313
308
|
|
314
|
-
|
309
|
+
target.delay(0.2);
|
315
310
|
}
|
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.1.0.pre1
|
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-
|
11
|
+
date: 2013-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -84,9 +84,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
84
84
|
version: '0'
|
85
85
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - '
|
87
|
+
- - '>'
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: 1.3.1
|
90
90
|
requirements: []
|
91
91
|
rubyforge_project:
|
92
92
|
rubygems_version: 2.0.2
|