run_loop 0.1.0.pre5 → 0.1.0.pre7
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.rb +1 -0
- data/lib/run_loop/core.rb +5 -4
- data/lib/run_loop/version.rb +1 -1
- data/scripts/{run_loop.js → run_loop_fast_uia.js} +0 -0
- data/scripts/run_loop_host.js +315 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f1aa1bf39411877482d2ca079fbd8e96747e431
|
4
|
+
data.tar.gz: baf35e919dce4c6324cb6f282cce54e9d7c0d889
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec68e7fa940bef32781762f85fbeaf7bc915394e20b7ece3e83b06ca5bddc46d16fb922c1bdbcda0afd9c0f834e7919e6a3ad5756d587855514589f591bd6ddf
|
7
|
+
data.tar.gz: 8ee7716edf4f0bb09561100f41dfde7e5e69aaba8b512ee6dd134d42da9e26da1460c8857f39a4272e989496cd97bc52700458f5b2b2a907eac5021ee1384d0e
|
data/lib/run_loop.rb
CHANGED
data/lib/run_loop/core.rb
CHANGED
@@ -15,8 +15,9 @@ module RunLoop
|
|
15
15
|
|
16
16
|
SCRIPTS_PATH = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'scripts'))
|
17
17
|
SCRIPTS = {
|
18
|
-
:dismiss =>
|
19
|
-
:
|
18
|
+
:dismiss => 'run_dismiss_location.js',
|
19
|
+
:run_loop_fast_uia => 'run_loop_fast_uia.js',
|
20
|
+
:run_loop_host => 'run_loop_host.js'
|
20
21
|
}
|
21
22
|
|
22
23
|
def self.scripts_path
|
@@ -308,7 +309,7 @@ module RunLoop
|
|
308
309
|
end
|
309
310
|
|
310
311
|
|
311
|
-
def self.instruments_command(udid, results_dir_trace, bundle_dir_or_bundle_id, results_dir, script, log_file, args)
|
312
|
+
def self.instruments_command(udid, results_dir_trace, bundle_dir_or_bundle_id, results_dir, script, log_file, args=[])
|
312
313
|
instruments_prefix = instruments_command_prefix(udid, results_dir_trace)
|
313
314
|
cmd = [
|
314
315
|
instruments_prefix,
|
@@ -443,7 +444,7 @@ module RunLoop
|
|
443
444
|
raise "Unknown type for :script key: #{options[:script].class}"
|
444
445
|
end
|
445
446
|
else
|
446
|
-
script = Core.script_for_key(:
|
447
|
+
script = Core.script_for_key(:run_loop_fast_uia)
|
447
448
|
end
|
448
449
|
script
|
449
450
|
end
|
data/lib/run_loop/version.rb
CHANGED
File without changes
|
@@ -0,0 +1,315 @@
|
|
1
|
+
#import "calabash_script_uia.js"
|
2
|
+
|
3
|
+
if (typeof JSON !== 'object') {
|
4
|
+
JSON = {};
|
5
|
+
}
|
6
|
+
(function () {
|
7
|
+
'use strict';
|
8
|
+
function f(n) {
|
9
|
+
return n < 10 ? '0' + n : n;
|
10
|
+
}
|
11
|
+
|
12
|
+
if (typeof Date.prototype.toJSON !== 'function') {
|
13
|
+
Date.prototype.toJSON = function (key) {
|
14
|
+
return isFinite(this.valueOf()) ? this.getUTCFullYear() + '-' +
|
15
|
+
f(this.getUTCMonth() + 1) + '-' +
|
16
|
+
f(this.getUTCDate()) + 'T' +
|
17
|
+
f(this.getUTCHours()) + ':' +
|
18
|
+
f(this.getUTCMinutes()) + ':' +
|
19
|
+
f(this.getUTCSeconds()) + 'Z' : null;
|
20
|
+
};
|
21
|
+
String.prototype.toJSON = Number.prototype.toJSON = Boolean.prototype.toJSON = function (key) {
|
22
|
+
return this.valueOf();
|
23
|
+
};
|
24
|
+
}
|
25
|
+
var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, gap, indent, meta = {'\b': '\\b', '\t': '\\t', '\n': '\\n', '\f': '\\f', '\r': '\\r', '"': '\\"', '\\': '\\\\'}, rep;
|
26
|
+
|
27
|
+
function quote(string) {
|
28
|
+
escapable.lastIndex = 0;
|
29
|
+
return escapable.test(string) ? '"' + string.replace(escapable, function (a) {
|
30
|
+
var c = meta[a];
|
31
|
+
return typeof c === 'string' ? c : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
|
32
|
+
}) + '"' : '"' + string + '"';
|
33
|
+
}
|
34
|
+
|
35
|
+
function str(key, holder) {
|
36
|
+
var i, k, v, length, mind = gap, partial, value = holder[key];
|
37
|
+
if (value && typeof value === 'object' && typeof value.toJSON === 'function') {
|
38
|
+
value = value.toJSON(key);
|
39
|
+
}
|
40
|
+
if (typeof rep === 'function') {
|
41
|
+
value = rep.call(holder, key, value);
|
42
|
+
}
|
43
|
+
switch (typeof value) {
|
44
|
+
case'string':
|
45
|
+
return quote(value);
|
46
|
+
case'number':
|
47
|
+
return isFinite(value) ? String(value) : 'null';
|
48
|
+
case'boolean':
|
49
|
+
case'null':
|
50
|
+
return String(value);
|
51
|
+
case'object':
|
52
|
+
if (!value) {
|
53
|
+
return'null';
|
54
|
+
}
|
55
|
+
gap += indent;
|
56
|
+
partial = [];
|
57
|
+
if (Object.prototype.toString.apply(value) === '[object Array]') {
|
58
|
+
length = value.length;
|
59
|
+
for (i = 0; i < length; i += 1) {
|
60
|
+
partial[i] = str(i, value) || 'null';
|
61
|
+
}
|
62
|
+
v = partial.length === 0 ? '[]' : gap ? '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' : '[' + partial.join(',') + ']';
|
63
|
+
gap = mind;
|
64
|
+
return v;
|
65
|
+
}
|
66
|
+
if (rep && typeof rep === 'object') {
|
67
|
+
length = rep.length;
|
68
|
+
for (i = 0; i < length; i += 1) {
|
69
|
+
if (typeof rep[i] === 'string') {
|
70
|
+
k = rep[i];
|
71
|
+
v = str(k, value);
|
72
|
+
if (v) {
|
73
|
+
partial.push(quote(k) + (gap ? ': ' : ':') + v);
|
74
|
+
}
|
75
|
+
}
|
76
|
+
}
|
77
|
+
} else {
|
78
|
+
for (k in value) {
|
79
|
+
if (Object.prototype.hasOwnProperty.call(value, k)) {
|
80
|
+
v = str(k, value);
|
81
|
+
if (v) {
|
82
|
+
partial.push(quote(k) + (gap ? ': ' : ':') + v);
|
83
|
+
}
|
84
|
+
}
|
85
|
+
}
|
86
|
+
}
|
87
|
+
v = partial.length === 0 ? '{}' : gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' : '{' + partial.join(',') + '}';
|
88
|
+
gap = mind;
|
89
|
+
return v;
|
90
|
+
}
|
91
|
+
}
|
92
|
+
|
93
|
+
if (typeof JSON.stringify !== 'function') {
|
94
|
+
JSON.stringify = function (value, replacer, space) {
|
95
|
+
var i;
|
96
|
+
gap = '';
|
97
|
+
indent = '';
|
98
|
+
if (typeof space === 'number') {
|
99
|
+
for (i = 0; i < space; i += 1) {
|
100
|
+
indent += ' ';
|
101
|
+
}
|
102
|
+
} else if (typeof space === 'string') {
|
103
|
+
indent = space;
|
104
|
+
}
|
105
|
+
rep = replacer;
|
106
|
+
if (replacer && typeof replacer !== 'function' && (typeof replacer !== 'object' || typeof replacer.length !== 'number')) {
|
107
|
+
throw new Error('JSON.stringify');
|
108
|
+
}
|
109
|
+
return str('', {'': value});
|
110
|
+
};
|
111
|
+
}
|
112
|
+
if (typeof JSON.parse !== 'function') {
|
113
|
+
JSON.parse = function (text, reviver) {
|
114
|
+
var j;
|
115
|
+
|
116
|
+
function walk(holder, key) {
|
117
|
+
var k, v, value = holder[key];
|
118
|
+
if (value && typeof value === 'object') {
|
119
|
+
for (k in value) {
|
120
|
+
if (Object.prototype.hasOwnProperty.call(value, k)) {
|
121
|
+
v = walk(value, k);
|
122
|
+
if (v !== undefined) {
|
123
|
+
value[k] = v;
|
124
|
+
} else {
|
125
|
+
delete value[k];
|
126
|
+
}
|
127
|
+
}
|
128
|
+
}
|
129
|
+
}
|
130
|
+
return reviver.call(holder, key, value);
|
131
|
+
}
|
132
|
+
|
133
|
+
text = String(text);
|
134
|
+
cx.lastIndex = 0;
|
135
|
+
if (cx.test(text)) {
|
136
|
+
text = text.replace(cx, function (a) {
|
137
|
+
return'\\u' +
|
138
|
+
('0000' + a.charCodeAt(0).toString(16)).slice(-4);
|
139
|
+
});
|
140
|
+
}
|
141
|
+
if (/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
|
142
|
+
j = eval('(' + text + ')');
|
143
|
+
return typeof reviver === 'function' ? walk({'': j}, '') : j;
|
144
|
+
}
|
145
|
+
throw new SyntaxError('JSON.parse');
|
146
|
+
};
|
147
|
+
}
|
148
|
+
}());
|
149
|
+
|
150
|
+
var commandPath = "$PATH";
|
151
|
+
if (!/\/$/.test(commandPath)) {
|
152
|
+
commandPath += "/";
|
153
|
+
}
|
154
|
+
commandPath += "repl-cmd.txt";
|
155
|
+
|
156
|
+
|
157
|
+
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
|
160
|
+
_exp,//expression to be eval'ed
|
161
|
+
_result,//result of eval
|
162
|
+
_input,//command
|
163
|
+
_process;//host command process
|
164
|
+
|
165
|
+
var Log = (function () {
|
166
|
+
// According to Appium,
|
167
|
+
//16384 is the buffer size used by instruments
|
168
|
+
var forceFlush = [],
|
169
|
+
N = "$MODE" == "FLUSH" ? 16384 : 0,
|
170
|
+
i = N;
|
171
|
+
while (i--) {
|
172
|
+
forceFlush[i] = "*";
|
173
|
+
}
|
174
|
+
forceFlush = forceFlush.join('');
|
175
|
+
|
176
|
+
function log_json(object)
|
177
|
+
{
|
178
|
+
UIALogger.logMessage("OUTPUT_JSON:\n"+JSON.stringify(object)+"\nEND_OUTPUT");
|
179
|
+
}
|
180
|
+
|
181
|
+
return {
|
182
|
+
result: function (status, data) {
|
183
|
+
log_json({"status": status, "value": data, "index":_actualIndex})
|
184
|
+
if (forceFlush.length > 0) {
|
185
|
+
UIALogger.logMessage(forceFlush);
|
186
|
+
}
|
187
|
+
},
|
188
|
+
output: function (msg) {
|
189
|
+
log_json({"output": msg,"last_index":_actualIndex});
|
190
|
+
if (forceFlush.length > 0) {
|
191
|
+
UIALogger.logMessage(forceFlush);
|
192
|
+
}
|
193
|
+
}
|
194
|
+
};
|
195
|
+
})();
|
196
|
+
|
197
|
+
|
198
|
+
function findAlertViewText(alert) {
|
199
|
+
if (!alert) {
|
200
|
+
return false;
|
201
|
+
}
|
202
|
+
var txt = alert.name(),
|
203
|
+
txts;
|
204
|
+
if (txt == null) {
|
205
|
+
txts = alert.staticTexts();
|
206
|
+
if (txts != null && txts.length > 0) {
|
207
|
+
txt = txts[0].name();
|
208
|
+
}
|
209
|
+
}
|
210
|
+
return txt;
|
211
|
+
}
|
212
|
+
|
213
|
+
function isLocationPrompt(alert) {
|
214
|
+
var exps = [
|
215
|
+
["OK", /vil bruge din aktuelle placering/],
|
216
|
+
["OK", /Would Like to Use Your Current Location/],
|
217
|
+
["Ja", /Darf (?:.)+ Ihren aktuellen Ort verwenden/]
|
218
|
+
],
|
219
|
+
ans, exp,
|
220
|
+
txt,
|
221
|
+
txts;
|
222
|
+
|
223
|
+
txt = findAlertViewText(alert);
|
224
|
+
for (var i = 0; i < exps.length; i++) {
|
225
|
+
ans = exps[i][0];
|
226
|
+
exp = exps[i][1];
|
227
|
+
if (exp.test(txt)) {
|
228
|
+
return ans;
|
229
|
+
}
|
230
|
+
}
|
231
|
+
return false;
|
232
|
+
}
|
233
|
+
|
234
|
+
UIATarget.onAlert = function (alert) {
|
235
|
+
var target = UIATarget.localTarget();
|
236
|
+
target.pushTimeout(10);
|
237
|
+
function attemptTouchOKOnLocation(retry_count) {
|
238
|
+
retry_count = retry_count || 0;
|
239
|
+
if (retry_count >= 5) {
|
240
|
+
Log.output("Maxed out retry (5) - unable to dismiss location dialog.");
|
241
|
+
return;
|
242
|
+
}
|
243
|
+
try {
|
244
|
+
var answer = isLocationPrompt(alert);
|
245
|
+
if (answer) {
|
246
|
+
alert.buttons()[answer].tap();
|
247
|
+
}
|
248
|
+
}
|
249
|
+
catch (e) {
|
250
|
+
Log.output("Exception while trying to touch alert dialog. Retrying...");
|
251
|
+
if (e && typeof e.toString == 'function') {
|
252
|
+
Log.output(e.toString());
|
253
|
+
}
|
254
|
+
target.delay(1);
|
255
|
+
attemptTouchOKOnLocation(retry_count + 1);
|
256
|
+
}
|
257
|
+
}
|
258
|
+
|
259
|
+
attemptTouchOKOnLocation(0);
|
260
|
+
target.popTimeout();
|
261
|
+
return true;
|
262
|
+
};
|
263
|
+
|
264
|
+
|
265
|
+
var target = null,
|
266
|
+
host = null;
|
267
|
+
|
268
|
+
|
269
|
+
|
270
|
+
while (true) {
|
271
|
+
target = UIATarget.localTarget();
|
272
|
+
host = target.host();
|
273
|
+
target.delay(0.2);
|
274
|
+
try {
|
275
|
+
_process = host.performTaskWithPathArgumentsTimeout("/bin/cat",
|
276
|
+
[commandPath],
|
277
|
+
2);
|
278
|
+
|
279
|
+
} catch (e) {
|
280
|
+
Log.output("Timeout on cat...");
|
281
|
+
continue;
|
282
|
+
}
|
283
|
+
if (_process.exitCode != 0) {
|
284
|
+
Log.output("unable to execute /bin/cat " + commandPath + " exitCode " + _process.exitCode + ". Error: " + _process.stderr);
|
285
|
+
}
|
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
|
+
|
304
|
+
}
|
305
|
+
catch (err) {
|
306
|
+
Log.result("error", err.toString() + " " + (err.stack ? err.stack.toString() : ""));
|
307
|
+
_expectedIndex++;
|
308
|
+
continue;
|
309
|
+
}
|
310
|
+
|
311
|
+
_expectedIndex++;
|
312
|
+
Log.result("success", _result);
|
313
|
+
|
314
|
+
}
|
315
|
+
}
|
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.1.0.
|
4
|
+
version: 0.1.0.pre7
|
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-12-
|
11
|
+
date: 2013-12-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -69,7 +69,8 @@ files:
|
|
69
69
|
- scripts/json2-min.js
|
70
70
|
- scripts/json2.js
|
71
71
|
- scripts/run_dismiss_location.js
|
72
|
-
- scripts/
|
72
|
+
- scripts/run_loop_fast_uia.js
|
73
|
+
- scripts/run_loop_host.js
|
73
74
|
homepage: http://calaba.sh
|
74
75
|
licenses: []
|
75
76
|
metadata: {}
|