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
@@ -0,0 +1,13 @@
1
+ import { findTsconfigProperty as e } from "./find-tsconfig-property.js";
2
+ import { parseTsconfig as t } from "./parse-tsconfig.js";
3
+ import n from "node:path";
4
+ function r(r) {
5
+ let i = e(t(r), "references"), a = i?.type === "ArrayExpression" ? i.elements : [], o = n.dirname(r);
6
+ return a.flatMap((t) => {
7
+ let r = e(t, "path");
8
+ if (r?.type !== "Literal" || typeof r.value != "string") return [];
9
+ let i = n.resolve(o, r.value);
10
+ return [i.endsWith(".json") ? i : n.join(i, "tsconfig.json")];
11
+ });
12
+ }
13
+ export { r as readTsconfigReferences };
@@ -23,18 +23,19 @@ export interface FileAccessReceiver {
23
23
  * `open` reads unless its flags create, empty or append to the file, as `w`,
24
24
  * `a` or `O_CREAT` do; `r+` reads. The source of a copy, a move or a link is
25
25
  * read, and so is every file and directory in a directory `cp` copies, outside
26
- * `node_modules` and `.git`, whose copies it writes once it succeeded, unless a
27
- * `filter`, `force: false` or `verbatimSymlinks` may make a copy other than its
28
- * source (`listCopies`); `mkdir` writes only the directories that did not
29
- * exist. `mkdtemp` and `mkdtempDisposable` write the directory they made once
30
- * they give it. A recursive `readdir` or `opendir` reads the directory and
31
- * every directory in it, each listed by its own names, so adding a file
32
- * anywhere in the tree changes what was read; `readdir` also reads the
33
- * directories behind the links it follows. `glob` reads the same of the
34
- * directory where each pattern's fixed part ends. Calls of `node:fs` that a
35
- * wrapped function makes while it runs report nothing, and neither do those of
36
- * the asynchronous work of `glob` and `cp`, but those of their callbacks do.
37
- * Descriptors and file handles are not paths and are not reported.
26
+ * `.git`, and outside `node_modules` too with a `filter`, whose copies it
27
+ * writes once it succeeded, unless a `filter`, `force: false` or
28
+ * `verbatimSymlinks` may make a copy other than its source (`listCopies`);
29
+ * `mkdir` writes only the directories that did not exist. `mkdtemp` and
30
+ * `mkdtempDisposable` write the directory they made once they give it. A
31
+ * recursive `readdir` or `opendir` reads the directory and every directory in
32
+ * it, each listed by its own names, so adding a file anywhere in the tree
33
+ * changes what was read; `readdir` also reads the directories behind the links
34
+ * it follows. `glob` reads the same of the directory where each pattern's fixed
35
+ * part ends. Calls of `node:fs` that a wrapped function makes while it runs
36
+ * report nothing, and neither do those of the asynchronous work of `glob` and
37
+ * `cp`, but those of their callbacks do. Descriptors and file handles are not
38
+ * paths and are not reported.
38
39
  *
39
40
  * @param receiver - Receives the paths while it is the current receiver; the
40
41
  * next call replaces it, and null stops recording.
@@ -34,10 +34,10 @@ const a = /* @__PURE__ */ new Set([
34
34
  "rename",
35
35
  "link",
36
36
  "cp"
37
- ]), c = /* @__PURE__ */ new Set(["mkdtempDisposable", "mkdtemp"]), l = /* @__PURE__ */ new Set(["glob", "cp"]), u = /* @__PURE__ */ new Set(["node_modules", ".git"]), d = /[!()*+?@[\\\]{}]/u, f = t.constants.O_WRONLY | t.constants.O_APPEND | t.constants.O_CREAT | t.constants.O_TRUNC, p = Symbol.for("mootant.file-reads");
38
- let m = n.resolve, h = n.dirname, g = n.join, _ = r;
39
- function v(n) {
40
- let r = globalThis, s = r[p];
37
+ ]), c = /* @__PURE__ */ new Set(["mkdtempDisposable", "mkdtemp"]), l = /* @__PURE__ */ new Set(["glob", "cp"]), u = /* @__PURE__ */ new Set([".git"]), d = /* @__PURE__ */ new Set([...u, "node_modules"]), f = /[!()*+?@[\\\]{}]/u, p = t.constants.O_WRONLY | t.constants.O_APPEND | t.constants.O_CREAT | t.constants.O_TRUNC, m = Symbol.for("mootant.file-reads");
38
+ let h = n.resolve, g = n.dirname, _ = n.join, v = r;
39
+ function y(n) {
40
+ let r = globalThis, s = r[m];
41
41
  if (s === void 0) {
42
42
  s = {
43
43
  original: {
@@ -49,7 +49,7 @@ function v(n) {
49
49
  walking: new i(),
50
50
  receiver: null,
51
51
  inside: !1
52
- }, r[p] = s;
52
+ }, r[m] = s;
53
53
  let n = [
54
54
  ...a,
55
55
  ...Object.keys(o),
@@ -57,13 +57,13 @@ function v(n) {
57
57
  ].flatMap((e) => [e, `${e}Sync`]);
58
58
  for (let e of [t, t.promises]) for (let t of n) {
59
59
  let n = Reflect.get(e, t);
60
- typeof n == "function" && Reflect.set(e, t, y(n, t, s));
60
+ typeof n == "function" && Reflect.set(e, t, b(n, t, s));
61
61
  }
62
62
  e();
63
63
  }
64
64
  s.receiver = n;
65
65
  }
66
- function y(e, t, n) {
66
+ function b(e, t, n) {
67
67
  let r = t.replace(/Sync$/u, "");
68
68
  function i(...i) {
69
69
  if (n.inside || n.walking.getStore() === !0) return e.apply(this, i);
@@ -72,33 +72,33 @@ function y(e, t, n) {
72
72
  let e = a;
73
73
  try {
74
74
  if (c.has(r)) o = (t) => {
75
- let n = t.path ?? t, r = m(Buffer.isBuffer(n) ? n.toString() : String(n));
75
+ let n = t.path ?? t, r = h(Buffer.isBuffer(n) ? n.toString() : String(n));
76
76
  e.write(r);
77
77
  };
78
78
  else {
79
- let t = A(r, i, n);
79
+ let t = j(r, i, n);
80
80
  for (let n of t.read) e.read(n);
81
81
  for (let n of t.written) e.write(n);
82
- let a = r === "cp" ? S(i, t.read, n) : [];
82
+ let a = r === "cp" ? T(i, t.read, n) : [];
83
83
  a.length > 0 && (o = () => {
84
84
  for (let t of a) e.write(t);
85
85
  });
86
86
  }
87
87
  } catch {}
88
88
  }
89
- let s = (t) => o === null ? e.apply(this, t) : b((...t) => e.apply(this, t), t, o);
89
+ let s = (t) => o === null ? e.apply(this, t) : x((...t) => e.apply(this, t), t, o);
90
90
  n.inside = !0;
91
91
  try {
92
92
  if (!l.has(t)) return s(i);
93
- let e = j(i, n), r = n.walking.run(!0, () => s(e));
94
- return t === "glob" ? O(r, n) : r;
93
+ let e = M(i, n), r = n.walking.run(!0, () => s(e));
94
+ return t === "glob" ? k(r, n) : r;
95
95
  } finally {
96
96
  n.inside = !1;
97
97
  }
98
98
  }
99
99
  return Object.defineProperties(i, Object.getOwnPropertyDescriptors(e)), i;
100
100
  }
101
- function b(e, t, n) {
101
+ function x(e, t, n) {
102
102
  function r(e) {
103
103
  try {
104
104
  n(e);
@@ -117,7 +117,7 @@ function b(e, t, n) {
117
117
  let o = e(...t);
118
118
  return o instanceof Promise ? a(o) : (r(o), o);
119
119
  }
120
- function x(e, t, n) {
120
+ function S(e, t, n) {
121
121
  let r = [e], i = /* @__PURE__ */ new Set(), a = [e];
122
122
  for (; a.length > 0;) {
123
123
  let e = a.shift(), o = [];
@@ -125,7 +125,7 @@ function x(e, t, n) {
125
125
  i.add(t.original.realpathSync(e)), o = t.original.readdirSync(e, { withFileTypes: !0 });
126
126
  } catch {}
127
127
  for (let s of o) {
128
- let o = g(e, s.name), c = s.isDirectory();
128
+ let o = _(e, s.name), c = s.isDirectory();
129
129
  if (n && s.isSymbolicLink()) try {
130
130
  if (c = t.original.statSync(o).isDirectory(), c && i.has(t.original.realpathSync(o))) {
131
131
  r.push(o);
@@ -137,70 +137,70 @@ function x(e, t, n) {
137
137
  }
138
138
  return r;
139
139
  }
140
- function S(e, t, n) {
141
- let [r] = t, i = M(e[1]), a = e[2] ?? {};
142
- return r === void 0 || i === null || a.filter !== void 0 || a.force === !1 || a.verbatimSymlinks === !0 ? [] : t.map((e) => `${i}${e.slice(r.length)}`).filter((e) => {
143
- try {
144
- return !n.original.statSync(e).isDirectory();
145
- } catch {
146
- return !0;
147
- }
148
- });
149
- }
150
140
  function C(e, t, n) {
151
- n.push(e);
152
- let r = [];
141
+ let r = [e], i = [];
153
142
  try {
154
- t.original.statSync(e).isDirectory() && r.push(e);
143
+ t.original.statSync(e).isDirectory() && i.push(e);
155
144
  } catch {}
156
- for (; r.length > 0;) {
157
- let e = r.shift(), i = [];
145
+ for (; i.length > 0;) {
146
+ let e = i.shift(), a = [];
158
147
  try {
159
- i = t.original.readdirSync(e, { withFileTypes: !0 });
148
+ a = t.original.readdirSync(e, { withFileTypes: !0 });
160
149
  } catch {}
161
- for (let t of i) if (!u.has(t.name)) {
162
- let i = g(e, t.name);
163
- n.push(i), t.isDirectory() && r.push(i);
150
+ for (let t of a) if (!n.has(t.name)) {
151
+ let n = _(e, t.name);
152
+ r.push(n), t.isDirectory() && i.push(n);
164
153
  }
165
154
  }
155
+ return r;
166
156
  }
167
157
  function w(e, t, n) {
168
- let r = {
169
- written: [],
170
- read: []
171
- }, i = M(t[0]);
172
- return i === null || (e === "open" && !P(t[1]) ? r.written.push(i) : (e === "readdir" || e === "opendir") && t[1]?.recursive ? r.read.push(...x(i, n, e === "readdir")) : r.read.push(i)), r;
173
- }
174
- function T(e, t, n) {
175
- let r = M(t[0]);
158
+ let r = N(t[0]);
176
159
  if (r === null || !s.has(e)) return [];
177
160
  if (e === "symlink") {
178
- let e = M(t[1]);
179
- return [e === null || typeof t[0] != "string" ? r : m(h(e), t[0])];
161
+ let e = N(t[1]);
162
+ return [e === null || typeof t[0] != "string" ? r : h(g(e), t[0])];
180
163
  }
181
164
  if (e === "cp") {
182
- let e = [];
183
- return C(r, n, e), e;
165
+ let e = t[2];
166
+ return C(r, n, typeof e == "object" && e && Reflect.get(e, "filter") !== void 0 ? d : u);
184
167
  }
185
168
  return [r];
186
169
  }
187
- function E(e, t) {
188
- let n = [], r = [e[0]].flat(), i = e[1], a = typeof i == "object" ? M(i.cwd) : null;
189
- for (let e of r) typeof e == "string" && n.push(...x(k(e, a ?? process.cwd()), t, !1));
170
+ function T(e, t, n) {
171
+ let [r] = t, i = N(e[1]), a = e[2] ?? {};
172
+ return r === void 0 || i === null || a.filter !== void 0 || a.force === !1 || a.verbatimSymlinks === !0 ? [] : t.map((e) => `${i}${e.slice(r.length)}`).filter((e) => {
173
+ try {
174
+ return !n.original.statSync(e).isDirectory();
175
+ } catch {
176
+ return !0;
177
+ }
178
+ });
179
+ }
180
+ function E(e, t, n) {
181
+ let r = {
182
+ written: [],
183
+ read: []
184
+ }, i = N(t[0]);
185
+ return i === null || (e === "open" && !F(t[1]) ? r.written.push(i) : (e === "readdir" || e === "opendir") && t[1]?.recursive ? r.read.push(...S(i, n, e === "readdir")) : r.read.push(i)), r;
186
+ }
187
+ function D(e, t) {
188
+ let n = [], r = [e[0]].flat(), i = e[1], a = typeof i == "object" ? N(i.cwd) : null;
189
+ for (let e of r) typeof e == "string" && n.push(...S(A(e, a ?? process.cwd()), t, !1));
190
190
  return n;
191
191
  }
192
- function D(e, t, n) {
192
+ function O(e, t, n) {
193
193
  let r = [], i = o[e];
194
194
  for (let a of i) {
195
- let i = M(t[a]);
195
+ let i = N(t[a]);
196
196
  if (i !== null) {
197
- if (e === "mkdir") for (; !n.original.existsSync(i);) r.push(i), i = h(i);
197
+ if (e === "mkdir") for (; !n.original.existsSync(i);) r.push(i), i = g(i);
198
198
  else r.push(i);
199
199
  }
200
200
  }
201
201
  return r;
202
202
  }
203
- function O(e, t) {
203
+ function k(e, t) {
204
204
  if (e === void 0) return e;
205
205
  let n = e, r = {
206
206
  return: (e) => t.walking.run(!0, () => n.return(e)),
@@ -209,35 +209,35 @@ function O(e, t) {
209
209
  };
210
210
  return r;
211
211
  }
212
- function k(e, t) {
213
- let n = e.split("/"), r = n.findIndex((e) => d.test(e));
214
- if (r === -1) return m(t, e);
215
- let i = m(t, n.slice(0, r).join("/"));
216
- for (let e of n.slice(r)) e === ".." && (i = h(i));
212
+ function A(e, t) {
213
+ let n = e.split("/"), r = n.findIndex((e) => f.test(e));
214
+ if (r === -1) return h(t, e);
215
+ let i = h(t, n.slice(0, r).join("/"));
216
+ for (let e of n.slice(r)) e === ".." && (i = g(i));
217
217
  return i;
218
218
  }
219
- function A(e, t, n) {
219
+ function j(e, t, n) {
220
220
  return e === "glob" ? {
221
- read: E(t, n),
221
+ read: D(t, n),
222
222
  written: []
223
- } : a.has(e) ? w(e, t, n) : {
224
- read: T(e, t, n),
225
- written: D(e, t, n)
223
+ } : a.has(e) ? E(e, t, n) : {
224
+ read: w(e, t, n),
225
+ written: O(e, t, n)
226
226
  };
227
227
  }
228
- function j(e, t) {
228
+ function M(e, t) {
229
229
  let n = e.at(-1);
230
230
  return typeof n == "function" ? [...e.slice(0, -1), (...e) => t.walking.exit(() => Reflect.apply(n, void 0, e))] : e;
231
231
  }
232
- function M(e) {
232
+ function N(e) {
233
233
  let t = null;
234
- return typeof e == "string" ? t = e : N(e) ? t = e.protocol === "file:" ? _(e) : null : e instanceof Buffer && (t = e.toString()), t === null ? null : m(t);
234
+ return typeof e == "string" ? t = e : P(e) ? t = e.protocol === "file:" ? v(e) : null : e instanceof Buffer && (t = e.toString()), t === null ? null : h(t);
235
235
  }
236
- function N(e) {
236
+ function P(e) {
237
237
  let t = e;
238
238
  return !!t?.href && !!t?.protocol && t?.auth === void 0 && t?.path === void 0;
239
239
  }
240
- function P(e) {
241
- return typeof e == "number" ? (e & f) === 0 : typeof e != "string" || !/[aw]/u.test(e);
240
+ function F(e) {
241
+ return typeof e == "number" ? (e & p) === 0 : typeof e != "string" || !/[aw]/u.test(e);
242
242
  }
243
- export { v as trackFileReads };
243
+ export { y as trackFileReads };
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * Remembers a test process, which leads a process group of its own and so gets
3
3
  * no signal the terminal sends, until it ends: while any is remembered, this
4
- * process stops them all when it exits or gets SIGINT or SIGTERM.
4
+ * process stops them all when it exits or gets SIGHUP, SIGINT, SIGQUIT or
5
+ * SIGTERM.
5
6
  *
6
7
  * @param pid - Process id of the test process.
7
8
  * @returns Function that forgets the process once it ended.
@@ -1,6 +1,11 @@
1
1
  import { stopLiveProcessGroups as e } from "./stop-live-process-groups.js";
2
2
  import { LIVE_PROCESS_GROUPS as t } from "./live-process-groups.js";
3
- const n = ["SIGINT", "SIGTERM"];
3
+ const n = [
4
+ "SIGHUP",
5
+ "SIGINT",
6
+ "SIGQUIT",
7
+ "SIGTERM"
8
+ ];
4
9
  function r(r) {
5
10
  if (!process.listeners("exit").includes(e)) {
6
11
  process.on("exit", e);
@@ -11,7 +16,7 @@ function r(r) {
11
16
  };
12
17
  }
13
18
  function i(t) {
14
- e(), a(), process.listenerCount(t) === 0 && process.kill(process.pid, t);
19
+ e(), a(), process.listenerCount(t) === 0 && process.kill(process.pid, process.platform === "win32" ? "SIGINT" : t);
15
20
  }
16
21
  function a() {
17
22
  process.off("exit", e);
@@ -7,9 +7,10 @@ import { UnitOutcome } from './types/unit-outcome.js';
7
7
  * stopped its worker, else `crash`. A failed cleanup of worker-scoped fixtures
8
8
  * or a failed teardown of the test environment is the unit's hook error; a
9
9
  * suite hook that hit Vitest's hook timeout marks the unit as timed out. A unit
10
- * that ended reports how long its process took to start: from the moment the
11
- * pool started the worker to the moment the worker began the unit, before it
12
- * waited for its turn.
10
+ * that ended reports how long its process took to start: from the moment its
11
+ * task got the worker from the pool, a spare one included, to the moment the
12
+ * worker began the unit, before it waited for its turn, both on the wall
13
+ * clock.
13
14
  *
14
15
  * @param handle - Live Vitest instance of the session.
15
16
  * @param unit - Index of the unit in the plan.
@@ -6,11 +6,17 @@ import { TestProject } from 'vitest/node';
6
6
  * module graph, transitively, which takes in files plugins watch and literal
7
7
  * dynamic imports that did not run, with all they import: modules that were
8
8
  * never transformed are transformed first, so their imports are known. Each
9
- * directory of those files adds the `tsconfig.json` files that may decide how
10
- * Vite transforms it (`listTsconfigFiles`). Virtual modules (`isVirtualModule`)
11
- * are followed but not listed, so the files plugins watch for them are in;
12
- * files under `node_modules`, which the lockfile stands for, are left out with
13
- * what they import. The test file itself is always in.
9
+ * directory of those files, of TypeScript files only under `node_modules`, adds
10
+ * the `tsconfig.json` files that may decide how Vite transforms it
11
+ * (`listTsconfigFiles`). Virtual modules (`isVirtualModule`) are followed but
12
+ * not listed, so the files plugins watch for them are in; files under
13
+ * `node_modules` are listed but not followed, as Vite transforms none of the
14
+ * packages Node loads, so what they import is in only when the worker reported
15
+ * it, each with the `package.json` files that decide its format and its `#`
16
+ * imports (`listPackageFiles`) and the `package.json` of its package, which
17
+ * decides what an import of the package resolves to (`getPackageManifest`), as
18
+ * Node, not Vite, resolves and loads what Vitest leaves to it. The test file
19
+ * itself is always in.
14
20
  *
15
21
  * @param input - Test file, its project and what its worker reported.
16
22
  * @param input.project - Project the test file ran in.
@@ -1,39 +1,48 @@
1
- import { listTsconfigFiles as e } from "../shared/list-tsconfig-files.js";
2
- import { compareCodeUnits as t } from "../../core/compare-code-units.js";
3
- import { isVirtualModule as n } from "./is-virtual-module.js";
4
- import { getModuleFile as r } from "./get-module-file.js";
5
- import i from "node:path";
6
- async function a(a) {
7
- let { reported: o, project: s } = a;
8
- if (o == null) return null;
9
- let c = /* @__PURE__ */ new Set([a.file]);
10
- function l(e) {
11
- let t = r(e);
12
- return t === null ? n(e) : (c.add(t), !0);
1
+ import { getPackageManifest as e } from "../../core/files/get-package-manifest.js";
2
+ import { listPackageFiles as t } from "../../core/files/list-package-files.js";
3
+ import { listTsconfigFiles as n } from "../shared/list-tsconfig-files.js";
4
+ import { compareCodeUnits as r } from "../../core/compare-code-units.js";
5
+ import { isVirtualModule as i } from "./is-virtual-module.js";
6
+ import { getModuleFile as a } from "./get-module-file.js";
7
+ import o from "node:path";
8
+ const s = /[/\\]node_modules[/\\]/u, c = /\.[cm]?tsx?$/u;
9
+ async function l(l) {
10
+ let { reported: u, project: d } = l;
11
+ if (u == null) return null;
12
+ let f = /* @__PURE__ */ new Set([l.file]);
13
+ function p(e) {
14
+ let t = a(e);
15
+ return t === null ? i(e) : (f.add(t), !s.test(t));
13
16
  }
14
- let u = Object.values(s.vite.environments), d = /* @__PURE__ */ new Set();
15
- async function f(e, t) {
17
+ let m = Object.values(d.vite.environments), h = /* @__PURE__ */ new Set();
18
+ async function g(e, t) {
16
19
  if (e.transformResult === null) try {
17
20
  await t.transformRequest(e.url);
18
21
  } catch {}
19
- let n = [...e.importedModules].filter((e) => !d.has(e) && l(e.file ?? e.id ?? ""));
20
- for (let e of n) d.add(e);
21
- await Promise.all(n.map((e) => f(e, t)));
22
+ let n = [...e.importedModules].filter((e) => !h.has(e) && p(e.file ?? e.id ?? ""));
23
+ for (let e of n) h.add(e);
24
+ await Promise.all(n.map((e) => g(e, t)));
22
25
  }
23
- let p = [];
24
- for (let e of o) if (l(e)) for (let t of u) {
26
+ let _ = [];
27
+ for (let e of u) if (p(e)) for (let t of m) {
25
28
  let n = t.moduleGraph.getModuleById(e);
26
29
  if (n !== void 0) {
27
- d.has(n) || (d.add(n), p.push(f(n, t)));
30
+ h.has(n) || (h.add(n), _.push(g(n, t)));
28
31
  break;
29
32
  }
30
33
  }
31
- await Promise.all(p);
32
- let m = new Set([...c].map(i.dirname));
33
- for (let t of m) {
34
- let n = e(t, a.tsconfigs);
35
- for (let e of n) c.add(e);
34
+ await Promise.all(_);
35
+ let v = /* @__PURE__ */ new Map(), y = [...f].flatMap((n) => {
36
+ if (!s.test(n)) return [];
37
+ let r = e(n);
38
+ return [...t(o.dirname(n), v), ...r === null ? [] : [r]];
39
+ });
40
+ for (let e of y) f.add(e);
41
+ let b = new Set([...f].filter((e) => !s.test(e) || c.test(e)).map(o.dirname));
42
+ for (let e of b) {
43
+ let t = n(e, l.tsconfigs, { references: !0 });
44
+ for (let e of t) f.add(e);
36
45
  }
37
- return [...c].toSorted(t);
46
+ return [...f].toSorted(r);
38
47
  }
39
- export { a as collectDependencies };
48
+ export { l as collectDependencies };
@@ -7,8 +7,9 @@ import { VitestSessionState } from './types/vitest-session-state.js';
7
7
  * no shuffled tests, so runs follow the dry run's order (concurrency, retries
8
8
  * and repeats stay; the runner makes tests sequential where it switches mutants
9
9
  * between tries); snapshots are never written; transformed modules are not
10
- * cached on disk; test locations are recorded. Changing the pool or isolation
11
- * adds a `config-overridden` warning. An unsupported setting is recorded as the
10
+ * cached on disk. Test locations keep the project's setting: the runner turns
11
+ * them on in dry runs only. Changing the pool or isolation adds a
12
+ * `config-overridden` warning. An unsupported setting is recorded as the
12
13
  * session error instead. Typecheck-only projects are left alone.
13
14
  *
14
15
  * @param project - Vitest project as resolved from the user's configuration.
@@ -9,7 +9,7 @@ function n(n, i) {
9
9
  return;
10
10
  }
11
11
  let s = t(n);
12
- a.pool !== "forks" && i.diagnostics.push(r(s, "pool: 'forks'", `pool: '${a.pool}'`)), a.isolate || i.diagnostics.push(r(s, "isolate: true", "isolate: false")), a.pool = i.pool.name, a.poolRunner = i.pool, a.isolate = !0, a.runner = i.runnerPath, a.sequence.shuffle = !1, a.snapshotOptions.updateSnapshot = "none", n.globalConfig.snapshotOptions.updateSnapshot = "none", n.vitest.snapshot.options.updateSnapshot = "none", a.fsModuleCache = !1, a.includeTaskLocation = !0;
12
+ a.pool !== "forks" && i.diagnostics.push(r(s, "pool: 'forks'", `pool: '${a.pool}'`)), a.isolate || i.diagnostics.push(r(s, "isolate: true", "isolate: false")), a.pool = i.pool.name, a.poolRunner = i.pool, a.isolate = !0, a.runner = i.runnerPath, a.sequence.shuffle = !1, a.snapshotOptions.updateSnapshot = "none", n.globalConfig.snapshotOptions.updateSnapshot = "none", n.vitest.snapshot.options.updateSnapshot = "none", a.fsModuleCache = !1;
13
13
  }
14
14
  function r(e, t, n) {
15
15
  return {
@@ -1,7 +1,8 @@
1
- import { PoolRunnerInitializer, ForksPoolWorker } from 'vitest/node';
1
+ import { ForksPoolWorker } from 'vitest/node';
2
+ import { MootantForksPool } from './types/mootant-forks-pool.js';
2
3
  /**
3
4
  * Creates the custom pool mootant runs every project with: Vitest's own forks
4
- * workers, through Vitest's public pool API, with one change. Vitest asks a
5
+ * workers, through Vitest's public pool API, with two changes. Vitest asks a
5
6
  * worker to stop with a `stop` message and waits for its `stopped` answer, up
6
7
  * to a minute, without watching the process meanwhile. A worker that hangs in
7
8
  * its teardown never answers, and the watchdog kills it; so when the process of
@@ -10,13 +11,39 @@ import { PoolRunnerInitializer, ForksPoolWorker } from 'vitest/node';
10
11
  * process that exited is not stopped again: Vitest's forks worker waits for an
11
12
  * `exit` event that a process killed by a signal has already sent. Should
12
13
  * Vitest change its stop messages, the stop simply waits for Vitest's timer as
13
- * before. The pool also notes when it started each worker process, so the cost
14
- * of a unit can include the start of its process; should Vitest stop exposing
15
- * the process, nothing is noted.
14
+ * before.
15
+ *
16
+ * The pool also keeps spare workers for the tasks of the run it is told of
17
+ * (`prepare`): their processes start ahead and load Vitest's worker, but get
18
+ * the project, the test environment and the test file only once a task takes
19
+ * them, as messages of Vitest, so a task skips the start of a process, while no
20
+ * code of the project runs before. After each task takes its worker, spares
21
+ * start in the background for the tasks of its project still to come, as many
22
+ * in all as `getSpareLimit` allows for the project's `maxWorkers`; a task takes
23
+ * a spare whose process runs and whose key matches its own (`getSpareKey`),
24
+ * else starts a worker of its own. A spare that fails or ends is dropped; one
25
+ * that cannot start ends the spares of its project for the run. The spares left
26
+ * stop when the run is over (`drain`). Without spares (`MOOTANT_PREFORK=0`),
27
+ * with a worker whose flags rule them out, or should Vitest stop exposing the
28
+ * process of its first worker, every task starts its own worker.
29
+ *
30
+ * The pool notes when each task got its worker process, so the cost of a unit
31
+ * can include the start of its process.
32
+ *
33
+ * Once the run is interrupted (`interrupt`), the pool stops the process of
34
+ * every worker and spare it started that still runs, with `SIGKILL` through the
35
+ * process itself, which cannot stand for another process before it ended, and
36
+ * starts none: the start of a task fails at once, and a worker refused so has
37
+ * no process to stop. Vitest ends the run then as after a watchdog's kill.
38
+ * Should Vitest stop exposing the processes of its workers, an interrupted run
39
+ * waits until they end or the watchdog stops them. The watchdog stops a hung
40
+ * worker the same way (`stopWorker`); a process id that is none of the pool's
41
+ * running processes is left.
16
42
  *
17
43
  * @param Worker - Forks worker class of the project's Vitest.
18
- * @param spawns - Receives the epoch milliseconds at which the pool started a
44
+ * @param spawns - Receives the epoch milliseconds at which a task got its
19
45
  * worker process, by process id.
46
+ * @param prefork - Whether the pool may keep spare workers.
20
47
  * @returns Pool to set as the projects' `poolRunner`.
21
48
  */
22
- export declare function createForksPool(Worker: typeof ForksPoolWorker, spawns: Map<number, number>): PoolRunnerInitializer;
49
+ export declare function createForksPool(Worker: typeof ForksPoolWorker, spawns: Map<number, number>, prefork: boolean): MootantForksPool;