@eggjs/mock 6.0.6 → 6.1.0-beta.10
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/README.md +35 -56
- package/README.zh_CN.md +30 -50
- package/dist/_virtual/rolldown_runtime.js +30 -0
- package/dist/app/extend/agent.d.ts +39 -0
- package/dist/app/extend/agent.js +48 -0
- package/dist/app/extend/application.d.ts +175 -0
- package/dist/app/extend/application.js +385 -0
- package/dist/app/middleware/cluster_app_mock.d.ts +6 -0
- package/dist/app/middleware/cluster_app_mock.js +97 -0
- package/dist/app.d.ts +10 -0
- package/dist/app.js +17 -0
- package/dist/bootstrap.d.ts +9 -0
- package/dist/bootstrap.js +14 -0
- package/dist/index.d.ts +81 -0
- package/dist/index.js +47 -0
- package/dist/inject_mocha.d.ts +1 -0
- package/dist/inject_mocha.js +35 -0
- package/dist/lib/agent_handler.d.ts +7 -0
- package/dist/lib/agent_handler.js +26 -0
- package/dist/lib/app.d.ts +7 -0
- package/dist/lib/app.js +251 -0
- package/dist/lib/app_handler.d.ts +9 -0
- package/dist/lib/app_handler.js +56 -0
- package/dist/lib/cluster.d.ts +126 -0
- package/dist/lib/cluster.js +283 -0
- package/dist/lib/context.d.ts +4 -0
- package/dist/lib/context.js +12 -0
- package/dist/lib/format_options.d.ts +10 -0
- package/dist/lib/format_options.js +65 -0
- package/dist/lib/inject_context.d.ts +9 -0
- package/dist/lib/inject_context.js +106 -0
- package/dist/lib/mock_agent.d.ts +9 -0
- package/dist/lib/mock_agent.js +45 -0
- package/dist/lib/mock_custom_loader.d.ts +4 -0
- package/dist/lib/mock_custom_loader.js +35 -0
- package/dist/lib/mock_http_server.d.ts +6 -0
- package/dist/lib/mock_http_server.js +17 -0
- package/dist/lib/mock_httpclient.d.ts +40 -0
- package/dist/lib/mock_httpclient.js +110 -0
- package/dist/lib/parallel/agent.d.ts +24 -0
- package/dist/lib/parallel/agent.js +111 -0
- package/dist/lib/parallel/app.d.ts +24 -0
- package/dist/lib/parallel/app.js +99 -0
- package/dist/lib/parallel/util.d.ts +6 -0
- package/dist/lib/parallel/util.js +59 -0
- package/dist/lib/prerequire.d.ts +1 -0
- package/dist/lib/prerequire.js +1 -0
- package/dist/lib/request_call_function.d.ts +1 -0
- package/dist/lib/request_call_function.js +37 -0
- package/dist/lib/restore.d.ts +4 -0
- package/dist/lib/restore.js +16 -0
- package/dist/lib/start-cluster.d.ts +1 -0
- package/dist/lib/start-cluster.js +19 -0
- package/dist/lib/supertest.d.ts +16 -0
- package/dist/lib/supertest.js +39 -0
- package/dist/lib/tmp/empty.d.ts +1 -0
- package/dist/lib/tmp/empty.js +1 -0
- package/{src/lib/types.ts → dist/lib/types.d.ts} +12 -29
- package/dist/lib/types.js +1 -0
- package/dist/lib/utils.d.ts +12 -0
- package/dist/lib/utils.js +40 -0
- package/dist/node_modules/.pnpm/ansi-styles@4.3.0/node_modules/ansi-styles/index.js +142 -0
- package/dist/node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/index.js +157 -0
- package/dist/node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/templates.js +97 -0
- package/dist/node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/util.js +40 -0
- package/dist/node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/conversions.js +814 -0
- package/dist/node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/index.js +50 -0
- package/dist/node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/route.js +68 -0
- package/dist/node_modules/.pnpm/color-name@1.1.4/node_modules/color-name/index.js +752 -0
- package/dist/node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/browser.js +203 -0
- package/dist/node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/common.js +209 -0
- package/dist/node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/index.js +18 -0
- package/dist/node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/node.js +215 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/convert/dmp.js +24 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/convert/xml.js +33 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/array.js +29 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/base.js +185 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/character.js +23 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/css.js +26 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/json.js +83 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/line.js +51 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/sentence.js +26 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/word.js +151 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/index.js +178 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/apply.js +168 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/create.js +301 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/line-endings.js +137 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/merge.js +367 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/parse.js +91 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/reverse.js +99 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/util/array.js +23 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/util/distance-iterator.js +30 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/util/params.js +22 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/util/string.js +97 -0
- package/dist/node_modules/.pnpm/escape-string-regexp@4.0.0/node_modules/escape-string-regexp/index.js +14 -0
- package/dist/node_modules/.pnpm/has-flag@4.0.0/node_modules/has-flag/index.js +16 -0
- package/dist/node_modules/.pnpm/he@1.2.0/node_modules/he/he.js +4093 -0
- package/dist/node_modules/.pnpm/is-unicode-supported@0.1.0/node_modules/is-unicode-supported/index.js +14 -0
- package/dist/node_modules/.pnpm/log-symbols@4.1.0/node_modules/log-symbols/index.js +27 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/index.js +12 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/context.js +83 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/error-constants.js +35 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/errors.js +392 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/hook.js +86 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/bdd.js +104 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/common.js +99 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/exports.js +65 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/index.js +18 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/qunit.js +95 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/tdd.js +105 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/mocha.js +1037 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/mocharc.js +24 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/buffered-worker-pool.js +152 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/esm-utils.js +74 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/file-unloader.js +22 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/parallel-buffered-runner.js +329 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/serializer.js +314 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/pending.js +22 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/base.js +417 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/doc.js +79 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/dot.js +75 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/html.js +283 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/index.js +40 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/json-stream.js +90 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/json.js +145 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/landing.js +107 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/list.js +77 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/markdown.js +106 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/min.js +57 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/nyan.js +233 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/progress.js +92 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/spec.js +91 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/tap.js +261 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/xunit.js +166 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/runnable.js +346 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/runner.js +922 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/stats-collector.js +72 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/suite.js +517 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/test.js +105 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/utils.js +505 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/package.js +225 -0
- package/dist/node_modules/.pnpm/ms@2.1.3/node_modules/ms/index.js +124 -0
- package/dist/node_modules/.pnpm/randombytes@2.1.0/node_modules/randombytes/index.js +11 -0
- package/dist/node_modules/.pnpm/serialize-javascript@6.0.2/node_modules/serialize-javascript/index.js +114 -0
- package/dist/node_modules/.pnpm/supports-color@7.2.0/node_modules/supports-color/index.js +76 -0
- package/dist/node_modules/.pnpm/supports-color@8.1.1/node_modules/supports-color/index.js +89 -0
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/Pool.js +366 -0
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/Promise.js +248 -0
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/WorkerHandler.js +419 -0
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/debug-port-allocator.js +27 -0
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/environment.js +18 -0
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/generated/embeddedWorker.js +16 -0
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/index.js +63 -0
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/transfer.js +21 -0
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/validateOptions.js +9 -0
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/worker.js +277 -0
- package/dist/register.d.ts +10 -0
- package/dist/register.js +40 -0
- package/dist/typings/index.d.ts +1 -0
- package/package.json +71 -98
- package/dist/commonjs/app/extend/agent.d.ts +0 -34
- package/dist/commonjs/app/extend/agent.js +0 -49
- package/dist/commonjs/app/extend/application.d.ts +0 -171
- package/dist/commonjs/app/extend/application.js +0 -450
- package/dist/commonjs/app/middleware/cluster_app_mock.d.ts +0 -3
- package/dist/commonjs/app/middleware/cluster_app_mock.js +0 -101
- package/dist/commonjs/app.d.ts +0 -6
- package/dist/commonjs/app.js +0 -20
- package/dist/commonjs/bootstrap.d.ts +0 -5
- package/dist/commonjs/bootstrap.js +0 -59
- package/dist/commonjs/index.d.ts +0 -77
- package/dist/commonjs/index.js +0 -114
- package/dist/commonjs/lib/agent_handler.d.ts +0 -3
- package/dist/commonjs/lib/agent_handler.js +0 -28
- package/dist/commonjs/lib/app.d.ts +0 -3
- package/dist/commonjs/lib/app.js +0 -301
- package/dist/commonjs/lib/app_handler.d.ts +0 -5
- package/dist/commonjs/lib/app_handler.js +0 -71
- package/dist/commonjs/lib/cluster.d.ts +0 -114
- package/dist/commonjs/lib/cluster.js +0 -337
- package/dist/commonjs/lib/context.d.ts +0 -1
- package/dist/commonjs/lib/context.js +0 -16
- package/dist/commonjs/lib/format_options.d.ts +0 -5
- package/dist/commonjs/lib/format_options.js +0 -100
- package/dist/commonjs/lib/inject_context.d.ts +0 -6
- package/dist/commonjs/lib/inject_context.js +0 -132
- package/dist/commonjs/lib/mock_agent.d.ts +0 -5
- package/dist/commonjs/lib/mock_agent.js +0 -49
- package/dist/commonjs/lib/mock_custom_loader.d.ts +0 -1
- package/dist/commonjs/lib/mock_custom_loader.js +0 -37
- package/dist/commonjs/lib/mock_http_server.d.ts +0 -2
- package/dist/commonjs/lib/mock_http_server.js +0 -24
- package/dist/commonjs/lib/mock_httpclient.d.ts +0 -36
- package/dist/commonjs/lib/mock_httpclient.js +0 -147
- package/dist/commonjs/lib/parallel/agent.d.ts +0 -20
- package/dist/commonjs/lib/parallel/agent.js +0 -125
- package/dist/commonjs/lib/parallel/app.d.ts +0 -20
- package/dist/commonjs/lib/parallel/app.js +0 -115
- package/dist/commonjs/lib/parallel/util.d.ts +0 -3
- package/dist/commonjs/lib/parallel/util.js +0 -77
- package/dist/commonjs/lib/prerequire.d.ts +0 -1
- package/dist/commonjs/lib/prerequire.js +0 -26
- package/dist/commonjs/lib/request_call_function.d.ts +0 -1
- package/dist/commonjs/lib/request_call_function.js +0 -52
- package/dist/commonjs/lib/restore.d.ts +0 -1
- package/dist/commonjs/lib/restore.js +0 -16
- package/dist/commonjs/lib/start-cluster.d.ts +0 -2
- package/dist/commonjs/lib/start-cluster.js +0 -23
- package/dist/commonjs/lib/supertest.d.ts +0 -11
- package/dist/commonjs/lib/supertest.js +0 -48
- package/dist/commonjs/lib/tmp/empty.d.ts +0 -1
- package/dist/commonjs/lib/tmp/empty.js +0 -3
- package/dist/commonjs/lib/types.d.ts +0 -68
- package/dist/commonjs/lib/types.js +0 -3
- package/dist/commonjs/lib/utils.d.ts +0 -9
- package/dist/commonjs/lib/utils.js +0 -80
- package/dist/commonjs/package.json +0 -3
- package/dist/commonjs/register.d.ts +0 -8
- package/dist/commonjs/register.js +0 -80
- package/dist/esm/app/extend/agent.d.ts +0 -34
- package/dist/esm/app/extend/agent.js +0 -46
- package/dist/esm/app/extend/application.d.ts +0 -171
- package/dist/esm/app/extend/application.js +0 -444
- package/dist/esm/app/middleware/cluster_app_mock.d.ts +0 -3
- package/dist/esm/app/middleware/cluster_app_mock.js +0 -99
- package/dist/esm/app.d.ts +0 -6
- package/dist/esm/app.js +0 -17
- package/dist/esm/bootstrap.d.ts +0 -5
- package/dist/esm/bootstrap.js +0 -15
- package/dist/esm/index.d.ts +0 -77
- package/dist/esm/index.js +0 -91
- package/dist/esm/lib/agent_handler.d.ts +0 -3
- package/dist/esm/lib/agent_handler.js +0 -24
- package/dist/esm/lib/app.d.ts +0 -3
- package/dist/esm/lib/app.js +0 -295
- package/dist/esm/lib/app_handler.d.ts +0 -5
- package/dist/esm/lib/app_handler.js +0 -65
- package/dist/esm/lib/cluster.d.ts +0 -114
- package/dist/esm/lib/cluster.js +0 -328
- package/dist/esm/lib/context.d.ts +0 -1
- package/dist/esm/lib/context.js +0 -13
- package/dist/esm/lib/format_options.d.ts +0 -5
- package/dist/esm/lib/format_options.js +0 -94
- package/dist/esm/lib/inject_context.d.ts +0 -6
- package/dist/esm/lib/inject_context.js +0 -126
- package/dist/esm/lib/mock_agent.d.ts +0 -5
- package/dist/esm/lib/mock_agent.js +0 -45
- package/dist/esm/lib/mock_custom_loader.d.ts +0 -1
- package/dist/esm/lib/mock_custom_loader.js +0 -34
- package/dist/esm/lib/mock_http_server.d.ts +0 -2
- package/dist/esm/lib/mock_http_server.js +0 -18
- package/dist/esm/lib/mock_httpclient.d.ts +0 -36
- package/dist/esm/lib/mock_httpclient.js +0 -144
- package/dist/esm/lib/parallel/agent.d.ts +0 -20
- package/dist/esm/lib/parallel/agent.js +0 -117
- package/dist/esm/lib/parallel/app.d.ts +0 -20
- package/dist/esm/lib/parallel/app.js +0 -110
- package/dist/esm/lib/parallel/util.d.ts +0 -3
- package/dist/esm/lib/parallel/util.js +0 -73
- package/dist/esm/lib/prerequire.d.ts +0 -1
- package/dist/esm/lib/prerequire.js +0 -25
- package/dist/esm/lib/request_call_function.d.ts +0 -1
- package/dist/esm/lib/request_call_function.js +0 -47
- package/dist/esm/lib/restore.d.ts +0 -1
- package/dist/esm/lib/restore.js +0 -13
- package/dist/esm/lib/start-cluster.d.ts +0 -2
- package/dist/esm/lib/start-cluster.js +0 -18
- package/dist/esm/lib/supertest.d.ts +0 -11
- package/dist/esm/lib/supertest.js +0 -40
- package/dist/esm/lib/tmp/empty.d.ts +0 -1
- package/dist/esm/lib/tmp/empty.js +0 -2
- package/dist/esm/lib/types.d.ts +0 -68
- package/dist/esm/lib/types.js +0 -2
- package/dist/esm/lib/utils.d.ts +0 -9
- package/dist/esm/lib/utils.js +0 -69
- package/dist/esm/package.json +0 -3
- package/dist/esm/register.d.ts +0 -8
- package/dist/esm/register.js +0 -75
- package/dist/package.json +0 -4
- package/src/app/extend/agent.ts +0 -57
- package/src/app/extend/application.ts +0 -510
- package/src/app/middleware/cluster_app_mock.ts +0 -102
- package/src/app.ts +0 -18
- package/src/bootstrap.ts +0 -25
- package/src/index.ts +0 -112
- package/src/lib/agent_handler.ts +0 -28
- package/src/lib/app.ts +0 -314
- package/src/lib/app_handler.ts +0 -77
- package/src/lib/cluster.ts +0 -363
- package/src/lib/context.ts +0 -14
- package/src/lib/format_options.ts +0 -103
- package/src/lib/inject_context.ts +0 -134
- package/src/lib/mock_agent.ts +0 -57
- package/src/lib/mock_custom_loader.ts +0 -36
- package/src/lib/mock_http_server.ts +0 -19
- package/src/lib/mock_httpclient.ts +0 -183
- package/src/lib/parallel/agent.ts +0 -128
- package/src/lib/parallel/app.ts +0 -123
- package/src/lib/parallel/util.ts +0 -66
- package/src/lib/prerequire.ts +0 -25
- package/src/lib/request_call_function.ts +0 -49
- package/src/lib/restore.ts +0 -14
- package/src/lib/start-cluster.ts +0 -23
- package/src/lib/supertest.ts +0 -45
- package/src/lib/tmp/.gitkeep +0 -0
- package/src/lib/tmp/empty.ts +0 -0
- package/src/lib/utils.ts +0 -82
- package/src/register.ts +0 -80
- package/src/typings/index.d.ts +0 -4
|
@@ -0,0 +1,24 @@
|
|
|
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 };
|
package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/buffered-worker-pool.js
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
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 };
|
|
@@ -0,0 +1,74 @@
|
|
|
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 };
|
|
@@ -0,0 +1,22 @@
|
|
|
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 };
|
|
@@ -0,0 +1,329 @@
|
|
|
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 };
|