run_loop_tcc 2.1.3

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.
Files changed (87) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +21 -0
  3. data/bin/run-loop +19 -0
  4. data/lib/run_loop/abstract.rb +18 -0
  5. data/lib/run_loop/app.rb +372 -0
  6. data/lib/run_loop/cache/cache.rb +68 -0
  7. data/lib/run_loop/cli/cli.rb +48 -0
  8. data/lib/run_loop/cli/codesign.rb +24 -0
  9. data/lib/run_loop/cli/errors.rb +11 -0
  10. data/lib/run_loop/cli/instruments.rb +160 -0
  11. data/lib/run_loop/cli/locale.rb +31 -0
  12. data/lib/run_loop/cli/simctl.rb +257 -0
  13. data/lib/run_loop/cli/tcc.rb +139 -0
  14. data/lib/run_loop/codesign.rb +76 -0
  15. data/lib/run_loop/core.rb +902 -0
  16. data/lib/run_loop/core_simulator.rb +960 -0
  17. data/lib/run_loop/detect_aut/detect.rb +185 -0
  18. data/lib/run_loop/detect_aut/errors.rb +126 -0
  19. data/lib/run_loop/detect_aut/xamarin_studio.rb +46 -0
  20. data/lib/run_loop/detect_aut/xcode.rb +157 -0
  21. data/lib/run_loop/device.rb +722 -0
  22. data/lib/run_loop/device_agent/app/CBX-Runner.app.zip +0 -0
  23. data/lib/run_loop/device_agent/bin/xctestctl +0 -0
  24. data/lib/run_loop/device_agent/cbxrunner.rb +156 -0
  25. data/lib/run_loop/device_agent/frameworks/Frameworks.zip +0 -0
  26. data/lib/run_loop/device_agent/frameworks.rb +65 -0
  27. data/lib/run_loop/device_agent/ipa/CBX-Runner.app.zip +0 -0
  28. data/lib/run_loop/device_agent/launcher.rb +51 -0
  29. data/lib/run_loop/device_agent/xcodebuild.rb +91 -0
  30. data/lib/run_loop/device_agent/xctestctl.rb +109 -0
  31. data/lib/run_loop/directory.rb +179 -0
  32. data/lib/run_loop/dnssd.rb +148 -0
  33. data/lib/run_loop/dot_dir.rb +87 -0
  34. data/lib/run_loop/dylib_injector.rb +145 -0
  35. data/lib/run_loop/encoding.rb +56 -0
  36. data/lib/run_loop/environment.rb +361 -0
  37. data/lib/run_loop/fifo.rb +40 -0
  38. data/lib/run_loop/host_cache.rb +128 -0
  39. data/lib/run_loop/http/error.rb +15 -0
  40. data/lib/run_loop/http/request.rb +44 -0
  41. data/lib/run_loop/http/retriable_client.rb +166 -0
  42. data/lib/run_loop/http/server.rb +17 -0
  43. data/lib/run_loop/instruments.rb +436 -0
  44. data/lib/run_loop/ipa.rb +142 -0
  45. data/lib/run_loop/l10n.rb +93 -0
  46. data/lib/run_loop/language.rb +63 -0
  47. data/lib/run_loop/lipo.rb +132 -0
  48. data/lib/run_loop/lldb.rb +52 -0
  49. data/lib/run_loop/locale.rb +101 -0
  50. data/lib/run_loop/logging.rb +111 -0
  51. data/lib/run_loop/otool.rb +76 -0
  52. data/lib/run_loop/patches/awesome_print.rb +17 -0
  53. data/lib/run_loop/physical_device/life_cycle.rb +268 -0
  54. data/lib/run_loop/plist_buddy.rb +189 -0
  55. data/lib/run_loop/process_terminator.rb +128 -0
  56. data/lib/run_loop/process_waiter.rb +117 -0
  57. data/lib/run_loop/regex.rb +19 -0
  58. data/lib/run_loop/shell.rb +103 -0
  59. data/lib/run_loop/sim_control.rb +1264 -0
  60. data/lib/run_loop/simctl.rb +275 -0
  61. data/lib/run_loop/sqlite.rb +61 -0
  62. data/lib/run_loop/strings.rb +88 -0
  63. data/lib/run_loop/tcc/TCC.db +0 -0
  64. data/lib/run_loop/tcc/tcc.rb +240 -0
  65. data/lib/run_loop/template.rb +61 -0
  66. data/lib/run_loop/version.rb +182 -0
  67. data/lib/run_loop/xcode.rb +318 -0
  68. data/lib/run_loop/xcrun.rb +107 -0
  69. data/lib/run_loop/xcuitest.rb +550 -0
  70. data/lib/run_loop.rb +230 -0
  71. data/plists/simctl/com.apple.UIAutomation.plist +0 -0
  72. data/plists/simctl/com.apple.UIAutomationPlugIn.plist +0 -0
  73. data/scripts/calabash_script_uia.js +28184 -0
  74. data/scripts/lib/json2.min.js +26 -0
  75. data/scripts/lib/log.js +26 -0
  76. data/scripts/lib/on_alert.js +224 -0
  77. data/scripts/read-cmd.sh +2 -0
  78. data/scripts/run_dismiss_location.js +89 -0
  79. data/scripts/run_loop_basic.js +34 -0
  80. data/scripts/run_loop_fast_uia.js +188 -0
  81. data/scripts/run_loop_host.js +117 -0
  82. data/scripts/run_loop_shared_element.js +125 -0
  83. data/scripts/timeout3 +23 -0
  84. data/scripts/udidetect +0 -0
  85. data/vendor-licenses/FBSimulatorControl.LICENSE +30 -0
  86. data/vendor-licenses/xctestctl.LICENSE +32 -0
  87. metadata +443 -0
