detox 20.1.0-next-is-hittable-check.0 → 20.1.1
Sign up to get free protection for your applications and to get access to all the features.
- package/.eslintrc.js +2 -7
- package/Detox-android/com/wix/detox/{20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-javadoc.jar → 20.1.1/detox-20.1.1-javadoc.jar} +0 -0
- package/Detox-android/com/wix/detox/20.1.1/detox-20.1.1-javadoc.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.1.1/detox-20.1.1-javadoc.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.1.1/detox-20.1.1-javadoc.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.1.1/detox-20.1.1-javadoc.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-sources.jar → 20.1.1/detox-20.1.1-sources.jar} +0 -0
- package/Detox-android/com/wix/detox/20.1.1/detox-20.1.1-sources.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.1.1/detox-20.1.1-sources.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.1.1/detox-20.1.1-sources.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.1.1/detox-20.1.1-sources.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/20.1.1/detox-20.1.1.aar +0 -0
- package/Detox-android/com/wix/detox/20.1.1/detox-20.1.1.aar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.1.1/detox-20.1.1.aar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.1.1/detox-20.1.1.aar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.1.1/detox-20.1.1.aar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.pom → 20.1.1/detox-20.1.1.pom} +1 -1
- package/Detox-android/com/wix/detox/20.1.1/detox-20.1.1.pom.md5 +1 -0
- package/Detox-android/com/wix/detox/20.1.1/detox-20.1.1.pom.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.1.1/detox-20.1.1.pom.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.1.1/detox-20.1.1.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/android/build.gradle +0 -1
- package/android/detox/src/full/java/com/wix/detox/TestEngineFacade.kt +3 -3
- package/android/detox/src/full/java/com/wix/detox/adapters/server/QueryStatusActionHandler.kt +12 -80
- package/android/detox/src/full/java/com/wix/detox/espresso/common/UiControllerImplReflected.kt +16 -0
- package/android/detox/src/full/java/com/wix/detox/espresso/idlingresources/DescriptiveIdlingResource.kt +8 -0
- package/android/detox/src/full/java/com/wix/detox/espresso/registry/BusyResourcesInquirer.kt +48 -0
- package/android/detox/src/full/java/com/wix/detox/inquiry/DetoxBusyResource.kt +92 -0
- package/android/detox/src/full/java/com/wix/detox/{reactnative/idlingresources/IdlingResourceDescription.kt → inquiry/DetoxBusyResourceDescription.kt} +6 -6
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/AnimatedModuleIdlingResource.java +18 -7
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/AsyncStorageIdlingResource.kt +3 -4
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/BridgeIdlingResource.java +12 -6
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/DetoxBaseIdlingResource.java +2 -0
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/NetworkIdlingResource.java +14 -8
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/timers/TimersIdlingResource.kt +2 -6
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/uimodule/UIManagerModuleReflected.kt +1 -1
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/uimodule/UIModuleIdlingResource.kt +4 -6
- package/android/detox/src/testFull/java/com/wix/detox/adapters/server/QueryStatusActionHandlerSpec.kt +35 -94
- package/android/detox/src/testFull/java/com/wix/detox/espresso/registry/{IRStatusInquirerTest.kt → BusyResourcesInquirerTest.kt} +46 -7
- package/android/detox/src/testFull/java/com/wix/detox/{reactnative/idlingresources/IdlingResourceDescriptionSpec.kt → inquiry/DetoxBusyResourceDescriptionSpec.kt} +6 -6
- package/android/detox/src/testFull/java/com/wix/detox/inquiry/DetoxBusyResourceSpec.kt +134 -0
- package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/AsyncStorageIdlingResourceSpec.kt +4 -5
- package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/NetworkIdlingResourcesTest.kt +5 -5
- package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/timers/TimersIdlingResourceSpec.kt +4 -6
- package/index.d.ts +102 -18
- package/index.js +12 -1
- package/internals.d.ts +34 -9
- package/internals.js +10 -3
- package/local-cli/cli.js +6 -3
- package/local-cli/init.js +1 -1
- package/local-cli/test.js +6 -6
- package/local-cli/testCommand/TestRunnerCommand.js +97 -94
- package/local-cli/testCommand/TestRunnerError.js +17 -0
- package/local-cli/testCommand/builder.js +0 -1
- package/local-cli/testCommand/middlewares.js +4 -13
- package/local-cli/testCommand/warnings.js +0 -3
- package/package.json +31 -16
- package/runners/deprecation.js +42 -44
- package/runners/jest/index.d.ts +60 -0
- package/runners/jest/index.js +3 -8
- package/runners/jest/reporters/DetoxReporter.js +21 -10
- package/runners/jest/testEnvironment/index.js +57 -41
- package/runners/jest/testEnvironment/listeners/DetoxCoreListener.js +62 -35
- package/runners/jest/testEnvironment/listeners/SpecReporter.js +12 -14
- package/runners/jest/testEnvironment/listeners/WorkerAssignReporter.js +1 -5
- package/runners/jest/testEnvironment/utils/assertJestCircus27.js +17 -3
- package/src/DetoxWorker.js +96 -50
- package/src/android/core/NativeMatcher.js +14 -10
- package/src/android/espressoapi/EspressoDetox.js +1 -1
- package/src/android/espressoapi/web/WebElement.js +1 -1
- package/src/android/interactions/native.js +3 -2
- package/src/android/matchers/native.js +1 -2
- package/src/artifacts/ArtifactsManager.js +6 -6
- package/src/artifacts/templates/plugin/ArtifactPlugin.js +1 -1
- package/src/artifacts/templates/plugin/TwoSnapshotsPerTestPlugin.js +2 -1
- package/src/artifacts/templates/plugin/WholeTestRecorderPlugin.js +3 -2
- package/src/artifacts/utils/temporaryPath.js +32 -2
- package/src/client/AsyncWebSocket.js +3 -2
- package/src/client/actions/SyncStatusSchema.json +21 -0
- package/src/client/actions/formatters/SyncStatusFormatter.js +2 -0
- package/src/client/actions/formatters/sync-resources/BgThreadFormatter.js +5 -0
- package/src/configuration/collectCliConfig.js +2 -13
- package/src/configuration/composeLoggerConfig.js +1 -0
- package/src/configuration/composeRunnerConfig.js +5 -4
- package/src/devices/allocation/drivers/AllocationDriverBase.js +4 -2
- package/src/devices/allocation/drivers/android/emulator/EmulatorLauncher.js +3 -3
- package/src/devices/allocation/drivers/android/emulator/launchEmulatorProcess.js +3 -16
- package/src/devices/allocation/factories/base.js +1 -1
- package/src/devices/common/drivers/android/exec/ADB.js +4 -0
- package/src/devices/common/drivers/android/tools/AppInstallHelper.js +4 -4
- package/src/devices/common/drivers/android/tools/{FileXfer.js → FileTransfer.js} +2 -2
- package/src/devices/common/drivers/android/tools/TempFileTransfer.js +14 -0
- package/src/devices/common/drivers/ios/tools/AppleSimUtils.js +1 -1
- package/src/devices/lifecycle/GenyGlobalLifecycleHandler.js +2 -0
- package/src/devices/runtime/RuntimeDevice.js +3 -3
- package/src/devices/runtime/drivers/android/AndroidDriver.js +7 -6
- package/src/devices/runtime/factories/android.js +6 -5
- package/src/devices/runtime/factories/base.js +3 -2
- package/src/errors/DetoxConfigErrorComposer.js +6 -1
- package/src/errors/DetoxError.js +5 -1
- package/src/ios/expectTwo.js +22 -13
- package/src/ipc/IPCClient.js +26 -17
- package/src/ipc/IPCServer.js +11 -3
- package/src/ipc/SessionState.js +11 -11
- package/src/logger/DetoxLogger.js +67 -47
- package/src/logger/index.js +1 -0
- package/src/logger/utils/BunyanLogger.js +54 -10
- package/src/logger/utils/CategoryThreadDispatcher.js +8 -29
- package/src/logger/utils/DetoxLogFinalizer.js +166 -0
- package/src/logger/utils/MessageStack.js +17 -6
- package/src/logger/utils/ThreadDispatcher.js +5 -25
- package/src/logger/utils/customConsoleLogger.js +22 -5
- package/src/logger/utils/getMainCategory.js +5 -0
- package/src/logger/utils/sanitizeBunyanContext.js +3 -1
- package/src/logger/utils/streams/BunyanTransformer.js +72 -0
- package/src/logger/utils/streams/ChromeTraceTransformer.js +132 -0
- package/src/logger/utils/streams/DetoxJSONLParser.js +31 -0
- package/src/logger/utils/streams/JSONLStringer.js +55 -0
- package/src/logger/utils/streams/index.js +7 -0
- package/src/logger/utils/streams/transformers.js +39 -0
- package/src/logger/utils/tracerLegacy.js +14 -25
- package/src/realms/DetoxContext.js +16 -9
- package/src/realms/DetoxInternalsFacade.js +1 -7
- package/src/realms/DetoxPrimaryContext.js +42 -87
- package/src/realms/DetoxSecondaryContext.js +9 -13
- package/src/{symbols.js → realms/symbols.js} +0 -0
- package/src/servicelocator/android/index.js +2 -2
- package/src/utils/ExclusiveLockfile.js +1 -0
- package/src/utils/argparse.js +11 -27
- package/src/utils/logger.js +1 -1
- package/src/utils/pathUtils.js +11 -0
- package/src/utils/shellUtils.js +17 -0
- package/src/utils/traceInvocationCall.js +21 -0
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-javadoc.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-javadoc.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-javadoc.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-javadoc.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-sources.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-sources.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-sources.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-sources.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.aar +0 -0
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.aar.md5 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.aar.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.aar.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.aar.sha512 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.pom.md5 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.pom.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.pom.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.pom.sha512 +0 -1
- package/android/detox/src/full/java/com/wix/detox/espresso/registry/IRStatusInquirer.kt +0 -24
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/DescriptiveIdlingResource.kt +0 -10
- package/local-cli/build.test.js +0 -104
- package/local-cli/run-server.test.js +0 -23
- package/local-cli/test.test.js +0 -569
- package/runners/jest/deprecation.js +0 -25
- package/runners/jest/testEnvironment/utils/assertJestCircus27.test.js +0 -23
- package/src/configuration/utils/warnings.js +0 -12
- package/src/devices/common/drivers/android/tools/TempFileXfer.js +0 -16
- package/src/logger/utils/streamUtils.js +0 -240
- package/src/realms/index.js +0 -10
- package/src/utils/trace.js +0 -3
@@ -1,45 +1,34 @@
|
|
1
1
|
const methods = {
|
2
2
|
startSection(logger) {
|
3
|
-
return (msg, args) =>
|
3
|
+
return (msg, args) => {
|
4
|
+
if (args !== undefined) {
|
5
|
+
return logger.trace.begin(args, msg);
|
6
|
+
} else {
|
7
|
+
return logger.trace.begin(msg);
|
8
|
+
}
|
9
|
+
};
|
4
10
|
},
|
5
11
|
|
6
12
|
endSection(logger) {
|
7
|
-
return (
|
13
|
+
return (_msg, args) => {
|
14
|
+
if (args !== undefined) {
|
15
|
+
return logger.trace.end(args);
|
16
|
+
} else {
|
17
|
+
return logger.trace.end();
|
18
|
+
}
|
19
|
+
};
|
8
20
|
},
|
9
21
|
|
10
22
|
traceCall(logger) {
|
11
23
|
return (name, action, args = {}) => logger.trace.complete(args, name, action);
|
12
24
|
},
|
13
|
-
|
14
|
-
invocationCall(logger) {
|
15
|
-
return (sectionName, invocation, action) => {
|
16
|
-
return logger.trace.complete({
|
17
|
-
cat: 'ws-client,ws-client-invocation',
|
18
|
-
data: invocation,
|
19
|
-
stack: _getCallStackTrace(),
|
20
|
-
}, sectionName, action);
|
21
|
-
};
|
22
|
-
},
|
23
25
|
};
|
24
26
|
|
25
|
-
function _getCallStackTrace() {
|
26
|
-
return new Error().stack
|
27
|
-
.split('\n')
|
28
|
-
.slice(1) // Ignore Error message
|
29
|
-
.map(line => line
|
30
|
-
.replace(/^\s*at\s+/, '')
|
31
|
-
.replace(process.cwd(), '')
|
32
|
-
)
|
33
|
-
.filter(line => !line.includes('/detox/src')) // Ignore detox internal calls
|
34
|
-
.join('\n');
|
35
|
-
}
|
36
|
-
|
37
27
|
function installLegacyTracerInterface(logger, target) {
|
38
28
|
target.traceCall = methods.traceCall(logger);
|
39
29
|
target.trace = Object.freeze({
|
40
30
|
startSection: methods.startSection(logger),
|
41
31
|
endSection: methods.endSection(logger),
|
42
|
-
invocationCall: methods.invocationCall(logger),
|
43
32
|
});
|
44
33
|
|
45
34
|
return this;
|
@@ -2,16 +2,19 @@ const funpermaproxy = require('funpermaproxy');
|
|
2
2
|
|
3
3
|
const temporary = require('../artifacts/utils/temporaryPath');
|
4
4
|
const { DetoxRuntimeError } = require('../errors');
|
5
|
-
const { DetoxLogger, installLegacyTracerInterface } = require('../logger');
|
6
|
-
const symbols = require('../symbols');
|
5
|
+
const { DetoxLogger, DetoxLogFinalizer, installLegacyTracerInterface } = require('../logger');
|
7
6
|
|
8
7
|
const DetoxConstants = require('./DetoxConstants');
|
8
|
+
const symbols = require('./symbols');
|
9
9
|
|
10
|
+
//#region Protected symbols
|
10
11
|
const $cleanup = Symbol('cleanup');
|
12
|
+
const $logFinalizer = Symbol('logFinalizer');
|
11
13
|
const $restoreSessionState = Symbol('restoreSessionState');
|
12
14
|
const $sessionState = Symbol('restoreSessionState');
|
13
15
|
const $status = Symbol('status');
|
14
16
|
const $worker = Symbol('worker');
|
17
|
+
//#endregion
|
15
18
|
|
16
19
|
class DetoxContext {
|
17
20
|
constructor() {
|
@@ -56,6 +59,11 @@ class DetoxContext {
|
|
56
59
|
this.log = this[symbols.logger].child({ cat: 'user' });
|
57
60
|
installLegacyTracerInterface(this.log, this);
|
58
61
|
|
62
|
+
this[$logFinalizer] = new DetoxLogFinalizer({
|
63
|
+
session: this[$sessionState],
|
64
|
+
logger: this[symbols.logger],
|
65
|
+
});
|
66
|
+
|
59
67
|
/** @type {import('../DetoxWorker') | null} */
|
60
68
|
this[$worker] = null;
|
61
69
|
}
|
@@ -89,12 +97,7 @@ class DetoxContext {
|
|
89
97
|
[symbols.config] = funpermaproxy(() => this[symbols.session].detoxConfig);
|
90
98
|
[symbols.session] = funpermaproxy(() => this[$sessionState]);
|
91
99
|
[symbols.tracing] = Object.freeze({
|
92
|
-
createEventStream: () =>
|
93
|
-
const streamUtils = require('../logger/utils/streamUtils');
|
94
|
-
return streamUtils
|
95
|
-
.uniteSessionLogs(this[$sessionState].id)
|
96
|
-
.pipe(streamUtils.chromeTraceStream());
|
97
|
-
},
|
100
|
+
createEventStream: () => this[$logFinalizer].createEventStream(),
|
98
101
|
});
|
99
102
|
/** @abstract */
|
100
103
|
[symbols.reportTestResults](_testResults) {}
|
@@ -132,7 +135,10 @@ class DetoxContext {
|
|
132
135
|
*/
|
133
136
|
async [symbols.installWorker](opts) {
|
134
137
|
if (opts.global) {
|
135
|
-
opts.global['__detox__'] =
|
138
|
+
opts.global['__detox__'] = {
|
139
|
+
clientApi: require('../../index'),
|
140
|
+
internalsApi: require('../../internals'),
|
141
|
+
};
|
136
142
|
this.log.overrideConsole(opts.global);
|
137
143
|
}
|
138
144
|
|
@@ -173,6 +179,7 @@ class DetoxContext {
|
|
173
179
|
module.exports = DetoxContext;
|
174
180
|
module.exports.protected = {
|
175
181
|
$cleanup,
|
182
|
+
$logFinalizer,
|
176
183
|
$restoreSessionState,
|
177
184
|
$status,
|
178
185
|
$sessionState,
|
@@ -1,6 +1,6 @@
|
|
1
1
|
const funpermaproxy = require('funpermaproxy');
|
2
2
|
|
3
|
-
const symbols = require('
|
3
|
+
const symbols = require('./symbols');
|
4
4
|
|
5
5
|
class DetoxInternalsFacade {
|
6
6
|
/**
|
@@ -15,16 +15,10 @@ class DetoxInternalsFacade {
|
|
15
15
|
this.installWorker = context[symbols.installWorker];
|
16
16
|
this.uninstallWorker = context[symbols.uninstallWorker];
|
17
17
|
this.onHookFailure = context[symbols.onHookFailure];
|
18
|
-
this.onHookStart = context[symbols.onHookStart];
|
19
|
-
this.onHookSuccess = context[symbols.onHookSuccess];
|
20
18
|
this.onRunDescribeFinish = context[symbols.onRunDescribeFinish];
|
21
19
|
this.onRunDescribeStart = context[symbols.onRunDescribeStart];
|
22
|
-
this.onRunFinish = context[symbols.onRunFinish];
|
23
|
-
this.onRunStart = context[symbols.onRunStart];
|
24
20
|
this.onTestDone = context[symbols.onTestDone];
|
25
21
|
this.onTestFnFailure = context[symbols.onTestFnFailure];
|
26
|
-
this.onTestFnStart = context[symbols.onTestFnStart];
|
27
|
-
this.onTestFnSuccess = context[symbols.onTestFnSuccess];
|
28
22
|
this.onTestStart = context[symbols.onTestStart];
|
29
23
|
this.reportTestResults = context[symbols.reportTestResults];
|
30
24
|
this.resolveConfig = context[symbols.resolveConfig];
|
@@ -1,34 +1,31 @@
|
|
1
|
-
const path = require('path');
|
2
1
|
const { URL } = require('url');
|
3
|
-
const { promisify } = require('util');
|
4
2
|
|
5
3
|
const fs = require('fs-extra');
|
6
|
-
const glob = require('glob');
|
7
|
-
const pipe = require('multipipe');
|
8
4
|
const onSignalExit = require('signal-exit');
|
9
5
|
|
10
6
|
const temporary = require('../artifacts/utils/temporaryPath');
|
11
7
|
const { DetoxRuntimeError } = require('../errors');
|
12
8
|
const SessionState = require('../ipc/SessionState');
|
13
|
-
const
|
14
|
-
|
15
|
-
const globAsync = promisify(glob);
|
16
|
-
const globSync = glob.sync;
|
9
|
+
const { getCurrentCommand } = require('../utils/argparse');
|
10
|
+
const uuid = require('../utils/uuid');
|
17
11
|
|
18
12
|
const DetoxContext = require('./DetoxContext');
|
13
|
+
const symbols = require('./symbols');
|
19
14
|
|
20
|
-
|
15
|
+
// Protected symbols
|
16
|
+
const { $logFinalizer, $restoreSessionState, $sessionState, $worker } = DetoxContext.protected;
|
21
17
|
|
22
|
-
|
23
|
-
const _finalizeLogsSync = Symbol('finalizeLogsSync');
|
18
|
+
//#region Private symbols
|
24
19
|
const _globalLifecycleHandler = Symbol('globalLifecycleHandler');
|
25
20
|
const _ipcServer = Symbol('ipcServer');
|
26
21
|
const _resetLockFile = Symbol('resetLockFile');
|
27
22
|
const _wss = Symbol('wss');
|
28
23
|
const _dirty = Symbol('dirty');
|
29
24
|
const _emergencyTeardown = Symbol('emergencyTeardown');
|
30
|
-
const _areLogsEnabled = Symbol('areLogsEnabled');
|
31
25
|
const _lifecycleLogger = Symbol('lifecycleLogger');
|
26
|
+
const _sessionFile = Symbol('sessionFile');
|
27
|
+
const _logFinalError = Symbol('logFinalError');
|
28
|
+
//#endregion
|
32
29
|
|
33
30
|
class DetoxPrimaryContext extends DetoxContext {
|
34
31
|
constructor() {
|
@@ -37,6 +34,8 @@ class DetoxPrimaryContext extends DetoxContext {
|
|
37
34
|
this[_dirty] = false;
|
38
35
|
this[_wss] = null;
|
39
36
|
this[_globalLifecycleHandler] = null;
|
37
|
+
/** Path to file where the initial session object is serialized */
|
38
|
+
this[_sessionFile] = '';
|
40
39
|
/**
|
41
40
|
* @type {import('../ipc/IPCServer') | null}
|
42
41
|
*/
|
@@ -88,9 +87,11 @@ class DetoxPrimaryContext extends DetoxContext {
|
|
88
87
|
await this[symbols.logger].setConfig(loggerConfig);
|
89
88
|
|
90
89
|
this[_lifecycleLogger].trace.begin({
|
90
|
+
cwd: process.cwd(),
|
91
91
|
data: this[$sessionState],
|
92
|
-
},
|
92
|
+
}, getCurrentCommand());
|
93
93
|
|
94
|
+
// TODO: IPC Server creation ought to be delegated to a generator/factory.
|
94
95
|
const IPCServer = require('../ipc/IPCServer');
|
95
96
|
this[_ipcServer] = new IPCServer({
|
96
97
|
sessionState: this[$sessionState],
|
@@ -110,6 +111,7 @@ class DetoxPrimaryContext extends DetoxContext {
|
|
110
111
|
await this[_resetLockFile]();
|
111
112
|
}
|
112
113
|
|
114
|
+
// TODO: Detox-server creation ought to be delegated to a generator/factory.
|
113
115
|
const DetoxServer = require('../server/DetoxServer');
|
114
116
|
if (sessionConfig.autoStart) {
|
115
117
|
this[_wss] = new DetoxServer({
|
@@ -122,13 +124,16 @@ class DetoxPrimaryContext extends DetoxContext {
|
|
122
124
|
await this[_wss].open();
|
123
125
|
}
|
124
126
|
|
127
|
+
// TODO: double check that this config is indeed propogated onto the client create at the detox-worker side
|
125
128
|
if (!sessionConfig.server && this[_wss]) {
|
126
129
|
// @ts-ignore
|
127
130
|
sessionConfig.server = `ws://localhost:${this[_wss].port}`;
|
128
131
|
}
|
129
132
|
|
130
|
-
|
131
|
-
|
133
|
+
this[_sessionFile] = temporary.for.json(this[$sessionState].id);
|
134
|
+
await fs.writeFile(this[_sessionFile], this[$sessionState].stringify());
|
135
|
+
process.env.DETOX_CONFIG_SNAPSHOT_PATH = this[_sessionFile];
|
136
|
+
this[_lifecycleLogger].trace(`Serialized the session state at: ${this[_sessionFile]}`);
|
132
137
|
|
133
138
|
if (opts.workerId !== null) {
|
134
139
|
await this[symbols.installWorker](opts);
|
@@ -140,10 +145,12 @@ class DetoxPrimaryContext extends DetoxContext {
|
|
140
145
|
* @param {Partial<DetoxInternals.DetoxInstallWorkerOptions>} [opts]
|
141
146
|
*/
|
142
147
|
async [symbols.installWorker](opts = {}) {
|
143
|
-
const workerId =
|
148
|
+
const workerId = opts.workerId || 'worker';
|
149
|
+
|
150
|
+
this[$sessionState].workerId = workerId;
|
144
151
|
this[_ipcServer].onRegisterWorker({ workerId });
|
145
152
|
|
146
|
-
await super[symbols.installWorker](opts);
|
153
|
+
await super[symbols.installWorker]({ ...opts, workerId });
|
147
154
|
}
|
148
155
|
|
149
156
|
/** @override */
|
@@ -168,14 +175,17 @@ class DetoxPrimaryContext extends DetoxContext {
|
|
168
175
|
this[_ipcServer] = null;
|
169
176
|
}
|
170
177
|
|
171
|
-
|
178
|
+
if (this[_sessionFile]) {
|
179
|
+
await fs.remove(this[_sessionFile]);
|
180
|
+
}
|
172
181
|
|
173
182
|
if (this[_dirty]) {
|
174
183
|
try {
|
175
184
|
this[_lifecycleLogger].trace.end();
|
176
|
-
await this[
|
185
|
+
await this[symbols.logger].close();
|
186
|
+
await this[$logFinalizer].finalize();
|
177
187
|
} catch (err) {
|
178
|
-
this[
|
188
|
+
this[_logFinalError](err);
|
179
189
|
}
|
180
190
|
}
|
181
191
|
}
|
@@ -199,14 +209,23 @@ class DetoxPrimaryContext extends DetoxContext {
|
|
199
209
|
this[_ipcServer].dispose();
|
200
210
|
}
|
201
211
|
|
212
|
+
if (this[_sessionFile]) {
|
213
|
+
fs.removeSync(this[_sessionFile]);
|
214
|
+
}
|
215
|
+
|
202
216
|
try {
|
203
217
|
this[_lifecycleLogger].trace.end({ abortSignal: signal });
|
204
|
-
this[
|
218
|
+
this[symbols.logger].close().catch(this[_logFinalError]);
|
219
|
+
this[$logFinalizer].finalizeSync();
|
205
220
|
} catch (err) {
|
206
|
-
this[
|
221
|
+
this[_logFinalError](err);
|
207
222
|
}
|
208
223
|
};
|
209
224
|
|
225
|
+
[_logFinalError] = (err) => {
|
226
|
+
this[_lifecycleLogger].error(err, 'Encountered an error while merging the process logs:');
|
227
|
+
};
|
228
|
+
|
210
229
|
//#endregion
|
211
230
|
|
212
231
|
//#region Protected members
|
@@ -217,77 +236,13 @@ class DetoxPrimaryContext extends DetoxContext {
|
|
217
236
|
*/
|
218
237
|
[$restoreSessionState]() {
|
219
238
|
return new SessionState({
|
220
|
-
|
239
|
+
id: uuid.UUID(),
|
221
240
|
detoxIPCServer: `primary-${process.pid}`,
|
222
241
|
});
|
223
242
|
}
|
224
243
|
//#endregion
|
225
244
|
|
226
245
|
//#region Private members
|
227
|
-
async[_finalizeLogs]() {
|
228
|
-
const sessionId = this[$sessionState].id;
|
229
|
-
const logs = await globAsync(temporary.for.jsonl(`${sessionId}.*`));
|
230
|
-
if (logs.length === 0) {
|
231
|
-
return;
|
232
|
-
}
|
233
|
-
|
234
|
-
if (this[_areLogsEnabled]()) {
|
235
|
-
const streamUtils = require('../logger/utils/streamUtils');
|
236
|
-
const { rootDir } = this[symbols.config].artifacts;
|
237
|
-
|
238
|
-
await fs.mkdirp(rootDir);
|
239
|
-
const [out1Stream, out2Stream] = ['detox.log', 'detox.trace.json']
|
240
|
-
.map((filename) => fs.createWriteStream(path.join(rootDir, filename)));
|
241
|
-
|
242
|
-
const mergedStream = streamUtils.uniteSessionLogs(sessionId);
|
243
|
-
|
244
|
-
await Promise.all([
|
245
|
-
pipe(mergedStream, streamUtils.debugStream(this[symbols.logger].config.options), out1Stream),
|
246
|
-
pipe(mergedStream, streamUtils.chromeTraceStream(), streamUtils.writeJSON(), out2Stream),
|
247
|
-
]);
|
248
|
-
}
|
249
|
-
|
250
|
-
await Promise.all(logs.map(filepath => fs.remove(filepath)));
|
251
|
-
}
|
252
|
-
|
253
|
-
async[_finalizeLogsSync]() {
|
254
|
-
const logsEnabled = this[_areLogsEnabled]();
|
255
|
-
|
256
|
-
const { rootDir } = this[symbols.config].artifacts;
|
257
|
-
|
258
|
-
if (logsEnabled) {
|
259
|
-
fs.mkdirpSync(rootDir);
|
260
|
-
}
|
261
|
-
|
262
|
-
const sessionId = this[$sessionState].id;
|
263
|
-
const logs = globSync(temporary.for.jsonl(`${sessionId}.*`));
|
264
|
-
|
265
|
-
for (const log of logs) {
|
266
|
-
if (logsEnabled) {
|
267
|
-
fs.moveSync(log, path.join(rootDir, path.basename(log)));
|
268
|
-
} else {
|
269
|
-
fs.removeSync(log);
|
270
|
-
}
|
271
|
-
}
|
272
|
-
}
|
273
|
-
|
274
|
-
[_areLogsEnabled]() {
|
275
|
-
const { rootDir, plugins } = this[symbols.config].artifacts || {};
|
276
|
-
if (!rootDir || !plugins) {
|
277
|
-
return false;
|
278
|
-
}
|
279
|
-
|
280
|
-
if (!plugins.log.enabled) {
|
281
|
-
return false;
|
282
|
-
}
|
283
|
-
|
284
|
-
if (!plugins.log.keepOnlyFailedTestsArtifacts) {
|
285
|
-
return true;
|
286
|
-
}
|
287
|
-
|
288
|
-
return this[$sessionState].testResults.some(r => !r.success);
|
289
|
-
}
|
290
|
-
|
291
246
|
async[_resetLockFile]() {
|
292
247
|
const DeviceRegistry = require('../devices/DeviceRegistry');
|
293
248
|
|
@@ -1,14 +1,17 @@
|
|
1
|
-
const fs = require('fs');
|
1
|
+
const fs = require('fs-extra');
|
2
2
|
|
3
3
|
const { DetoxInternalError } = require('../errors');
|
4
4
|
const SessionState = require('../ipc/SessionState');
|
5
|
-
const symbols = require('../symbols');
|
6
5
|
|
7
6
|
const DetoxContext = require('./DetoxContext');
|
7
|
+
const symbols = require('./symbols');
|
8
8
|
|
9
|
+
// Protected symbols
|
9
10
|
const { $restoreSessionState, $sessionState, $worker } = DetoxContext.protected;
|
11
|
+
|
12
|
+
//#region Private symbols
|
10
13
|
const _ipcClient = Symbol('ipcClient');
|
11
|
-
|
14
|
+
//#endregion
|
12
15
|
|
13
16
|
class DetoxSecondaryContext extends DetoxContext {
|
14
17
|
constructor() {
|
@@ -19,13 +22,6 @@ class DetoxSecondaryContext extends DetoxContext {
|
|
19
22
|
* @type {import('../ipc/IPCClient')}
|
20
23
|
*/
|
21
24
|
this[_ipcClient] = null;
|
22
|
-
/**
|
23
|
-
* @private
|
24
|
-
* @type {undefined | boolean}
|
25
|
-
*
|
26
|
-
* TODO: explain what is short lifecycle and why we need it
|
27
|
-
*/
|
28
|
-
this[_shortLifecycle] = false;
|
29
25
|
}
|
30
26
|
|
31
27
|
//#region Internal members
|
@@ -47,7 +43,7 @@ class DetoxSecondaryContext extends DetoxContext {
|
|
47
43
|
|
48
44
|
this[_ipcClient] = new IPCClient({
|
49
45
|
id: `secondary-${process.pid}`,
|
50
|
-
|
46
|
+
sessionState: this[$sessionState],
|
51
47
|
logger: this[symbols.logger],
|
52
48
|
});
|
53
49
|
|
@@ -74,9 +70,9 @@ class DetoxSecondaryContext extends DetoxContext {
|
|
74
70
|
|
75
71
|
/** @override */
|
76
72
|
async [symbols.installWorker](opts = {}) {
|
77
|
-
const workerId = opts.workerId
|
73
|
+
const workerId = opts.workerId || 'worker';
|
78
74
|
await this[_ipcClient].registerWorker(workerId);
|
79
|
-
await super[symbols.installWorker](opts);
|
75
|
+
await super[symbols.installWorker]({ ...opts, workerId });
|
80
76
|
}
|
81
77
|
//#endregion
|
82
78
|
|
File without changes
|
@@ -3,7 +3,7 @@ const DeviceRegistry = require('../../devices/DeviceRegistry');
|
|
3
3
|
const AAPT = require('../../devices/common/drivers/android/exec/AAPT');
|
4
4
|
const ADB = require('../../devices/common/drivers/android/exec/ADB');
|
5
5
|
const ApkValidator = require('../../devices/common/drivers/android/tools/ApkValidator');
|
6
|
-
const
|
6
|
+
const { TempFileTransfer } = require('../../devices/common/drivers/android/tools/TempFileTransfer');
|
7
7
|
|
8
8
|
const AndroidServiceLocator = {
|
9
9
|
get emulator() {
|
@@ -18,7 +18,7 @@ const AndroidServiceLocator = {
|
|
18
18
|
AndroidServiceLocator.adb = new ADB();
|
19
19
|
AndroidServiceLocator.aapt = new AAPT();
|
20
20
|
AndroidServiceLocator.apkValidator = new ApkValidator(AndroidServiceLocator.aapt);
|
21
|
-
AndroidServiceLocator.
|
21
|
+
AndroidServiceLocator.fileTransfer = new TempFileTransfer(AndroidServiceLocator.adb);
|
22
22
|
AndroidServiceLocator.deviceRegistry = DeviceRegistry.forAndroid();
|
23
23
|
AndroidServiceLocator.devicePathBuilder = new AndroidDevicePathBuilder();
|
24
24
|
|
package/src/utils/argparse.js
CHANGED
@@ -1,13 +1,9 @@
|
|
1
|
+
const path = require('path');
|
2
|
+
|
1
3
|
const _ = require('lodash');
|
2
|
-
const argv = require('minimist')(process.argv.slice(2));
|
3
4
|
|
4
5
|
const { escape } = require('./pipeCommands');
|
5
6
|
|
6
|
-
function getArgValue(key, alias) {
|
7
|
-
const value = _getArgvValue(key, alias);
|
8
|
-
return value === undefined ? getEnvValue(key) : value;
|
9
|
-
}
|
10
|
-
|
11
7
|
function getEnvValue(key) {
|
12
8
|
const envKey = _.findKey(process.env, matchesKey(
|
13
9
|
`DETOX_${_.snakeCase(key)}`.toUpperCase()
|
@@ -21,31 +17,12 @@ function getEnvValue(key) {
|
|
21
17
|
return value;
|
22
18
|
}
|
23
19
|
|
24
|
-
function _getArgvValue(...aliases) {
|
25
|
-
if (!argv) {
|
26
|
-
return;
|
27
|
-
}
|
28
|
-
|
29
|
-
for (const alias of aliases) {
|
30
|
-
if (alias && argv[alias]) {
|
31
|
-
return argv[alias];
|
32
|
-
}
|
33
|
-
}
|
34
|
-
}
|
35
|
-
|
36
20
|
function matchesKey(key) {
|
37
21
|
return /* istanbul ignore next */ process.platform === 'win32'
|
38
22
|
? (value, envKey) => envKey.toUpperCase() === key
|
39
23
|
: (value, envKey) => envKey === key;
|
40
24
|
}
|
41
25
|
|
42
|
-
function getFlag(key) {
|
43
|
-
if (argv && argv[key]) {
|
44
|
-
return true;
|
45
|
-
}
|
46
|
-
return false;
|
47
|
-
}
|
48
|
-
|
49
26
|
const DEFAULT_JOIN_ARGUMENTS_OPTIONS = {
|
50
27
|
prefix: '--',
|
51
28
|
joiner: ' ',
|
@@ -81,9 +58,16 @@ function joinArgs(keyValues, options = DEFAULT_JOIN_ARGUMENTS_OPTIONS) {
|
|
81
58
|
return argArray.join(' ');
|
82
59
|
}
|
83
60
|
|
61
|
+
function getCurrentCommand() {
|
62
|
+
const cwd = process.cwd();
|
63
|
+
|
64
|
+
return process.argv.slice(1).map((value, index) => {
|
65
|
+
return index ? value : path.relative(cwd, value);
|
66
|
+
}).join(' ');
|
67
|
+
}
|
68
|
+
|
84
69
|
module.exports = {
|
85
|
-
getArgValue,
|
86
70
|
getEnvValue,
|
87
|
-
getFlag,
|
88
71
|
joinArgs,
|
72
|
+
getCurrentCommand,
|
89
73
|
};
|
package/src/utils/logger.js
CHANGED
@@ -0,0 +1,11 @@
|
|
1
|
+
const path = require('path');
|
2
|
+
|
3
|
+
function toSimplePath(filePath, cwd = process.cwd()) {
|
4
|
+
const relativePath = path.relative(cwd, filePath);
|
5
|
+
const isOutsideCwd = relativePath.split(path.sep, 1)[0] === '..';
|
6
|
+
return isOutsideCwd ? filePath : relativePath;
|
7
|
+
}
|
8
|
+
|
9
|
+
module.exports = {
|
10
|
+
toSimplePath,
|
11
|
+
};
|
package/src/utils/shellUtils.js
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
const SPACE = ' ';
|
2
2
|
const BACK_SLASH = '\\';
|
3
|
+
const FORWARD_SLASH = '/';
|
3
4
|
const SINGLE_QUOTE = "'";
|
4
5
|
const DOUBLE_QUOTE = '"';
|
5
6
|
|
@@ -64,6 +65,14 @@ function autoEscapeCmd(str) {
|
|
64
65
|
return escapeWithDoubleQuotedString(str);
|
65
66
|
}
|
66
67
|
|
68
|
+
function useForwardSlashesCMD(str) {
|
69
|
+
return str.split(BACK_SLASH).join(FORWARD_SLASH);
|
70
|
+
}
|
71
|
+
|
72
|
+
function useForwardSlashesShell(str) {
|
73
|
+
return str; // already POSIX, so no-op
|
74
|
+
}
|
75
|
+
|
67
76
|
const hasUnsafeChars = isRunningInCMDEXE()
|
68
77
|
/* istanbul ignore next */ ? hasUnsafeCMDChars
|
69
78
|
/* istanbul ignore next */ : hasUnsafeShellChars;
|
@@ -76,6 +85,10 @@ const escapeSpaces = isRunningInCMDEXE()
|
|
76
85
|
/* istanbul ignore next */ ? escapeSpacesCMD
|
77
86
|
/* istanbul ignore next */ : escapeSpacesShell;
|
78
87
|
|
88
|
+
const usePosixSlashes = isRunningInCMDEXE()
|
89
|
+
/* istanbul ignore next */ ? useForwardSlashesCMD
|
90
|
+
/* istanbul ignore next */ : useForwardSlashesShell;
|
91
|
+
|
79
92
|
module.exports = {
|
80
93
|
escapeInDoubleQuotedString,
|
81
94
|
escapeInDoubleQuotedRegexp,
|
@@ -94,4 +107,8 @@ module.exports = {
|
|
94
107
|
cmd: autoEscapeCmd,
|
95
108
|
shell: autoEscapeShell,
|
96
109
|
}),
|
110
|
+
useForwardSlashes: Object.assign(usePosixSlashes, {
|
111
|
+
cmd: useForwardSlashesCMD,
|
112
|
+
shell: useForwardSlashesShell,
|
113
|
+
}),
|
97
114
|
};
|
@@ -0,0 +1,21 @@
|
|
1
|
+
function _getCallStackTrace() {
|
2
|
+
return new Error().stack
|
3
|
+
.split('\n')
|
4
|
+
.slice(1) // Ignore Error message
|
5
|
+
.map(line => line
|
6
|
+
.replace(/^\s*at\s+/, '')
|
7
|
+
.replace(process.cwd(), '')
|
8
|
+
)
|
9
|
+
.filter(line => !line.includes('/detox/src')) // Ignore detox internal calls
|
10
|
+
.join('\n');
|
11
|
+
}
|
12
|
+
|
13
|
+
function invocationCall(logger, sectionName, invocation, action) {
|
14
|
+
return logger.trace.complete({
|
15
|
+
cat: 'ws-client,ws-client-invocation',
|
16
|
+
data: invocation,
|
17
|
+
stack: _getCallStackTrace(),
|
18
|
+
}, sectionName, action);
|
19
|
+
}
|
20
|
+
|
21
|
+
module.exports = invocationCall;
|
@@ -1 +0,0 @@
|
|
1
|
-
3f9aa853e15bb15aa9558ac3d2b7252f
|
@@ -1 +0,0 @@
|
|
1
|
-
f1dd211a2bbbe503be2e90573c9aa465d39f029e
|
@@ -1 +0,0 @@
|
|
1
|
-
251b43c4d9cac5fbae87a75c015c577257212beb1c9a0ab294981f8d12310019
|
@@ -1 +0,0 @@
|
|
1
|
-
08cc04feb00bd8b233b990b7127b42af544865adf28b2cb57601c791d313672f0dbe20c5673d393395edeb970d8d11127c7eb098add143b13b044a62999d60a9
|
@@ -1 +0,0 @@
|
|
1
|
-
24df5a9831b657b7ebb686b3677bdd78
|
@@ -1 +0,0 @@
|
|
1
|
-
996291301615fc1a37a2a3cea94459b0d315864f
|
@@ -1 +0,0 @@
|
|
1
|
-
ebd8dbf8bb38883b6988fd82932ce0a09f287e13501ec31d80677abe8c077589
|
@@ -1 +0,0 @@
|
|
1
|
-
35852565ad133c30234f00c3e518761068bf749a47e7c600e768b6b9756e76ed5fe40bfb139d5cdce27f30b9b76792c8cc2218f7086b39e68ac4658609eb75a5
|
Binary file
|
@@ -1 +0,0 @@
|
|
1
|
-
3bdd1b42fa0f182255a47fcdda8f544c
|
@@ -1 +0,0 @@
|
|
1
|
-
457ae10d202b196ea92bade4a33ce2dbc2f8bb3f
|
@@ -1 +0,0 @@
|
|
1
|
-
52342d1b0d1fae681b2ea1e6f9ac6f6278299ed70d7867fd60b95d63eb7a9ec3
|
@@ -1 +0,0 @@
|
|
1
|
-
5dfa73d84d647fd870a2e915d9943c9502c967abfd89a834ef7dee50a2a77d5a8b0be7b13407a34a6b97cbc10e9ed6f5e608fe7366d5a3041e462e3322d5b10d
|
@@ -1 +0,0 @@
|
|
1
|
-
185b91e2be7cfaeaf995b7ca85cefe7b
|
@@ -1 +0,0 @@
|
|
1
|
-
e4cd532fd4f1339057ffe02814349398e9dc1a49
|
@@ -1 +0,0 @@
|
|
1
|
-
76bdd7d38a6da78a81a590e378879fcb0f66c432af1bd280e0fdb60b37da7d79
|