detox 20.0.3-breaking.new-global-lifecycle.0 → 20.0.6-breaking.new-global-lifecycle.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.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0-javadoc.jar → 20.0.6-breaking.new-global-lifecycle.0/detox-20.0.6-breaking.new-global-lifecycle.0-javadoc.jar} +0 -0
- package/Detox-android/com/wix/detox/20.0.6-breaking.new-global-lifecycle.0/detox-20.0.6-breaking.new-global-lifecycle.0-javadoc.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.0.6-breaking.new-global-lifecycle.0/detox-20.0.6-breaking.new-global-lifecycle.0-javadoc.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.0.6-breaking.new-global-lifecycle.0/detox-20.0.6-breaking.new-global-lifecycle.0-javadoc.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.0.6-breaking.new-global-lifecycle.0/detox-20.0.6-breaking.new-global-lifecycle.0-javadoc.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0-sources.jar → 20.0.6-breaking.new-global-lifecycle.0/detox-20.0.6-breaking.new-global-lifecycle.0-sources.jar} +0 -0
- package/Detox-android/com/wix/detox/20.0.6-breaking.new-global-lifecycle.0/detox-20.0.6-breaking.new-global-lifecycle.0-sources.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.0.6-breaking.new-global-lifecycle.0/detox-20.0.6-breaking.new-global-lifecycle.0-sources.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.0.6-breaking.new-global-lifecycle.0/detox-20.0.6-breaking.new-global-lifecycle.0-sources.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.0.6-breaking.new-global-lifecycle.0/detox-20.0.6-breaking.new-global-lifecycle.0-sources.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0.aar → 20.0.6-breaking.new-global-lifecycle.0/detox-20.0.6-breaking.new-global-lifecycle.0.aar} +0 -0
- package/Detox-android/com/wix/detox/{20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0.aar.md5 → 20.0.6-breaking.new-global-lifecycle.0/detox-20.0.6-breaking.new-global-lifecycle.0.aar.md5} +0 -0
- package/Detox-android/com/wix/detox/{20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0.aar.sha1 → 20.0.6-breaking.new-global-lifecycle.0/detox-20.0.6-breaking.new-global-lifecycle.0.aar.sha1} +0 -0
- package/Detox-android/com/wix/detox/{20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0.aar.sha256 → 20.0.6-breaking.new-global-lifecycle.0/detox-20.0.6-breaking.new-global-lifecycle.0.aar.sha256} +0 -0
- package/Detox-android/com/wix/detox/{20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0.aar.sha512 → 20.0.6-breaking.new-global-lifecycle.0/detox-20.0.6-breaking.new-global-lifecycle.0.aar.sha512} +0 -0
- package/Detox-android/com/wix/detox/{20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0.pom → 20.0.6-breaking.new-global-lifecycle.0/detox-20.0.6-breaking.new-global-lifecycle.0.pom} +1 -1
- package/Detox-android/com/wix/detox/20.0.6-breaking.new-global-lifecycle.0/detox-20.0.6-breaking.new-global-lifecycle.0.pom.md5 +1 -0
- package/Detox-android/com/wix/detox/20.0.6-breaking.new-global-lifecycle.0/detox-20.0.6-breaking.new-global-lifecycle.0.pom.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.0.6-breaking.new-global-lifecycle.0/detox-20.0.6-breaking.new-global-lifecycle.0.pom.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.0.6-breaking.new-global-lifecycle.0/detox-20.0.6-breaking.new-global-lifecycle.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-src.tbz +0 -0
- package/Detox-ios.tbz +0 -0
- package/index.d.ts +49 -40
- package/internals.d.ts +63 -15
- package/local-cli/cli.js +1 -1
- package/local-cli/rebuild-framework-cache.js +1 -1
- package/local-cli/test.js +3 -2
- package/local-cli/test.test.js +1 -1
- package/local-cli/testCommand/TestRunnerCommand.js +10 -7
- package/package.json +5 -4
- package/runners/jest/globalSetup.js +1 -1
- package/runners/jest/globalTeardown.js +1 -1
- package/runners/jest/testEnvironment/index.js +33 -16
- package/runners/jest/testEnvironment/listeners/DetoxCoreListener.js +76 -41
- package/runners/jest/testEnvironment/listeners/SpecReporter.js +1 -1
- package/runners/jest/testEnvironment/listeners/WorkerAssignReporter.js +1 -1
- package/src/DetoxWorker.js +4 -1
- package/src/artifacts/ArtifactsManager.js +8 -23
- package/src/artifacts/instruments/ios/SimulatorInstrumentsRecording.js +3 -3
- package/src/artifacts/log/ios/SimulatorLogRecording.js +1 -1
- package/src/artifacts/screenshot/SimulatorScreenshotPlugin.js +1 -1
- package/src/artifacts/templates/artifact/Artifact.js +1 -1
- package/src/artifacts/templates/plugin/ArtifactPlugin.js +1 -1
- package/src/artifacts/utils/temporaryPath.js +18 -7
- package/src/artifacts/video/SimulatorRecordVideoPlugin.js +1 -1
- package/src/client/AsyncWebSocket.js +8 -17
- package/src/client/Client.js +1 -1
- package/src/configuration/collectCliConfig.js +1 -1
- package/src/configuration/composeDeviceConfig.js +1 -1
- package/src/configuration/composeLoggerConfig.js +17 -8
- package/src/configuration/composeRunnerConfig.js +1 -1
- package/src/configuration/index.js +5 -1
- package/src/configuration/loadExternalConfig.js +1 -1
- package/src/devices/allocation/DeviceAllocator.js +3 -2
- package/src/devices/allocation/drivers/android/emulator/AVDValidator.js +1 -1
- package/src/devices/allocation/drivers/android/emulator/EmulatorAllocDriver.js +3 -2
- package/src/devices/allocation/drivers/android/emulator/EmulatorAllocationHelper.js +1 -1
- package/src/devices/allocation/drivers/android/emulator/EmulatorLauncher.js +3 -2
- package/src/devices/allocation/drivers/android/emulator/EmulatorVersionResolver.js +4 -6
- package/src/devices/allocation/drivers/android/emulator/launchEmulatorProcess.js +1 -1
- package/src/devices/allocation/drivers/android/genycloud/GenyInstanceAllocationHelper.js +1 -1
- package/src/devices/common/drivers/android/genycloud/services/GenyInstanceNaming.js +3 -3
- package/src/devices/common/drivers/android/genycloud/services/GenyRecipesService.js +1 -1
- package/src/devices/common/drivers/android/tools/EmulatorTelnet.js +1 -1
- package/src/devices/common/drivers/android/tools/FreeDeviceFinder.js +1 -1
- package/src/devices/common/drivers/ios/tools/AppleSimUtils.js +1 -1
- package/src/devices/lifecycle/GenyGlobalLifecycleHandler.js +9 -13
- package/src/devices/runtime/RuntimeDevice.js +7 -8
- package/src/devices/runtime/drivers/DeviceDriverBase.js +1 -1
- package/src/devices/runtime/drivers/android/AndroidDriver.js +1 -1
- package/src/devices/runtime/drivers/ios/SimulatorDriver.js +1 -1
- package/src/ipc/IPCClient.js +3 -8
- package/src/ipc/IPCServer.js +11 -11
- package/src/ipc/{state.js → SessionState.js} +23 -50
- package/src/logger/DetoxLogger.js +264 -155
- package/src/logger/index.js +4 -0
- package/src/logger/utils/BunyanLogger.js +72 -0
- package/src/logger/utils/CategoryThreadDispatcher.js +58 -0
- package/src/logger/utils/MessageStack.js +24 -0
- package/src/logger/{TraceThreadDispatcher.js → utils/ThreadDispatcher.js} +34 -5
- package/src/logger/{customConsoleLogger.js → utils/customConsoleLogger.js} +4 -4
- package/src/logger/utils/sanitizeBunyanContext.js +28 -0
- package/src/logger/utils/tracerLegacy.js +25 -0
- package/src/realms/DetoxContext.js +65 -57
- package/src/realms/DetoxInternalsFacade.js +7 -5
- package/src/realms/DetoxPrimaryContext.js +125 -40
- package/src/realms/DetoxSecondaryContext.js +31 -30
- package/src/server/DetoxConnection.js +18 -23
- package/src/server/DetoxServer.js +7 -10
- package/src/server/DetoxSession.js +6 -6
- package/src/server/DetoxSessionManager.js +1 -1
- package/src/server/handlers/RegisteredConnectionHandler.js +1 -2
- package/src/symbols.js +12 -8
- package/src/utils/childProcess/exec.js +1 -1
- package/src/utils/childProcess/spawn.js +1 -1
- package/src/utils/streamUtils.js +10 -11
- package/src/utils/trace.js +2 -18
- package/src/utils/traceMethods.js +15 -0
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0-javadoc.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0-javadoc.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0-javadoc.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0-javadoc.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0-sources.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0-sources.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0-sources.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0-sources.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0.pom.md5 +0 -1
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0.pom.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0.pom.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0.pom.sha512 +0 -1
- package/src/logger/DetoxTraceEventBuilder.js +0 -21
- package/src/logger/DetoxTracer.js +0 -133
- package/src/utils/ChromeTracingExporter.js +0 -54
@@ -1,7 +1,8 @@
|
|
1
1
|
// @ts-nocheck
|
2
2
|
const { DetoxRuntimeError } = require('../../../../../errors');
|
3
|
+
const log = require('../../../../../utils/logger').child({ cat: 'device' });
|
3
4
|
const retry = require('../../../../../utils/retry');
|
4
|
-
const
|
5
|
+
const traceMethods = require('../../../../../utils/traceMethods');
|
5
6
|
const DeviceLauncher = require('../../../../common/drivers/DeviceLauncher');
|
6
7
|
const { LaunchCommand } = require('../../../../common/drivers/android/emulator/exec/EmulatorExec');
|
7
8
|
|
@@ -14,7 +15,7 @@ class EmulatorLauncher extends DeviceLauncher {
|
|
14
15
|
super(eventEmitter);
|
15
16
|
this._adb = adb;
|
16
17
|
this._emulatorExec = emulatorExec;
|
17
|
-
traceMethods(
|
18
|
+
traceMethods(log, this, ['_awaitEmulatorBoot']);
|
18
19
|
}
|
19
20
|
|
20
21
|
/**
|
@@ -1,8 +1,6 @@
|
|
1
|
-
const log = require('../../../../../utils/logger').child({
|
1
|
+
const log = require('../../../../../utils/logger').child({ cat: 'device' });
|
2
2
|
const { QueryVersionCommand } = require('../../../../common/drivers/android/emulator/exec/EmulatorExec');
|
3
3
|
|
4
|
-
const EMU_BIN_VERSION_DETECT_EV = 'EMU_BIN_VERSION_DETECT';
|
5
|
-
|
6
4
|
class EmulatorVersionResolver {
|
7
5
|
constructor(emulatorExec) {
|
8
6
|
this._emulatorExec = emulatorExec;
|
@@ -21,18 +19,18 @@ class EmulatorVersionResolver {
|
|
21
19
|
try {
|
22
20
|
rawOutput = await this._emulatorExec.exec(new QueryVersionCommand({ headless })) || '';
|
23
21
|
} catch (error) {
|
24
|
-
log.error({
|
22
|
+
log.error({ success: false, error }, 'Could not detect emulator binary version', error);
|
25
23
|
return null;
|
26
24
|
}
|
27
25
|
|
28
26
|
const matches = rawOutput.match(/Android emulator version ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]*)/);
|
29
27
|
if (!matches) {
|
30
|
-
log.warn({
|
28
|
+
log.warn({ success: false }, 'Could not detect emulator binary version, got:', rawOutput);
|
31
29
|
return null;
|
32
30
|
}
|
33
31
|
|
34
32
|
const version = this._parseVersionString(matches[1]);
|
35
|
-
log.debug({
|
33
|
+
log.debug({ success: true }, 'Detected emulator binary version', version);
|
36
34
|
return version;
|
37
35
|
}
|
38
36
|
|
@@ -3,7 +3,7 @@ const fs = require('fs');
|
|
3
3
|
const _ = require('lodash');
|
4
4
|
const { Tail } = require('tail');
|
5
5
|
|
6
|
-
const unitLogger = require('../../../../../utils/logger').child({
|
6
|
+
const unitLogger = require('../../../../../utils/logger').child({ cat: 'device' });
|
7
7
|
|
8
8
|
function launchEmulatorProcess(emulatorName, emulatorExec, emulatorLaunchCommand) {
|
9
9
|
let childProcessOutput;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
// @ts-nocheck
|
2
|
-
const logger = require('../../../../../utils/logger').child({
|
2
|
+
const logger = require('../../../../../utils/logger').child({ cat: 'device' });
|
3
3
|
const DeviceAllocationHelper = require('../../../../common/drivers/DeviceAllocationHelper');
|
4
4
|
|
5
5
|
const { ALLOCATE_DEVICE_LOG_EVT } = DeviceAllocationHelper;
|
@@ -1,9 +1,9 @@
|
|
1
|
-
const
|
1
|
+
const internals = () => require('../../../../../../../internals');
|
2
2
|
|
3
3
|
class GenyInstanceNaming {
|
4
4
|
generateName() {
|
5
|
-
const {
|
6
|
-
return `Detox.${id}.${
|
5
|
+
const { session, worker } = internals();
|
6
|
+
return `Detox.${session.id}.${worker.id}`;
|
7
7
|
}
|
8
8
|
|
9
9
|
isFamilial(name) {
|
@@ -5,7 +5,7 @@ const path = require('path');
|
|
5
5
|
const fs = require('fs-extra');
|
6
6
|
const Telnet = require('telnet-client');
|
7
7
|
|
8
|
-
const log = require('../../../../../utils/logger').child({
|
8
|
+
const log = require('../../../../../utils/logger').child({ cat: 'device' });
|
9
9
|
|
10
10
|
class EmulatorTelnet {
|
11
11
|
constructor() {
|
@@ -7,7 +7,7 @@ const DetoxRuntimeError = require('../../../../../errors/DetoxRuntimeError');
|
|
7
7
|
const { joinArgs } = require('../../../../../utils/argparse');
|
8
8
|
const childProcess = require('../../../../../utils/childProcess');
|
9
9
|
const environment = require('../../../../../utils/environment');
|
10
|
-
const log = require('../../../../../utils/logger').child({
|
10
|
+
const log = require('../../../../../utils/logger').child({ cat: 'device' });
|
11
11
|
const { quote } = require('../../../../../utils/shellQuote');
|
12
12
|
|
13
13
|
class AppleSimUtils {
|
@@ -1,6 +1,4 @@
|
|
1
|
-
const
|
2
|
-
|
3
|
-
const logger = require('../../utils/logger').child({ __filename });
|
1
|
+
const logger = require('../../utils/logger').child({ cat: 'device' });
|
4
2
|
|
5
3
|
const cleanupLogData = {
|
6
4
|
event: 'GENYCLOUD_TEARDOWN',
|
@@ -12,16 +10,14 @@ class GenyGlobalLifecycleHandler {
|
|
12
10
|
this._instanceLifecycleService = instanceLifecycleService;
|
13
11
|
}
|
14
12
|
|
15
|
-
async globalInit() {
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
}
|
24
|
-
});
|
13
|
+
async globalInit() {}
|
14
|
+
|
15
|
+
emergencyCleanup() {
|
16
|
+
const { rawDevices } = this._deviceCleanupRegistry.readRegisteredDevicesUNSAFE();
|
17
|
+
const instanceHandles = rawDevicesToInstanceHandles(rawDevices);
|
18
|
+
if (instanceHandles.length) {
|
19
|
+
reportGlobalCleanupSummary(instanceHandles);
|
20
|
+
}
|
25
21
|
}
|
26
22
|
|
27
23
|
async globalCleanup() {
|
@@ -1,6 +1,8 @@
|
|
1
1
|
const DetoxRuntimeError = require('../../errors/DetoxRuntimeError');
|
2
2
|
const debug = require('../../utils/debug'); // debug utils, leave here even if unused
|
3
|
-
const
|
3
|
+
const log = require('../../utils/logger').child({ cat: 'device' });
|
4
|
+
const { traceCall } = require('../../utils/trace');
|
5
|
+
const traceMethods = require('../../utils/traceMethods');
|
4
6
|
const wrapWithStackTraceCutter = require('../../utils/wrapWithStackTraceCutter');
|
5
7
|
|
6
8
|
const LaunchArgsEditor = require('./utils/LaunchArgsEditor');
|
@@ -48,7 +50,7 @@ class RuntimeDevice {
|
|
48
50
|
'unreverseTcpPort',
|
49
51
|
];
|
50
52
|
|
51
|
-
traceMethods(
|
53
|
+
traceMethods(log, this, methodNames);
|
52
54
|
wrapWithStackTraceCutter(this, methodNames);
|
53
55
|
|
54
56
|
this._appsConfig = appsConfig;
|
@@ -234,16 +236,13 @@ class RuntimeDevice {
|
|
234
236
|
}
|
235
237
|
|
236
238
|
async installApp(binaryPath, testBinaryPath) {
|
237
|
-
|
238
|
-
|
239
|
-
return this.deviceDriver.installApp(currentApp.binaryPath, currentApp.testBinaryPath);
|
240
|
-
});
|
239
|
+
const currentApp = binaryPath ? { binaryPath, testBinaryPath } : this._getCurrentApp();
|
240
|
+
await this.deviceDriver.installApp(currentApp.binaryPath, currentApp.testBinaryPath);
|
241
241
|
}
|
242
242
|
|
243
243
|
async uninstallApp(bundleId) {
|
244
244
|
const _bundleId = bundleId || this._bundleId;
|
245
|
-
await
|
246
|
-
this.deviceDriver.uninstallApp(_bundleId));
|
245
|
+
await this.deviceDriver.uninstallApp(_bundleId);
|
247
246
|
}
|
248
247
|
|
249
248
|
async installUtilBinaries() {
|
@@ -18,7 +18,7 @@ const sleep = require('../../../../utils/sleep');
|
|
18
18
|
const apkUtils = require('../../../common/drivers/android/tools/apk');
|
19
19
|
const DeviceDriverBase = require('../DeviceDriverBase');
|
20
20
|
|
21
|
-
const log = logger.child({
|
21
|
+
const log = logger.child({ cat: 'device' });
|
22
22
|
|
23
23
|
/**
|
24
24
|
* @typedef AndroidDriverProps
|
@@ -7,7 +7,7 @@ const _ = require('lodash');
|
|
7
7
|
const temporaryPath = require('../../../../artifacts/utils/temporaryPath');
|
8
8
|
const DetoxRuntimeError = require('../../../../errors/DetoxRuntimeError');
|
9
9
|
const getAbsoluteBinaryPath = require('../../../../utils/getAbsoluteBinaryPath');
|
10
|
-
const log = require('../../../../utils/logger').child({
|
10
|
+
const log = require('../../../../utils/logger').child({ cat: 'device' });
|
11
11
|
const pressAnyKey = require('../../../../utils/pressAnyKey');
|
12
12
|
|
13
13
|
const IosDriver = require('./IosDriver');
|
package/src/ipc/IPCClient.js
CHANGED
@@ -6,8 +6,8 @@ class IPCClient {
|
|
6
6
|
constructor({ id, logger, state }) {
|
7
7
|
this._id = id;
|
8
8
|
/** @type {import('../logger/DetoxLogger')} logger */
|
9
|
-
this._logger = logger.child({
|
10
|
-
/** @type {import('./
|
9
|
+
this._logger = logger.child({ cat: 'ipc' });
|
10
|
+
/** @type {import('./SessionState')} */
|
11
11
|
this._state = state;
|
12
12
|
|
13
13
|
this._client = null;
|
@@ -47,7 +47,6 @@ class IPCClient {
|
|
47
47
|
}
|
48
48
|
|
49
49
|
async registerWorker(workerId) {
|
50
|
-
this._state.workerId = workerId;
|
51
50
|
await this._emit('registerWorker', { workerId });
|
52
51
|
}
|
53
52
|
|
@@ -75,11 +74,7 @@ class IPCClient {
|
|
75
74
|
}
|
76
75
|
|
77
76
|
async _registerContext() {
|
78
|
-
const sessionState = await this._emit('registerContext', {
|
79
|
-
id: this._id,
|
80
|
-
logFile: this._logger.file,
|
81
|
-
});
|
82
|
-
|
77
|
+
const sessionState = await this._emit('registerContext', { id: this._id });
|
83
78
|
this._state.patch(sessionState);
|
84
79
|
}
|
85
80
|
|
package/src/ipc/IPCServer.js
CHANGED
@@ -3,13 +3,14 @@ const { IPC } = require('node-ipc');
|
|
3
3
|
class IPCServer {
|
4
4
|
/**
|
5
5
|
* @param {object} options
|
6
|
-
* @param {import('./
|
6
|
+
* @param {import('./SessionState')} options.sessionState
|
7
7
|
* @param {Detox.Logger} options.logger
|
8
8
|
*/
|
9
9
|
constructor({ sessionState, logger }) {
|
10
10
|
this._sessionState = sessionState;
|
11
|
-
this._logger = logger.child({
|
11
|
+
this._logger = logger.child({ cat: 'ipc,ipc-server' });
|
12
12
|
this._ipc = null;
|
13
|
+
this._workers = new Set();
|
13
14
|
}
|
14
15
|
|
15
16
|
get id() {
|
@@ -48,13 +49,9 @@ class IPCServer {
|
|
48
49
|
});
|
49
50
|
}
|
50
51
|
|
51
|
-
onRegisterContext({ id
|
52
|
+
onRegisterContext({ id }, socket) {
|
52
53
|
this._sessionState.contexts.push(id);
|
53
54
|
|
54
|
-
if (logFile && !this._sessionState.logFiles.includes(logFile)) {
|
55
|
-
this._sessionState.logFiles.push(logFile);
|
56
|
-
}
|
57
|
-
|
58
55
|
this._ipc.server.emit(socket, 'registerContextDone', {
|
59
56
|
failedTestFiles: this._sessionState.failedTestFiles,
|
60
57
|
testFilesToRetry: this._sessionState.testFilesToRetry,
|
@@ -62,13 +59,16 @@ class IPCServer {
|
|
62
59
|
});
|
63
60
|
}
|
64
61
|
|
65
|
-
onRegisterWorker({ workerId }, socket) {
|
62
|
+
onRegisterWorker({ workerId }, socket = null) {
|
63
|
+
const workersCount = this._workers.add(workerId).size;
|
64
|
+
const shouldBroadcast = workersCount > this._sessionState.workersCount;
|
65
|
+
this._sessionState.workersCount = workersCount;
|
66
|
+
|
66
67
|
if (socket) {
|
67
|
-
this._ipc.server.emit(socket, 'registerWorkerDone', {});
|
68
|
+
this._ipc.server.emit(socket, 'registerWorkerDone', { workersCount });
|
68
69
|
}
|
69
70
|
|
70
|
-
if (
|
71
|
-
const workersCount = this._sessionState.workersCount = workerId;
|
71
|
+
if (shouldBroadcast) {
|
72
72
|
this._ipc.server.broadcast('sessionStateUpdate', { workersCount });
|
73
73
|
}
|
74
74
|
}
|
@@ -3,6 +3,28 @@ const cycle = require('json-cycle');
|
|
3
3
|
const uuid = require('../utils/uuid');
|
4
4
|
|
5
5
|
class SessionState {
|
6
|
+
constructor({
|
7
|
+
id = uuid.UUID(),
|
8
|
+
contexts = [],
|
9
|
+
detoxConfigSnapshotPath = '',
|
10
|
+
detoxConfig = null,
|
11
|
+
detoxIPCServer = '',
|
12
|
+
failedTestFiles = [],
|
13
|
+
testFilesToRetry = [],
|
14
|
+
testSessionIndex = 0,
|
15
|
+
workersCount = 0
|
16
|
+
}) {
|
17
|
+
this.id = id;
|
18
|
+
this.contexts = contexts;
|
19
|
+
this.detoxConfigSnapshotPath = detoxConfigSnapshotPath;
|
20
|
+
this.detoxConfig = detoxConfig;
|
21
|
+
this.detoxIPCServer = detoxIPCServer;
|
22
|
+
this.failedTestFiles = failedTestFiles;
|
23
|
+
this.testFilesToRetry = testFilesToRetry;
|
24
|
+
this.testSessionIndex = testSessionIndex;
|
25
|
+
this.workersCount = workersCount;
|
26
|
+
}
|
27
|
+
|
6
28
|
patch(state) {
|
7
29
|
Object.assign(this, state);
|
8
30
|
}
|
@@ -37,53 +59,4 @@ class SessionState {
|
|
37
59
|
}
|
38
60
|
}
|
39
61
|
|
40
|
-
|
41
|
-
constructor({
|
42
|
-
id = uuid.UUID(),
|
43
|
-
detoxConfigSnapshotPath = '',
|
44
|
-
detoxConfig = null,
|
45
|
-
detoxIPCServer = '',
|
46
|
-
failedTestFiles = [],
|
47
|
-
testFilesToRetry = [],
|
48
|
-
testSessionIndex = 0,
|
49
|
-
workerId = undefined,
|
50
|
-
workersCount = 0
|
51
|
-
}) {
|
52
|
-
super();
|
53
|
-
|
54
|
-
this.id = id;
|
55
|
-
this.detoxConfigSnapshotPath = detoxConfigSnapshotPath;
|
56
|
-
this.detoxConfig = detoxConfig;
|
57
|
-
this.detoxIPCServer = detoxIPCServer;
|
58
|
-
this.failedTestFiles = failedTestFiles;
|
59
|
-
this.testFilesToRetry = testFilesToRetry;
|
60
|
-
this.testSessionIndex = testSessionIndex;
|
61
|
-
this.workerId = workerId;
|
62
|
-
this.workersCount = workersCount;
|
63
|
-
}
|
64
|
-
}
|
65
|
-
|
66
|
-
class PrimarySessionState extends SecondarySessionState {
|
67
|
-
constructor({
|
68
|
-
contexts = [],
|
69
|
-
logFiles = [],
|
70
|
-
failedTestFiles = [],
|
71
|
-
testFilesToRetry = [],
|
72
|
-
testSessionIndex = 0,
|
73
|
-
...baseOpts
|
74
|
-
}) {
|
75
|
-
super(baseOpts);
|
76
|
-
|
77
|
-
this.contexts = contexts;
|
78
|
-
this.failedTestFiles = failedTestFiles;
|
79
|
-
this.logFiles = logFiles;
|
80
|
-
this.testSessionIndex = testSessionIndex;
|
81
|
-
this.testFilesToRetry = testFilesToRetry;
|
82
|
-
}
|
83
|
-
}
|
84
|
-
|
85
|
-
module.exports = {
|
86
|
-
SessionState,
|
87
|
-
PrimarySessionState,
|
88
|
-
SecondarySessionState,
|
89
|
-
};
|
62
|
+
module.exports = SessionState;
|