detox 20.9.0 → 21.0.0-rc.0
Sign up to get free protection for your applications and to get access to all the features.
- package/Detox-android/com/wix/detox/{20.9.0/detox-20.9.0-javadoc.jar → 21.0.0-rc.0/detox-21.0.0-rc.0-javadoc.jar} +0 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.0/detox-21.0.0-rc.0-javadoc.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.0/detox-21.0.0-rc.0-javadoc.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.0/detox-21.0.0-rc.0-javadoc.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.0/detox-21.0.0-rc.0-javadoc.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{20.9.0/detox-20.9.0-sources.jar → 21.0.0-rc.0/detox-21.0.0-rc.0-sources.jar} +0 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.0/detox-21.0.0-rc.0-sources.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.0/detox-21.0.0-rc.0-sources.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.0/detox-21.0.0-rc.0-sources.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.0/detox-21.0.0-rc.0-sources.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{20.9.0/detox-20.9.0.pom → 21.0.0-rc.0/detox-21.0.0-rc.0.pom} +1 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.0/detox-21.0.0-rc.0.pom.md5 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.0/detox-21.0.0-rc.0.pom.sha1 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.0/detox-21.0.0-rc.0.pom.sha256 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.0/detox-21.0.0-rc.0.pom.sha512 +1 -0
- package/Detox-android/com/wix/detox/maven-metadata.xml +4 -4
- package/Detox-android/com/wix/detox/maven-metadata.xml.md5 +1 -1
- package/Detox-android/com/wix/detox/maven-metadata.xml.sha1 +1 -1
- package/Detox-android/com/wix/detox/maven-metadata.xml.sha256 +1 -1
- package/Detox-android/com/wix/detox/maven-metadata.xml.sha512 +1 -1
- package/Detox-ios-framework.tbz +0 -0
- package/Detox-ios-src.tbz +0 -0
- package/Detox-ios-xcuitest.tbz +0 -0
- package/local-cli/build-framework-cache.js +1 -1
- package/local-cli/build-xcuitest-cache.js +16 -0
- package/local-cli/clean-framework-cache.js +1 -1
- package/local-cli/clean-xcuitest-cache.js +19 -0
- package/local-cli/rebuild-framework-cache.js +3 -3
- package/local-cli/rebuild-xcuitest-cache.js +21 -0
- package/package.json +3 -2
- package/scripts/build_framework.ios.sh +26 -60
- package/scripts/build_local_framework.ios.sh +62 -0
- package/scripts/build_local_xcuitest.ios.sh +53 -0
- package/scripts/build_xcuitest.ios.sh +23 -0
- package/scripts/pack_ios.sh +14 -5
- package/scripts/postinstall.js +10 -4
- package/src/client/Client.js +16 -1
- package/src/client/actions/actions.js +38 -0
- package/src/devices/common/drivers/ios/tools/AppleSimUtils.js +3 -12
- package/src/devices/runtime/RuntimeDevice.js +5 -0
- package/src/devices/runtime/drivers/DeviceDriverBase.js +1 -0
- package/src/devices/runtime/drivers/ios/SimulatorDriver.js +58 -2
- package/src/devices/runtime/drivers/ios/XCUITestUtils.js +209 -0
- package/src/devices/runtime/drivers/ios/allowNetworkPermissionsXCUITest.scpt +14 -0
- package/src/realms/DetoxPrimaryContext.js +2 -1
- package/src/server/DetoxSession.js +3 -0
- package/src/server/DetoxSessionManager.js +1 -0
- package/src/server/handlers/AnonymousConnectionHandler.js +1 -0
- package/src/utils/childProcess/exec.js +3 -1
- package/src/utils/environment.js +25 -1
- package/src/validation/ios/IosSimulatorEnvValidator.js +7 -4
- package/Detox-android/com/wix/detox/20.9.0/detox-20.9.0-javadoc.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/20.9.0/detox-20.9.0-javadoc.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.9.0/detox-20.9.0-javadoc.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.9.0/detox-20.9.0-javadoc.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/20.9.0/detox-20.9.0-sources.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/20.9.0/detox-20.9.0-sources.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.9.0/detox-20.9.0-sources.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.9.0/detox-20.9.0-sources.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/20.9.0/detox-20.9.0.pom.md5 +0 -1
- package/Detox-android/com/wix/detox/20.9.0/detox-20.9.0.pom.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.9.0/detox-20.9.0.pom.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.9.0/detox-20.9.0.pom.sha512 +0 -1
- package/Detox-ios.tbz +0 -0
- package/scripts/build_universal_framework.sh +0 -14
- package/scripts/build_universal_framework_legacy.sh +0 -76
- package/scripts/build_universal_framework_modern.sh +0 -28
- /package/Detox-android/com/wix/detox/{20.9.0/detox-20.9.0.aar → 21.0.0-rc.0/detox-21.0.0-rc.0.aar} +0 -0
- /package/Detox-android/com/wix/detox/{20.9.0/detox-20.9.0.aar.md5 → 21.0.0-rc.0/detox-21.0.0-rc.0.aar.md5} +0 -0
- /package/Detox-android/com/wix/detox/{20.9.0/detox-20.9.0.aar.sha1 → 21.0.0-rc.0/detox-21.0.0-rc.0.aar.sha1} +0 -0
- /package/Detox-android/com/wix/detox/{20.9.0/detox-20.9.0.aar.sha256 → 21.0.0-rc.0/detox-21.0.0-rc.0.aar.sha256} +0 -0
- /package/Detox-android/com/wix/detox/{20.9.0/detox-20.9.0.aar.sha512 → 21.0.0-rc.0/detox-21.0.0-rc.0.aar.sha512} +0 -0
@@ -140,6 +140,9 @@ class AppleSimUtils {
|
|
140
140
|
|
141
141
|
async launch(udid, bundleId, launchArgs, languageAndLocale) {
|
142
142
|
const frameworkPath = await environment.getFrameworkPath();
|
143
|
+
|
144
|
+
delete launchArgs.detoxServer;
|
145
|
+
|
143
146
|
const result = await this._launchMagically(frameworkPath, udid, bundleId, launchArgs, languageAndLocale);
|
144
147
|
await this._printLoggingHint(udid, bundleId);
|
145
148
|
|
@@ -156,18 +159,6 @@ class AppleSimUtils {
|
|
156
159
|
);
|
157
160
|
}
|
158
161
|
|
159
|
-
async sendToHome(udid) {
|
160
|
-
if (await this._isSpringBoardInaccessible(udid)) {
|
161
|
-
// SpringBoard is not directly accessible by Simctl on iOS 16.0 and above, therefore we launch and terminate the
|
162
|
-
// Settings app instead. This sends the currently open app to the background and brings the home screen to the
|
163
|
-
// foreground.
|
164
|
-
await this._launchAndTerminateSettings(udid);
|
165
|
-
return;
|
166
|
-
}
|
167
|
-
|
168
|
-
await this._launchSpringBoard(udid);
|
169
|
-
}
|
170
|
-
|
171
162
|
async _isSpringBoardInaccessible(udid) {
|
172
163
|
const device = await this._findDeviceByUDID(udid);
|
173
164
|
const majorIOSVersion = parseInt(device.os.version.split('.')[0]);
|
@@ -53,6 +53,7 @@ class RuntimeDevice {
|
|
53
53
|
traceMethods(log, this, methodNames);
|
54
54
|
wrapWithStackTraceCutter(this, methodNames);
|
55
55
|
|
56
|
+
this._isTestRunnerConnected = false;
|
56
57
|
this._appsConfig = appsConfig;
|
57
58
|
this._behaviorConfig = behaviorConfig;
|
58
59
|
this._deviceConfig = deviceConfig;
|
@@ -157,8 +158,11 @@ class RuntimeDevice {
|
|
157
158
|
this._processes[bundleId] = await this.deviceDriver.waitForAppLaunch(bundleId, this._prepareLaunchArgs(baseLaunchArgs), params.languageAndLocale);
|
158
159
|
} else {
|
159
160
|
this._processes[bundleId] = await this.deviceDriver.launchApp(bundleId, this._prepareLaunchArgs(baseLaunchArgs), params.languageAndLocale);
|
161
|
+
console.log('Launched app process:', this._processes[bundleId]);
|
160
162
|
await this.deviceDriver.waitUntilReady();
|
163
|
+
console.log('wait for active');
|
161
164
|
await this.deviceDriver.waitForActive();
|
165
|
+
console.log('App launched. Running test...');
|
162
166
|
}
|
163
167
|
|
164
168
|
await this._emitter.emit('appReady', {
|
@@ -362,6 +366,7 @@ class RuntimeDevice {
|
|
362
366
|
}
|
363
367
|
return this._currentApp;
|
364
368
|
}
|
369
|
+
|
365
370
|
async _sendPayload(key, params) {
|
366
371
|
const payloadFilePath = this.deviceDriver.createPayloadFile(params);
|
367
372
|
const payload = {
|
@@ -6,11 +6,14 @@ const _ = require('lodash');
|
|
6
6
|
|
7
7
|
const temporaryPath = require('../../../../artifacts/utils/temporaryPath');
|
8
8
|
const DetoxRuntimeError = require('../../../../errors/DetoxRuntimeError');
|
9
|
+
const environment = require('../../../../utils/environment');
|
9
10
|
const getAbsoluteBinaryPath = require('../../../../utils/getAbsoluteBinaryPath');
|
10
|
-
const log = require('../../../../utils/logger').child({ cat: '
|
11
|
+
const log = require('../../../../utils/logger').child({ cat: 'driver' });
|
11
12
|
const pressAnyKey = require('../../../../utils/pressAnyKey');
|
12
13
|
|
13
14
|
const IosDriver = require('./IosDriver');
|
15
|
+
const { launchXCUITest } = require('./XCUITestUtils');
|
16
|
+
|
14
17
|
|
15
18
|
/**
|
16
19
|
* @typedef SimulatorDriverDeps { DeviceDriverDeps }
|
@@ -25,6 +28,19 @@ const IosDriver = require('./IosDriver');
|
|
25
28
|
* @property bootArgs { Object }
|
26
29
|
*/
|
27
30
|
|
31
|
+
let SingletonPortToUsageMap = (function () {
|
32
|
+
let instance;
|
33
|
+
|
34
|
+
return {
|
35
|
+
getInstance: function () {
|
36
|
+
if (!instance) {
|
37
|
+
instance = {};
|
38
|
+
}
|
39
|
+
return instance;
|
40
|
+
}
|
41
|
+
};
|
42
|
+
})();
|
43
|
+
|
28
44
|
class SimulatorDriver extends IosDriver {
|
29
45
|
/**
|
30
46
|
* @param deps { SimulatorDriverDeps }
|
@@ -75,19 +91,53 @@ class SimulatorDriver extends IosDriver {
|
|
75
91
|
}
|
76
92
|
|
77
93
|
async launchApp(bundleId, launchArgs, languageAndLocale) {
|
94
|
+
const xcuitestRunnerPath = await environment.getXCUITestRunnerPath();
|
95
|
+
|
78
96
|
const { udid } = this;
|
97
|
+
launchArgs = this.enrichArgs(launchArgs);
|
98
|
+
|
79
99
|
await this.emitter.emit('beforeLaunchApp', { bundleId, deviceId: udid, launchArgs });
|
100
|
+
|
101
|
+
log.debug({ event: 'CLIENT_CONNECTED', params: { connected: this.client.isConnected } }, 'client connected: ' + this.client.isConnected);
|
102
|
+
if (!this.client.isConnected) {
|
103
|
+
await launchXCUITest(
|
104
|
+
xcuitestRunnerPath,
|
105
|
+
this.udid,
|
106
|
+
launchArgs.detoxServer,
|
107
|
+
launchArgs.detoxSessionId,
|
108
|
+
bundleId,
|
109
|
+
launchArgs.detoxDebugVisibility,
|
110
|
+
launchArgs.detoxDisableHierarchyDump,
|
111
|
+
_.findLast(launchArgs.detoxTestTargetServer.split(':'))
|
112
|
+
);
|
113
|
+
}
|
114
|
+
|
80
115
|
const pid = await this._applesimutils.launch(udid, bundleId, launchArgs, languageAndLocale);
|
81
116
|
await this.emitter.emit('launchApp', { bundleId, deviceId: udid, launchArgs, pid });
|
82
117
|
|
83
118
|
return pid;
|
84
119
|
}
|
85
120
|
|
121
|
+
enrichArgs(args) {
|
122
|
+
const detoxServerPort = _.findLast(args.detoxServer.split(':'));
|
123
|
+
const portToUsagesCountMap = SingletonPortToUsageMap.getInstance();
|
124
|
+
const portUsagesCount = portToUsagesCountMap[detoxServerPort] = (portToUsagesCountMap[detoxServerPort] || 0) + 1;
|
125
|
+
const testTargetPort = Number(detoxServerPort) + 1000 * portUsagesCount;
|
126
|
+
|
127
|
+
return {
|
128
|
+
...args,
|
129
|
+
detoxTestTargetServer: `ws://localhost:${testTargetPort}`,
|
130
|
+
};
|
131
|
+
}
|
132
|
+
|
86
133
|
async waitForAppLaunch(bundleId, launchArgs, languageAndLocale) {
|
87
134
|
const { udid } = this;
|
88
135
|
|
136
|
+
launchArgs = this.enrichArgs(launchArgs);
|
137
|
+
|
89
138
|
await this.emitter.emit('beforeLaunchApp', { bundleId, deviceId: udid, launchArgs });
|
90
139
|
|
140
|
+
// print xcuitest launch hint
|
91
141
|
this._applesimutils.printLaunchHint(udid, bundleId, launchArgs, languageAndLocale);
|
92
142
|
await pressAnyKey();
|
93
143
|
|
@@ -109,6 +159,12 @@ class SimulatorDriver extends IosDriver {
|
|
109
159
|
async terminate(bundleId) {
|
110
160
|
const { udid } = this;
|
111
161
|
await this.emitter.emit('beforeTerminateApp', { deviceId: udid, bundleId });
|
162
|
+
|
163
|
+
await this.client.terminateIfNeeded();
|
164
|
+
|
165
|
+
// Sleep for 200 ms to allow the XCUITest to terminate gracefully.
|
166
|
+
await new Promise(resolve => setTimeout(resolve, 200));
|
167
|
+
|
112
168
|
await this._applesimutils.terminate(udid, bundleId);
|
113
169
|
await this.emitter.emit('terminateApp', { deviceId: udid, bundleId });
|
114
170
|
}
|
@@ -134,7 +190,7 @@ class SimulatorDriver extends IosDriver {
|
|
134
190
|
}
|
135
191
|
|
136
192
|
async sendToHome() {
|
137
|
-
await this.
|
193
|
+
return await this.client.sendToHome();
|
138
194
|
}
|
139
195
|
|
140
196
|
async setLocation(lat, lon) {
|
@@ -0,0 +1,209 @@
|
|
1
|
+
const { exec } = require('child-process-promise');
|
2
|
+
const osascript = require('node-osascript');
|
3
|
+
|
4
|
+
const { execWithRetriesAndLogs } = require('../../../../utils/childProcess');
|
5
|
+
const log = require('../../../../utils/logger').child({ cat: 'device,xcuitest' });
|
6
|
+
|
7
|
+
async function launchXCUITest(
|
8
|
+
xcuitestRunnerPath,
|
9
|
+
simulatorId,
|
10
|
+
detoxServer,
|
11
|
+
detoxSessionId,
|
12
|
+
bundleId,
|
13
|
+
debugVisibility,
|
14
|
+
disableDumpViewHierarchy,
|
15
|
+
testTargetServerPort
|
16
|
+
) {
|
17
|
+
log.debug('[XCUITest] Launch was called');
|
18
|
+
|
19
|
+
await _runLaunchCommand(
|
20
|
+
xcuitestRunnerPath,
|
21
|
+
simulatorId,
|
22
|
+
detoxServer,
|
23
|
+
detoxSessionId,
|
24
|
+
bundleId,
|
25
|
+
debugVisibility,
|
26
|
+
disableDumpViewHierarchy,
|
27
|
+
testTargetServerPort
|
28
|
+
);
|
29
|
+
|
30
|
+
log.debug('[XCUITest] Launch succeeded');
|
31
|
+
}
|
32
|
+
|
33
|
+
async function _runLaunchCommand(
|
34
|
+
xcuitestRunnerPath,
|
35
|
+
simulatorId,
|
36
|
+
detoxServer,
|
37
|
+
detoxSessionId,
|
38
|
+
bundleId,
|
39
|
+
debugVisibility,
|
40
|
+
disableDumpViewHierarchy,
|
41
|
+
testTargetServerPort
|
42
|
+
) {
|
43
|
+
log.info(`Launching XUICTest runner. See target logs using:\n` +
|
44
|
+
`\t/usr/bin/xcrun simctl spawn ${simulatorId} log stream --level debug --style compact ` +
|
45
|
+
`--predicate 'process == "DetoxTester-Runner" && subsystem == "com.wix.DetoxTester.xctrunner"'`);
|
46
|
+
|
47
|
+
const spawnedProcess = runXCUITest(
|
48
|
+
xcuitestRunnerPath,
|
49
|
+
simulatorId,
|
50
|
+
detoxServer,
|
51
|
+
detoxSessionId,
|
52
|
+
testTargetServerPort,
|
53
|
+
bundleId,
|
54
|
+
debugVisibility,
|
55
|
+
disableDumpViewHierarchy
|
56
|
+
).then(r => {
|
57
|
+
log.info(`[XCUITest] XCUITest runner execution finished`);
|
58
|
+
}).catch(e => {
|
59
|
+
log.error(`[XCUITest] xcodebuild error has occurred during XCUITest execution:\n${e}`);
|
60
|
+
});
|
61
|
+
|
62
|
+
// Get firewall global state (Firewall socketfilterfw):
|
63
|
+
const state = await exec(`/usr/libexec/ApplicationFirewall/socketfilterfw --getglobalstate`);
|
64
|
+
const isFirewallDisabled = state.stdout.toString().includes('Firewall is disabled');
|
65
|
+
if (!isFirewallDisabled) {
|
66
|
+
_allowNetworkPermissionsXCUITest();
|
67
|
+
}
|
68
|
+
|
69
|
+
const isServerUp = await _waitForTestTargetServerToStart(testTargetServerPort, spawnedProcess);
|
70
|
+
log.debug(`[XCUITest] Finished waiting for test target server to start, server is up: ${isServerUp}`);
|
71
|
+
}
|
72
|
+
|
73
|
+
function runXCUITest(
|
74
|
+
xcuitestRunnerPath,
|
75
|
+
simulatorId,
|
76
|
+
detoxServer,
|
77
|
+
detoxSessionId,
|
78
|
+
testTargetServerPort,
|
79
|
+
bundleId,
|
80
|
+
debugVisibility,
|
81
|
+
disableDumpViewHierarchy,
|
82
|
+
) {
|
83
|
+
log.debug(`[XCUITest] Running xcodebuild test with bundle id: ${bundleId}`);
|
84
|
+
let xcodebuildBinary = 'xcodebuild';
|
85
|
+
const flags = [
|
86
|
+
'-xctestrun', xcuitestRunnerPath,
|
87
|
+
'-sdk', 'iphonesimulator',
|
88
|
+
'-allowProvisioningUpdates',
|
89
|
+
'-destination', `platform=iOS Simulator,id=${simulatorId}`,
|
90
|
+
'test-without-building'
|
91
|
+
];
|
92
|
+
|
93
|
+
const env = {
|
94
|
+
TEST_RUNNER_IS_DETOX_ACTIVE: '1',
|
95
|
+
TEST_RUNNER_DETOX_SERVER: detoxServer,
|
96
|
+
TEST_RUNNER_DETOX_SESSION_ID: detoxSessionId,
|
97
|
+
TEST_RUNNER_TEST_TARGET_SERVER_PORT: testTargetServerPort,
|
98
|
+
TEST_RUNNER_BUNDLE_ID: bundleId,
|
99
|
+
TEST_RUNNER_DETOX_DEBUG_VISIBILITY: debugVisibility,
|
100
|
+
TEST_RUNNER_DETOX_DISABLE_VIEW_HIERARCHY_DUMP: disableDumpViewHierarchy
|
101
|
+
};
|
102
|
+
|
103
|
+
const options = {
|
104
|
+
maxBuffer: 1024 * 1024 * 1024,
|
105
|
+
retries: 1,
|
106
|
+
verbosity: 'high',
|
107
|
+
};
|
108
|
+
|
109
|
+
const command = `${env.TEST_RUNNER_IS_DETOX_ACTIVE ? Object.keys(env).map(key => `${key}=${env[key]}`).join(' ') : ''} ${xcodebuildBinary} ${flags.map(flag => flag.includes(' ') ? `"${flag}"` : flag).join(' ')}`;
|
110
|
+
log.debug(`[XCUITest] Running command: ${command}`);
|
111
|
+
|
112
|
+
// TODO: consider using this instead of the Terminal approach below.
|
113
|
+
// const isRunningOnTerminal = process.stdout.isTTY;
|
114
|
+
// if (isRunningOnTerminal === true) {
|
115
|
+
// return execWithRetriesAndLogs(command, options);
|
116
|
+
// }
|
117
|
+
//
|
118
|
+
// log.info(`[XCUITest] Currently not running through the Terminal, will run the xcodebuild command on the Terminal`);
|
119
|
+
return _runCommandInTerminal(command, options);
|
120
|
+
}
|
121
|
+
|
122
|
+
function _runCommandInTerminal(command, options) {
|
123
|
+
const escapedCommand = command.replace(/"/g, '\\"'); // escape double quotes
|
124
|
+
|
125
|
+
// opens the Terminal app and runs the command in a new window, then closes the window when the command is done running.
|
126
|
+
const appleScript = `
|
127
|
+
tell application "Terminal"
|
128
|
+
if not running then
|
129
|
+
open
|
130
|
+
end if
|
131
|
+
|
132
|
+
activate
|
133
|
+
do script "${escapedCommand}; exit"
|
134
|
+
|
135
|
+
repeat
|
136
|
+
delay 1
|
137
|
+
if not busy of window 1 then
|
138
|
+
close window 1
|
139
|
+
exit repeat
|
140
|
+
end if
|
141
|
+
end repeat
|
142
|
+
end tell
|
143
|
+
`;
|
144
|
+
|
145
|
+
return execWithRetriesAndLogs(`osascript -e '${appleScript}'`, options);
|
146
|
+
}
|
147
|
+
|
148
|
+
function _allowNetworkPermissionsXCUITest() {
|
149
|
+
log.debug(`[XCUITest] Allowing network permissions`);
|
150
|
+
let didCallback = false;
|
151
|
+
|
152
|
+
const childProcess = osascript.executeFile(
|
153
|
+
`${__dirname}/allowNetworkPermissionsXCUITest.scpt`,
|
154
|
+
function(err, _, __) {
|
155
|
+
if (err) {
|
156
|
+
log.error(`[XCUITest] Failed to approve network permissions for XCUITest target:\n\t${err}`);
|
157
|
+
} else {
|
158
|
+
log.debug(`[XCUITest] Network permissions are allowed`);
|
159
|
+
}
|
160
|
+
|
161
|
+
didCallback = true;
|
162
|
+
});
|
163
|
+
|
164
|
+
setTimeout(() => {
|
165
|
+
if (didCallback || !childProcess) {
|
166
|
+
return;
|
167
|
+
}
|
168
|
+
|
169
|
+
log.debug(`[XCUITest] Killing the process that allows network permissions (timed-out)`);
|
170
|
+
childProcess.stdin.pause();
|
171
|
+
childProcess.kill('SIGTERM');
|
172
|
+
|
173
|
+
}, 30000);
|
174
|
+
}
|
175
|
+
|
176
|
+
async function _waitForTestTargetServerToStart(testTargetServerPort, cpPromise) {
|
177
|
+
log.debug(`[XCUITest] Waiting for test target server to start on port ${testTargetServerPort}...`);
|
178
|
+
let isServerUp = false;
|
179
|
+
let retries = 0;
|
180
|
+
|
181
|
+
while (!isServerUp && retries++ < 90) {
|
182
|
+
try {
|
183
|
+
await exec(`nc -z localhost ${testTargetServerPort}`);
|
184
|
+
isServerUp = true;
|
185
|
+
} catch (e) {
|
186
|
+
log.debug(`[XCUITest] Test target server is not up yet, waiting...`);
|
187
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
188
|
+
}
|
189
|
+
}
|
190
|
+
|
191
|
+
if (!isServerUp) {
|
192
|
+
log.error(`[XCUITest] Test target server is not up after 90 seconds, aborting`);
|
193
|
+
|
194
|
+
if (cpPromise.childProcess.kill('SIGTERM')) {
|
195
|
+
log.debug(`[XCUITest] Test target process was killed`);
|
196
|
+
} else {
|
197
|
+
log.debug(`[XCUITest] Test target process was not killed`);
|
198
|
+
}
|
199
|
+
|
200
|
+
return false;
|
201
|
+
}
|
202
|
+
|
203
|
+
log.debug(`[XCUITest] Test target server is up and running`);
|
204
|
+
return true;
|
205
|
+
}
|
206
|
+
|
207
|
+
module.exports = {
|
208
|
+
launchXCUITest
|
209
|
+
};
|
@@ -0,0 +1,14 @@
|
|
1
|
+
tell application "System Events"
|
2
|
+
set frontmost of process "UserNotificationCenter" to true
|
3
|
+
tell process "UserNotificationCenter"
|
4
|
+
repeat until (exists button "Allow" of window 1)
|
5
|
+
delay 1
|
6
|
+
end repeat
|
7
|
+
|
8
|
+
repeat while exists button "Allow" of window 1
|
9
|
+
if exists button "Allow" of window 1 then
|
10
|
+
click button "Allow" of window 1
|
11
|
+
end if
|
12
|
+
end repeat
|
13
|
+
end tell
|
14
|
+
end tell
|
@@ -51,7 +51,8 @@ class DetoxPrimaryContext extends DetoxContext {
|
|
51
51
|
}
|
52
52
|
}
|
53
53
|
|
54
|
-
async [symbols.resolveConfig](opts = {})
|
54
|
+
async [symbols.resolveConfig](opts = { argv: { configuration: process.env.DETOX_DBG_SELECTED_CFG } })
|
55
|
+
{
|
55
56
|
const session = this[$sessionState];
|
56
57
|
if (!session.detoxConfig) {
|
57
58
|
const configuration = require('../configuration');
|
@@ -61,6 +61,7 @@ class DetoxSession {
|
|
61
61
|
}
|
62
62
|
|
63
63
|
notify() {
|
64
|
+
console.log(`notify: pendingAppStatus=${this._pendingAppStatus}, pendingTesterStatus=${this._pendingTesterStatus}\n\n`);
|
64
65
|
if (this._pendingTesterStatus === true) {
|
65
66
|
this._notifyAboutTesterConnect();
|
66
67
|
}
|
@@ -121,8 +122,10 @@ class DetoxSession {
|
|
121
122
|
|
122
123
|
_notifyAboutAppConnect() {
|
123
124
|
log.trace(`app joined session ${this.id}`);
|
125
|
+
console.log(`app joined session ${this.id}`);
|
124
126
|
|
125
127
|
if (!this._tester) {
|
128
|
+
console.warn(`app joined session ${this.id} without a tester`);
|
126
129
|
return;
|
127
130
|
}
|
128
131
|
|
@@ -23,6 +23,7 @@ class AnonymousConnectionHandler {
|
|
23
23
|
}
|
24
24
|
|
25
25
|
_handleLoginAction(action) {
|
26
|
+
console.log(`[DetoxServer.js/LOGIN] role=${action.params.role}, sessionId=${action.params.sessionId}`);
|
26
27
|
if (!action.params) {
|
27
28
|
throw new DetoxRuntimeError({
|
28
29
|
message: `Invalid login action received, it has no .params`,
|
@@ -17,6 +17,7 @@ async function execWithRetriesAndLogs(bin, options = {}) {
|
|
17
17
|
timeout = 0,
|
18
18
|
statusLogs = {},
|
19
19
|
verbosity = 'normal',
|
20
|
+
maxBuffer = 1024 * 1024,
|
20
21
|
} = options;
|
21
22
|
|
22
23
|
const trackingId = execsCounter.inc();
|
@@ -35,7 +36,7 @@ async function execWithRetriesAndLogs(bin, options = {}) {
|
|
35
36
|
} else if (statusLogs.retrying) {
|
36
37
|
_logExecRetrying(logger, cmd, tryNumber, lastError);
|
37
38
|
}
|
38
|
-
result = await exec(cmd, { timeout });
|
39
|
+
result = await exec(cmd, { timeout, maxBuffer });
|
39
40
|
});
|
40
41
|
} catch (err) {
|
41
42
|
const failReason = err.code == null && timeout > 0
|
@@ -126,6 +127,7 @@ async function execAsync(command) {
|
|
126
127
|
const result = await exec(command);
|
127
128
|
return _.trim(result.stdout);
|
128
129
|
}
|
130
|
+
|
129
131
|
module.exports = {
|
130
132
|
execWithRetriesAndLogs,
|
131
133
|
execAsync
|
package/src/utils/environment.js
CHANGED
@@ -188,7 +188,30 @@ async function getFrameworkPath() {
|
|
188
188
|
async function _doGetFrameworkPath() {
|
189
189
|
const detoxVersion = getDetoxVersion();
|
190
190
|
const sha1 = (await exec(`(echo "${detoxVersion}" && xcodebuild -version) | shasum | awk '{print $1}'`)).stdout.trim();
|
191
|
-
return `${DETOX_LIBRARY_ROOT_PATH}/ios/${sha1}/Detox.framework`;
|
191
|
+
return `${DETOX_LIBRARY_ROOT_PATH}/ios/framework/${sha1}/Detox.framework`;
|
192
|
+
}
|
193
|
+
|
194
|
+
let _iosXCUITestRunnerPath;
|
195
|
+
async function getXCUITestRunnerPath() {
|
196
|
+
if (!_iosXCUITestRunnerPath) {
|
197
|
+
_iosXCUITestRunnerPath = _doGetXCUITestRunnerPath();
|
198
|
+
}
|
199
|
+
|
200
|
+
return _iosXCUITestRunnerPath;
|
201
|
+
}
|
202
|
+
|
203
|
+
async function _doGetXCUITestRunnerPath() {
|
204
|
+
const detoxVersion = getDetoxVersion();
|
205
|
+
const sha1 = (await exec(`(echo "${detoxVersion}" && xcodebuild -version) | shasum | awk '{print $1}'`)).stdout.trim();
|
206
|
+
|
207
|
+
const derivedDataPath = `${DETOX_LIBRARY_ROOT_PATH}/ios/xcuitest-runner/${sha1}`;
|
208
|
+
|
209
|
+
const xctestrunPath = (await exec(`find ${derivedDataPath} -name "*.xctestrun" -print -quit`)).stdout.trim();
|
210
|
+
if (!xctestrunPath) {
|
211
|
+
throw new DetoxRuntimeError(`Failed to find .xctestrun file in ${derivedDataPath}`);
|
212
|
+
}
|
213
|
+
|
214
|
+
return xctestrunPath;
|
192
215
|
}
|
193
216
|
|
194
217
|
function getDetoxLibraryRootPath() {
|
@@ -226,6 +249,7 @@ module.exports = {
|
|
226
249
|
getGmsaasPath,
|
227
250
|
getDetoxVersion,
|
228
251
|
getFrameworkPath,
|
252
|
+
getXCUITestRunnerPath,
|
229
253
|
getAndroidSDKPath,
|
230
254
|
getAndroidEmulatorPath,
|
231
255
|
getDetoxLibraryRootPath,
|
@@ -8,14 +8,17 @@ class IosSimulatorEnvValidator extends EnvironmentValidatorBase {
|
|
8
8
|
async validate() {
|
9
9
|
const detoxFrameworkPath = await environment.getFrameworkPath();
|
10
10
|
|
11
|
-
if (!
|
11
|
+
if (!fs.existsSync(detoxFrameworkPath)) {
|
12
12
|
throw new DetoxRuntimeError(`${detoxFrameworkPath} could not be found, this means either you changed a version of Xcode or Detox postinstall script was unsuccessful.
|
13
13
|
To attempt a fix try running 'detox clean-framework-cache && detox build-framework-cache'`);
|
14
14
|
}
|
15
|
-
}
|
16
15
|
|
17
|
-
|
18
|
-
|
16
|
+
const detoxXCUITestRunnerPath = await environment.getXCUITestRunnerPath();
|
17
|
+
|
18
|
+
if (!fs.existsSync(detoxXCUITestRunnerPath)) {
|
19
|
+
throw new DetoxRuntimeError(`${detoxXCUITestRunnerPath} could not be found, this means either you changed a version of Xcode or Detox postinstall script was unsuccessful.
|
20
|
+
To attempt a fix try running 'detox clean-xcuitest-cache && detox build-xcuitest-cache'`);
|
21
|
+
}
|
19
22
|
}
|
20
23
|
}
|
21
24
|
|
@@ -1 +0,0 @@
|
|
1
|
-
12d1a9cfa955008ce7e6e8f43ef74da1
|
@@ -1 +0,0 @@
|
|
1
|
-
4c7895239a15b9acae9679a26667e27631a2be19
|
@@ -1 +0,0 @@
|
|
1
|
-
93cee9902249260f8f05a2659650938f4164b90daca144fc81a70b9263b36fa9
|
@@ -1 +0,0 @@
|
|
1
|
-
b65a42554b5d9a2eeac7d3b9001811f1e7a633b708b4dd841849a91eb7118f7ada259bb58700a08ec2d659b7035afead27aa800a9311a1514b00a04202bde7cb
|
@@ -1 +0,0 @@
|
|
1
|
-
09f94e47a00171571d1738b4a3f75bb2
|
@@ -1 +0,0 @@
|
|
1
|
-
8e9ec0a0059796344f457b77b4474039c976fdee
|
@@ -1 +0,0 @@
|
|
1
|
-
121c023a311947235b10d14987a0de078f3760f9264ebe20ac061d47a334a376
|
@@ -1 +0,0 @@
|
|
1
|
-
544a899292284a949f905f8c181236b39319980180f28b20d4e6827c9bfc1e1d01564d7ad44ca014f15e38aa572f528c9886b9e1d8825a577b86cc21235134db
|
@@ -1 +0,0 @@
|
|
1
|
-
acd9cc7c446bdbec5e2ed126330f8178
|
@@ -1 +0,0 @@
|
|
1
|
-
ec0e48ff2b6fb3fa8a114a10fab451a8386a1528
|
@@ -1 +0,0 @@
|
|
1
|
-
da04b622faa4f09ebc5395c8177812e905c42836f489147046d394e2f33aa7b3
|
@@ -1 +0,0 @@
|
|
1
|
-
86b45511393ffa8d74be60e343701a364698a95c6f12135ee6fb207b9190ef611f14b7db0e90334b6ab53faac783ec46164a03e2ebde217c5d75e3e86e3075f6
|
package/Detox-ios.tbz
DELETED
Binary file
|
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/bin/bash -e
|
2
|
-
|
3
|
-
SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
|
4
|
-
|
5
|
-
XCODEVERSION=$(xcodebuild -version | grep -oEi "([0-9]*(\.[0-9]*)+)")
|
6
|
-
if [ "${XCODEVERSION}" == "`echo -e "${XCODEVERSION}\n12.0" | sort --version-sort -r | head -n1`" ]; then
|
7
|
-
echo "Xcode 12 and above; using modern script for building the framework to support Apple Silicon"
|
8
|
-
FRAMEWORK_SCRIPT="build_universal_framework_modern.sh"
|
9
|
-
else
|
10
|
-
echo "Xcode 11 and below; using legacy script for building"
|
11
|
-
FRAMEWORK_SCRIPT="build_universal_framework_legacy.sh"
|
12
|
-
fi
|
13
|
-
|
14
|
-
"${SCRIPTPATH}/${FRAMEWORK_SCRIPT}" "$@"
|
@@ -1,76 +0,0 @@
|
|
1
|
-
#!/bin/bash -e
|
2
|
-
|
3
|
-
PROJECT=$1
|
4
|
-
OUTPUT_DIR=$2
|
5
|
-
CONFIGURATION=Release
|
6
|
-
PROJECT_NAME=Detox
|
7
|
-
|
8
|
-
set -e
|
9
|
-
|
10
|
-
function remove_arch() {
|
11
|
-
lipo -create "${1}" "${2}" -output "${3}"
|
12
|
-
}
|
13
|
-
|
14
|
-
# Make sure the output directory exists
|
15
|
-
|
16
|
-
mkdir -p "${OUTPUT_DIR}"
|
17
|
-
rm -fr "${OUTPUT_DIR}/${PROJECT_NAME}.framework"
|
18
|
-
|
19
|
-
TEMP_DIR=$(mktemp -d "$TMPDIR"DetoxBuild.XXXX)
|
20
|
-
echo TEMP_DIR = "${TEMP_DIR}"
|
21
|
-
|
22
|
-
# Step 0. Xcode version
|
23
|
-
|
24
|
-
XCODEVERSION=$(xcodebuild -version | grep -oEi "([0-9]*(\.[0-9]*)+)")
|
25
|
-
echo "Xcode ${XCODEVERSION}"
|
26
|
-
USE_NEW_BUILD_SYSTEM="YES"
|
27
|
-
if [ "${XCODEVERSION}" != "`echo -e "${XCODEVERSION}\n11.0" | sort --version-sort -r | head -n1`" ]; then
|
28
|
-
USE_NEW_BUILD_SYSTEM="NO"
|
29
|
-
fi
|
30
|
-
echo "Using -UseNewBuildSystem=${USE_NEW_BUILD_SYSTEM}"
|
31
|
-
|
32
|
-
# Step 1. Build Device and Simulator versions
|
33
|
-
|
34
|
-
BUILD_IOS=`xcodebuild -project "${PROJECT}" -UseNewBuildSystem=${USE_NEW_BUILD_SYSTEM} -scheme Detox -configuration "${CONFIGURATION}" -arch arm64 -sdk iphoneos ONLY_ACTIVE_ARCH=NO VALID_ARCHS=arm64 -showBuildSettings | awk -F= '/TARGET_BUILD_DIR/{x=$NF; gsub(/^[ \t]+|[ \t]+$/,"",x); print x}'`
|
35
|
-
BUILD_SIM=`xcodebuild -project "${PROJECT}" -UseNewBuildSystem=${USE_NEW_BUILD_SYSTEM} -scheme Detox -configuration "${CONFIGURATION}" -arch x86_64 -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO VALID_ARCHS=x86_64 -showBuildSettings | awk -F= '/TARGET_BUILD_DIR/{x=$NF; gsub(/^[ \t]+|[ \t]+$/,"",x); print x}'`
|
36
|
-
|
37
|
-
echo ${BUILD_IOS}
|
38
|
-
echo ${BUILD_SIM}
|
39
|
-
|
40
|
-
xcodebuild -project "${PROJECT}" -UseNewBuildSystem=${USE_NEW_BUILD_SYSTEM} -scheme Detox -configuration "${CONFIGURATION}" -arch arm64 -sdk iphoneos ONLY_ACTIVE_ARCH=NO clean build VALID_ARCHS=arm64 -quiet
|
41
|
-
xcodebuild -project "${PROJECT}" -UseNewBuildSystem=${USE_NEW_BUILD_SYSTEM} -scheme Detox -configuration "${CONFIGURATION}" -arch x86_64 -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO build VALID_ARCHS=x86_64 -quiet
|
42
|
-
|
43
|
-
# Step 2. Copy the framework structure (from iphoneos build) to the universal folder
|
44
|
-
|
45
|
-
cp -fR "${BUILD_IOS}/${PROJECT_NAME}.framework" "${TEMP_DIR}/"
|
46
|
-
|
47
|
-
# Step 3. Copy Swift modules from iphonesimulator build (if it exists) to the copied framework directory
|
48
|
-
|
49
|
-
SIMULATOR_SWIFT_MODULES_DIR="${BUILD_SIM}/${PROJECT_NAME}.framework/Modules/${PROJECT_NAME}.swiftmodule/."
|
50
|
-
if [ -d "${SIMULATOR_SWIFT_MODULES_DIR}" ]; then
|
51
|
-
cp -fR "${SIMULATOR_SWIFT_MODULES_DIR}" "${TEMP_DIR}/${PROJECT_NAME}.framework/Modules/${PROJECT_NAME}.swiftmodule"
|
52
|
-
fi
|
53
|
-
|
54
|
-
# Step 4. Create universal binary file using lipo and place the combined executable in the copied framework directory
|
55
|
-
|
56
|
-
remove_arch "${BUILD_SIM}/${PROJECT_NAME}.framework/${PROJECT_NAME}" "${BUILD_IOS}/${PROJECT_NAME}.framework/${PROJECT_NAME}" "${TEMP_DIR}/${PROJECT_NAME}.framework/${PROJECT_NAME}"
|
57
|
-
|
58
|
-
# Step 5. Create universal binaries for embedded frameworks
|
59
|
-
|
60
|
-
for SUB_FRAMEWORK in $( ls "${TEMP_DIR}/${PROJECT_NAME}.framework/Frameworks" ); do
|
61
|
-
if [ -d "${TEMP_DIR}/${PROJECT_NAME}.framework/Frameworks/$SUB_FRAMEWORK" ]; then
|
62
|
-
echo "Processing ${SUB_FRAMEWORK} as a dir"
|
63
|
-
BINARY_NAME="${SUB_FRAMEWORK%.*}"
|
64
|
-
|
65
|
-
remove_arch "${BUILD_SIM}/${PROJECT_NAME}.framework/Frameworks/${SUB_FRAMEWORK}/${BINARY_NAME}" "${BUILD_IOS}/${PROJECT_NAME}.framework/Frameworks/${SUB_FRAMEWORK}/${BINARY_NAME}" "${TEMP_DIR}/${PROJECT_NAME}.framework/Frameworks/${SUB_FRAMEWORK}/${BINARY_NAME}"
|
66
|
-
|
67
|
-
else
|
68
|
-
echo "Processing ${SUB_FRAMEWORK} as a file"
|
69
|
-
|
70
|
-
remove_arch "${BUILD_SIM}/${PROJECT_NAME}.framework/Frameworks/${SUB_FRAMEWORK}" "${BUILD_IOS}/${PROJECT_NAME}.framework/Frameworks/${SUB_FRAMEWORK}" "${TEMP_DIR}/${PROJECT_NAME}.framework/Frameworks/${SUB_FRAMEWORK}"
|
71
|
-
|
72
|
-
fi
|
73
|
-
done
|
74
|
-
|
75
|
-
mv "${TEMP_DIR}/${PROJECT_NAME}.framework" "${OUTPUT_DIR}"/
|
76
|
-
rm -fr "${TEMP_DIR}"
|