mootant 0.2.0 → 0.3.0

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 (313) hide show
  1. package/bin/mootant.js +3 -2
  2. package/dist/adapters/jest/collect-jest-dependencies.d.ts +8 -6
  3. package/dist/adapters/jest/collect-jest-dependencies.js +20 -14
  4. package/dist/adapters/jest/get-jest-cache-inputs.d.ts +14 -13
  5. package/dist/adapters/jest/index.d.ts +3 -1
  6. package/dist/adapters/jest/run-dry.js +20 -20
  7. package/dist/adapters/jest/start-jest-session.d.ts +6 -2
  8. package/dist/adapters/jest/start-jest-session.js +9 -2
  9. package/dist/adapters/jest/types/jest-handle.d.ts +2 -1
  10. package/dist/adapters/jest/types/jest-record.d.ts +4 -3
  11. package/dist/adapters/jest/types/worker-channel.d.ts +7 -0
  12. package/dist/adapters/jest/worker/boot-worker.d.ts +5 -4
  13. package/dist/adapters/jest/worker/create-test-runner.d.ts +4 -1
  14. package/dist/adapters/jest/worker/keep-reset-loads.d.ts +13 -0
  15. package/dist/adapters/jest/worker/list-runtime-files.d.ts +13 -0
  16. package/dist/adapters/jest/worker/run-unit.d.ts +25 -20
  17. package/dist/adapters/jest/worker/vm-setup.js +1 -1
  18. package/dist/adapters/jest/worker/worker.js +1 -1
  19. package/dist/adapters/node-test/check-typescript.js +2 -2
  20. package/dist/adapters/node-test/collect-node-dependencies.d.ts +7 -5
  21. package/dist/adapters/node-test/collect-node-dependencies.js +26 -20
  22. package/dist/adapters/node-test/create-spare-processes.d.ts +26 -0
  23. package/dist/adapters/node-test/create-spare-processes.js +53 -0
  24. package/dist/adapters/node-test/filter-exec-argv.d.ts +2 -1
  25. package/dist/adapters/node-test/filter-exec-argv.js +13 -12
  26. package/dist/adapters/node-test/get-node-cache-inputs.js +1 -1
  27. package/dist/adapters/node-test/get-unit-deadline.d.ts +6 -5
  28. package/dist/adapters/node-test/index.d.ts +2 -2
  29. package/dist/adapters/node-test/index.js +1 -0
  30. package/dist/adapters/node-test/is-group-alive.d.ts +8 -0
  31. package/dist/adapters/node-test/is-group-alive.js +8 -0
  32. package/dist/adapters/node-test/list-setup-files.js +2 -2
  33. package/dist/adapters/node-test/place-preload.d.ts +2 -1
  34. package/dist/adapters/node-test/place-preload.js +24 -18
  35. package/dist/adapters/node-test/preload/create-commonjs-route.js +1 -1
  36. package/dist/adapters/node-test/preload/preload.js +54 -52
  37. package/dist/adapters/node-test/preload/read-line-sync.d.ts +11 -0
  38. package/dist/adapters/node-test/preload/read-line-sync.js +25 -0
  39. package/dist/adapters/node-test/preload/read-unit.d.ts +11 -5
  40. package/dist/adapters/node-test/preload/read-unit.js +5 -4
  41. package/dist/adapters/node-test/run-isolated.d.ts +19 -10
  42. package/dist/adapters/node-test/run-isolated.js +68 -52
  43. package/dist/adapters/node-test/run-test-file.d.ts +12 -4
  44. package/dist/adapters/node-test/run-test-file.js +18 -14
  45. package/dist/adapters/node-test/run-test-process.d.ts +30 -13
  46. package/dist/adapters/node-test/run-test-process.js +38 -40
  47. package/dist/adapters/node-test/start-node-test-session.d.ts +10 -2
  48. package/dist/adapters/node-test/start-node-test-session.js +90 -84
  49. package/dist/adapters/node-test/start-test-process.d.ts +30 -0
  50. package/dist/adapters/node-test/start-test-process.js +27 -0
  51. package/dist/adapters/node-test/types/node-test-handle.d.ts +14 -1
  52. package/dist/adapters/node-test/types/process-watch.d.ts +4 -3
  53. package/dist/adapters/node-test/types/spare-processes.d.ts +20 -0
  54. package/dist/adapters/node-test/types/test-process-outcome.d.ts +8 -1
  55. package/dist/adapters/shared/allows-spares.d.ts +11 -0
  56. package/dist/adapters/shared/allows-spares.js +23 -0
  57. package/dist/adapters/shared/create-environment-proxy.d.ts +4 -3
  58. package/dist/adapters/shared/create-input-filter.d.ts +17 -14
  59. package/dist/adapters/shared/create-input-filter.js +2 -2
  60. package/dist/adapters/shared/enable-compile-cache.d.ts +32 -0
  61. package/dist/adapters/shared/enable-compile-cache.js +7 -0
  62. package/dist/adapters/shared/find-tsconfig-property.d.ts +13 -0
  63. package/dist/adapters/shared/find-tsconfig-property.js +6 -0
  64. package/dist/adapters/shared/get-spare-limit.d.ts +10 -0
  65. package/dist/adapters/shared/get-spare-limit.js +5 -0
  66. package/dist/adapters/shared/index-environment-hashes.d.ts +2 -2
  67. package/dist/adapters/shared/index-environment-hashes.js +5 -13
  68. package/dist/adapters/{node-test → shared}/list-flag-values.d.ts +2 -1
  69. package/dist/adapters/shared/list-flag-values.js +10 -0
  70. package/dist/adapters/shared/list-tsconfig-files.d.ts +14 -5
  71. package/dist/adapters/shared/list-tsconfig-files.js +15 -13
  72. package/dist/adapters/shared/parse-tsconfig.d.ts +10 -0
  73. package/dist/adapters/shared/parse-tsconfig.js +19 -0
  74. package/dist/adapters/shared/read-flag-name.d.ts +9 -0
  75. package/dist/adapters/shared/read-flag-name.js +5 -0
  76. package/dist/adapters/shared/read-node-options.d.ts +11 -0
  77. package/dist/adapters/shared/read-node-options.js +6 -0
  78. package/dist/adapters/shared/read-prefork-switch.d.ts +10 -0
  79. package/dist/adapters/shared/read-prefork-switch.js +5 -0
  80. package/dist/adapters/shared/read-tsconfig-extends.d.ts +2 -5
  81. package/dist/adapters/shared/read-tsconfig-extends.js +16 -31
  82. package/dist/adapters/shared/read-tsconfig-references.d.ts +12 -0
  83. package/dist/adapters/shared/read-tsconfig-references.js +13 -0
  84. package/dist/adapters/shared/track-file-reads.d.ts +13 -12
  85. package/dist/adapters/shared/track-file-reads.js +71 -71
  86. package/dist/adapters/shared/track-process-group.d.ts +2 -1
  87. package/dist/adapters/shared/track-process-group.js +7 -2
  88. package/dist/adapters/vitest/build-isolated-facts.d.ts +4 -3
  89. package/dist/adapters/vitest/collect-dependencies.d.ts +11 -5
  90. package/dist/adapters/vitest/collect-dependencies.js +36 -27
  91. package/dist/adapters/vitest/configure-project.d.ts +3 -2
  92. package/dist/adapters/vitest/configure-project.js +1 -1
  93. package/dist/adapters/vitest/create-forks-pool.d.ts +34 -7
  94. package/dist/adapters/vitest/create-forks-pool.js +102 -24
  95. package/dist/adapters/vitest/create-interleaved-sequencer.d.ts +3 -2
  96. package/dist/adapters/vitest/drop-signal-listeners.d.ts +14 -0
  97. package/dist/adapters/vitest/drop-signal-listeners.js +15 -0
  98. package/dist/adapters/vitest/get-cache-inputs.d.ts +3 -1
  99. package/dist/adapters/vitest/get-cache-inputs.js +43 -28
  100. package/dist/adapters/vitest/get-module-file.d.ts +3 -5
  101. package/dist/adapters/vitest/get-module-file.js +1 -1
  102. package/dist/adapters/vitest/get-spare-key.d.ts +15 -0
  103. package/dist/adapters/vitest/get-spare-key.js +15 -0
  104. package/dist/adapters/vitest/index.d.ts +2 -1
  105. package/dist/adapters/vitest/index.js +1 -0
  106. package/dist/adapters/vitest/is-virtual-module.d.ts +1 -2
  107. package/dist/adapters/vitest/is-virtual-module.js +1 -1
  108. package/dist/adapters/vitest/list-script-defines.d.ts +13 -0
  109. package/dist/adapters/vitest/list-script-defines.js +22 -0
  110. package/dist/adapters/vitest/read-unit-inputs.d.ts +2 -1
  111. package/dist/adapters/vitest/run-dry.js +1 -1
  112. package/dist/adapters/vitest/run-plan.d.ts +10 -8
  113. package/dist/adapters/vitest/run-plan.js +1 -1
  114. package/dist/adapters/vitest/run-specifications.d.ts +9 -2
  115. package/dist/adapters/vitest/run-specifications.js +22 -12
  116. package/dist/adapters/vitest/runner.d.ts +60 -29
  117. package/dist/adapters/vitest/runner.js +109 -86
  118. package/dist/adapters/vitest/start-vitest-session.d.ts +5 -1
  119. package/dist/adapters/vitest/start-vitest-session.js +64 -59
  120. package/dist/adapters/vitest/stop-hung-worker.d.ts +11 -4
  121. package/dist/adapters/vitest/stop-hung-worker.js +20 -7
  122. package/dist/adapters/vitest/types/mootant-forks-pool.d.ts +47 -0
  123. package/dist/adapters/vitest/types/vitest-session-state.d.ts +9 -8
  124. package/dist/adapters/vitest/types/vitest-worker.d.ts +48 -33
  125. package/dist/adapters/vitest/wait-for-workers.d.ts +5 -2
  126. package/dist/adapters/vitest/wait-for-workers.js +15 -15
  127. package/dist/adapters/vitest/worker/track-meta-defines.d.ts +39 -0
  128. package/dist/adapters/vitest/worker/track-meta-defines.js +23 -0
  129. package/dist/adapters/vitest/worker/track-values.d.ts +38 -0
  130. package/dist/adapters/vitest/worker/track-values.js +45 -0
  131. package/dist/adapters/vitest/worker/value-prefixes.d.ts +12 -0
  132. package/dist/adapters/vitest/worker/value-prefixes.js +6 -0
  133. package/dist/adapters/vitest/worker/wait-for-turn.d.ts +8 -6
  134. package/dist/adapters/vitest/worker/watch-property.d.ts +17 -0
  135. package/dist/adapters/vitest/worker/watch-property.js +27 -0
  136. package/dist/cli/create-run-progress.d.ts +8 -1
  137. package/dist/cli/create-run-progress.js +4 -1
  138. package/dist/cli/ensure-exit.d.ts +11 -0
  139. package/dist/cli/ensure-exit.js +15 -0
  140. package/dist/cli/html/build-html-report.js +1 -0
  141. package/dist/cli/html/client/main.js +1 -1
  142. package/dist/cli/html/client/render-overview.d.ts +3 -3
  143. package/dist/cli/index.d.ts +1 -0
  144. package/dist/cli/index.js +3 -2
  145. package/dist/cli/parse-arguments.d.ts +4 -0
  146. package/dist/cli/parse-arguments.js +4 -1
  147. package/dist/cli/report/build-run-report.js +1 -0
  148. package/dist/cli/report/format-command.d.ts +5 -0
  149. package/dist/cli/report/format-command.js +1 -1
  150. package/dist/cli/report/format-run-text-report.d.ts +5 -4
  151. package/dist/cli/report/format-run-text-report.js +10 -10
  152. package/dist/cli/report/slim-run-report.d.ts +10 -10
  153. package/dist/cli/report/slim-run-report.js +1 -0
  154. package/dist/cli/run-mutation.d.ts +5 -1
  155. package/dist/cli/run-mutation.js +32 -24
  156. package/dist/cli/terminal/create-spinner.d.ts +1 -2
  157. package/dist/cli/terminal/create-spinner.js +23 -32
  158. package/dist/cli/watch-interrupts.d.ts +41 -0
  159. package/dist/cli/watch-interrupts.js +32 -0
  160. package/dist/core/cache/apply-cached-units.d.ts +8 -7
  161. package/dist/core/cache/build-hash.d.ts +9 -0
  162. package/dist/core/cache/build-hash.js +2 -0
  163. package/dist/core/cache/cache-version.d.ts +4 -4
  164. package/dist/core/cache/check-dry-snapshot.d.ts +25 -0
  165. package/dist/core/cache/check-dry-snapshot.js +13 -0
  166. package/dist/core/cache/create-dry-reuse-miss.d.ts +12 -0
  167. package/dist/core/cache/create-dry-reuse-miss.js +7 -0
  168. package/dist/core/cache/create-dry-snapshot.d.ts +71 -0
  169. package/dist/core/cache/create-dry-snapshot.js +27 -0
  170. package/dist/core/cache/create-run-cache.d.ts +20 -2
  171. package/dist/core/cache/create-run-cache.js +31 -22
  172. package/dist/core/cache/create-snapshot-session.d.ts +12 -0
  173. package/dist/core/cache/create-snapshot-session.js +19 -0
  174. package/dist/core/cache/get-build-id.d.ts +11 -0
  175. package/dist/core/cache/get-build-id.js +7 -0
  176. package/dist/core/cache/get-cache-path.d.ts +1 -1
  177. package/dist/core/cache/get-cache-path.js +1 -1
  178. package/dist/core/cache/get-dry-snapshot-key.d.ts +47 -0
  179. package/dist/core/cache/get-dry-snapshot-key.js +43 -0
  180. package/dist/core/cache/get-dry-snapshot-path.d.ts +9 -0
  181. package/dist/core/cache/get-dry-snapshot-path.js +5 -0
  182. package/dist/core/cache/get-environment-key.d.ts +9 -4
  183. package/dist/core/cache/get-environment-key.js +3 -2
  184. package/dist/core/cache/get-test-file-keys.d.ts +2 -1
  185. package/dist/core/cache/get-test-file-keys.js +11 -10
  186. package/dist/core/cache/hash-files.d.ts +8 -7
  187. package/dist/core/cache/hash-files.js +17 -11
  188. package/dist/core/cache/hash-project-tree.d.ts +22 -0
  189. package/dist/core/cache/hash-project-tree.js +69 -0
  190. package/dist/core/cache/is-dry-reuse-miss.d.ts +8 -0
  191. package/dist/core/cache/is-dry-reuse-miss.js +4 -0
  192. package/dist/core/cache/list-file-hashes.d.ts +4 -0
  193. package/dist/core/cache/list-file-hashes.js +5 -2
  194. package/dist/core/cache/list-install-states.d.ts +12 -0
  195. package/dist/core/cache/list-install-states.js +19 -0
  196. package/dist/core/cache/list-variable-hashes.d.ts +15 -0
  197. package/dist/core/cache/list-variable-hashes.js +14 -0
  198. package/dist/core/cache/prepare-run-cache.d.ts +48 -22
  199. package/dist/core/cache/prepare-run-cache.js +86 -73
  200. package/dist/core/cache/read-dry-snapshot.d.ts +10 -0
  201. package/dist/core/cache/read-dry-snapshot.js +15 -0
  202. package/dist/core/cache/read-run-cache.js +6 -2
  203. package/dist/core/cache/save-dry-snapshot.d.ts +34 -0
  204. package/dist/core/cache/save-dry-snapshot.js +32 -0
  205. package/dist/core/cache/volatile-variables.d.ts +7 -0
  206. package/dist/core/cache/volatile-variables.js +11 -0
  207. package/dist/core/cache/write-run-cache.js +1 -1
  208. package/dist/core/config/load-typescript-config.d.ts +6 -1
  209. package/dist/core/config/load-typescript-config.js +26 -10
  210. package/dist/core/config/prepare-run.d.ts +7 -3
  211. package/dist/core/config/prepare-run.js +1 -0
  212. package/dist/core/config/resolve-run-settings.d.ts +3 -2
  213. package/dist/core/config/resolve-run-settings.js +1 -0
  214. package/dist/core/config/validate-config.js +3 -2
  215. package/dist/core/files/get-package-manifest.d.ts +12 -0
  216. package/dist/core/files/get-package-manifest.js +7 -0
  217. package/dist/core/generate/collect-candidates.d.ts +5 -1
  218. package/dist/core/generate/collect-candidates.js +125 -97
  219. package/dist/core/generate/generate-file-mutants.js +6 -5
  220. package/dist/core/index.d.ts +18 -0
  221. package/dist/core/mutators/shared/get-branch-copy-skip.d.ts +2 -2
  222. package/dist/core/mutators/shared/get-comparison-plan.d.ts +2 -2
  223. package/dist/core/mutators/shared/get-default-option-skip.d.ts +2 -2
  224. package/dist/core/mutators/shared/get-group-constant.d.ts +2 -2
  225. package/dist/core/mutators/shared/get-literal-skip.d.ts +3 -3
  226. package/dist/core/mutators/shared/get-loop-running-skip.d.ts +2 -2
  227. package/dist/core/mutators/shared/get-nullish-swap-skip.d.ts +2 -2
  228. package/dist/core/mutators/shared/get-or-default-skip.d.ts +2 -2
  229. package/dist/core/mutators/shared/get-owned-constants.d.ts +2 -2
  230. package/dist/core/mutators/shared/leave-now-skip.d.ts +2 -2
  231. package/dist/core/mutators/shared/no-op-callback-skip.d.ts +2 -2
  232. package/dist/core/plugins/create-mutator-registry.d.ts +4 -2
  233. package/dist/core/plugins/create-mutator-registry.js +15 -5
  234. package/dist/core/plugins/validate-plugin.d.ts +3 -3
  235. package/dist/core/plugins/validate-plugin.js +32 -10
  236. package/dist/core/regex/collect-pattern-changes.d.ts +2 -2
  237. package/dist/core/regex/create-regex-replacement.d.ts +2 -2
  238. package/dist/core/run/apply-isolated-result.d.ts +22 -14
  239. package/dist/core/run/apply-isolated-result.js +45 -26
  240. package/dist/core/run/count-run.d.ts +2 -1
  241. package/dist/core/run/create-run-state.d.ts +5 -0
  242. package/dist/core/run/create-run-state.js +1 -0
  243. package/dist/core/run/create-work-directory.d.ts +4 -1
  244. package/dist/core/run/create-work-directory.js +15 -12
  245. package/dist/core/run/decide-evidence.d.ts +4 -3
  246. package/dist/core/run/get-unit-evidence.d.ts +13 -7
  247. package/dist/core/run/get-unit-evidence.js +1 -1
  248. package/dist/core/run/guard-session.d.ts +18 -0
  249. package/dist/core/run/guard-session.js +30 -0
  250. package/dist/core/run/live-work-directories.d.ts +5 -0
  251. package/dist/core/run/live-work-directories.js +2 -0
  252. package/dist/core/run/read-isolated-unit.d.ts +6 -3
  253. package/dist/core/run/read-isolated-unit.js +77 -38
  254. package/dist/core/run/remove-live-work-directories.d.ts +7 -0
  255. package/dist/core/run/remove-live-work-directories.js +12 -0
  256. package/dist/core/run/run-isolated-rounds.d.ts +16 -12
  257. package/dist/core/run/run-isolated-rounds.js +3 -2
  258. package/dist/core/run/validate-adapter.d.ts +1 -1
  259. package/dist/core/run/validate-adapter.js +1 -1
  260. package/dist/core/run-mutants.d.ts +34 -2
  261. package/dist/core/run-mutants.js +356 -216
  262. package/dist/core/skips/skip-rules.d.ts +3 -1
  263. package/dist/package.js +1 -1
  264. package/dist/types/adapter/adapter-context.d.ts +20 -0
  265. package/dist/types/adapter/adapter-session.d.ts +2 -1
  266. package/dist/types/adapter/cache-inputs.d.ts +3 -2
  267. package/dist/types/adapter/dry-file.d.ts +4 -2
  268. package/dist/types/adapter/isolated-plan.d.ts +2 -1
  269. package/dist/types/adapter/isolated-result.d.ts +3 -1
  270. package/dist/types/adapter/run-inputs.d.ts +5 -4
  271. package/dist/types/adapter/test-adapter.d.ts +7 -0
  272. package/dist/types/cache/cache-entry.d.ts +9 -7
  273. package/dist/types/cache/cached-inputs.d.ts +2 -2
  274. package/dist/types/cache/dry-snapshot.d.ts +76 -0
  275. package/dist/types/cache/project-tree.d.ts +16 -0
  276. package/dist/types/cache/run-cache-file.d.ts +1 -1
  277. package/dist/types/cache/run-cache.d.ts +6 -5
  278. package/dist/types/config/plugin.d.ts +11 -2
  279. package/dist/types/config/run-config.d.ts +10 -0
  280. package/dist/types/config/run-settings.d.ts +6 -0
  281. package/dist/types/mutant/core-note.d.ts +12 -0
  282. package/dist/types/mutant/diagnostic.d.ts +1 -0
  283. package/dist/types/mutant/registered-skip-rule.d.ts +11 -0
  284. package/dist/types/mutant/skip-note.d.ts +7 -6
  285. package/dist/types/mutant/skip-rule-id.d.ts +3 -2
  286. package/dist/types/mutant/skip-rule.d.ts +2 -1
  287. package/dist/types/mutant/skipped-candidate.d.ts +14 -7
  288. package/dist/types/mutant/skipped-mutant.d.ts +6 -6
  289. package/dist/types/mutator/mutator.d.ts +3 -2
  290. package/dist/types/mutator/registered-mutator.d.ts +8 -0
  291. package/dist/types/regex/regex-change.d.ts +2 -2
  292. package/dist/types/report/html-report.d.ts +3 -2
  293. package/dist/types/report/list-report-skipped.d.ts +3 -2
  294. package/dist/types/report/run-report.d.ts +11 -2
  295. package/dist/types/report/slim-run-report.d.ts +1 -1
  296. package/dist/types/run/isolated-evidence.d.ts +3 -2
  297. package/dist/types/run/isolated-reason.d.ts +2 -1
  298. package/dist/types/run/run-durations.d.ts +8 -3
  299. package/dist/types/run/run-event.d.ts +10 -7
  300. package/dist/types/run/run-result.d.ts +11 -2
  301. package/dist/types/run/run-state.d.ts +21 -0
  302. package/dist/types/run/try-cause.d.ts +2 -1
  303. package/package.json +1 -1
  304. package/readme.md +85 -68
  305. package/skills/mootant/SKILL.md +36 -19
  306. package/skills/mootant/references/mutators.md +29 -23
  307. package/dist/adapters/node-test/list-flag-values.js +0 -9
  308. /package/dist/adapters/{node-test → shared}/loader-flags.d.ts +0 -0
  309. /package/dist/adapters/{node-test → shared}/loader-flags.js +0 -0
  310. /package/dist/{adapters/shared → core/files}/list-package-files.d.ts +0 -0
  311. /package/dist/{adapters/shared → core/files}/list-package-files.js +0 -0
  312. /package/dist/{adapters/shared → core/files}/read-package-type.d.ts +0 -0
  313. /package/dist/{adapters/shared → core/files}/read-package-type.js +0 -0
