mocha 11.7.4 → 11.7.6
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/bin/_mocha +2 -2
- package/bin/mocha.js +46 -44
- package/browser-entry.js +20 -20
- package/index.js +2 -2
- package/lib/browser/highlight-tags.js +6 -6
- package/lib/browser/parse-query.js +5 -5
- package/lib/browser/template.html +2 -2
- package/lib/cli/cli.js +32 -27
- package/lib/cli/collect-files.js +25 -25
- package/lib/cli/commands.js +4 -4
- package/lib/cli/config.js +26 -25
- package/lib/cli/index.js +2 -2
- package/lib/cli/init.js +19 -19
- package/lib/cli/lookup-files.js +20 -20
- package/lib/cli/node-flags.js +12 -12
- package/lib/cli/one-and-dones.js +12 -11
- package/lib/cli/options.js +49 -49
- package/lib/cli/run-helpers.js +52 -54
- package/lib/cli/run-option-metadata.js +75 -75
- package/lib/cli/run.js +164 -159
- package/lib/cli/watch-run.js +75 -75
- package/lib/context.js +1 -1
- package/lib/error-constants.js +17 -17
- package/lib/errors.js +26 -26
- package/lib/hook.js +9 -9
- package/lib/interfaces/bdd.js +8 -8
- package/lib/interfaces/common.js +12 -12
- package/lib/interfaces/exports.js +8 -8
- package/lib/interfaces/index.js +5 -5
- package/lib/interfaces/qunit.js +7 -7
- package/lib/interfaces/tdd.js +7 -7
- package/lib/mocha.js +97 -97
- package/lib/nodejs/buffered-worker-pool.js +30 -30
- package/lib/nodejs/esm-utils.js +24 -21
- package/lib/nodejs/file-unloader.js +2 -2
- package/lib/nodejs/parallel-buffered-runner.js +67 -67
- package/lib/nodejs/reporters/parallel-buffered.js +13 -10
- package/lib/nodejs/serializer.js +47 -47
- package/lib/nodejs/worker.js +38 -38
- package/lib/pending.js +1 -1
- package/lib/plugin-loader.js +48 -48
- package/lib/reporters/base.js +97 -94
- package/lib/reporters/doc.js +17 -17
- package/lib/reporters/dot.js +14 -14
- package/lib/reporters/html.js +73 -67
- package/lib/reporters/index.js +16 -16
- package/lib/reporters/json-stream.js +10 -10
- package/lib/reporters/json.js +16 -16
- package/lib/reporters/landing.js +20 -20
- package/lib/reporters/list.js +10 -10
- package/lib/reporters/markdown.js +21 -21
- package/lib/reporters/min.js +7 -7
- package/lib/reporters/nyan.js +35 -35
- package/lib/reporters/progress.js +14 -14
- package/lib/reporters/spec.js +15 -15
- package/lib/reporters/tap.js +26 -26
- package/lib/reporters/xunit.js +38 -34
- package/lib/runnable.js +41 -41
- package/lib/runner.js +105 -105
- package/lib/stats-collector.js +4 -4
- package/lib/suite.js +56 -46
- package/lib/test.js +10 -10
- package/lib/utils.js +122 -122
- package/mocha.css +68 -50
- package/mocha.js +826 -803
- package/mocha.js.map +1 -1
- package/package.json +8 -13
package/lib/nodejs/serializer.js
CHANGED
|
@@ -4,21 +4,21 @@
|
|
|
4
4
|
* @private
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
"use strict";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* @typedef {import('../types.d.ts').SerializedEvent} SerializedEvent
|
|
11
11
|
* @typedef {import('../types.d.ts').SerializedWorkerResult} SerializedWorkerResult
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
const {type, breakCircularDeps} = require(
|
|
15
|
-
const {createInvalidArgumentTypeError} = require(
|
|
14
|
+
const { type, breakCircularDeps } = require("../utils");
|
|
15
|
+
const { createInvalidArgumentTypeError } = require("../errors");
|
|
16
16
|
// this is not named `mocha:parallel:serializer` because it's noisy and it's
|
|
17
17
|
// helpful to be able to write `DEBUG=mocha:parallel*` and get everything else.
|
|
18
|
-
const debug = require(
|
|
18
|
+
const debug = require("debug")("mocha:serializer");
|
|
19
19
|
|
|
20
|
-
const SERIALIZABLE_RESULT_NAME =
|
|
21
|
-
const SERIALIZABLE_TYPES = new Set([
|
|
20
|
+
const SERIALIZABLE_RESULT_NAME = "SerializableWorkerResult";
|
|
21
|
+
const SERIALIZABLE_TYPES = new Set(["object", "array", "function", "error"]);
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* The serializable result of a test file run from a worker.
|
|
@@ -51,10 +51,10 @@ class SerializableWorkerResult {
|
|
|
51
51
|
* this object (once it's been received over IPC).
|
|
52
52
|
* @type {Readonly<"SerializableWorkerResult">}
|
|
53
53
|
*/
|
|
54
|
-
Object.defineProperty(this,
|
|
54
|
+
Object.defineProperty(this, "__type", {
|
|
55
55
|
value: SERIALIZABLE_RESULT_NAME,
|
|
56
56
|
enumerable: true,
|
|
57
|
-
writable: false
|
|
57
|
+
writable: false,
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
60
|
|
|
@@ -73,7 +73,7 @@ class SerializableWorkerResult {
|
|
|
73
73
|
* @returns {Readonly<SerializableWorkerResult>}
|
|
74
74
|
*/
|
|
75
75
|
serialize() {
|
|
76
|
-
this.events.forEach(event => {
|
|
76
|
+
this.events.forEach((event) => {
|
|
77
77
|
event.serialize();
|
|
78
78
|
});
|
|
79
79
|
return Object.freeze(this);
|
|
@@ -87,7 +87,7 @@ class SerializableWorkerResult {
|
|
|
87
87
|
* @returns {SerializedWorkerResult}
|
|
88
88
|
*/
|
|
89
89
|
static deserialize(obj) {
|
|
90
|
-
obj.events.forEach(event => {
|
|
90
|
+
obj.events.forEach((event) => {
|
|
91
91
|
SerializableEvent.deserialize(event);
|
|
92
92
|
});
|
|
93
93
|
return obj;
|
|
@@ -102,7 +102,7 @@ class SerializableWorkerResult {
|
|
|
102
102
|
static isSerializedWorkerResult(value) {
|
|
103
103
|
return (
|
|
104
104
|
value instanceof SerializableWorkerResult ||
|
|
105
|
-
(type(value) ===
|
|
105
|
+
(type(value) === "object" && value.__type === SERIALIZABLE_RESULT_NAME)
|
|
106
106
|
);
|
|
107
107
|
}
|
|
108
108
|
}
|
|
@@ -137,9 +137,9 @@ class SerializableEvent {
|
|
|
137
137
|
constructor(eventName, originalValue, originalError) {
|
|
138
138
|
if (!eventName) {
|
|
139
139
|
throw createInvalidArgumentTypeError(
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
140
|
+
"Empty `eventName` string argument",
|
|
141
|
+
"eventName",
|
|
142
|
+
"string",
|
|
143
143
|
);
|
|
144
144
|
}
|
|
145
145
|
/**
|
|
@@ -148,20 +148,20 @@ class SerializableEvent {
|
|
|
148
148
|
*/
|
|
149
149
|
this.eventName = eventName;
|
|
150
150
|
const originalValueType = type(originalValue);
|
|
151
|
-
if (originalValueType !==
|
|
151
|
+
if (originalValueType !== "object" && originalValueType !== "undefined") {
|
|
152
152
|
throw createInvalidArgumentTypeError(
|
|
153
153
|
`Expected object but received ${originalValueType}`,
|
|
154
|
-
|
|
155
|
-
|
|
154
|
+
"originalValue",
|
|
155
|
+
"object",
|
|
156
156
|
);
|
|
157
157
|
}
|
|
158
158
|
/**
|
|
159
159
|
* An error, if present.
|
|
160
160
|
* @memberof SerializableEvent
|
|
161
161
|
*/
|
|
162
|
-
Object.defineProperty(this,
|
|
162
|
+
Object.defineProperty(this, "originalError", {
|
|
163
163
|
value: originalError,
|
|
164
|
-
enumerable: false
|
|
164
|
+
enumerable: false,
|
|
165
165
|
});
|
|
166
166
|
|
|
167
167
|
/**
|
|
@@ -171,9 +171,9 @@ class SerializableEvent {
|
|
|
171
171
|
*
|
|
172
172
|
* @memberof SerializableEvent
|
|
173
173
|
*/
|
|
174
|
-
Object.defineProperty(this,
|
|
174
|
+
Object.defineProperty(this, "originalValue", {
|
|
175
175
|
value: originalValue,
|
|
176
|
-
enumerable: false
|
|
176
|
+
enumerable: false,
|
|
177
177
|
});
|
|
178
178
|
}
|
|
179
179
|
|
|
@@ -197,44 +197,44 @@ class SerializableEvent {
|
|
|
197
197
|
static _serialize(pairs, parent, key) {
|
|
198
198
|
let value = parent[key];
|
|
199
199
|
let _type = type(value);
|
|
200
|
-
if (_type ===
|
|
200
|
+
if (_type === "error") {
|
|
201
201
|
// we need to reference the stack prop b/c it's lazily-loaded.
|
|
202
202
|
// `__type` is necessary for deserialization to create an `Error` later.
|
|
203
203
|
// `message` is apparently not enumerable, so we must handle it specifically.
|
|
204
204
|
value = Object.assign(Object.create(null), value, {
|
|
205
205
|
stack: value.stack,
|
|
206
206
|
message: value.message,
|
|
207
|
-
__type:
|
|
207
|
+
__type: "Error",
|
|
208
208
|
});
|
|
209
209
|
parent[key] = value;
|
|
210
210
|
// after this, set the result of type(value) to be `object`, and we'll throw
|
|
211
211
|
// whatever other junk is in the original error into the new `value`.
|
|
212
|
-
_type =
|
|
212
|
+
_type = "object";
|
|
213
213
|
}
|
|
214
214
|
switch (_type) {
|
|
215
|
-
case
|
|
216
|
-
if (type(value.serialize) ===
|
|
215
|
+
case "object":
|
|
216
|
+
if (type(value.serialize) === "function") {
|
|
217
217
|
parent[key] = value.serialize();
|
|
218
218
|
} else {
|
|
219
219
|
// by adding props to the `pairs` array, we will process it further
|
|
220
220
|
pairs.push(
|
|
221
221
|
...Object.keys(value)
|
|
222
|
-
.filter(key => SERIALIZABLE_TYPES.has(type(value[key])))
|
|
223
|
-
.map(key => [value, key])
|
|
222
|
+
.filter((key) => SERIALIZABLE_TYPES.has(type(value[key])))
|
|
223
|
+
.map((key) => [value, key]),
|
|
224
224
|
);
|
|
225
225
|
}
|
|
226
226
|
break;
|
|
227
|
-
case
|
|
227
|
+
case "function":
|
|
228
228
|
// we _may_ want to dig in to functions for some assertion libraries
|
|
229
229
|
// that might put a usable property on a function.
|
|
230
230
|
// for now, just zap it.
|
|
231
231
|
delete parent[key];
|
|
232
232
|
break;
|
|
233
|
-
case
|
|
233
|
+
case "array":
|
|
234
234
|
pairs.push(
|
|
235
235
|
...value
|
|
236
|
-
.filter(value => SERIALIZABLE_TYPES.has(type(value)))
|
|
237
|
-
.map((value, index) => [value, index])
|
|
236
|
+
.filter((value) => SERIALIZABLE_TYPES.has(type(value)))
|
|
237
|
+
.map((value, index) => [value, index]),
|
|
238
238
|
);
|
|
239
239
|
break;
|
|
240
240
|
}
|
|
@@ -256,17 +256,17 @@ class SerializableEvent {
|
|
|
256
256
|
const originalValue = this.originalValue;
|
|
257
257
|
const result = Object.assign(Object.create(null), {
|
|
258
258
|
data:
|
|
259
|
-
type(originalValue) ===
|
|
260
|
-
type(originalValue.serialize) ===
|
|
259
|
+
type(originalValue) === "object" &&
|
|
260
|
+
type(originalValue.serialize) === "function"
|
|
261
261
|
? originalValue.serialize()
|
|
262
262
|
: originalValue,
|
|
263
|
-
error: this.originalError
|
|
263
|
+
error: this.originalError,
|
|
264
264
|
});
|
|
265
265
|
|
|
266
266
|
// mutates the object
|
|
267
267
|
breakCircularDeps(result.error);
|
|
268
268
|
|
|
269
|
-
const pairs = Object.keys(result).map(key => [result, key]);
|
|
269
|
+
const pairs = Object.keys(result).map((key) => [result, key]);
|
|
270
270
|
const seenPairs = new Set();
|
|
271
271
|
let pair;
|
|
272
272
|
|
|
@@ -307,7 +307,7 @@ class SerializableEvent {
|
|
|
307
307
|
* @param {string|number} key - Some prop name or array index within `parent`
|
|
308
308
|
*/
|
|
309
309
|
static _deserializeObject(parent, key) {
|
|
310
|
-
if (key ===
|
|
310
|
+
if (key === "__proto__") {
|
|
311
311
|
delete parent[key];
|
|
312
312
|
return;
|
|
313
313
|
}
|
|
@@ -315,21 +315,21 @@ class SerializableEvent {
|
|
|
315
315
|
// keys beginning with `$$` are converted into functions returning the value
|
|
316
316
|
// and renamed, stripping the `$$` prefix.
|
|
317
317
|
// functions defined this way cannot be array members!
|
|
318
|
-
if (type(key) ===
|
|
318
|
+
if (type(key) === "string" && key.startsWith("$$")) {
|
|
319
319
|
const newKey = key.slice(2);
|
|
320
320
|
parent[newKey] = () => value;
|
|
321
321
|
delete parent[key];
|
|
322
322
|
key = newKey;
|
|
323
323
|
}
|
|
324
|
-
if (type(value) ===
|
|
324
|
+
if (type(value) === "array") {
|
|
325
325
|
value.forEach((_, idx) => {
|
|
326
326
|
SerializableEvent._deserializeObject(value, idx);
|
|
327
327
|
});
|
|
328
|
-
} else if (type(value) ===
|
|
329
|
-
if (value.__type ===
|
|
328
|
+
} else if (type(value) === "object") {
|
|
329
|
+
if (value.__type === "Error") {
|
|
330
330
|
parent[key] = SerializableEvent._deserializeError(value);
|
|
331
331
|
} else {
|
|
332
|
-
Object.keys(value).forEach(key => {
|
|
332
|
+
Object.keys(value).forEach((key) => {
|
|
333
333
|
SerializableEvent._deserializeObject(value, key);
|
|
334
334
|
});
|
|
335
335
|
}
|
|
@@ -345,13 +345,13 @@ class SerializableEvent {
|
|
|
345
345
|
*/
|
|
346
346
|
static deserialize(obj) {
|
|
347
347
|
if (!obj) {
|
|
348
|
-
throw createInvalidArgumentTypeError(
|
|
348
|
+
throw createInvalidArgumentTypeError("Expected value", obj);
|
|
349
349
|
}
|
|
350
350
|
|
|
351
351
|
obj = Object.assign(Object.create(null), obj);
|
|
352
352
|
|
|
353
353
|
if (obj.data) {
|
|
354
|
-
Object.keys(obj.data).forEach(key => {
|
|
354
|
+
Object.keys(obj.data).forEach((key) => {
|
|
355
355
|
SerializableEvent._deserializeObject(obj.data, key);
|
|
356
356
|
});
|
|
357
357
|
}
|
|
@@ -373,10 +373,10 @@ class SerializableEvent {
|
|
|
373
373
|
*/
|
|
374
374
|
exports.serialize = function serialize(value) {
|
|
375
375
|
const result =
|
|
376
|
-
type(value) ===
|
|
376
|
+
type(value) === "object" && type(value.serialize) === "function"
|
|
377
377
|
? value.serialize()
|
|
378
378
|
: value;
|
|
379
|
-
debug(
|
|
379
|
+
debug("serialized: %O", result);
|
|
380
380
|
return result;
|
|
381
381
|
};
|
|
382
382
|
|
|
@@ -392,7 +392,7 @@ exports.deserialize = function deserialize(value) {
|
|
|
392
392
|
const result = SerializableWorkerResult.isSerializedWorkerResult(value)
|
|
393
393
|
? SerializableWorkerResult.deserialize(value)
|
|
394
394
|
: value;
|
|
395
|
-
debug(
|
|
395
|
+
debug("deserialized: %O", result);
|
|
396
396
|
return result;
|
|
397
397
|
};
|
|
398
398
|
|
package/lib/nodejs/worker.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @private
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
"use strict";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* @typedef {import('../types.d.ts').BufferedEvent} BufferedEvent
|
|
@@ -13,22 +13,22 @@
|
|
|
13
13
|
|
|
14
14
|
const {
|
|
15
15
|
createInvalidArgumentTypeError,
|
|
16
|
-
createInvalidArgumentValueError
|
|
17
|
-
} = require(
|
|
18
|
-
const workerpool = require(
|
|
19
|
-
const Mocha = require(
|
|
20
|
-
const {handleRequires, validateLegacyPlugin} = require(
|
|
21
|
-
const d = require(
|
|
16
|
+
createInvalidArgumentValueError,
|
|
17
|
+
} = require("../errors");
|
|
18
|
+
const workerpool = require("workerpool");
|
|
19
|
+
const Mocha = require("../mocha");
|
|
20
|
+
const { handleRequires, validateLegacyPlugin } = require("../cli/run-helpers");
|
|
21
|
+
const d = require("debug");
|
|
22
22
|
const debug = d.debug(`mocha:parallel:worker:${process.pid}`);
|
|
23
23
|
const isDebugEnabled = d.enabled(`mocha:parallel:worker:${process.pid}`);
|
|
24
|
-
const {serialize} = require(
|
|
25
|
-
const {setInterval, clearInterval} = global;
|
|
24
|
+
const { serialize } = require("./serializer");
|
|
25
|
+
const { setInterval, clearInterval } = global;
|
|
26
26
|
|
|
27
27
|
let rootHooks;
|
|
28
28
|
|
|
29
29
|
if (workerpool.isMainThread) {
|
|
30
30
|
throw new Error(
|
|
31
|
-
|
|
31
|
+
"This script is intended to be run as a worker (by the `workerpool` package).",
|
|
32
32
|
);
|
|
33
33
|
}
|
|
34
34
|
|
|
@@ -43,16 +43,16 @@ if (workerpool.isMainThread) {
|
|
|
43
43
|
*
|
|
44
44
|
* @param {MochaOptions} argv - Command-line options
|
|
45
45
|
*/
|
|
46
|
-
let bootstrap = async argv => {
|
|
46
|
+
let bootstrap = async (argv) => {
|
|
47
47
|
// globalSetup and globalTeardown do not run in workers
|
|
48
48
|
const plugins = await handleRequires(argv.require, {
|
|
49
|
-
ignoredPlugins: [
|
|
49
|
+
ignoredPlugins: ["mochaGlobalSetup", "mochaGlobalTeardown"],
|
|
50
50
|
});
|
|
51
|
-
validateLegacyPlugin(argv,
|
|
51
|
+
validateLegacyPlugin(argv, "ui", Mocha.interfaces);
|
|
52
52
|
|
|
53
53
|
rootHooks = plugins.rootHooks;
|
|
54
54
|
bootstrap = () => {};
|
|
55
|
-
debug(
|
|
55
|
+
debug("bootstrap(): finished with args: %O", argv);
|
|
56
56
|
};
|
|
57
57
|
|
|
58
58
|
/**
|
|
@@ -63,43 +63,43 @@ let bootstrap = async argv => {
|
|
|
63
63
|
* @returns {Promise<{failures: number, events: BufferedEvent[]}>} - Test
|
|
64
64
|
* failure count and list of events.
|
|
65
65
|
*/
|
|
66
|
-
async function run(filepath, serializedOptions =
|
|
66
|
+
async function run(filepath, serializedOptions = "{}") {
|
|
67
67
|
if (!filepath) {
|
|
68
68
|
throw createInvalidArgumentTypeError(
|
|
69
69
|
'Expected a non-empty "filepath" argument',
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
"file",
|
|
71
|
+
"string",
|
|
72
72
|
);
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
debug(
|
|
75
|
+
debug("run(): running test file %s", filepath);
|
|
76
76
|
|
|
77
|
-
if (typeof serializedOptions !==
|
|
77
|
+
if (typeof serializedOptions !== "string") {
|
|
78
78
|
throw createInvalidArgumentTypeError(
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
"run() expects second parameter to be a string which was serialized by the `serialize-javascript` module",
|
|
80
|
+
"serializedOptions",
|
|
81
|
+
"string",
|
|
82
82
|
);
|
|
83
83
|
}
|
|
84
84
|
let argv;
|
|
85
85
|
try {
|
|
86
86
|
// eslint-disable-next-line no-eval
|
|
87
|
-
argv = eval(
|
|
87
|
+
argv = eval("(" + serializedOptions + ")");
|
|
88
88
|
} catch (err) {
|
|
89
89
|
throw createInvalidArgumentValueError(
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
serializedOptions
|
|
90
|
+
"run() was unable to deserialize the options",
|
|
91
|
+
"serializedOptions",
|
|
92
|
+
serializedOptions,
|
|
93
93
|
);
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
const opts = Object.assign({ui:
|
|
96
|
+
const opts = Object.assign({ ui: "bdd" }, argv, {
|
|
97
97
|
// if this was true, it would cause infinite recursion.
|
|
98
98
|
parallel: false,
|
|
99
99
|
// this doesn't work in parallel mode
|
|
100
100
|
forbidOnly: true,
|
|
101
101
|
// it's useful for a Mocha instance to know if it's running in a worker process.
|
|
102
|
-
isWorker: true
|
|
102
|
+
isWorker: true,
|
|
103
103
|
});
|
|
104
104
|
|
|
105
105
|
await bootstrap(opts);
|
|
@@ -111,7 +111,7 @@ async function run(filepath, serializedOptions = '{}') {
|
|
|
111
111
|
try {
|
|
112
112
|
await mocha.loadFilesAsync();
|
|
113
113
|
} catch (err) {
|
|
114
|
-
debug(
|
|
114
|
+
debug("run(): could not load file %s: %s", filepath, err);
|
|
115
115
|
throw err;
|
|
116
116
|
}
|
|
117
117
|
|
|
@@ -120,25 +120,25 @@ async function run(filepath, serializedOptions = '{}') {
|
|
|
120
120
|
/* istanbul ignore next */
|
|
121
121
|
if (isDebugEnabled) {
|
|
122
122
|
debugInterval = setInterval(() => {
|
|
123
|
-
debug(
|
|
123
|
+
debug("run(): still running %s...", filepath);
|
|
124
124
|
}, 5000).unref();
|
|
125
125
|
}
|
|
126
|
-
mocha.run(result => {
|
|
126
|
+
mocha.run((result) => {
|
|
127
127
|
// Runner adds these; if we don't remove them, we'll get a leak.
|
|
128
|
-
process.removeAllListeners(
|
|
129
|
-
process.removeAllListeners(
|
|
128
|
+
process.removeAllListeners("uncaughtException");
|
|
129
|
+
process.removeAllListeners("unhandledRejection");
|
|
130
130
|
|
|
131
131
|
try {
|
|
132
132
|
const serialized = serialize(result);
|
|
133
133
|
debug(
|
|
134
|
-
|
|
135
|
-
typeof result.failures ===
|
|
134
|
+
"run(): completed run with %d test failures; returning to main process",
|
|
135
|
+
typeof result.failures === "number" ? result.failures : 0,
|
|
136
136
|
);
|
|
137
137
|
resolve(serialized);
|
|
138
138
|
} catch (err) {
|
|
139
139
|
// TODO: figure out exactly what the sad path looks like here.
|
|
140
140
|
// rejection should only happen if an error is "unrecoverable"
|
|
141
|
-
debug(
|
|
141
|
+
debug("run(): serialization failed; rejecting: %O", err);
|
|
142
142
|
reject(err);
|
|
143
143
|
} finally {
|
|
144
144
|
clearInterval(debugInterval);
|
|
@@ -148,9 +148,9 @@ async function run(filepath, serializedOptions = '{}') {
|
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
// this registers the `run` function.
|
|
151
|
-
workerpool.worker({run});
|
|
151
|
+
workerpool.worker({ run });
|
|
152
152
|
|
|
153
|
-
debug(
|
|
153
|
+
debug("started worker process");
|
|
154
154
|
|
|
155
155
|
// for testing
|
|
156
156
|
exports.run = run;
|
package/lib/pending.js
CHANGED