@eggjs/mock 6.1.0-beta.8 → 7.0.0-beta.13

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.
Files changed (102) hide show
  1. package/README.md +1 -1
  2. package/README.zh_CN.md +1 -1
  3. package/dist/_virtual/rolldown_runtime.js +1 -24
  4. package/dist/inject_mocha.d.ts +1 -1
  5. package/dist/inject_mocha.js +2 -3
  6. package/dist/lib/context.js +1 -3
  7. package/package.json +9 -11
  8. package/dist/node_modules/.pnpm/ansi-styles@4.3.0/node_modules/ansi-styles/index.js +0 -142
  9. package/dist/node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/index.js +0 -157
  10. package/dist/node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/templates.js +0 -97
  11. package/dist/node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/util.js +0 -40
  12. package/dist/node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/conversions.js +0 -814
  13. package/dist/node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/index.js +0 -50
  14. package/dist/node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/route.js +0 -68
  15. package/dist/node_modules/.pnpm/color-name@1.1.4/node_modules/color-name/index.js +0 -752
  16. package/dist/node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/browser.js +0 -203
  17. package/dist/node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/common.js +0 -209
  18. package/dist/node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/index.js +0 -18
  19. package/dist/node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/node.js +0 -215
  20. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/convert/dmp.js +0 -24
  21. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/convert/xml.js +0 -33
  22. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/array.js +0 -29
  23. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/base.js +0 -185
  24. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/character.js +0 -23
  25. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/css.js +0 -26
  26. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/json.js +0 -83
  27. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/line.js +0 -51
  28. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/sentence.js +0 -26
  29. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/word.js +0 -151
  30. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/index.js +0 -178
  31. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/apply.js +0 -168
  32. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/create.js +0 -301
  33. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/line-endings.js +0 -137
  34. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/merge.js +0 -367
  35. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/parse.js +0 -91
  36. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/reverse.js +0 -99
  37. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/util/array.js +0 -23
  38. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/util/distance-iterator.js +0 -30
  39. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/util/params.js +0 -22
  40. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/util/string.js +0 -97
  41. package/dist/node_modules/.pnpm/escape-string-regexp@4.0.0/node_modules/escape-string-regexp/index.js +0 -14
  42. package/dist/node_modules/.pnpm/has-flag@4.0.0/node_modules/has-flag/index.js +0 -16
  43. package/dist/node_modules/.pnpm/he@1.2.0/node_modules/he/he.js +0 -4093
  44. package/dist/node_modules/.pnpm/is-unicode-supported@0.1.0/node_modules/is-unicode-supported/index.js +0 -14
  45. package/dist/node_modules/.pnpm/log-symbols@4.1.0/node_modules/log-symbols/index.js +0 -27
  46. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/index.js +0 -12
  47. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/context.js +0 -83
  48. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/error-constants.js +0 -35
  49. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/errors.js +0 -392
  50. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/hook.js +0 -86
  51. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/bdd.js +0 -104
  52. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/common.js +0 -99
  53. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/exports.js +0 -65
  54. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/index.js +0 -18
  55. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/qunit.js +0 -95
  56. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/tdd.js +0 -105
  57. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/mocha.js +0 -1037
  58. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/mocharc.js +0 -24
  59. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/buffered-worker-pool.js +0 -152
  60. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/esm-utils.js +0 -74
  61. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/file-unloader.js +0 -22
  62. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/parallel-buffered-runner.js +0 -329
  63. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/serializer.js +0 -314
  64. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/pending.js +0 -22
  65. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/base.js +0 -417
  66. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/doc.js +0 -79
  67. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/dot.js +0 -75
  68. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/html.js +0 -283
  69. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/index.js +0 -40
  70. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/json-stream.js +0 -90
  71. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/json.js +0 -145
  72. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/landing.js +0 -107
  73. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/list.js +0 -77
  74. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/markdown.js +0 -106
  75. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/min.js +0 -57
  76. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/nyan.js +0 -233
  77. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/progress.js +0 -92
  78. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/spec.js +0 -91
  79. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/tap.js +0 -261
  80. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/xunit.js +0 -166
  81. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/runnable.js +0 -346
  82. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/runner.js +0 -922
  83. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/stats-collector.js +0 -72
  84. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/suite.js +0 -517
  85. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/test.js +0 -105
  86. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/utils.js +0 -505
  87. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/package.js +0 -225
  88. package/dist/node_modules/.pnpm/ms@2.1.3/node_modules/ms/index.js +0 -124
  89. package/dist/node_modules/.pnpm/randombytes@2.1.0/node_modules/randombytes/index.js +0 -11
  90. package/dist/node_modules/.pnpm/serialize-javascript@6.0.2/node_modules/serialize-javascript/index.js +0 -114
  91. package/dist/node_modules/.pnpm/supports-color@7.2.0/node_modules/supports-color/index.js +0 -76
  92. package/dist/node_modules/.pnpm/supports-color@8.1.1/node_modules/supports-color/index.js +0 -89
  93. package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/Pool.js +0 -366
  94. package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/Promise.js +0 -248
  95. package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/WorkerHandler.js +0 -419
  96. package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/debug-port-allocator.js +0 -27
  97. package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/environment.js +0 -18
  98. package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/generated/embeddedWorker.js +0 -16
  99. package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/index.js +0 -63
  100. package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/transfer.js +0 -21
  101. package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/validateOptions.js +0 -9
  102. package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/worker.js +0 -277
