版博士V2.0程序
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. import { fileURLToPath } from 'url';
  2. import c from 'picocolors';
  3. import { e as execa } from './vendor-index.2cbcdd1e.js';
  4. import { E as EXIT_CODE_RESTART } from './chunk-constants.bc18a549.js';
  5. import 'node:buffer';
  6. import 'node:path';
  7. import 'node:child_process';
  8. import 'node:process';
  9. import 'child_process';
  10. import 'path';
  11. import './vendor-_commonjsHelpers.addc3445.js';
  12. import 'fs';
  13. import 'node:url';
  14. import 'node:os';
  15. import 'assert';
  16. import 'events';
  17. import 'buffer';
  18. import 'stream';
  19. import 'util';
  20. const ENTRY = new URL("./cli.js", import.meta.url);
  21. const NODE_ARGS = [
  22. "--trace-deprecation",
  23. "--experimental-wasm-threads",
  24. "--wasm-atomics-on-non-shared-memory"
  25. ];
  26. const SegfaultErrors = [
  27. {
  28. trigger: "Check failed: result.second.",
  29. url: "https://github.com/nodejs/node/issues/43617"
  30. },
  31. {
  32. trigger: "FATAL ERROR: v8::FromJust Maybe value is Nothing.",
  33. url: "https://github.com/vitest-dev/vitest/issues/1191"
  34. },
  35. {
  36. trigger: "FATAL ERROR: v8::ToLocalChecked Empty MaybeLocal.",
  37. url: "https://github.com/nodejs/node/issues/42407"
  38. }
  39. ];
  40. main();
  41. async function main() {
  42. var _a;
  43. let retries = 0;
  44. const args = process.argv.slice(2);
  45. if (process.env.VITEST_SEGFAULT_RETRY) {
  46. retries = +process.env.VITEST_SEGFAULT_RETRY;
  47. } else {
  48. for (let i = 0; i < args.length; i++) {
  49. if (args[i].startsWith("--segfault-retry=") || args[i].startsWith("--segfaultRetry=")) {
  50. retries = +args[i].split("=")[1];
  51. break;
  52. } else if ((args[i] === "--segfault-retry" || args[i] === "--segfaultRetry") && ((_a = args[i + 1]) == null ? void 0 : _a.match(/^\d+$/))) {
  53. retries = +args[i + 1];
  54. break;
  55. }
  56. }
  57. }
  58. if (retries <= 0) {
  59. await import('./cli.js');
  60. return;
  61. }
  62. const nodeArgs = [];
  63. const vitestArgs = [];
  64. for (let i = 0; i < args.length; i++) {
  65. let matched = false;
  66. for (const nodeArg of NODE_ARGS) {
  67. if (args[i] === nodeArg || args[i].startsWith(`${nodeArg}=`)) {
  68. matched = true;
  69. nodeArgs.push(args[i]);
  70. break;
  71. }
  72. }
  73. if (!matched)
  74. vitestArgs.push(args[i]);
  75. }
  76. retries = Math.max(1, retries || 1);
  77. for (let i = 1; i <= retries; i++) {
  78. const result = await start(nodeArgs, vitestArgs);
  79. if (result === "restart") {
  80. i -= 1;
  81. continue;
  82. }
  83. if (i === 1 && retries === 1) {
  84. console.log(c.yellow(`It seems to be an upstream bug of Node.js. To improve the test stability,
  85. you could pass ${c.bold(c.green("--segfault-retry=3"))} or set env ${c.bold(c.green("VITEST_SEGFAULT_RETRY=3"))} to
  86. have Vitest auto retries on flaky segfaults.
  87. `));
  88. }
  89. if (i !== retries)
  90. console.log(`${c.inverse(c.bold(c.magenta(" Retrying ")))} vitest ${args.join(" ")} ${c.gray(`(${i + 1} of ${retries})`)}`);
  91. }
  92. process.exit(1);
  93. }
  94. async function start(preArgs, postArgs) {
  95. var _a;
  96. const child = execa(
  97. "node",
  98. [
  99. ...preArgs,
  100. fileURLToPath(ENTRY),
  101. ...postArgs
  102. ],
  103. {
  104. reject: false,
  105. stderr: "pipe",
  106. stdout: "inherit",
  107. stdin: "inherit",
  108. env: {
  109. ...process.env,
  110. VITEST_CLI_WRAPPER: "true"
  111. }
  112. }
  113. );
  114. (_a = child.stderr) == null ? void 0 : _a.pipe(process.stderr);
  115. const { stderr = "" } = await child;
  116. if (child.exitCode === EXIT_CODE_RESTART)
  117. return "restart";
  118. for (const error of SegfaultErrors) {
  119. if (stderr.includes(error.trigger)) {
  120. if (process.env.GITHUB_ACTIONS)
  121. console.log(`::warning:: Segmentfault Error Detected: ${error.trigger}
  122. Refer to ${error.url}`);
  123. const RED_BLOCK = c.inverse(c.red(" "));
  124. console.log(`
  125. ${c.inverse(c.bold(c.red(" Segmentfault Error Detected ")))}
  126. ${RED_BLOCK} ${c.red(error.trigger)}
  127. ${RED_BLOCK} ${c.red(`Refer to ${error.url}`)}
  128. `);
  129. return "error";
  130. }
  131. }
  132. process.exit(child.exitCode);
  133. }