detox 20.0.1 → 20.0.2
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.
- package/Detox-android/com/wix/detox/{20.0.1/detox-20.0.1-javadoc.jar → 20.0.2/detox-20.0.2-javadoc.jar} +0 -0
- package/Detox-android/com/wix/detox/20.0.2/detox-20.0.2-javadoc.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.0.2/detox-20.0.2-javadoc.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.0.2/detox-20.0.2-javadoc.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.0.2/detox-20.0.2-javadoc.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{20.0.1/detox-20.0.1-sources.jar → 20.0.2/detox-20.0.2-sources.jar} +0 -0
- package/Detox-android/com/wix/detox/20.0.2/detox-20.0.2-sources.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.0.2/detox-20.0.2-sources.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.0.2/detox-20.0.2-sources.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.0.2/detox-20.0.2-sources.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{20.0.1/detox-20.0.1.aar → 20.0.2/detox-20.0.2.aar} +0 -0
- package/Detox-android/com/wix/detox/{20.0.1/detox-20.0.1.aar.md5 → 20.0.2/detox-20.0.2.aar.md5} +0 -0
- package/Detox-android/com/wix/detox/{20.0.1/detox-20.0.1.aar.sha1 → 20.0.2/detox-20.0.2.aar.sha1} +0 -0
- package/Detox-android/com/wix/detox/{20.0.1/detox-20.0.1.aar.sha256 → 20.0.2/detox-20.0.2.aar.sha256} +0 -0
- package/Detox-android/com/wix/detox/{20.0.1/detox-20.0.1.aar.sha512 → 20.0.2/detox-20.0.2.aar.sha512} +0 -0
- package/Detox-android/com/wix/detox/{20.0.1/detox-20.0.1.pom → 20.0.2/detox-20.0.2.pom} +1 -1
- package/Detox-android/com/wix/detox/20.0.2/detox-20.0.2.pom.md5 +1 -0
- package/Detox-android/com/wix/detox/20.0.2/detox-20.0.2.pom.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.0.2/detox-20.0.2.pom.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.0.2/detox-20.0.2.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/local-cli/cli.js +6 -3
- package/local-cli/testCommand/TestRunnerCommand.js +25 -12
- package/local-cli/testCommand/TestRunnerError.js +17 -0
- package/local-cli/testCommand/TestRunnerError.test.js +25 -0
- package/package.json +2 -3
- package/src/artifacts/utils/temporaryPath.js +32 -2
- package/src/errors/DetoxError.js +5 -1
- package/src/logger/DetoxLogger.js +34 -5
- package/src/logger/utils/BunyanLogger.js +39 -0
- package/src/logger/utils/CategoryThreadDispatcher.js +2 -1
- package/src/logger/utils/DetoxLogFinalizer.js +73 -51
- package/src/logger/utils/MessageStack.js +17 -6
- package/src/logger/utils/customConsoleLogger.js +18 -2
- package/src/logger/utils/getMainCategory.js +5 -0
- package/src/logger/utils/streams/BunyanTransformer.js +72 -0
- package/src/logger/utils/streams/ChromeTraceTransformer.js +127 -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/realms/DetoxContext.js +2 -1
- package/src/realms/DetoxPrimaryContext.js +9 -2
- package/src/utils/pathUtils.js +11 -0
- package/src/utils/shellUtils.js +17 -0
- package/Detox-android/com/wix/detox/20.0.1/detox-20.0.1-javadoc.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/20.0.1/detox-20.0.1-javadoc.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.0.1/detox-20.0.1-javadoc.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.0.1/detox-20.0.1-javadoc.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/20.0.1/detox-20.0.1-sources.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/20.0.1/detox-20.0.1-sources.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.0.1/detox-20.0.1-sources.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.0.1/detox-20.0.1-sources.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/20.0.1/detox-20.0.1.pom.md5 +0 -1
- package/Detox-android/com/wix/detox/20.0.1/detox-20.0.1.pom.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.0.1/detox-20.0.1.pom.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.0.1/detox-20.0.1.pom.sha512 +0 -1
- package/src/logger/utils/streamUtils.js +0 -248
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
514cd58d623830ff11b1b7b32035b2f5
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
9cd358d37b6a4abeaf910f3cba214f0e9e0e5550
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
d26c25b365a5848bcab24a07c1dcd5cb4e55e221b641642cca3007889187af5e
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
5759ed953a4d0854ef67219e01102a2ec30da9a685cf997c1e9aaa0e138a3160d7acf68bac3c61ed93169b96122e9631413415ac3ef0a23099b07f4f0ad7e877
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3d3ff582ffc1e63d8439b6c1c870d072
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
a6b2b9706eefba7a98ee96bfd74c9e6c0953c560
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
f226e31a8f73581be7a622873f1648ad7ff3689fb69c6803b162891d6432a222
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3f161dca3fbcb2dc70b4994ea2e0889b7c259688188d8831fa05f54b9d1a4ec5ac1cd9e05296e1d6928a3cb95afc3871006855b6081593c0be96469bf46ff9eb
|
|
File without changes
|
package/Detox-android/com/wix/detox/{20.0.1/detox-20.0.1.aar.md5 → 20.0.2/detox-20.0.2.aar.md5}
RENAMED
|
File without changes
|
package/Detox-android/com/wix/detox/{20.0.1/detox-20.0.1.aar.sha1 → 20.0.2/detox-20.0.2.aar.sha1}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<modelVersion>4.0.0</modelVersion>
|
|
4
4
|
<groupId>com.wix</groupId>
|
|
5
5
|
<artifactId>detox</artifactId>
|
|
6
|
-
<version>20.0.
|
|
6
|
+
<version>20.0.2</version>
|
|
7
7
|
<packaging>aar</packaging>
|
|
8
8
|
<name>Detox</name>
|
|
9
9
|
<description>Gray box end-to-end testing and automation library for mobile apps</description>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
4f7a1a7399a5af7b35c036d2fc0718cb
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
dac8c057b62ac30f745c079966af8414dcb091f3
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
b5fd933f8d07b16518b57ba0eb8e1b81408705c6a14300c98b2b6db643dc7a07
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
6396385afa4de70131d6db2911f0044aab4f739cb1e8b7b212473ff8ddcd356e928a489dbca9cd978b190f7d5134466afc1a58d2fd6a85664e0979fe13f80b86
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
<groupId>com.wix</groupId>
|
|
4
4
|
<artifactId>detox</artifactId>
|
|
5
5
|
<versioning>
|
|
6
|
-
<latest>20.0.
|
|
7
|
-
<release>20.0.
|
|
6
|
+
<latest>20.0.2</latest>
|
|
7
|
+
<release>20.0.2</release>
|
|
8
8
|
<versions>
|
|
9
|
-
<version>20.0.
|
|
9
|
+
<version>20.0.2</version>
|
|
10
10
|
</versions>
|
|
11
|
-
<lastUpdated>
|
|
11
|
+
<lastUpdated>20221116093316</lastUpdated>
|
|
12
12
|
</versioning>
|
|
13
13
|
</metadata>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
05e0bb75beb5d6a3094aebcdba7b4563
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
88cff9cd55696025d566b3eb466acd91f27ecd64
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
1d14b7cac08e76b539d975cb4149bbcf827557ef2359a1cb39ec524fd06fcd2b
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
c42f63528cf78b14e8d23dc1543fd2ed09f67c9f83fd39763c945093780dd63cef41d8ffcaa6da7b758b2e88725d8a45ad8df7e9f92e120ec88e5b0172868f54
|
package/Detox-ios-src.tbz
CHANGED
|
Binary file
|
package/Detox-ios.tbz
CHANGED
|
Binary file
|
package/local-cli/cli.js
CHANGED
|
@@ -28,9 +28,12 @@ yargs
|
|
|
28
28
|
.wrap(yargs.terminalWidth() * 0.9)
|
|
29
29
|
.fail(function(msg, err, program) {
|
|
30
30
|
if (err) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
const message = DetoxError.format(err);
|
|
32
|
+
if (message) {
|
|
33
|
+
logger.error(message);
|
|
34
|
+
process.stderr.write('\n');
|
|
35
|
+
}
|
|
36
|
+
|
|
34
37
|
// @ts-ignore
|
|
35
38
|
_.attempt(() => fs.unlinkSync(logger.file));
|
|
36
39
|
// eslint-disable-next-line no-process-exit
|
|
@@ -6,9 +6,11 @@ const unparse = require('yargs-unparser');
|
|
|
6
6
|
|
|
7
7
|
const detox = require('../../internals');
|
|
8
8
|
const log = detox.log.child({ cat: ['lifecycle', 'cli'] });
|
|
9
|
-
const { DetoxRuntimeError } = require('../../src/errors');
|
|
10
9
|
const { printEnvironmentVariables, prependNodeModulesBinToPATH } = require('../../src/utils/envUtils');
|
|
11
|
-
const {
|
|
10
|
+
const { toSimplePath } = require('../../src/utils/pathUtils');
|
|
11
|
+
const { escapeSpaces, useForwardSlashes } = require('../../src/utils/shellUtils');
|
|
12
|
+
|
|
13
|
+
const TestRunnerError = require('./TestRunnerError');
|
|
12
14
|
|
|
13
15
|
class TestRunnerCommand {
|
|
14
16
|
/*
|
|
@@ -57,8 +59,9 @@ class TestRunnerCommand {
|
|
|
57
59
|
if (--runsLeft > 0) {
|
|
58
60
|
// @ts-ignore
|
|
59
61
|
detox.session.testSessionIndex++; // it is always the primary context, so we can update it
|
|
60
|
-
|
|
61
|
-
this.
|
|
62
|
+
|
|
63
|
+
this._argv._ = testFilesToRetry.map(useForwardSlashes);
|
|
64
|
+
this._logRelaunchError(testFilesToRetry);
|
|
62
65
|
}
|
|
63
66
|
}
|
|
64
67
|
} while (launchError && runsLeft > 0);
|
|
@@ -114,7 +117,7 @@ class TestRunnerCommand {
|
|
|
114
117
|
const fullCommand = this._buildSpawnArguments().map(escapeSpaces);
|
|
115
118
|
const fullCommandWithHint = printEnvironmentVariables(this._envHint) + fullCommand.join(' ');
|
|
116
119
|
|
|
117
|
-
log.info({ env: this._envHint }, fullCommandWithHint);
|
|
120
|
+
log.info.begin({ env: this._envHint }, fullCommandWithHint);
|
|
118
121
|
|
|
119
122
|
return new Promise((resolve, reject) => {
|
|
120
123
|
cp.spawn(fullCommand[0], fullCommand.slice(1), {
|
|
@@ -128,10 +131,20 @@ class TestRunnerCommand {
|
|
|
128
131
|
.value()
|
|
129
132
|
})
|
|
130
133
|
.on('error', /* istanbul ignore next */ (err) => reject(err))
|
|
131
|
-
.on('exit', (code) =>
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
134
|
+
.on('exit', (code, signal) => {
|
|
135
|
+
if (code === 0) {
|
|
136
|
+
log.trace.end({ success: true });
|
|
137
|
+
resolve();
|
|
138
|
+
} else {
|
|
139
|
+
const error = new TestRunnerError({
|
|
140
|
+
command: fullCommandWithHint,
|
|
141
|
+
code,
|
|
142
|
+
signal,
|
|
143
|
+
});
|
|
144
|
+
log.error.end({ success: false, code, signal }, error.message);
|
|
145
|
+
reject(error);
|
|
146
|
+
}
|
|
147
|
+
});
|
|
135
148
|
});
|
|
136
149
|
}
|
|
137
150
|
|
|
@@ -148,9 +161,9 @@ class TestRunnerCommand {
|
|
|
148
161
|
].map(String);
|
|
149
162
|
}
|
|
150
163
|
|
|
151
|
-
_logRelaunchError() {
|
|
152
|
-
const list =
|
|
153
|
-
return ` ${index + 1}. ${file}`;
|
|
164
|
+
_logRelaunchError(filePaths) {
|
|
165
|
+
const list = filePaths.map((file, index) => {
|
|
166
|
+
return ` ${index + 1}. ${toSimplePath(file)}`;
|
|
154
167
|
}).join('\n');
|
|
155
168
|
|
|
156
169
|
log.error(
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const { DetoxError } = require('../../src/errors');
|
|
2
|
+
|
|
3
|
+
class TestRunnerError extends DetoxError {
|
|
4
|
+
constructor({ command, code, signal }) {
|
|
5
|
+
super(`Command failed with exit code = ${code}:\n${command}`);
|
|
6
|
+
|
|
7
|
+
this.code = code;
|
|
8
|
+
this.signal = signal;
|
|
9
|
+
this.name = 'TestRunnerError';
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
format() {
|
|
13
|
+
return '';
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
module.exports = TestRunnerError;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const { DetoxError } = require('../../src/errors');
|
|
2
|
+
|
|
3
|
+
const TestRunnerError = require('./TestRunnerError');
|
|
4
|
+
|
|
5
|
+
describe('TestRunnerError', () => {
|
|
6
|
+
let error;
|
|
7
|
+
|
|
8
|
+
beforeAll(() => {
|
|
9
|
+
error = new TestRunnerError({ command: 'foo', code: 1, signal: null });
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('should format an error message', () => {
|
|
13
|
+
expect(`${error}`).toMatch(/Command failed with exit code = 1:\nfoo/);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it('should assign properties (code, signal)', () => {
|
|
17
|
+
expect(error.code).toBe(1);
|
|
18
|
+
expect(error.signal).toBe(null);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('should be formatted to an empty string', () => {
|
|
22
|
+
// So that the try-catch block in cli.js will not print it for the second time
|
|
23
|
+
expect(DetoxError.format(error)).toBe('');
|
|
24
|
+
});
|
|
25
|
+
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "detox",
|
|
3
3
|
"description": "E2E tests and automation for mobile",
|
|
4
|
-
"version": "20.0.
|
|
4
|
+
"version": "20.0.2",
|
|
5
5
|
"bin": {
|
|
6
6
|
"detox": "local-cli/cli.js"
|
|
7
7
|
},
|
|
@@ -61,7 +61,6 @@
|
|
|
61
61
|
"caf": "^15.0.1",
|
|
62
62
|
"chalk": "^2.4.2",
|
|
63
63
|
"child-process-promise": "^2.2.0",
|
|
64
|
-
"duplexify": "^4.1.2",
|
|
65
64
|
"find-up": "^4.1.0",
|
|
66
65
|
"fs-extra": "^4.0.2",
|
|
67
66
|
"funpermaproxy": "^1.1.0",
|
|
@@ -190,5 +189,5 @@
|
|
|
190
189
|
}
|
|
191
190
|
}
|
|
192
191
|
},
|
|
193
|
-
"gitHead": "
|
|
192
|
+
"gitHead": "caef3fd2ce6fe7ad2a8267102ee521153abbcbb2"
|
|
194
193
|
}
|
|
@@ -1,14 +1,42 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
+
const { promisify } = require('util');
|
|
2
3
|
|
|
4
|
+
const glob = require('glob');
|
|
3
5
|
const tempfile = require('tempfile');
|
|
4
6
|
|
|
7
|
+
const { useForwardSlashes } = require('../../utils/shellUtils');
|
|
8
|
+
|
|
9
|
+
const globSync = glob.sync;
|
|
10
|
+
const globAsync = promisify(glob);
|
|
11
|
+
|
|
12
|
+
function getRoot() {
|
|
13
|
+
return path.dirname(tempfile());
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function createGlobber(ext) {
|
|
17
|
+
const fullExt = `.detox.${ext}`;
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
sync: (pattern) => {
|
|
21
|
+
const cwd = getRoot();
|
|
22
|
+
const files = globSync(useForwardSlashes(pattern + fullExt), { cwd });
|
|
23
|
+
return files.map(f => path.join(cwd, f));
|
|
24
|
+
},
|
|
25
|
+
async: async (pattern) => {
|
|
26
|
+
const cwd = getRoot();
|
|
27
|
+
const files = await globAsync(useForwardSlashes(pattern + fullExt), { cwd });
|
|
28
|
+
return files.map(f => path.join(cwd, f));
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
5
33
|
function createTempFileBuilderFn(fileExtension) {
|
|
6
34
|
/**
|
|
7
35
|
* @param {string} [basename]
|
|
8
36
|
*/
|
|
9
37
|
return (basename) => {
|
|
10
38
|
return basename
|
|
11
|
-
? path.join(
|
|
39
|
+
? path.join(getRoot(), `${basename}.detox.${fileExtension}`)
|
|
12
40
|
: tempfile(`.detox.${fileExtension}`);
|
|
13
41
|
};
|
|
14
42
|
}
|
|
@@ -23,5 +51,7 @@ module.exports = {
|
|
|
23
51
|
dtxrec: createTempFileBuilderFn('dtxrec'),
|
|
24
52
|
viewhierarchy: createTempFileBuilderFn('viewhierarchy'),
|
|
25
53
|
},
|
|
26
|
-
|
|
54
|
+
find: {
|
|
55
|
+
jsonl: createGlobber('jsonl'),
|
|
56
|
+
},
|
|
27
57
|
};
|
package/src/errors/DetoxError.js
CHANGED
|
@@ -8,6 +8,10 @@ class DetoxError extends Error {
|
|
|
8
8
|
this.name = 'DetoxError';
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
format() {
|
|
12
|
+
return this.message;
|
|
13
|
+
}
|
|
14
|
+
|
|
11
15
|
static get reportIssue() {
|
|
12
16
|
return 'Please report this issue on our GitHub tracker:\nhttps://github.com/wix/Detox/issues';
|
|
13
17
|
}
|
|
@@ -32,7 +36,7 @@ class DetoxError extends Error {
|
|
|
32
36
|
*/
|
|
33
37
|
static format(err, inspectOptions = { depth: 1 }) {
|
|
34
38
|
if (err instanceof DetoxError) {
|
|
35
|
-
return err.
|
|
39
|
+
return err.format();
|
|
36
40
|
}
|
|
37
41
|
|
|
38
42
|
if (_.isError(err) && /^Command failed:/.test(err.message)) {
|
|
@@ -19,11 +19,12 @@ const sanitizeBunyanContext = require('./utils/sanitizeBunyanContext');
|
|
|
19
19
|
* @property {CategoryThreadDispatcher} [dispatcher]
|
|
20
20
|
* @property {BunyanLogger} [bunyan]
|
|
21
21
|
* @property {MessageStack} [messageStack]
|
|
22
|
+
* @property {boolean} [unsafeMode] Disables sanitization of user input, used for integration tests.
|
|
22
23
|
*/
|
|
23
24
|
|
|
24
25
|
class DetoxLogger {
|
|
25
26
|
/**
|
|
26
|
-
* @param {
|
|
27
|
+
* @param {SharedLoggerConfig} sharedConfig
|
|
27
28
|
* @param {object} [context]
|
|
28
29
|
*/
|
|
29
30
|
constructor(sharedConfig, context) {
|
|
@@ -91,7 +92,7 @@ class DetoxLogger {
|
|
|
91
92
|
* @returns {DetoxLogger}
|
|
92
93
|
*/
|
|
93
94
|
child(overrides) {
|
|
94
|
-
const merged = this._mergeContexts(this._context,
|
|
95
|
+
const merged = this._mergeContexts(this._context, this._sanitizeContext(overrides));
|
|
95
96
|
return new DetoxLogger(this._sharedConfig, merged);
|
|
96
97
|
}
|
|
97
98
|
|
|
@@ -119,6 +120,25 @@ class DetoxLogger {
|
|
|
119
120
|
this.overrideConsole();
|
|
120
121
|
}
|
|
121
122
|
|
|
123
|
+
/**
|
|
124
|
+
* Closes the file descriptors to make sure that the temporary
|
|
125
|
+
* JSONL files are flushed and contain the last error messages.
|
|
126
|
+
* This safety measure is especially important for Windows OS.
|
|
127
|
+
*
|
|
128
|
+
* @async
|
|
129
|
+
* @internal
|
|
130
|
+
*/
|
|
131
|
+
async close() {
|
|
132
|
+
if (this._context) {
|
|
133
|
+
throw new DetoxInternalError(
|
|
134
|
+
'Trying to close file streams from a non-root logger.\n' +
|
|
135
|
+
'If you are not fiddling with Detox internals on purpose, yet you see this error, then...'
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
await this._sharedConfig.bunyan.closeFileStreams();
|
|
140
|
+
}
|
|
141
|
+
|
|
122
142
|
/**
|
|
123
143
|
* @internal
|
|
124
144
|
*/
|
|
@@ -192,7 +212,7 @@ class DetoxLogger {
|
|
|
192
212
|
|
|
193
213
|
/** @private */
|
|
194
214
|
_beginInternal(level, context, msg) {
|
|
195
|
-
this._sharedConfig.messageStack.push(context
|
|
215
|
+
this._sharedConfig.messageStack.push(context, msg);
|
|
196
216
|
this._sharedConfig.bunyan.logger[level](context, ...msg);
|
|
197
217
|
}
|
|
198
218
|
|
|
@@ -204,7 +224,7 @@ class DetoxLogger {
|
|
|
204
224
|
|
|
205
225
|
/** @private */
|
|
206
226
|
_endInternal(level, context, msg) {
|
|
207
|
-
const beginMsg = this._sharedConfig.messageStack.pop(context
|
|
227
|
+
const beginMsg = this._sharedConfig.messageStack.pop(context);
|
|
208
228
|
if (msg.length === 0) {
|
|
209
229
|
msg = beginMsg;
|
|
210
230
|
}
|
|
@@ -272,12 +292,21 @@ class DetoxLogger {
|
|
|
272
292
|
const context = this._mergeContexts(
|
|
273
293
|
this._context,
|
|
274
294
|
boundContext,
|
|
275
|
-
|
|
295
|
+
this._sanitizeContext(userContext),
|
|
276
296
|
);
|
|
277
297
|
|
|
278
298
|
return { context, msg };
|
|
279
299
|
}
|
|
280
300
|
|
|
301
|
+
/** @private */
|
|
302
|
+
_sanitizeContext(context) {
|
|
303
|
+
if (this._sharedConfig.unsafeMode) {
|
|
304
|
+
return context;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
return sanitizeBunyanContext(context);
|
|
308
|
+
}
|
|
309
|
+
|
|
281
310
|
/** @internal */
|
|
282
311
|
static defaultOptions({ level }) {
|
|
283
312
|
const ph = level === 'trace' || level === 'debug'
|
|
@@ -71,6 +71,45 @@ class BunyanLogger {
|
|
|
71
71
|
|
|
72
72
|
return this;
|
|
73
73
|
}
|
|
74
|
+
|
|
75
|
+
async closeFileStreams() {
|
|
76
|
+
const { _closeStream } = BunyanLogger;
|
|
77
|
+
const internalBunyanStreams = this._bunyan['streams'];
|
|
78
|
+
const openFileStreams = _.filter(internalBunyanStreams, this._isOpenFileStream);
|
|
79
|
+
_.remove(internalBunyanStreams, openFileStreams);
|
|
80
|
+
|
|
81
|
+
await Promise.all(openFileStreams.map(_closeStream));
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** @private */
|
|
85
|
+
_isOpenFileStream = (bunyanStream) => {
|
|
86
|
+
switch (bunyanStream.type) {
|
|
87
|
+
case 'file':
|
|
88
|
+
return bunyanStream.path && !bunyanStream.stream.destroyed;
|
|
89
|
+
case 'raw':
|
|
90
|
+
/* istanbul ignore next */
|
|
91
|
+
const stream = bunyanStream.stream === this._debugStream.stream
|
|
92
|
+
? bunyanStream.stream._out
|
|
93
|
+
: bunyanStream.stream;
|
|
94
|
+
|
|
95
|
+
/* istanbul ignore next */
|
|
96
|
+
return stream.fd !== undefined && !stream.closed;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
/** @private */
|
|
101
|
+
static _closeStream(bunyanStream) {
|
|
102
|
+
return new Promise((resolve, reject) => {
|
|
103
|
+
bunyanStream.stream.end((err) => {
|
|
104
|
+
/* istanbul ignore next */
|
|
105
|
+
if (err) {
|
|
106
|
+
reject(err);
|
|
107
|
+
} else {
|
|
108
|
+
resolve();
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
}
|
|
74
113
|
}
|
|
75
114
|
|
|
76
115
|
module.exports = BunyanLogger;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const ThreadDispatcher = require('./ThreadDispatcher');
|
|
2
|
+
const getMainCategory = require('./getMainCategory');
|
|
2
3
|
|
|
3
4
|
class CategoryThreadDispatcher {
|
|
4
5
|
constructor() {
|
|
@@ -24,7 +25,7 @@ class CategoryThreadDispatcher {
|
|
|
24
25
|
|
|
25
26
|
/** @returns {ThreadDispatcher} */
|
|
26
27
|
_resolveDispatcher(cat) {
|
|
27
|
-
const mainCategory = cat
|
|
28
|
+
const mainCategory = getMainCategory(cat);
|
|
28
29
|
if (!this._dispatchers[mainCategory]) {
|
|
29
30
|
this._dispatchers[mainCategory] = new ThreadDispatcher(mainCategory);
|
|
30
31
|
}
|