@@ -1,24 +0,0 @@
1
- import { __commonJS } from "../../../../../../_virtual/rolldown_runtime.js";
2
-
3
- //#region ../../node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/mocharc.json
4
- var require_mocharc = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/mocharc.json": ((exports, module) => {
5
- module.exports = {
6
- "diff": true,
7
- "extension": [
8
- "js",
9
- "cjs",
10
- "mjs"
11
- ],
12
- "package": "./package.json",
13
- "reporter": "spec",
14
- "slow": 75,
15
- "timeout": 2e3,
16
- "ui": "bdd",
17
- "watch-ignore": ["node_modules", ".git"]
18
- };
19
- }) });
20
-
21
- //#endregion
22
- export default require_mocharc();
23
-
24
- export { require_mocharc };
@@ -1,152 +0,0 @@
1
- import { __commonJS, __require } from "../../../../../../../_virtual/rolldown_runtime.js";
2
- import { require_src } from "../../../../../debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/index.js";
3
- import { require_errors } from "../errors.js";
4
- import { require_serialize_javascript } from "../../../../../serialize-javascript@6.0.2/node_modules/serialize-javascript/index.js";
5
- import { require_src as require_src$1 } from "../../../../../workerpool@9.3.4/node_modules/workerpool/src/index.js";
6
- import { require_serializer } from "./serializer.js";
7
-
8
- //#region ../../node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/buffered-worker-pool.js
9
- var require_buffered_worker_pool = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/buffered-worker-pool.js": ((exports) => {
10
- /**
11
- * @typedef {import('workerpool').WorkerPoolOptions} WorkerPoolOptions
12
- * @typedef {import('../types.d.ts').MochaOptions} MochaOptions
13
- * @typedef {import('../types.d.ts').SerializedWorkerResult} SerializedWorkerResult
14
- */
15
- const serializeJavascript = require_serialize_javascript();
16
- const workerpool = require_src$1();
17
- const { deserialize } = require_serializer();
18
- const debug = require_src()("mocha:parallel:buffered-worker-pool");
19
- const { createInvalidArgumentTypeError } = require_errors();
20
- const WORKER_PATH = __require.resolve("./worker.js");
21
- /**
22
- * A mapping of Mocha `Options` objects to serialized values.
23
- *
24
- * This is helpful because we tend to same the same options over and over
25
- * over IPC.
26
- * @type {WeakMap<MochaOptions,string>}
27
- */
28
- let optionsCache = /* @__PURE__ */ new WeakMap();
29
- /**
30
- * These options are passed into the [workerpool](https://npm.im/workerpool) module.
31
- * @type {Partial<WorkerPoolOptions>}
32
- */
33
- const WORKER_POOL_DEFAULT_OPTS = {
34
- workerType: "process",
35
- forkOpts: { execArgv: process.execArgv },
36
- maxWorkers: workerpool.cpus - 1
37
- };
38
- /**
39
- * A wrapper around a third-party worker pool implementation.
40
- * @private
41
- */
42
- var BufferedWorkerPool = class BufferedWorkerPool {
43
- /**
44
- * Creates an underlying worker pool instance; determines max worker count
45
- * @param {Partial<WorkerPoolOptions>} [opts] - Options
46
- */
47
- constructor(opts = {}) {
48
- const maxWorkers = Math.max(1, typeof opts.maxWorkers === "undefined" ? WORKER_POOL_DEFAULT_OPTS.maxWorkers : opts.maxWorkers);
49
- /* istanbul ignore next */
50
- if (workerpool.cpus < 2) debug("not enough CPU cores available to run multiple jobs; avoid --parallel on this machine");
51
- else if (maxWorkers >= workerpool.cpus) debug("%d concurrent job(s) requested, but only %d core(s) available", maxWorkers, workerpool.cpus);
52
- /* istanbul ignore next */
53
- debug("run(): starting worker pool of max size %d, using node args: %s", maxWorkers, process.execArgv.join(" "));
54
- let counter = 0;
55
- const onCreateWorker = ({ forkOpts }) => {
56
- return { forkOpts: {
57
- ...forkOpts,
58
- env: {
59
- ...process.env,
60
- MOCHA_WORKER_ID: counter++
61
- }
62
- } };
63
- };
64
- this.options = {
65
- ...WORKER_POOL_DEFAULT_OPTS,
66
- ...opts,
67
- maxWorkers,
68
- onCreateWorker
69
- };
70
- this._pool = workerpool.pool(WORKER_PATH, this.options);
71
- }
72
- /**
73
- * Terminates all workers in the pool.
74
- * @param {boolean} [force] - Whether to force-kill workers. By default, lets workers finish their current task before termination.
75
- * @private
76
- * @returns {Promise<void>}
77
- */
78
- async terminate(force = false) {
79
- /* istanbul ignore next */
80
- debug("terminate(): terminating with force = %s", force);
81
- return this._pool.terminate(force);
82
- }
83
- /**
84
- * Adds a test file run to the worker pool queue for execution by a worker process.
85
- *
86
- * Handles serialization/deserialization.
87
- *
88
- * @param {string} filepath - Filepath of test
89
- * @param {MochaOptions} [options] - Options for Mocha instance
90
- * @private
91
- * @returns {Promise<SerializedWorkerResult>}
92
- */
93
- async run(filepath, options = {}) {
94
- if (!filepath || typeof filepath !== "string") throw createInvalidArgumentTypeError("Expected a non-empty filepath", "filepath", "string");
95
- const serializedOptions = BufferedWorkerPool.serializeOptions(options);
96
- const result = await this._pool.exec("run", [filepath, serializedOptions]);
97
- return deserialize(result);
98
- }
99
- /**
100
- * Returns stats about the state of the worker processes in the pool.
101
- *
102
- * Used for debugging.
103
- *
104
- * @private
105
- */
106
- stats() {
107
- return this._pool.stats();
108
- }
109
- /**
110
- * Instantiates a {@link WorkerPool}.
111
- * @private
112
- */
113
- static create(...args) {
114
- return new BufferedWorkerPool(...args);
115
- }
116
- /**
117
- * Given Mocha options object `opts`, serialize into a format suitable for
118
- * transmission over IPC.
119
- *
120
- * @param {MochaOptions} [opts] - Mocha options
121
- * @private
122
- * @returns {string} Serialized options
123
- */
124
- static serializeOptions(opts = {}) {
125
- if (!optionsCache.has(opts)) {
126
- const serialized = serializeJavascript(opts, {
127
- unsafe: true,
128
- ignoreFunction: true
129
- });
130
- optionsCache.set(opts, serialized);
131
- /* istanbul ignore next */
132
- debug("serializeOptions(): serialized options %O to: %s", opts, serialized);
133
- }
134
- return optionsCache.get(opts);
135
- }
136
- /**
137
- * Resets internal cache of serialized options objects.
138
- *
139
- * For testing/debugging
140
- * @private
141
- */
142
- static resetOptionsCache() {
143
- optionsCache = /* @__PURE__ */ new WeakMap();
144
- }
145
- };
146
- exports.BufferedWorkerPool = BufferedWorkerPool;
147
- }) });
148
-
149
- //#endregion
150
- export default require_buffered_worker_pool();
151
-
152
- export { require_buffered_worker_pool };
@@ -1,74 +0,0 @@
1
- import { __commonJS, __require } from "../../../../../../../_virtual/rolldown_runtime.js";
2
- import { require_src } from "../../../../../debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/index.js";
3
-
4
- //#region ../../node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/esm-utils.js
5
- var require_esm_utils = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/esm-utils.js": ((exports) => {
6
- const path = __require("node:path");
7
- const url = __require("node:url");
8
- const debug = require_src()("mocha:esm-utils");
9
- const forward = (x) => x;
10
- const formattedImport = async (file, esmDecorator = forward) => {
11
- if (path.isAbsolute(file)) try {
12
- return await exports.doImport(esmDecorator(url.pathToFileURL(file)));
13
- } catch (err) {
14
- if (err instanceof SyntaxError && err.message && err.stack && !err.stack.includes(file)) {
15
- const newErrorWithFilename = new SyntaxError(err.message);
16
- newErrorWithFilename.stack = err.stack.replace(/^SyntaxError/, `SyntaxError[ @${file} ]`);
17
- throw newErrorWithFilename;
18
- }
19
- throw err;
20
- }
21
- return exports.doImport(esmDecorator(file));
22
- };
23
- exports.doImport = async (file) => import(file);
24
- const tryImportAndRequire = async (file, esmDecorator) => {
25
- if (path.extname(file) === ".mjs") return formattedImport(file, esmDecorator);
26
- try {
27
- return dealWithExports(await formattedImport(file, esmDecorator));
28
- } catch (err) {
29
- if (err.code === "ERR_MODULE_NOT_FOUND" || err.code === "ERR_UNKNOWN_FILE_EXTENSION" || err.code === "ERR_UNSUPPORTED_DIR_IMPORT") try {
30
- return __require(file);
31
- } catch (requireErr) {
32
- if (requireErr.code === "ERR_REQUIRE_ESM" || requireErr instanceof SyntaxError && requireErr.toString().includes("Cannot use import statement outside a module")) throw err;
33
- else throw requireErr;
34
- }
35
- else throw err;
36
- }
37
- };
38
- const requireModule = async (file, esmDecorator) => {
39
- if (path.extname(file) === ".mjs") return formattedImport(file, esmDecorator);
40
- try {
41
- return __require(file);
42
- } catch (requireErr) {
43
- debug("requireModule caught err: %O", requireErr.message);
44
- try {
45
- return dealWithExports(await formattedImport(file, esmDecorator));
46
- } catch (importErr) {
47
- if (importErr.code === "ERR_INTERNAL_ASSERTION") throw requireErr;
48
- throw importErr;
49
- }
50
- }
51
- };
52
- debug("assigning requireOrImport, require_module === %O", process.features.require_module);
53
- if (process.features.require_module) exports.requireOrImport = requireModule;
54
- else exports.requireOrImport = tryImportAndRequire;
55
- function dealWithExports(module) {
56
- if (module.default) return module.default;
57
- else return {
58
- ...module,
59
- default: void 0
60
- };
61
- }
62
- exports.loadFilesAsync = async (files, preLoadFunc, postLoadFunc, esmDecorator) => {
63
- for (const file of files) {
64
- preLoadFunc(file);
65
- const result = await exports.requireOrImport(path.resolve(file), esmDecorator);
66
- postLoadFunc(file, result);
67
- }
68
- };
69
- }) });
70
-
71
- //#endregion
72
- export default require_esm_utils();
73
-
74
- export { require_esm_utils };
@@ -1,22 +0,0 @@
1
- import { __commonJS, __require } from "../../../../../../../_virtual/rolldown_runtime.js";
2
-
3
- //#region ../../node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/file-unloader.js
4
- var require_file_unloader = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/file-unloader.js": ((exports) => {
5
- /**
6
- * This module should not be in the browser bundle, so it's here.
7
- * @private
8
- * @module
9
- */
10
- /**
11
- * Deletes a file from the `require` cache.
12
- * @param {string} file - File
13
- */
14
- exports.unloadFile = (file) => {
15
- delete __require.cache[__require.resolve(file)];
16
- };
17
- }) });
18
-
19
- //#endregion
20
- export default require_file_unloader();
21
-
22
- export { require_file_unloader };
@@ -1,329 +0,0 @@
1
- import { __commonJS, __require } from "../../../../../../../_virtual/rolldown_runtime.js";
2
- import { require_utils } from "../utils.js";
3
- import { require_src } from "../../../../../debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/index.js";
4
- import { require_errors } from "../errors.js";
5
- import { require_runner } from "../runner.js";
6
- import { require_buffered_worker_pool } from "./buffered-worker-pool.js";
7
-
8
- //#region ../../node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/parallel-buffered-runner.js
9
- var require_parallel_buffered_runner = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/parallel-buffered-runner.js": ((exports, module) => {
10
- /**
11
- * @typedef {import('../types.d.ts').FileRunner} FileRunner
12
- * @typedef {import('../types.d.ts').RunnerOptions} RunnerOptions
13
- * @typedef {import('../types.d.ts').SerializedWorkerResult} SerializedWorkerResult
14
- * @typedef {import('../types.d.ts').SigIntListener} SigIntListener
15
- */
16
- const Runner = require_runner();
17
- const { EVENT_RUN_BEGIN, EVENT_RUN_END } = Runner.constants;
18
- const debug = require_src()("mocha:parallel:parallel-buffered-runner");
19
- const { BufferedWorkerPool } = require_buffered_worker_pool();
20
- const { setInterval, clearInterval } = global;
21
- const { createMap, constants } = require_utils();
22
- const { MOCHA_ID_PROP_NAME } = constants;
23
- const { createFatalError } = require_errors();
24
- const DEFAULT_WORKER_REPORTER = __require.resolve("./reporters/parallel-buffered");
25
- /**
26
- * List of options to _not_ serialize for transmission to workers
27
- */
28
- const DENY_OPTIONS = [
29
- "globalSetup",
30
- "globalTeardown",
31
- "parallel",
32
- "p",
33
- "jobs",
34
- "j"
35
- ];
36
- /**
37
- * Outputs a debug statement with worker stats
38
- * @param {BufferedWorkerPool} pool - Worker pool
39
- */
40
- /* istanbul ignore next */
41
- const debugStats = (pool) => {
42
- const { totalWorkers, busyWorkers, idleWorkers, pendingTasks } = pool.stats();
43
- debug("%d/%d busy workers; %d idle; %d tasks queued", busyWorkers, totalWorkers, idleWorkers, pendingTasks);
44
- };
45
- /**
46
- * The interval at which we will display stats for worker processes in debug mode
47
- */
48
- const DEBUG_STATS_INTERVAL = 5e3;
49
- const ABORTED = "ABORTED";
50
- const IDLE = "IDLE";
51
- const ABORTING = "ABORTING";
52
- const RUNNING = "RUNNING";
53
- const BAILING = "BAILING";
54
- const BAILED = "BAILED";
55
- const COMPLETE = "COMPLETE";
56
- const states = createMap({
57
- [IDLE]: new Set([RUNNING, ABORTING]),
58
- [RUNNING]: new Set([
59
- COMPLETE,
60
- BAILING,
61
- ABORTING
62
- ]),
63
- [COMPLETE]: /* @__PURE__ */ new Set(),
64
- [ABORTED]: /* @__PURE__ */ new Set(),
65
- [ABORTING]: new Set([ABORTED]),
66
- [BAILING]: new Set([BAILED, ABORTING]),
67
- [BAILED]: new Set([COMPLETE, ABORTING])
68
- });
69
- /**
70
- * This `Runner` delegates tests runs to worker threads. Does not execute any
71
- * {@link Runnable}s by itself!
72
- * @public
73
- */
74
- var ParallelBufferedRunner = class extends Runner {
75
- constructor(...args) {
76
- super(...args);
77
- let state = IDLE;
78
- Object.defineProperty(this, "_state", {
79
- get() {
80
- return state;
81
- },
82
- set(newState) {
83
- if (states[state].has(newState)) state = newState;
84
- else throw new Error(`invalid state transition: ${state} => ${newState}`);
85
- }
86
- });
87
- this._workerReporter = DEFAULT_WORKER_REPORTER;
88
- this._linkPartialObjects = false;
89
- this._linkedObjectMap = /* @__PURE__ */ new Map();
90
- this.once(Runner.constants.EVENT_RUN_END, () => {
91
- this._state = COMPLETE;
92
- });
93
- }
94
- /**
95
- * Returns a mapping function to enqueue a file in the worker pool and return results of its execution.
96
- * @param {BufferedWorkerPool} pool - Worker pool
97
- * @param {RunnerOptions} options - Mocha options
98
- * @returns {FileRunner} Mapping function
99
- * @private
100
- */
101
- _createFileRunner(pool, options) {
102
- /**
103
- * Emits event and sets `BAILING` state, if necessary.
104
- * @param {Object} event - Event having `eventName`, maybe `data` and maybe `error`
105
- * @param {number} failureCount - Failure count
106
- */
107
- const emitEvent = (event, failureCount) => {
108
- this.emit(event.eventName, event.data, event.error);
109
- if (this._state !== BAILING && event.data && event.data._bail && (failureCount || event.error)) {
110
- debug("run(): nonzero failure count & found bail flag");
111
- this._state = BAILING;
112
- }
113
- };
114
- /**
115
- * Given an event, recursively find any objects in its data that have ID's, and create object references to already-seen objects.
116
- * @param {Object} event - Event having `eventName`, maybe `data` and maybe `error`
117
- */
118
- const linkEvent = (event) => {
119
- const stack = [{
120
- parent: event,
121
- prop: "data"
122
- }];
123
- while (stack.length) {
124
- const { parent, prop } = stack.pop();
125
- const obj = parent[prop];
126
- let newObj;
127
- if (obj && typeof obj === "object") if (obj[MOCHA_ID_PROP_NAME]) {
128
- const id = obj[MOCHA_ID_PROP_NAME];
129
- newObj = this._linkedObjectMap.has(id) ? Object.assign(this._linkedObjectMap.get(id), obj) : obj;
130
- this._linkedObjectMap.set(id, newObj);
131
- parent[prop] = newObj;
132
- } else throw createFatalError("Object missing ID received in event data", obj);
133
- Object.keys(newObj).forEach((key) => {
134
- const value = obj[key];
135
- if (value && typeof value === "object" && value[MOCHA_ID_PROP_NAME]) stack.push({
136
- obj: value,
137
- parent: newObj,
138
- prop: key
139
- });
140
- });
141
- }
142
- };
143
- return async (file) => {
144
- debug("run(): enqueueing test file %s", file);
145
- try {
146
- const { failureCount, events } = await pool.run(file, options);
147
- if (this._state === BAILED) return;
148
- debug("run(): completed run of file %s; %d failures / %d events", file, failureCount, events.length);
149
- this.failures += failureCount;
150
- let event = events.shift();
151
- if (this._linkPartialObjects) while (event) {
152
- linkEvent(event);
153
- emitEvent(event, failureCount);
154
- event = events.shift();
155
- }
156
- else while (event) {
157
- emitEvent(event, failureCount);
158
- event = events.shift();
159
- }
160
- if (this._state === BAILING) {
161
- debug("run(): terminating pool due to \"bail\" flag");
162
- this._state = BAILED;
163
- await pool.terminate();
164
- }
165
- } catch (err) {
166
- if (this._state === BAILED || this._state === ABORTING) debug("run(): worker pool terminated with intent; skipping file %s", file);
167
- else {
168
- debug("run(): encountered uncaught exception: %O", err);
169
- if (this.allowUncaught) {
170
- this._state = ABORTING;
171
- await pool.terminate(true);
172
- }
173
- throw err;
174
- }
175
- } finally {
176
- debug("run(): done running file %s", file);
177
- }
178
- };
179
- }
180
- /**
181
- * Listen on `Process.SIGINT`; terminate pool if caught.
182
- * Returns the listener for later call to `process.removeListener()`.
183
- * @param {BufferedWorkerPool} pool - Worker pool
184
- * @returns {SigIntListener} Listener
185
- * @private
186
- */
187
- _bindSigIntListener(pool) {
188
- const sigIntListener = async () => {
189
- debug("run(): caught a SIGINT");
190
- this._state = ABORTING;
191
- try {
192
- debug("run(): force-terminating worker pool");
193
- await pool.terminate(true);
194
- } catch (err) {
195
- console.error(`Error while attempting to force-terminate worker pool: ${err}`);
196
- process.exitCode = 1;
197
- } finally {
198
- process.nextTick(() => {
199
- debug("run(): imminent death");
200
- this._state = ABORTED;
201
- process.kill(process.pid, "SIGINT");
202
- });
203
- }
204
- };
205
- process.once("SIGINT", sigIntListener);
206
- return sigIntListener;
207
- }
208
- /**
209
- * Runs Mocha tests by creating a thread pool, then delegating work to the
210
- * worker threads.
211
- *
212
- * Each worker receives one file, and as workers become available, they take a
213
- * file from the queue and run it. The worker thread execution is treated like
214
- * an RPC--it returns a `Promise` containing serialized information about the
215
- * run. The information is processed as it's received, and emitted to a
216
- * {@link Reporter}, which is likely listening for these events.
217
- *
218
- * @param {Function} callback - Called with an exit code corresponding to
219
- * number of test failures.
220
- * @param {RunnerOptions} [opts] - options
221
- */
222
- run(callback, { files, options = {} } = {}) {
223
- /**
224
- * Listener on `Process.SIGINT` which tries to cleanly terminate the worker pool.
225
- */
226
- let sigIntListener;
227
- options = {
228
- ...options,
229
- reporter: this._workerReporter
230
- };
231
- (async () => {
232
- /**
233
- * This is an interval that outputs stats about the worker pool every so often
234
- */
235
- let debugInterval;
236
- /**
237
- * @type {BufferedWorkerPool}
238
- */
239
- let pool;
240
- try {
241
- pool = BufferedWorkerPool.create({ maxWorkers: options.jobs });
242
- sigIntListener = this._bindSigIntListener(pool);
243
- /* istanbul ignore next */
244
- debugInterval = setInterval(() => debugStats(pool), DEBUG_STATS_INTERVAL).unref();
245
- this.started = true;
246
- this._state = RUNNING;
247
- this.emit(EVENT_RUN_BEGIN);
248
- options = { ...options };
249
- DENY_OPTIONS.forEach((opt) => {
250
- delete options[opt];
251
- });
252
- const results = await Promise.allSettled(files.map(this._createFileRunner(pool, options)));
253
- await pool.terminate();
254
- results.filter(({ status }) => status === "rejected").forEach(({ reason }) => {
255
- if (this.allowUncaught) throw reason;
256
- this.uncaught(reason);
257
- });
258
- if (this._state === ABORTING) return;
259
- this.emit(EVENT_RUN_END);
260
- debug("run(): completing with failure count %d", this.failures);
261
- callback(this.failures);
262
- } catch (err) {
263
- process.nextTick(() => {
264
- debug("run(): re-throwing uncaught exception");
265
- throw err;
266
- });
267
- } finally {
268
- clearInterval(debugInterval);
269
- process.removeListener("SIGINT", sigIntListener);
270
- }
271
- })();
272
- return this;
273
- }
274
- /**
275
- * Toggle partial object linking behavior; used for building object references from
276
- * unique ID's.
277
- * @param {boolean} [value] - If `true`, enable partial object linking, otherwise disable
278
- * @returns {Runner}
279
- * @chainable
280
- * @public
281
- * @example
282
- * // this reporter needs proper object references when run in parallel mode
283
- * class MyReporter() {
284
- * constructor(runner) {
285
- * runner.linkPartialObjects(true)
286
- * .on(EVENT_SUITE_BEGIN, suite => {
287
- * // this Suite may be the same object...
288
- * })
289
- * .on(EVENT_TEST_BEGIN, test => {
290
- * // ...as the `test.parent` property
291
- * });
292
- * }
293
- * }
294
- */
295
- linkPartialObjects(value) {
296
- this._linkPartialObjects = Boolean(value);
297
- return super.linkPartialObjects(value);
298
- }
299
- /**
300
- * If this class is the `Runner` in use, then this is going to return `true`.
301
- *
302
- * For use by reporters.
303
- * @returns {true}
304
- * @public
305
- */
306
- isParallelMode() {
307
- return true;
308
- }
309
- /**
310
- * Configures an alternate reporter for worker processes to use. Subclasses
311
- * using worker processes should implement this.
312
- * @public
313
- * @param {string} path - Absolute path to alternate reporter for worker processes to use
314
- * @returns {Runner}
315
- * @throws When in serial mode
316
- * @chainable
317
- */
318
- workerReporter(reporter) {
319
- this._workerReporter = reporter;
320
- return this;
321
- }
322
- };
323
- module.exports = ParallelBufferedRunner;
324
- }) });
325
-
326
- //#endregion
327
- export default require_parallel_buffered_runner();
328
-
329
- export { require_parallel_buffered_runner };