@@ -1,56 +1,72 @@
1
1
  import { collectNodeDependencies as e } from "./collect-node-dependencies.js";
2
- import { writeSwitchPlan as t } from "../shared/write-switch-plan.js";
3
- import { buildIsolatedFacts as n } from "./build-isolated-facts.js";
4
- import { getUnitDeadline as r } from "./get-unit-deadline.js";
5
- import { checkTodoBail as i } from "./check-todo-bail.js";
6
- import { runInPool as a } from "../shared/run-in-pool.js";
7
- import { runTestFile as o } from "./run-test-file.js";
8
- import s from "node:path";
9
- async function c(c, l) {
10
- let { context: u, state: d } = c, f = d.plan ?? t(s.join(u.workDirectory, "switched"), u.files);
11
- d.plan = f;
12
- let p = {
2
+ import { createSpareProcesses as t } from "./create-spare-processes.js";
3
+ import { writeSwitchPlan as n } from "../shared/write-switch-plan.js";
4
+ import { buildIsolatedFacts as r } from "./build-isolated-facts.js";
5
+ import { getUnitDeadline as i } from "./get-unit-deadline.js";
6
+ import { checkTodoBail as a } from "./check-todo-bail.js";
7
+ import { runInPool as o } from "../shared/run-in-pool.js";
8
+ import { runTestFile as s } from "./run-test-file.js";
9
+ import c from "node:path";
10
+ async function l(l, u) {
11
+ let { context: d, state: f } = l, p = f.plan ?? n(c.join(d.workDirectory, "switched"), d.files);
12
+ f.plan = p;
13
+ let m = {
13
14
  tsconfigs: /* @__PURE__ */ new Map(),
14
15
  packages: /* @__PURE__ */ new Map()
15
- };
16
- return { units: await a(l.units.map((t, a) => ({
17
- run: async () => {
18
- let { mutant: s, limits: l, file: m } = t;
19
- function h(e) {
20
- return o(c, {
21
- deadline: (e) => r(e, l.timeout),
22
- expected: d.expected.get(m) ?? [],
23
- hitLimit: l.hitLimit,
24
- mode: "isolated",
25
- plan: f,
26
- mutant: s,
27
- bail: e,
28
- file: m
29
- });
30
- }
31
- let g = await h(d.todo.get(m) !== !0);
32
- i(g.records) && (g = await h(!1));
33
- let _ = n(g, {
34
- root: u.root,
35
- unit: a,
36
- mutant: s,
37
- file: m
38
- }), v = g.records.find((e) => e.kind === "end");
39
- return _.inputs = v === void 0 ? null : {
40
- dependencies: e({
41
- records: g.records,
42
- preload: c.preload,
43
- tsx: c.tsx,
44
- cache: p,
45
- file: m
46
- }),
47
- environment: v.environment
48
- }, u.onUnitEnd?.({
49
- unit: a,
50
- facts: _
51
- }), _;
52
- },
53
- key: t.file
54
- })), c.workers) };
16
+ }, h = u.units.map((e, t) => d.parallelUnits === !0 ? String(t) : e.file), g = {
17
+ files: /* @__PURE__ */ new Set(),
18
+ jobs: 0
19
+ }, _ = t(l, u.units.map((e, t) => ({
20
+ key: h[t],
21
+ file: e.file
22
+ }))), v;
23
+ try {
24
+ v = await o(u.units.map((t, n) => ({
25
+ run: async () => {
26
+ let { mutant: o, limits: c, file: u } = t;
27
+ async function h(e, t) {
28
+ let n = await s(l, {
29
+ deadline: (e) => i(e, c.timeout),
30
+ expected: f.expected.get(u) ?? [],
31
+ ...t !== void 0 && { spare: t },
32
+ hitLimit: c.hitLimit,
33
+ mode: "isolated",
34
+ plan: p,
35
+ mutant: o,
36
+ bail: e,
37
+ file: u
38
+ });
39
+ return n.lingering ? (g.files.add(u), g.jobs += 1) : g.files.delete(u), n;
40
+ }
41
+ let v = f.todo.get(u) !== !0, y = g.jobs > 0 || g.files.has(u);
42
+ g.jobs = Math.max(0, g.jobs - 1);
43
+ let b = _.take(n, y) ?? void 0, x = await h(v, b);
44
+ b !== void 0 && x.records.every((e) => e.kind !== "start") && (x = await h(v)), a(x.records) && (x = await h(!1));
45
+ let S = r(x, {
46
+ root: d.root,
47
+ unit: n,
48
+ mutant: o,
49
+ file: u
50
+ }), C = x.records.find((e) => e.kind === "end");
51
+ return S.inputs = C === void 0 ? null : {
52
+ dependencies: e({
53
+ records: x.records,
54
+ preload: l.preload,
55
+ tsx: l.tsx,
56
+ cache: m,
57
+ file: u
58
+ }),
59
+ environment: C.environment
60
+ }, d.onUnitEnd?.({
61
+ unit: n,
62
+ facts: S
63
+ }), S;
64
+ },
65
+ key: h[n]
66
+ })), l.workers);
67
+ } finally {
68
+ _.stop();
69
+ }
70
+ return { units: v };
55
71
  }
56
- export { c as runIsolated };
72
+ export { l as runIsolated };
@@ -1,3 +1,4 @@
1
+ import { ChildProcess } from 'node:child_process';
1
2
  import { TestProcessOutcome } from './types/test-process-outcome.js';
2
3
  import { NodeTestHandle } from './types/node-test-handle.js';
3
4
  import { NodeTestUnit } from './types/node-test-unit.js';
@@ -5,18 +6,25 @@ import { ProcessWatch } from './types/process-watch.js';
5
6
  /**
6
7
  * Runs one test file in a test process of the session (`runTestProcess`):
7
8
  * mootant's preload and the project's flags, then the test file, in the project
8
- * root, with the unit in `MOOTANT_UNIT` and an out file of its own in the work
9
- * directory, removed once read. What the process writes goes to the context's
10
- * `onOutput` with the test file.
9
+ * root, with an out file of its own in the work directory, removed once read.
10
+ * The process gets its unit as a line on file descriptor 3, or, where the
11
+ * session sends none that way (`NodeTestHandle.pipe`), in `MOOTANT_UNIT`; a
12
+ * spare process of the test file, started before, may run it instead. What the
13
+ * process writes goes to the context's `onOutput` with the test file. Once the
14
+ * run is interrupted (`AdapterContext.signal`), no process starts.
11
15
  *
12
16
  * @param handle - Live session.
13
- * @param input - Test file, what the process runs and its deadline.
17
+ * @param input - Test file, what the process runs, its deadline and a spare
18
+ * process, if any.
14
19
  * @param input.file - Real absolute path of the test file.
15
20
  * @param input.deadline - Deadline of the watchdog from what is known of the
16
21
  * process.
22
+ * @param input.spare - Spare process of the test file to run in, if any.
17
23
  * @returns What the process left behind.
24
+ * @throws The reason of the context's signal once it aborted.
18
25
  */
19
26
  export declare function runTestFile(handle: NodeTestHandle, input: {
20
27
  deadline(watch: ProcessWatch): number;
28
+ spare?: ChildProcess;
21
29
  file: string;
22
30
  } & Pick<NodeTestUnit, 'expected' | 'hitLimit' | 'mutant' | 'mode' | 'bail' | 'plan'>): Promise<TestProcessOutcome>;
@@ -2,35 +2,39 @@ import { runTestProcess as e } from "./run-test-process.js";
2
2
  import { mkdirSync as t, rmSync as n, writeFileSync as r } from "node:fs";
3
3
  import i from "node:path";
4
4
  async function a(a, o) {
5
- let { context: s, state: c } = a, { deadline: l, file: u, ...d } = o, f = i.join(s.workDirectory, "out");
6
- t(f, { recursive: !0 });
7
- let p = i.join(f, `${c.count}.jsonl`);
8
- c.count += 1, r(p, "");
9
- let m = {
10
- ...d,
5
+ let { context: s, state: c } = a;
6
+ s.signal?.throwIfAborted();
7
+ let { deadline: l, spare: u, file: d, ...f } = o, p = i.join(s.workDirectory, "out");
8
+ t(p, { recursive: !0 });
9
+ let m = i.join(p, `${c.count}.jsonl`);
10
+ c.count += 1, r(m, "");
11
+ let h = {
12
+ ...f,
11
13
  directory: s.workDirectory,
12
14
  commonjs: a.commonjs,
13
15
  root: s.root,
14
- out: p
15
- }, { onOutput: h } = s;
16
+ out: m
17
+ }, { onOutput: g } = s, _ = JSON.stringify(h);
16
18
  try {
17
19
  return await e({
18
- ...h !== void 0 && { onOutput: (e) => {
19
- h(e, u);
20
+ ...g !== void 0 && { onOutput: (e) => {
21
+ g(e, d);
20
22
  } },
23
+ ...a.pipe && { unit: _ },
24
+ ...u !== void 0 && { spare: u },
21
25
  env: {
22
26
  ...a.env,
23
- MOOTANT_UNIT: JSON.stringify(m)
27
+ ...a.pipe ? { MOOTANT_UNIT_FD: "3" } : { MOOTANT_UNIT: _ }
24
28
  },
25
- args: [...a.args, u],
29
+ args: [...a.args, d],
26
30
  groups: a.groups,
27
31
  node: a.node,
28
32
  cwd: s.root,
29
33
  deadline: l,
30
- out: p
34
+ out: m
31
35
  });
32
36
  } finally {
33
- n(p, { force: !0 });
37
+ n(m, { force: !0 });
34
38
  }
35
39
  }
36
40
  export { a as runTestFile };
@@ -1,3 +1,4 @@
1
+ import { ChildProcess } from 'node:child_process';
1
2
  import { TestProcessOutcome } from './types/test-process-outcome.js';
2
3
  import { ProcessWatch } from './types/process-watch.js';
3
4
  /**
@@ -18,6 +19,11 @@ interface TestProcessOptions {
18
19
  * Environment variables of the process.
19
20
  */
20
21
  env: NodeJS.ProcessEnv;
22
+ /**
23
+ * Spare process of the test file, started with file descriptor 3, to run
24
+ * instead of a new one.
25
+ */
26
+ spare?: ChildProcess;
21
27
  /**
22
28
  * Process groups of the session's test processes that run, which holds this
23
29
  * one's while it runs.
@@ -27,6 +33,11 @@ interface TestProcessOptions {
27
33
  * Arguments after the Node binary.
28
34
  */
29
35
  args: string[];
36
+ /**
37
+ * The unit as JSON, sent on file descriptor 3 of the process; without it the
38
+ * environment carries the unit, and the process gets no descriptor 3.
39
+ */
40
+ unit?: string;
30
41
  /**
31
42
  * Node binary.
32
43
  */
@@ -43,20 +54,26 @@ interface TestProcessOptions {
43
54
  }
44
55
  /**
45
56
  * Runs one test process and collects the records it appends to its out file.
46
- * The process starts detached, as the leader of a process group, without stdin.
47
- * The out file is read every 50 ms; when the time passes the deadline the
48
- * options compute from the records so far, the watchdog stops the whole process
49
- * group (`stopProcessGroup`). Once the process exits, what is left of its group
50
- * is stopped too, the deadline no longer applies, and the output gets 300 ms to
51
- * close before it is dropped, so a process the tests detached into a group of
52
- * its own cannot hold the outcome back. While the process runs, it is stopped
53
- * when mootant exits or gets SIGINT or SIGTERM (`trackProcessGroup`), and its
54
- * group is in `groups`, which the session stops when it closes. A line that is
55
- * not JSON, as the last line of a stopped process, is ignored.
57
+ * The process starts detached, as the leader of a process group, without stdin
58
+ * (`startTestProcess`), or a spare process of the test file, started before,
59
+ * runs instead. With a unit in the options, the process gets it as a line on
60
+ * file descriptor 3, which is closed after it. Either way the start time is
61
+ * now, so the deadline and the start-up of a spare count from the moment it got
62
+ * its unit. The out file is read every 50 ms; when the time passes the deadline
63
+ * the options compute from the records so far, the watchdog stops the whole
64
+ * process group (`stopProcessGroup`). Once the process exits, what is left of
65
+ * its group is stopped too, and the outcome tells whether anything was left or
66
+ * the watchdog stopped it (`lingering`); the deadline no longer applies, and
67
+ * the output gets 300 ms to close before it is dropped, so a process the tests
68
+ * detached into a group of its own cannot hold the outcome back. While the
69
+ * process runs, its group is in `groups`, which the session stops when it
70
+ * closes. A line that is not JSON, as the last line of a stopped process, is
71
+ * ignored.
56
72
  *
57
- * @param options - Binary, arguments, environment, out file and deadline.
58
- * @returns Records, exit code or signal, start time and whether the watchdog
59
- * stopped the process.
73
+ * @param options - Binary, arguments, environment, out file, deadline, the unit
74
+ * for file descriptor 3 and a spare process, if any.
75
+ * @returns Records, exit code or signal, start time, whether the watchdog
76
+ * stopped the process and whether its group outlived it.
60
77
  * @throws {Error} When the process cannot start.
61
78
  */
62
79
  export declare function runTestProcess(options: TestProcessOptions): Promise<TestProcessOutcome>;
@@ -1,18 +1,18 @@
1
- import { trackProcessGroup as e } from "../shared/track-process-group.js";
2
- import { stopProcessGroup as t } from "../shared/stop-process-group.js";
3
- import { closeSync as n, fstatSync as r, openSync as i, readSync as a } from "node:fs";
4
- import { spawn as o } from "node:child_process";
1
+ import { stopProcessGroup as e } from "../shared/stop-process-group.js";
2
+ import { startTestProcess as t } from "./start-test-process.js";
3
+ import { isGroupAlive as n } from "./is-group-alive.js";
4
+ import { closeSync as r, fstatSync as i, openSync as a, readSync as o } from "node:fs";
5
5
  function s(s) {
6
- let { onOutput: c } = s, l = [], u = i(s.out, "r"), d = 0, f = "", p = Date.now(), m = {
6
+ let { onOutput: c } = s, l = [], u = a(s.out, "r"), d = 0, f = "", p = Date.now(), m = {
7
7
  last: p,
8
8
  records: l,
9
9
  spawned: p
10
10
  }, h = !1;
11
11
  function g() {
12
- let { size: e } = r(u);
12
+ let { size: e } = i(u);
13
13
  if (e <= d) return;
14
14
  let t = Buffer.alloc(e - d);
15
- a(u, t, 0, t.length, d), d = e;
15
+ o(u, t, 0, t.length, d), d = e;
16
16
  let n = (f + t.toString("utf8")).split("\n");
17
17
  f = n.pop();
18
18
  for (let e of n) try {
@@ -20,50 +20,48 @@ function s(s) {
20
20
  } catch {}
21
21
  m.last = Date.now();
22
22
  }
23
- let _ = c === void 0 ? "ignore" : "pipe", v = o(s.node, s.args, {
24
- stdio: [
25
- "ignore",
26
- _,
27
- _
28
- ],
29
- windowsHide: !0,
23
+ let { unit: _ } = s, v = s.spare ?? t({
24
+ output: c === void 0 ? "ignore" : "pipe",
25
+ pipe: _ !== void 0,
26
+ groups: s.groups,
27
+ node: s.node,
28
+ args: s.args,
30
29
  cwd: s.cwd,
31
- env: s.env,
32
- detached: !0
30
+ env: s.env
33
31
  });
32
+ if (_ !== void 0 && v.pid !== void 0) {
33
+ let e = v.stdio[3];
34
+ e?.on("error", () => {}), e?.end(`${_}\n`);
35
+ }
34
36
  for (let e of [v.stdout, v.stderr]) e?.setEncoding("utf8"), e?.on("data", (e) => {
35
37
  c(e);
36
38
  });
37
- let y = v.pid === void 0 ? () => {} : e(v.pid);
38
- v.pid !== void 0 && s.groups.add(v.pid);
39
- let b = !1, x = setInterval(() => {
40
- g(), !h && !b && Date.now() > s.deadline(m) && (h = !0, t(v.pid));
41
- }, 50), S = !1;
42
- function C() {
43
- return !S && (S = !0, clearInterval(x), y(), s.groups.delete(v.pid), g(), n(u), !0);
39
+ let y = !1, b = setInterval(() => {
40
+ g(), !h && !y && Date.now() > s.deadline(m) && (h = !0, e(v.pid));
41
+ }, 50), x = !1;
42
+ function S() {
43
+ return !x && (x = !0, clearInterval(b), g(), r(u), !0);
44
44
  }
45
- return new Promise((e, n) => {
46
- v.on("error", (e) => {
47
- C(), n(e);
48
- }), v.on("exit", (n, r) => {
49
- b = !0, t(v.pid), setTimeout(() => {
50
- v.stdout?.destroy(), v.stderr?.destroy(), C() && e({
51
- spawned: p,
52
- records: l,
53
- signal: r,
54
- code: n,
55
- hung: h
56
- });
57
- }, 300);
58
- }), v.on("close", (t, n) => {
59
- C() && e({
45
+ let C = !1;
46
+ return new Promise((t, r) => {
47
+ function i(e, n) {
48
+ S() && t({
49
+ lingering: C,
60
50
  spawned: p,
61
51
  records: l,
62
52
  signal: n,
63
- code: t,
53
+ code: e,
64
54
  hung: h
65
55
  });
66
- });
56
+ }
57
+ v.on("error", (e) => {
58
+ S(), r(e);
59
+ }), v.on("exit", (t, r) => {
60
+ y = !0, C = h || n(v.pid), e(v.pid), setTimeout(() => {
61
+ for (let e of v.stdio) e?.destroy();
62
+ i(t, r);
63
+ }, 300);
64
+ }), v.on("close", i);
67
65
  });
68
66
  }
69
67
  export { s as runTestProcess };
@@ -13,8 +13,16 @@ import { AdapterContext } from '../../types/adapter/adapter-context.js';
13
13
  * modules the project loads first (`placePreload`), the filtered flags and the
14
14
  * extra flags of the options, mootant's reporter and the spec reporter, then
15
15
  * one test file, in the project root, with the variables of mootant's process,
16
- * the command and the options, and mootant's own `NODE_TEST_CONTEXT`. Closing
17
- * the session stops the test processes that still run.
16
+ * the command and the options, and mootant's own `NODE_TEST_CONTEXT`. A test
17
+ * process gets its unit through file descriptor 3, except on Windows, where it
18
+ * gets it in a variable. Isolated runs start spare test processes
19
+ * (`createSpareProcesses`), up to the cores the running units leave free
20
+ * (`getSpareLimit`), unless `MOOTANT_PREFORK=0` (`readPreforkSwitch`), Windows,
21
+ * a legacy loader, whose code runs before mootant's preload, or flags that load
22
+ * code from a file first or watch the process (`allowsSpares`) rule them out.
23
+ * Closing the session stops the test processes that still run, spares too, and
24
+ * so does an interrupt of the run (`AdapterContext.signal`), after which no
25
+ * test process starts.
18
26
  *
19
27
  * @param context - Switched files, work directory, concurrency and root.
20
28
  * @param options - Options of the adapter.
@@ -1,49 +1,53 @@
1
- import { stopProcessGroup as e } from "../shared/stop-process-group.js";
2
- import { getNodeCacheInputs as t } from "./get-node-cache-inputs.js";
3
- import { getDefaultPatterns as n } from "./get-default-patterns.js";
4
- import { listNodeTestFiles as r } from "./list-node-test-files.js";
5
- import { checkNodeSupport as i } from "./check-node-support.js";
6
- import { readNodeRuntime as a } from "./read-node-runtime.js";
7
- import { findTestCommand as o } from "./find-test-command.js";
8
- import { readTestTimeout as s } from "./read-test-timeout.js";
9
- import { checkTypeScript as c } from "./check-typescript.js";
10
- import { filterExecArgv as l } from "./filter-exec-argv.js";
11
- import { listFlagValues as u } from "./list-flag-values.js";
12
- import { listSetupFiles as d } from "./list-setup-files.js";
13
- import { getPreloadPath as f } from "./get-preload-path.js";
14
- import { placePreload as p } from "./place-preload.js";
15
- import { LOADER_FLAGS as m } from "./loader-flags.js";
16
- import { includesTsx as h } from "./includes-tsx.js";
17
- import { runIsolated as g } from "./run-isolated.js";
18
- import { resolveTsx as _ } from "./resolve-tsx.js";
19
- import { runDry as v } from "./run-dry.js";
20
- import y from "node:path";
21
- import { pathToFileURL as b } from "node:url";
22
- import { availableParallelism as x } from "node:os";
23
- const S = /* @__PURE__ */ new Set(["--experimental-loader", "--loader"]);
24
- async function C(C, w) {
25
- let { root: T } = C, E = w.node ?? process.execPath, D = await o(T, w.command), O = await a(E, C.workDirectory);
26
- if (!i(O.version)) throw Error(`mootant runs node:test on Node 20.19 or a later 20.x and on Node 22.12 or later, but ${E} is Node ${O.version}.`);
27
- let { diagnostics: k, execArgv: A } = l(D.flags);
28
- A.push(...w.execArgv ?? []);
29
- let j = A.includes("--experimental-strip-types") || A.includes("--experimental-transform-types") || O.typescript && !A.includes("--no-experimental-strip-types"), M = w.files ?? D.files, N = await r(T, M, n(D.tool, j));
30
- if (N.length === 0) {
31
- let e = M.length > 0 ? M.map((e) => `"${e}"`).join(", ") : "the default test file patterns";
1
+ import { readPreforkSwitch as e } from "../shared/read-prefork-switch.js";
2
+ import { stopProcessGroup as t } from "../shared/stop-process-group.js";
3
+ import { readNodeOptions as n } from "../shared/read-node-options.js";
4
+ import { getNodeCacheInputs as r } from "./get-node-cache-inputs.js";
5
+ import { getDefaultPatterns as ee } from "./get-default-patterns.js";
6
+ import { listFlagValues as i } from "../shared/list-flag-values.js";
7
+ import { listNodeTestFiles as a } from "./list-node-test-files.js";
8
+ import { getSpareLimit as o } from "../shared/get-spare-limit.js";
9
+ import { checkNodeSupport as s } from "./check-node-support.js";
10
+ import { allowsSpares as c } from "../shared/allows-spares.js";
11
+ import { readNodeRuntime as l } from "./read-node-runtime.js";
12
+ import { findTestCommand as u } from "./find-test-command.js";
13
+ import { readTestTimeout as d } from "./read-test-timeout.js";
14
+ import { LOADER_FLAGS as f } from "../shared/loader-flags.js";
15
+ import { checkTypeScript as p } from "./check-typescript.js";
16
+ import { filterExecArgv as m } from "./filter-exec-argv.js";
17
+ import { listSetupFiles as h } from "./list-setup-files.js";
18
+ import { getPreloadPath as g } from "./get-preload-path.js";
19
+ import { placePreload as _ } from "./place-preload.js";
20
+ import { includesTsx as v } from "./includes-tsx.js";
21
+ import { runIsolated as y } from "./run-isolated.js";
22
+ import { resolveTsx as b } from "./resolve-tsx.js";
23
+ import { runDry as x } from "./run-dry.js";
24
+ import S from "node:path";
25
+ import { pathToFileURL as C } from "node:url";
26
+ import { availableParallelism as w } from "node:os";
27
+ const T = /* @__PURE__ */ new Set(["--experimental-loader", "--loader"]);
28
+ async function E(E, D) {
29
+ let { root: O } = E, k = e(), A = D.node ?? process.execPath, j = await u(O, D.command), M = await l(A, E.workDirectory);
30
+ if (!s(M.version)) throw Error(`mootant runs node:test on Node 20.19 or a later 20.x and on Node 22.12 or later, but ${A} is Node ${M.version}.`);
31
+ let { diagnostics: N, execArgv: P } = m(j.flags);
32
+ P.push(...D.execArgv ?? []);
33
+ let F = P.includes("--experimental-strip-types") || P.includes("--experimental-transform-types") || M.typescript && !P.includes("--no-experimental-strip-types"), I = D.files ?? j.files, L = await a(O, I, ee(j.tool, F));
34
+ if (L.length === 0) {
35
+ let e = I.length > 0 ? I.map((e) => `"${e}"`).join(", ") : "the default test file patterns";
32
36
  throw Error(`No test files match ${e}; set nodeTestAdapter({ files }) or fix the test script.`);
33
37
  }
34
- if (D.tool === "bnt" && N.some((e) => e.endsWith(".ts"))) {
35
- let e = _(T);
36
- Number.parseInt(O.version.slice(1)) >= 22 ? (A.unshift("--disable-warning=ExperimentalWarning", "--experimental-strip-types"), j = !0) : e !== null && A.unshift("--enable-source-maps", "--import", e);
38
+ if (j.tool === "bnt" && L.some((e) => e.endsWith(".ts"))) {
39
+ let e = b(O);
40
+ Number.parseInt(M.version.slice(1)) >= 22 ? (P.unshift("--disable-warning=ExperimentalWarning", "--experimental-strip-types"), F = !0) : e !== null && P.unshift("--enable-source-maps", "--import", e);
37
41
  }
38
- let P = {
42
+ let R = {
39
43
  ...process.env,
44
+ ...j.env,
40
45
  ...D.env,
41
- ...w.env,
42
46
  NODE_TEST_CONTEXT: "mootant"
43
47
  };
44
- delete P.MOOTANT_UNIT;
45
- let F = [...(P.NODE_OPTIONS ?? "").split(/\s+/u).filter(Boolean), ...A], I = u(F, m);
46
- for (let e of u(F, S)) k.push({
48
+ delete R.MOOTANT_UNIT, delete R.MOOTANT_UNIT_FD;
49
+ let z = [...n(R.NODE_OPTIONS ?? ""), ...P], B = i(z, f), V = i(z, T);
50
+ for (let e of V) N.push({
47
51
  message: `The loader ${e} runs before mootant's module hooks, so mootant cannot switch the modules it changes.`,
48
52
  code: "config-overridden",
49
53
  severity: "warning",
@@ -51,35 +55,35 @@ async function C(C, w) {
51
55
  line: null,
52
56
  file: null
53
57
  });
54
- function L(e) {
55
- return c({
56
- version: O.version,
58
+ function H(e) {
59
+ return p({
60
+ version: M.version,
57
61
  files: e,
58
- loaders: I,
59
- strips: j,
60
- root: T
62
+ loaders: B,
63
+ strips: F,
64
+ root: O
61
65
  });
62
66
  }
63
- let R = L(N);
64
- if (R !== null) throw Error(R);
65
- let z = h(I), B = d(T, A), V = t({
67
+ let U = H(L);
68
+ if (U !== null) throw Error(U);
69
+ let W = v(B), G = h(O, P), K = r({
66
70
  set: {
67
- ...D.env,
68
- ...w.env
71
+ ...j.env,
72
+ ...D.env
69
73
  },
70
- version: O.version,
71
- env: P,
72
- execArgv: A,
73
- setup: B,
74
- root: T,
75
- tsx: z
76
- }), H = f(), U = p(H, A, P.NODE_OPTIONS ?? "");
77
- U.nodeOptions !== "" && (P.NODE_OPTIONS = U.nodeOptions);
78
- let W = y.join(y.dirname(H), `reporter${y.extname(H)}`), G = {
74
+ version: M.version,
75
+ env: R,
76
+ execArgv: P,
77
+ setup: G,
78
+ root: O,
79
+ tsx: W
80
+ }), q = g(), J = _(q, P, R.NODE_OPTIONS ?? "");
81
+ J.nodeOptions !== "" && (R.NODE_OPTIONS = J.nodeOptions);
82
+ let Y = Math.max(1, E.concurrency ?? w() - 1), X = process.platform !== "win32", Z = S.join(S.dirname(q), `reporter${S.extname(q)}`), Q = {
79
83
  args: [
80
- ...U.args,
84
+ ...J.args,
81
85
  "--test-reporter",
82
- b(W).href,
86
+ C(Z).href,
83
87
  "--test-reporter-destination",
84
88
  "stderr",
85
89
  "--test-reporter",
@@ -94,31 +98,33 @@ async function C(C, w) {
94
98
  plan: null,
95
99
  count: 0
96
100
  },
97
- workers: Math.max(1, C.concurrency ?? x() - 1),
98
- testTimeout: s(A),
99
- commonjs: !O.compiles,
100
- checkTypeScript: L,
101
+ spares: X && k && V.length === 0 && c(z) ? o(Y) : 0,
102
+ testTimeout: d(P),
103
+ commonjs: !M.compiles,
104
+ checkTypeScript: H,
101
105
  groups: /* @__PURE__ */ new Set(),
102
- env: P,
103
- preload: H,
104
- context: C,
105
- files: N,
106
- node: E,
107
- tsx: z
106
+ env: R,
107
+ workers: Y,
108
+ preload: q,
109
+ context: E,
110
+ files: L,
111
+ pipe: X,
112
+ node: A,
113
+ tsx: W
108
114
  };
109
- return {
110
- close: () => {
111
- for (let t of G.groups) e(t);
112
- return G.groups.clear(), Promise.resolve();
113
- },
115
+ function $() {
116
+ for (let e of Q.groups) t(e);
117
+ }
118
+ return E.signal?.addEventListener("abort", $, { once: !0 }), {
119
+ close: () => ($(), Q.groups.clear(), Promise.resolve()),
114
120
  runBatch: () => Promise.reject(/* @__PURE__ */ Error("The node-test adapter has no batch mode.")),
115
- listTestFiles: () => Promise.resolve([...N, ...B]),
116
- runIsolated: (e) => g(G, e),
117
- cacheInputs: () => Promise.resolve(V),
118
- dryRun: (e) => v(G, e),
119
- version: O.version.slice(1),
120
- workers: G.workers,
121
- diagnostics: k
121
+ listTestFiles: () => Promise.resolve([...L, ...G]),
122
+ runIsolated: (e) => y(Q, e),
123
+ cacheInputs: () => Promise.resolve(K),
124
+ dryRun: (e) => x(Q, e),
125
+ version: M.version.slice(1),
126
+ workers: Q.workers,
127
+ diagnostics: N
122
128
  };
123
129
  }
124
- export { C as startNodeTestSession };
130
+ export { E as startNodeTestSession };