@@ -0,0 +1,117 @@
1
+ //#import "calabash_script_uia.js"
2
+
3
+ <%= render_template("lib/json2.min.js") %>
4
+
5
+ var commandPath = "$PATH";
6
+ if (!/\/$/.test(commandPath)) {
7
+ commandPath += "/";
8
+ }
9
+ commandPath += "repl-cmd.pipe";
10
+
11
+ var timeoutScriptPath = "$TIMEOUT_SCRIPT_PATH",
12
+ readPipeScriptPath = "$READ_SCRIPT_PATH";
13
+
14
+ var _expectedIndex = 0,//expected index of next command
15
+ _actualIndex,//actual index of next command by reading commandPath
16
+ _index,//index of ':' char in command
17
+ _exp = null,//expression to be eval'ed
18
+ _result,//result of eval
19
+ _input,//command
20
+ _process;//host command process
21
+
22
+ <%= render_template("lib/log.js"); %>
23
+ <%= render_template("lib/on_alert.js"); %>
24
+
25
+ UIATarget.onAlert = function (alert) {
26
+ Log.output({"output":"on alert"});
27
+ var target = UIATarget.localTarget();
28
+ target.pushTimeout(10);
29
+ function dismissPrivacyAlert(retry_count) {
30
+ retry_count = retry_count || 0;
31
+ if (retry_count >= 5) {
32
+ Log.output("Maxed out retry (5) - unable to dismiss location dialog.");
33
+ return;
34
+ }
35
+ try {
36
+ var answer = isPrivacyAlert(alert);
37
+ if (answer) {
38
+ alert.buttons()[answer].tap();
39
+ }
40
+ }
41
+ catch (e) {
42
+ Log.output("Exception while trying to touch alert dialog. Retrying...");
43
+ if (e && typeof e.toString == 'function') {
44
+ Log.output(e.toString());
45
+ }
46
+ target.delay(1);
47
+ dismissPrivacyAlert(retry_count + 1);
48
+ }
49
+ }
50
+
51
+ dismissPrivacyAlert(0);
52
+ target.popTimeout();
53
+ return true;
54
+ };
55
+
56
+
57
+ var target = null,
58
+ host = null;
59
+
60
+
61
+ Log.output('Starting loop');
62
+ while (true) {
63
+ target = UIATarget.localTarget();
64
+
65
+ host = target.host();
66
+ try {
67
+ _process = host.performTaskWithPathArgumentsTimeout(timeoutScriptPath,
68
+ [readPipeScriptPath, commandPath],
69
+ 10);
70
+
71
+ } catch (e) {
72
+ Log.output("Timeout on read command..." + e);
73
+ continue;
74
+ }
75
+ if (_process.exitCode != 0) {
76
+ if (_process.exitCode != 15) {
77
+ Log.output("unable to execute: " +
78
+ timeoutScriptPath + " " +
79
+ readPipeScriptPath + " " +
80
+ commandPath + " exitCode "
81
+ + _process.exitCode + ". Error: " +
82
+ _process.stderr + _process.stdout);
83
+ }
84
+ }
85
+ else {
86
+ _input = _process.stdout;
87
+ try {
88
+ _index = _input.indexOf(":", 0);
89
+ if (_index > -1) {
90
+ _actualIndex = parseInt(_input.substring(0, _index), 10);
91
+ if (!isNaN(_actualIndex) && _actualIndex >= _expectedIndex) {
92
+ _exp = _input.substring(_index + 1, _input.length);
93
+ Log.output(_actualIndex);
94
+ _result = eval(_exp);
95
+ }
96
+ else {//likely old command is lingering...
97
+ continue;
98
+ }
99
+ }
100
+ else {
101
+ continue;
102
+ }
103
+
104
+ }
105
+ catch (err) {
106
+ Log.result("error", "Input: " + (_exp ? _exp.toString() : "null") +
107
+ ". Error: " + err.toString() + " " +
108
+ (err.stack ? err.stack.toString() : ""));
109
+ _expectedIndex++;
110
+ continue;
111
+ }
112
+
113
+ _expectedIndex = Math.max(_actualIndex+1, _expectedIndex+1);
114
+ Log.result("success", _result);
115
+ target.delay(0.1);
116
+ }
117
+ }
@@ -0,0 +1,125 @@
1
+ <%= render_template("lib/json2.min.js") %>
2
+
3
+ _RUN_LOOP_MAX_RETRY_AFTER_HANDLER = 10;
4
+ var _expectedIndex = 0,//expected index of next command
5
+ _actualIndex=0,//actual index of next command by reading commandPath
6
+ _exp,//expression to be eval'ed
7
+ _result,
8
+ _lastResponse=null;
9
+
10
+ <%= render_template("lib/log.js"); %>
11
+ <%= render_template("lib/on_alert.js"); %>
12
+
13
+ UIATarget.onAlert = function (alert) {
14
+ var target = UIATarget.localTarget(),
15
+ app = target.frontMostApp(),
16
+ req = null,
17
+ rsp = null,
18
+ actualIndex = null;
19
+ target.pushTimeout(10);
20
+ function dismissPrivacyAlert(retry_count) {
21
+ retry_count = retry_count || 0;
22
+ if (retry_count >= 5) {
23
+ Log.output("Maxed out retry (5) - unable to dismiss privacy dialog.");
24
+ return;
25
+ }
26
+ try {
27
+ var answer = isPrivacyAlert(alert);
28
+ if (answer) {
29
+ alert.buttons()[answer].tap();
30
+ }
31
+ }
32
+ catch (e) {
33
+ Log.output("Exception while trying to touch alert. Retrying...");
34
+ if (e && typeof e.toString == 'function') {
35
+ Log.output(e.toString());
36
+ }
37
+ target.delay(1);
38
+ dismissPrivacyAlert(retry_count + 1);
39
+ }
40
+ }
41
+
42
+ dismissPrivacyAlert(0);
43
+ target.popTimeout();
44
+ return true;
45
+ };
46
+
47
+
48
+ Log.result('success', true);
49
+
50
+ var _calabashSharedTextField = null,
51
+ __calabashSharedTextFieldName = '__calabash_uia_channel',
52
+ _firstElement,
53
+ target = null,
54
+ failureMessage = null,
55
+ _request = null,
56
+ _response = function(response) {
57
+ response.type = 'response';
58
+ var jsonResponse = JSON.stringify(response);
59
+ UIALogger.logMessage("Response: "+ jsonResponse);
60
+ _calabashSharedTextField.setValue(jsonResponse);
61
+ },
62
+ _success = function(result,index) {
63
+ _lastResponse = {"status":'success', "value":result, "index": index};
64
+ _response(_lastResponse);
65
+ },
66
+ _failure = function(err, index) {
67
+ _lastResponse = {"status":'error',
68
+ "value":err.toString(),
69
+ "backtrace":(err.stack ? err.stack.toString() : ""),
70
+ "index":index};
71
+ _response(_lastResponse);
72
+ },
73
+ _syncDoneJSON='{"type":"syncDone"}';
74
+
75
+ UIALogger.logMessage("Waiting for shared element...");
76
+ target = UIATarget.localTarget();
77
+ while (!_calabashSharedTextField) {
78
+ _firstElement = target.frontMostApp().mainWindow().elements()[0];
79
+ if (_firstElement instanceof UIATextField) {
80
+ if (_firstElement.name() == __calabashSharedTextFieldName) {
81
+ _calabashSharedTextField = _firstElement;
82
+ UIALogger.logMessage("Found shared element... Responding: syncDone");
83
+ _calabashSharedTextField.setValue(_syncDoneJSON);
84
+ target.delay(0.5);
85
+ break;
86
+ }
87
+ }
88
+ target.delay(0.3);
89
+ }
90
+
91
+ while (true) {
92
+ _request = _calabashSharedTextField.value();
93
+
94
+ if (!_request || _request === _syncDoneJSON) {
95
+ target.delay(0.2);
96
+ continue;
97
+ }
98
+
99
+ UIALogger.logMessage("index " + _actualIndex + " is request: "+ _request);
100
+ _request = JSON.parse(_request);
101
+
102
+ _actualIndex = _request['index'];
103
+ if (!isNaN(_actualIndex) && _actualIndex >= _expectedIndex) {
104
+ _exp = _request['command'];
105
+ UIALogger.logMessage("index " + _actualIndex + " is command: "+ _exp);
106
+ try {
107
+ if (_exp == 'break;') {
108
+ _success("OK", _actualIndex);
109
+ break;
110
+ }
111
+ _result = eval(_exp);
112
+ UIALogger.logMessage("Success: "+ _result);
113
+ _success(_result, _actualIndex);
114
+ }
115
+ catch(err) {
116
+ failureMessage = "Failure: "+ err.toString() + " " + (err.stack ? err.stack.toString() : "");
117
+ Log.output({"output":failureMessage});
118
+ _failure(err, _actualIndex);
119
+ }
120
+ }
121
+ else {//likely old command is lingering...
122
+ continue;
123
+ }
124
+ _expectedIndex = Math.max(_actualIndex+1, _expectedIndex+1);
125
+ }
data/scripts/timeout3 ADDED
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env bash
2
+ # A specialized version of
3
+ # http://www.bashcookbook.com/bashinfo/source/bash-4.0/examples/scripts/timeout3
4
+ # Note the non-standard use of sleep 0.1, which is out
5
+ # of standard but works on OS X and Ubuntu
6
+ # Original design by Dmitry V Golovashkin <Dmitry.Golovashkin@sas.com>
7
+ (
8
+ ((t = 50))
9
+
10
+ while ((t > 0)); do
11
+ sleep 0.1
12
+ kill -0 $$ || exit 0
13
+ ((t -= 1))
14
+ done
15
+
16
+ # Be nice, post SIGTERM first.
17
+ # The 'exit 0' below will be executed if any preceeding command fails.
18
+ kill -s SIGTERM $$ && kill -0 $$ || exit 0
19
+ sleep $delay
20
+ kill -s SIGKILL $$
21
+ ) 2> /dev/null &
22
+
23
+ exec "$@"
data/scripts/udidetect ADDED
Binary file
@@ -0,0 +1,30 @@
1
+ BSD License
2
+
3
+ For FBSimulatorControl software
4
+
5
+ Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
6
+
7
+ Redistribution and use in source and binary forms, with or without modification,
8
+ are permitted provided that the following conditions are met:
9
+
10
+ * Redistributions of source code must retain the above copyright notice, this
11
+ list of conditions and the following disclaimer.
12
+
13
+ * Redistributions in binary form must reproduce the above copyright notice,
14
+ this list of conditions and the following disclaimer in the documentation
15
+ and/or other materials provided with the distribution.
16
+
17
+ * Neither the name Facebook nor the names of its contributors may be used to
18
+ endorse or promote products derived from this software without specific
19
+ prior written permission.
20
+
21
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
22
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
25
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
28
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,32 @@
1
+ BSD 3-Clause License
2
+
3
+ xctestctl
4
+
5
+ Copyright (c) 2016-present, Xamarin
6
+
7
+ All rights reserved.
8
+
9
+ Redistribution and use in source and binary forms, with or without
10
+ modification, are permitted provided that the following conditions are met:
11
+
12
+ 1. Redistributions of source code must retain the above copyright notice, this
13
+ list of conditions and the following disclaimer.
14
+
15
+ 2. Redistributions in binary form must reproduce the above copyright notice,
16
+ this list of conditions and the following disclaimer in the documentation
17
+ and/or other materials provided with the distribution.
18
+
19
+ 3. Neither the name of the copyright holder nor the names of its contributors
20
+ may be used to endorse or promote products derived from this software without
21
+ specific prior written permission.
22
+
23
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
24
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
27
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
31
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.