版博士V2.0程序
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

1 год назад
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. import v8 from 'node:v8';
  2. import { c as createBirpc } from './vendor-index.783e7f3e.js';
  3. import { parseRegexp } from '@vitest/utils';
  4. import { s as startViteNode, m as moduleCache, a as mockMap } from './chunk-runtime-mocker.3283818a.js';
  5. import { a as rpcDone } from './chunk-runtime-rpc.d6aa57f8.js';
  6. import { s as setupInspect } from './chunk-runtime-inspector.b1427a10.js';
  7. import 'node:url';
  8. import 'vite-node/client';
  9. import 'vite-node/utils';
  10. import 'pathe';
  11. import './vendor-index.bdee400f.js';
  12. import 'acorn';
  13. import 'node:module';
  14. import 'node:fs';
  15. import 'node:assert';
  16. import 'node:process';
  17. import 'node:path';
  18. import 'node:util';
  19. import '@vitest/runner/utils';
  20. import './chunk-utils-global.fd174983.js';
  21. import './chunk-paths.e36446b4.js';
  22. import './chunk-utils-base.b5ddfcc9.js';
  23. import '@vitest/spy';
  24. import 'node:inspector';
  25. function init(ctx) {
  26. const { config } = ctx;
  27. process.env.VITEST_WORKER_ID = "1";
  28. process.env.VITEST_POOL_ID = "1";
  29. globalThis.__vitest_environment__ = config.environment;
  30. globalThis.__vitest_worker__ = {
  31. ctx,
  32. moduleCache,
  33. config,
  34. mockMap,
  35. rpc: createBirpc(
  36. {},
  37. {
  38. eventNames: ["onUserConsoleLog", "onFinished", "onCollected", "onWorkerExit"],
  39. serialize: v8.serialize,
  40. deserialize: (v) => v8.deserialize(Buffer.from(v)),
  41. post(v) {
  42. var _a;
  43. (_a = process.send) == null ? void 0 : _a.call(process, v);
  44. },
  45. on(fn) {
  46. process.on("message", fn);
  47. }
  48. }
  49. )
  50. };
  51. if (ctx.invalidates) {
  52. ctx.invalidates.forEach((fsPath) => {
  53. moduleCache.delete(fsPath);
  54. moduleCache.delete(`mock:${fsPath}`);
  55. });
  56. }
  57. ctx.files.forEach((i) => moduleCache.delete(i));
  58. }
  59. function parsePossibleRegexp(str) {
  60. const prefix = "$$vitest:";
  61. if (typeof str === "string" && str.startsWith(prefix))
  62. return parseRegexp(str.slice(prefix.length));
  63. return str;
  64. }
  65. function unwrapConfig(config) {
  66. if (config.testNamePattern)
  67. config.testNamePattern = parsePossibleRegexp(config.testNamePattern);
  68. return config;
  69. }
  70. async function run(ctx) {
  71. const inspectorCleanup = setupInspect(ctx.config);
  72. try {
  73. init(ctx);
  74. const { run: run2, executor } = await startViteNode(ctx);
  75. await run2(ctx.files, ctx.config, ctx.environment, executor);
  76. await rpcDone();
  77. } finally {
  78. inspectorCleanup();
  79. }
  80. }
  81. const procesExit = process.exit;
  82. process.on("message", async (message) => {
  83. if (typeof message === "object" && message.command === "start") {
  84. try {
  85. message.config = unwrapConfig(message.config);
  86. await run(message);
  87. } finally {
  88. procesExit();
  89. }
  90. }
  91. });
  92. export { run };