mootant 0.1.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 (487) hide show
  1. package/bin/mootant.js +3 -2
  2. package/dist/adapters/jest/build-dry-file.d.ts +12 -12
  3. package/dist/adapters/jest/collect-jest-dependencies.d.ts +15 -12
  4. package/dist/adapters/jest/collect-jest-dependencies.js +20 -14
  5. package/dist/adapters/jest/get-jest-cache-inputs.d.ts +14 -13
  6. package/dist/adapters/jest/index.d.ts +3 -1
  7. package/dist/adapters/jest/run-dry.js +20 -20
  8. package/dist/adapters/jest/runner.d.ts +1 -1
  9. package/dist/adapters/jest/runner.js +1 -1
  10. package/dist/adapters/jest/start-jest-session.d.ts +6 -2
  11. package/dist/adapters/jest/start-jest-session.js +9 -2
  12. package/dist/adapters/jest/types/jest-handle.d.ts +2 -1
  13. package/dist/adapters/jest/types/jest-record.d.ts +5 -4
  14. package/dist/adapters/jest/types/unit-worker.d.ts +16 -8
  15. package/dist/adapters/jest/types/worker-channel.d.ts +7 -0
  16. package/dist/adapters/jest/types/worker-session.d.ts +6 -7
  17. package/dist/adapters/jest/worker/boot-worker.d.ts +5 -3
  18. package/dist/adapters/jest/worker/create-test-runner.d.ts +4 -1
  19. package/dist/adapters/jest/worker/keep-reset-loads.d.ts +13 -0
  20. package/dist/adapters/jest/worker/list-runtime-files.d.ts +13 -0
  21. package/dist/adapters/jest/worker/run-unit.d.ts +24 -17
  22. package/dist/adapters/jest/worker/vm-setup.js +1 -1
  23. package/dist/adapters/jest/worker/worker.js +1 -1
  24. package/dist/adapters/jest/write-worker-session.d.ts +1 -2
  25. package/dist/adapters/jest/write-worker-session.js +2 -2
  26. package/dist/adapters/node-test/check-typescript.js +2 -2
  27. package/dist/adapters/node-test/collect-node-dependencies.d.ts +7 -5
  28. package/dist/adapters/node-test/collect-node-dependencies.js +26 -20
  29. package/dist/adapters/node-test/create-spare-processes.d.ts +26 -0
  30. package/dist/adapters/node-test/create-spare-processes.js +53 -0
  31. package/dist/adapters/node-test/filter-exec-argv.d.ts +2 -1
  32. package/dist/adapters/node-test/filter-exec-argv.js +13 -12
  33. package/dist/adapters/node-test/get-node-cache-inputs.js +1 -1
  34. package/dist/adapters/node-test/get-unit-deadline.d.ts +6 -5
  35. package/dist/adapters/node-test/index.d.ts +2 -2
  36. package/dist/adapters/node-test/index.js +1 -0
  37. package/dist/adapters/node-test/is-group-alive.d.ts +8 -0
  38. package/dist/adapters/node-test/is-group-alive.js +8 -0
  39. package/dist/adapters/node-test/list-setup-files.js +2 -2
  40. package/dist/adapters/node-test/place-preload.d.ts +2 -1
  41. package/dist/adapters/node-test/place-preload.js +24 -18
  42. package/dist/adapters/node-test/preload/create-commonjs-route.js +1 -1
  43. package/dist/adapters/node-test/preload/preload.js +54 -49
  44. package/dist/adapters/node-test/preload/read-line-sync.d.ts +11 -0
  45. package/dist/adapters/node-test/preload/read-line-sync.js +25 -0
  46. package/dist/adapters/node-test/preload/read-unit.d.ts +11 -5
  47. package/dist/adapters/node-test/preload/read-unit.js +5 -4
  48. package/dist/adapters/node-test/run-isolated.d.ts +19 -10
  49. package/dist/adapters/node-test/run-isolated.js +68 -52
  50. package/dist/adapters/node-test/run-test-file.d.ts +12 -4
  51. package/dist/adapters/node-test/run-test-file.js +19 -14
  52. package/dist/adapters/node-test/run-test-process.d.ts +30 -13
  53. package/dist/adapters/node-test/run-test-process.js +38 -40
  54. package/dist/adapters/node-test/start-node-test-session.d.ts +10 -2
  55. package/dist/adapters/node-test/start-node-test-session.js +90 -84
  56. package/dist/adapters/node-test/start-test-process.d.ts +30 -0
  57. package/dist/adapters/node-test/start-test-process.js +27 -0
  58. package/dist/adapters/node-test/types/node-test-handle.d.ts +14 -1
  59. package/dist/adapters/node-test/types/node-test-record.d.ts +3 -3
  60. package/dist/adapters/node-test/types/node-test-unit.d.ts +6 -1
  61. package/dist/adapters/node-test/types/process-watch.d.ts +4 -3
  62. package/dist/adapters/node-test/types/spare-processes.d.ts +20 -0
  63. package/dist/adapters/node-test/types/test-process-outcome.d.ts +8 -1
  64. package/dist/adapters/shared/allows-spares.d.ts +11 -0
  65. package/dist/adapters/shared/allows-spares.js +23 -0
  66. package/dist/adapters/shared/create-environment-proxy.d.ts +4 -3
  67. package/dist/adapters/shared/create-input-filter.d.ts +29 -0
  68. package/dist/adapters/shared/create-input-filter.js +32 -0
  69. package/dist/adapters/shared/enable-compile-cache.d.ts +32 -0
  70. package/dist/adapters/shared/enable-compile-cache.js +7 -0
  71. package/dist/adapters/shared/find-tsconfig-property.d.ts +13 -0
  72. package/dist/adapters/shared/find-tsconfig-property.js +6 -0
  73. package/dist/adapters/shared/get-spare-limit.d.ts +10 -0
  74. package/dist/adapters/shared/get-spare-limit.js +5 -0
  75. package/dist/adapters/shared/index-environment-hashes.d.ts +2 -2
  76. package/dist/adapters/shared/index-environment-hashes.js +5 -13
  77. package/dist/adapters/{node-test → shared}/list-flag-values.d.ts +2 -1
  78. package/dist/adapters/shared/list-flag-values.js +10 -0
  79. package/dist/adapters/shared/list-tsconfig-files.d.ts +14 -5
  80. package/dist/adapters/shared/list-tsconfig-files.js +15 -13
  81. package/dist/adapters/shared/parse-tsconfig.d.ts +10 -0
  82. package/dist/adapters/shared/parse-tsconfig.js +19 -0
  83. package/dist/adapters/shared/read-flag-name.d.ts +9 -0
  84. package/dist/adapters/shared/read-flag-name.js +5 -0
  85. package/dist/adapters/shared/read-node-options.d.ts +11 -0
  86. package/dist/adapters/shared/read-node-options.js +6 -0
  87. package/dist/adapters/shared/read-prefork-switch.d.ts +10 -0
  88. package/dist/adapters/shared/read-prefork-switch.js +5 -0
  89. package/dist/adapters/shared/read-tsconfig-extends.d.ts +2 -5
  90. package/dist/adapters/shared/read-tsconfig-extends.js +16 -31
  91. package/dist/adapters/shared/read-tsconfig-references.d.ts +12 -0
  92. package/dist/adapters/shared/read-tsconfig-references.js +13 -0
  93. package/dist/adapters/shared/track-file-inputs.d.ts +7 -3
  94. package/dist/adapters/shared/track-file-inputs.js +16 -7
  95. package/dist/adapters/shared/track-file-reads.d.ts +13 -8
  96. package/dist/adapters/shared/track-file-reads.js +122 -69
  97. package/dist/adapters/shared/track-inputs.d.ts +13 -6
  98. package/dist/adapters/shared/track-inputs.js +7 -7
  99. package/dist/adapters/shared/track-process-group.d.ts +2 -1
  100. package/dist/adapters/shared/track-process-group.js +7 -2
  101. package/dist/adapters/shared/types/file-input-tracking.d.ts +6 -0
  102. package/dist/adapters/shared/types/input-tracking.d.ts +3 -3
  103. package/dist/adapters/vitest/build-isolated-facts.d.ts +4 -3
  104. package/dist/adapters/vitest/collect-dependencies.d.ts +10 -3
  105. package/dist/adapters/vitest/collect-dependencies.js +36 -26
  106. package/dist/adapters/vitest/configure-project.d.ts +3 -2
  107. package/dist/adapters/vitest/configure-project.js +1 -1
  108. package/dist/adapters/vitest/create-forks-pool.d.ts +34 -7
  109. package/dist/adapters/vitest/create-forks-pool.js +102 -24
  110. package/dist/adapters/vitest/create-interleaved-sequencer.d.ts +3 -2
  111. package/dist/adapters/vitest/drop-signal-listeners.d.ts +14 -0
  112. package/dist/adapters/vitest/drop-signal-listeners.js +15 -0
  113. package/dist/adapters/vitest/get-cache-inputs.d.ts +3 -1
  114. package/dist/adapters/vitest/get-cache-inputs.js +46 -29
  115. package/dist/adapters/vitest/get-module-file.d.ts +3 -5
  116. package/dist/adapters/vitest/get-module-file.js +1 -1
  117. package/dist/adapters/vitest/get-spare-key.d.ts +15 -0
  118. package/dist/adapters/vitest/get-spare-key.js +15 -0
  119. package/dist/adapters/vitest/index.d.ts +2 -1
  120. package/dist/adapters/vitest/index.js +1 -0
  121. package/dist/adapters/vitest/is-virtual-module.d.ts +10 -0
  122. package/dist/adapters/vitest/is-virtual-module.js +8 -0
  123. package/dist/adapters/vitest/list-script-defines.d.ts +13 -0
  124. package/dist/adapters/vitest/list-script-defines.js +22 -0
  125. package/dist/adapters/vitest/read-out-files.d.ts +7 -2
  126. package/dist/adapters/vitest/read-out-files.js +5 -5
  127. package/dist/adapters/vitest/read-out-records.d.ts +17 -0
  128. package/dist/adapters/vitest/read-out-records.js +27 -0
  129. package/dist/adapters/vitest/read-strays.d.ts +20 -0
  130. package/dist/adapters/vitest/read-strays.js +53 -0
  131. package/dist/adapters/vitest/read-unit-inputs.d.ts +9 -2
  132. package/dist/adapters/vitest/read-unit-inputs.js +1 -1
  133. package/dist/adapters/vitest/run-dry.js +17 -17
  134. package/dist/adapters/vitest/run-plan.d.ts +10 -6
  135. package/dist/adapters/vitest/run-plan.js +16 -16
  136. package/dist/adapters/vitest/run-specifications.d.ts +11 -3
  137. package/dist/adapters/vitest/run-specifications.js +22 -12
  138. package/dist/adapters/vitest/runner.d.ts +92 -46
  139. package/dist/adapters/vitest/runner.js +126 -104
  140. package/dist/adapters/vitest/start-vitest-session.d.ts +5 -1
  141. package/dist/adapters/vitest/start-vitest-session.js +64 -59
  142. package/dist/adapters/vitest/stop-hung-worker.d.ts +11 -4
  143. package/dist/adapters/vitest/stop-hung-worker.js +20 -7
  144. package/dist/adapters/vitest/types/mootant-forks-pool.d.ts +47 -0
  145. package/dist/adapters/vitest/types/stray-decisions.d.ts +8 -0
  146. package/dist/adapters/vitest/types/unit-outcome.d.ts +2 -1
  147. package/dist/adapters/vitest/types/vitest-session-state.d.ts +9 -8
  148. package/dist/adapters/vitest/types/vitest-worker.d.ts +118 -32
  149. package/dist/adapters/vitest/wait-for-workers.d.ts +5 -2
  150. package/dist/adapters/vitest/wait-for-workers.js +15 -15
  151. package/dist/adapters/vitest/worker/encode-stray.d.ts +16 -0
  152. package/dist/adapters/vitest/worker/encode-stray.js +16 -0
  153. package/dist/adapters/vitest/worker/intercept-strays.d.ts +26 -0
  154. package/dist/adapters/vitest/worker/intercept-strays.js +13 -0
  155. package/dist/adapters/vitest/worker/read-try-facts.d.ts +5 -4
  156. package/dist/adapters/vitest/worker/track-meta-defines.d.ts +39 -0
  157. package/dist/adapters/vitest/worker/track-meta-defines.js +23 -0
  158. package/dist/adapters/vitest/worker/track-values.d.ts +38 -0
  159. package/dist/adapters/vitest/worker/track-values.js +45 -0
  160. package/dist/adapters/vitest/worker/value-prefixes.d.ts +12 -0
  161. package/dist/adapters/vitest/worker/value-prefixes.js +6 -0
  162. package/dist/adapters/vitest/worker/wait-for-turn.d.ts +8 -6
  163. package/dist/adapters/vitest/worker/watch-property.d.ts +17 -0
  164. package/dist/adapters/vitest/worker/watch-property.js +27 -0
  165. package/dist/adapters/vitest/worker/write-out-record.d.ts +2 -2
  166. package/dist/cli/create-run-progress.d.ts +8 -1
  167. package/dist/cli/create-run-progress.js +4 -1
  168. package/dist/cli/ensure-exit.d.ts +11 -0
  169. package/dist/cli/ensure-exit.js +15 -0
  170. package/dist/cli/html/build-html-report.js +2 -1
  171. package/dist/cli/html/client/main.js +1 -1
  172. package/dist/cli/html/client/render-change.d.ts +3 -2
  173. package/dist/cli/html/client/render-code.d.ts +1 -1
  174. package/dist/cli/html/client/render-overview.d.ts +3 -3
  175. package/dist/cli/html/pack-replacement.d.ts +1 -1
  176. package/dist/cli/index.d.ts +1 -0
  177. package/dist/cli/index.js +3 -2
  178. package/dist/cli/parse-arguments.d.ts +4 -0
  179. package/dist/cli/parse-arguments.js +4 -1
  180. package/dist/cli/report/build-list-report.js +1 -1
  181. package/dist/cli/report/build-run-report.js +2 -1
  182. package/dist/cli/report/format-command.d.ts +5 -0
  183. package/dist/cli/report/format-command.js +1 -1
  184. package/dist/cli/report/format-file-groups.d.ts +1 -1
  185. package/dist/cli/report/format-run-text-report.d.ts +5 -4
  186. package/dist/cli/report/format-run-text-report.js +10 -10
  187. package/dist/cli/report/slim-run-report.d.ts +10 -10
  188. package/dist/cli/report/slim-run-report.js +1 -0
  189. package/dist/cli/run-mutation.d.ts +5 -1
  190. package/dist/cli/run-mutation.js +55 -47
  191. package/dist/cli/terminal/create-spinner.d.ts +2 -3
  192. package/dist/cli/terminal/create-spinner.js +23 -32
  193. package/dist/cli/terminal/get-text-style.js +4 -4
  194. package/dist/cli/watch-interrupts.d.ts +41 -0
  195. package/dist/cli/watch-interrupts.js +32 -0
  196. package/dist/core/cache/apply-cached-units.d.ts +8 -7
  197. package/dist/core/cache/build-hash.d.ts +9 -0
  198. package/dist/core/cache/build-hash.js +2 -0
  199. package/dist/core/cache/cache-version.d.ts +4 -4
  200. package/dist/core/cache/check-dry-snapshot.d.ts +25 -0
  201. package/dist/core/cache/check-dry-snapshot.js +13 -0
  202. package/dist/core/cache/create-dry-reuse-miss.d.ts +12 -0
  203. package/dist/core/cache/create-dry-reuse-miss.js +7 -0
  204. package/dist/core/cache/create-dry-snapshot.d.ts +71 -0
  205. package/dist/core/cache/create-dry-snapshot.js +27 -0
  206. package/dist/core/cache/create-run-cache.d.ts +20 -2
  207. package/dist/core/cache/create-run-cache.js +31 -22
  208. package/dist/core/cache/create-snapshot-session.d.ts +12 -0
  209. package/dist/core/cache/create-snapshot-session.js +19 -0
  210. package/dist/core/cache/get-build-id.d.ts +11 -0
  211. package/dist/core/cache/get-build-id.js +7 -0
  212. package/dist/core/cache/get-cache-path.d.ts +1 -1
  213. package/dist/core/cache/get-cache-path.js +1 -1
  214. package/dist/core/cache/get-dry-snapshot-key.d.ts +47 -0
  215. package/dist/core/cache/get-dry-snapshot-key.js +43 -0
  216. package/dist/core/cache/get-dry-snapshot-path.d.ts +9 -0
  217. package/dist/core/cache/get-dry-snapshot-path.js +5 -0
  218. package/dist/core/cache/get-environment-key.d.ts +9 -4
  219. package/dist/core/cache/get-environment-key.js +5 -4
  220. package/dist/core/cache/get-test-file-keys.d.ts +2 -1
  221. package/dist/core/cache/get-test-file-keys.js +11 -10
  222. package/dist/core/cache/hash-files.d.ts +11 -6
  223. package/dist/core/cache/hash-files.js +22 -17
  224. package/dist/core/cache/hash-project-tree.d.ts +22 -0
  225. package/dist/core/cache/hash-project-tree.js +69 -0
  226. package/dist/core/cache/is-dry-reuse-miss.d.ts +8 -0
  227. package/dist/core/cache/is-dry-reuse-miss.js +4 -0
  228. package/dist/core/cache/list-file-hashes.d.ts +4 -0
  229. package/dist/core/cache/list-file-hashes.js +5 -2
  230. package/dist/core/cache/list-install-states.d.ts +12 -0
  231. package/dist/core/cache/list-install-states.js +19 -0
  232. package/dist/core/cache/list-variable-hashes.d.ts +15 -0
  233. package/dist/core/cache/list-variable-hashes.js +14 -0
  234. package/dist/core/cache/prepare-run-cache.d.ts +64 -16
  235. package/dist/core/cache/prepare-run-cache.js +109 -62
  236. package/dist/core/cache/read-dry-snapshot.d.ts +10 -0
  237. package/dist/core/cache/read-dry-snapshot.js +15 -0
  238. package/dist/core/cache/read-run-cache.js +6 -2
  239. package/dist/core/cache/save-dry-snapshot.d.ts +34 -0
  240. package/dist/core/cache/save-dry-snapshot.js +32 -0
  241. package/dist/core/cache/save-run-cache.d.ts +8 -7
  242. package/dist/core/cache/save-run-cache.js +2 -1
  243. package/dist/core/cache/unknown-hash.d.ts +7 -0
  244. package/dist/core/cache/unknown-hash.js +2 -0
  245. package/dist/core/cache/volatile-variables.d.ts +7 -0
  246. package/dist/core/cache/volatile-variables.js +11 -0
  247. package/dist/core/cache/write-run-cache.js +1 -1
  248. package/dist/core/config/load-typescript-config.d.ts +6 -1
  249. package/dist/core/config/load-typescript-config.js +26 -10
  250. package/dist/core/config/prepare-run.d.ts +7 -3
  251. package/dist/core/config/prepare-run.js +1 -0
  252. package/dist/core/config/resolve-run-settings.d.ts +3 -2
  253. package/dist/core/config/resolve-run-settings.js +1 -0
  254. package/dist/core/config/validate-config.js +3 -2
  255. package/dist/core/files/get-package-manifest.d.ts +12 -0
  256. package/dist/core/files/get-package-manifest.js +7 -0
  257. package/dist/core/files/select-changed-mutants.d.ts +11 -6
  258. package/dist/core/files/select-changed-mutants.js +38 -13
  259. package/dist/core/generate/apply-solitary-rule.d.ts +8 -5
  260. package/dist/core/generate/apply-solitary-rule.js +36 -29
  261. package/dist/core/generate/collect-candidates.d.ts +23 -5
  262. package/dist/core/generate/collect-candidates.js +202 -92
  263. package/dist/core/generate/compare-targets.d.ts +14 -0
  264. package/dist/core/generate/compare-targets.js +6 -0
  265. package/dist/core/generate/deduplicate-candidates.d.ts +6 -4
  266. package/dist/core/generate/deduplicate-candidates.js +11 -9
  267. package/dist/core/generate/find-list-removal.d.ts +20 -0
  268. package/dist/core/generate/find-list-removal.js +26 -0
  269. package/dist/core/generate/generate-file-mutants.js +49 -47
  270. package/dist/core/generate/get-mutant-site.d.ts +18 -0
  271. package/dist/core/generate/get-mutant-site.js +4 -0
  272. package/dist/core/generate/get-target.d.ts +14 -0
  273. package/dist/core/generate/get-target.js +4 -0
  274. package/dist/core/generate/pick-host.d.ts +10 -0
  275. package/dist/core/generate/pick-host.js +16 -0
  276. package/dist/core/generate/validate-replacement.d.ts +15 -4
  277. package/dist/core/generate/validate-replacement.js +28 -13
  278. package/dist/core/ignore/find-ignore-rule.d.ts +8 -7
  279. package/dist/core/index.d.ts +18 -0
  280. package/dist/core/instrument/find-attribute-values.d.ts +12 -0
  281. package/dist/core/instrument/find-attribute-values.js +13 -0
  282. package/dist/core/instrument/get-site-syntax.d.ts +14 -0
  283. package/dist/core/instrument/get-site-syntax.js +12 -0
  284. package/dist/core/instrument/group-mutant-ranges.d.ts +7 -3
  285. package/dist/core/instrument/group-mutant-ranges.js +25 -19
  286. package/dist/core/instrument/instrument-file.d.ts +5 -3
  287. package/dist/core/instrument/instrument-file.js +10 -9
  288. package/dist/core/instrument/instrumenter-version.d.ts +1 -1
  289. package/dist/core/instrument/render-branch.d.ts +17 -0
  290. package/dist/core/instrument/render-branch.js +81 -0
  291. package/dist/core/instrument/render-mutant-range.d.ts +17 -6
  292. package/dist/core/instrument/render-mutant-range.js +39 -13
  293. package/dist/core/list-mutants.d.ts +7 -5
  294. package/dist/core/list-mutants.js +2 -2
  295. package/dist/core/mutators/array-element.d.ts +7 -6
  296. package/dist/core/mutators/array-element.js +13 -13
  297. package/dist/core/mutators/assignment-operator.js +34 -33
  298. package/dist/core/mutators/boolean-literal.d.ts +3 -2
  299. package/dist/core/mutators/number-literal.d.ts +1 -1
  300. package/dist/core/mutators/object-property.d.ts +4 -3
  301. package/dist/core/mutators/object-property.js +7 -8
  302. package/dist/core/mutators/return-value.js +65 -33
  303. package/dist/core/mutators/shared/get-branch-copy-skip.d.ts +14 -9
  304. package/dist/core/mutators/shared/get-branch-copy-skip.js +34 -35
  305. package/dist/core/mutators/shared/get-canonical-falsy-default.d.ts +32 -0
  306. package/dist/core/mutators/shared/get-canonical-falsy-default.js +11 -0
  307. package/dist/core/mutators/shared/get-comparison-plan.d.ts +2 -2
  308. package/dist/core/mutators/shared/get-comparison-plan.js +86 -85
  309. package/dist/core/mutators/shared/get-condition-constants.d.ts +8 -8
  310. package/dist/core/mutators/shared/get-condition-constants.js +3 -3
  311. package/dist/core/mutators/shared/get-default-option-skip.d.ts +2 -2
  312. package/dist/core/mutators/shared/get-endless-value.d.ts +20 -0
  313. package/dist/core/mutators/shared/get-endless-value.js +25 -0
  314. package/dist/core/mutators/shared/get-forced-test-justifier.d.ts +44 -0
  315. package/dist/core/mutators/shared/get-forced-test-justifier.js +25 -0
  316. package/dist/core/mutators/shared/get-group-constant.d.ts +6 -6
  317. package/dist/core/mutators/shared/get-group-constant.js +2 -2
  318. package/dist/core/mutators/shared/get-literal-skip.d.ts +9 -9
  319. package/dist/core/mutators/shared/get-literal-skip.js +2 -2
  320. package/dist/core/mutators/shared/get-logical-drops.d.ts +8 -8
  321. package/dist/core/mutators/shared/get-logical-drops.js +80 -82
  322. package/dist/core/mutators/shared/get-loop-running-skip.d.ts +2 -2
  323. package/dist/core/mutators/shared/get-nullish-swap-skip.d.ts +2 -2
  324. package/dist/core/mutators/shared/get-or-default-skip.d.ts +2 -2
  325. package/dist/core/mutators/shared/get-owned-constants.d.ts +2 -2
  326. package/dist/core/mutators/shared/get-owner-constant.d.ts +3 -1
  327. package/dist/core/mutators/shared/get-running-value.d.ts +5 -4
  328. package/dist/core/mutators/shared/get-toward-mutant.d.ts +10 -2
  329. package/dist/core/mutators/shared/get-toward-mutant.js +45 -40
  330. package/dist/core/mutators/shared/has-other-exit.js +16 -36
  331. package/dist/core/mutators/shared/is-loop-exit.d.ts +20 -0
  332. package/dist/core/mutators/shared/is-loop-exit.js +32 -0
  333. package/dist/core/mutators/shared/is-read-only.d.ts +26 -0
  334. package/dist/core/mutators/shared/is-read-only.js +53 -0
  335. package/dist/core/mutators/shared/leave-now-skip.d.ts +2 -2
  336. package/dist/core/mutators/shared/no-op-callback-skip.d.ts +2 -2
  337. package/dist/core/mutators/statement-removal.d.ts +4 -3
  338. package/dist/core/mutators/statement-removal.js +69 -73
  339. package/dist/core/mutators/string-literal.d.ts +15 -5
  340. package/dist/core/mutators/string-literal.js +79 -50
  341. package/dist/core/plugins/create-mutator-registry.d.ts +4 -2
  342. package/dist/core/plugins/create-mutator-registry.js +15 -5
  343. package/dist/core/plugins/validate-plugin.d.ts +3 -3
  344. package/dist/core/plugins/validate-plugin.js +32 -10
  345. package/dist/core/presets/recommended.d.ts +2 -2
  346. package/dist/core/presets/strict.d.ts +4 -2
  347. package/dist/core/regex/collect-pattern-changes.d.ts +2 -2
  348. package/dist/core/regex/create-regex-replacement.d.ts +2 -2
  349. package/dist/core/run/apply-batch-result.d.ts +23 -22
  350. package/dist/core/run/apply-batch-result.js +5 -5
  351. package/dist/core/run/apply-isolated-result.d.ts +21 -12
  352. package/dist/core/run/apply-isolated-result.js +45 -25
  353. package/dist/core/run/classify-try.d.ts +9 -8
  354. package/dist/core/run/count-run.d.ts +2 -1
  355. package/dist/core/run/create-run-state.d.ts +5 -0
  356. package/dist/core/run/create-run-state.js +1 -0
  357. package/dist/core/run/create-work-directory.d.ts +4 -1
  358. package/dist/core/run/create-work-directory.js +15 -12
  359. package/dist/core/run/decide-evidence.d.ts +4 -3
  360. package/dist/core/run/get-test-file-limits.d.ts +13 -0
  361. package/dist/core/run/get-test-file-limits.js +13 -0
  362. package/dist/core/run/get-unit-evidence.d.ts +12 -3
  363. package/dist/core/run/get-unit-evidence.js +1 -1
  364. package/dist/core/run/guard-session.d.ts +18 -0
  365. package/dist/core/run/guard-session.js +30 -0
  366. package/dist/core/run/live-work-directories.d.ts +5 -0
  367. package/dist/core/run/live-work-directories.js +2 -0
  368. package/dist/core/run/plan-batch.d.ts +6 -3
  369. package/dist/core/run/plan-batch.js +36 -31
  370. package/dist/core/run/plan-isolated.d.ts +3 -1
  371. package/dist/core/run/plan-isolated.js +8 -14
  372. package/dist/core/run/read-isolated-unit.d.ts +9 -6
  373. package/dist/core/run/read-isolated-unit.js +77 -38
  374. package/dist/core/run/remove-live-work-directories.d.ts +7 -0
  375. package/dist/core/run/remove-live-work-directories.js +12 -0
  376. package/dist/core/run/run-batch-phases.d.ts +4 -3
  377. package/dist/core/run/run-dry-phase.d.ts +35 -19
  378. package/dist/core/run/run-dry-phase.js +127 -77
  379. package/dist/core/run/run-isolated-rounds.d.ts +15 -10
  380. package/dist/core/run/run-isolated-rounds.js +4 -2
  381. package/dist/core/run/validate-adapter.d.ts +1 -1
  382. package/dist/core/run/validate-adapter.js +1 -1
  383. package/dist/core/run-mutants.d.ts +59 -22
  384. package/dist/core/run-mutants.js +356 -208
  385. package/dist/core/runtime/create-hit-limit-error.d.ts +5 -3
  386. package/dist/core/runtime/create-hit-limit-error.js +1 -1
  387. package/dist/core/runtime/install-mutant-runtime.js +23 -6
  388. package/dist/core/runtime/runtime-version.d.ts +4 -4
  389. package/dist/core/skips/skip-rules.d.ts +7 -1
  390. package/dist/core/skips/skip-rules.js +4 -0
  391. package/dist/core/syntax/is-brace-sensitive-attribute.d.ts +18 -0
  392. package/dist/core/syntax/is-brace-sensitive-attribute.js +28 -0
  393. package/dist/core/syntax/is-spread-safe-member.d.ts +18 -0
  394. package/dist/core/syntax/is-spread-safe-member.js +18 -0
  395. package/dist/core/syntax/is-value-position.d.ts +3 -1
  396. package/dist/core/text/get-list-removal-range.d.ts +22 -0
  397. package/dist/core/text/get-list-removal-range.js +46 -0
  398. package/dist/core/text/is-plain-attribute-string.d.ts +10 -0
  399. package/dist/core/text/is-plain-attribute-string.js +5 -0
  400. package/dist/core/text/parse-expression.d.ts +8 -4
  401. package/dist/core/text/parse-expression.js +1 -0
  402. package/dist/core/text/remove-list-element.d.ts +2 -4
  403. package/dist/core/text/remove-list-element.js +4 -45
  404. package/dist/docs/styles/colors.js +1 -1
  405. package/dist/package.js +1 -1
  406. package/dist/types/adapter/adapter-context.d.ts +20 -0
  407. package/dist/types/adapter/adapter-session.d.ts +2 -1
  408. package/dist/types/adapter/cache-inputs.d.ts +3 -2
  409. package/dist/types/adapter/dry-file.d.ts +6 -3
  410. package/dist/types/adapter/dry-run-request.d.ts +5 -4
  411. package/dist/types/adapter/isolated-plan.d.ts +2 -1
  412. package/dist/types/adapter/isolated-result.d.ts +3 -1
  413. package/dist/types/adapter/mutant-runtime.d.ts +30 -1
  414. package/dist/types/adapter/run-inputs.d.ts +5 -4
  415. package/dist/types/adapter/test-adapter.d.ts +7 -0
  416. package/dist/types/cache/cache-entry.d.ts +9 -7
  417. package/dist/types/cache/cached-inputs.d.ts +2 -2
  418. package/dist/types/cache/dry-snapshot.d.ts +76 -0
  419. package/dist/types/cache/project-tree.d.ts +16 -0
  420. package/dist/types/cache/run-cache-file.d.ts +1 -1
  421. package/dist/types/cache/run-cache.d.ts +6 -5
  422. package/dist/types/cli/text-style.d.ts +1 -1
  423. package/dist/types/config/plugin.d.ts +11 -2
  424. package/dist/types/config/preset-settings.d.ts +2 -2
  425. package/dist/types/config/run-config.d.ts +22 -4
  426. package/dist/types/config/run-settings.d.ts +6 -0
  427. package/dist/types/html/indexed-mutant.d.ts +4 -2
  428. package/dist/types/html/shown-change.d.ts +4 -3
  429. package/dist/types/mutant/core-note.d.ts +12 -0
  430. package/dist/types/mutant/diagnostic.d.ts +1 -0
  431. package/dist/types/mutant/list-removal.d.ts +37 -0
  432. package/dist/types/mutant/mutant-candidate.d.ts +11 -17
  433. package/dist/types/mutant/mutant-host.d.ts +49 -0
  434. package/dist/types/mutant/mutant-kind.d.ts +18 -0
  435. package/dist/types/mutant/mutant-range.d.ts +15 -8
  436. package/dist/types/mutant/mutant.d.ts +9 -15
  437. package/dist/types/mutant/registered-skip-rule.d.ts +11 -0
  438. package/dist/types/mutant/site-syntax.d.ts +14 -0
  439. package/dist/types/mutant/skip-justifier.d.ts +3 -1
  440. package/dist/types/mutant/skip-note.d.ts +7 -6
  441. package/dist/types/mutant/skip-rule-id.d.ts +3 -2
  442. package/dist/types/mutant/skip-rule.d.ts +2 -1
  443. package/dist/types/mutant/skipped-candidate.d.ts +27 -17
  444. package/dist/types/mutant/skipped-mutant.d.ts +15 -12
  445. package/dist/types/mutator/mutator.d.ts +3 -2
  446. package/dist/types/mutator/registered-mutator.d.ts +8 -0
  447. package/dist/types/mutator/replacement.d.ts +14 -3
  448. package/dist/types/regex/regex-change.d.ts +2 -2
  449. package/dist/types/report/html-report.d.ts +13 -9
  450. package/dist/types/report/list-report-focus.d.ts +3 -2
  451. package/dist/types/report/list-report-justifier.d.ts +4 -2
  452. package/dist/types/report/list-report-mutant.d.ts +15 -9
  453. package/dist/types/report/list-report-skipped.d.ts +6 -4
  454. package/dist/types/report/list-report.d.ts +1 -1
  455. package/dist/types/report/run-report.d.ts +13 -4
  456. package/dist/types/report/slim-list-report.d.ts +6 -3
  457. package/dist/types/report/slim-run-report.d.ts +2 -2
  458. package/dist/types/run/isolated-evidence.d.ts +3 -2
  459. package/dist/types/run/isolated-reason.d.ts +6 -4
  460. package/dist/types/run/mutant-state.d.ts +1 -1
  461. package/dist/types/run/run-durations.d.ts +8 -3
  462. package/dist/types/run/run-event.d.ts +11 -8
  463. package/dist/types/run/run-kind.d.ts +3 -2
  464. package/dist/types/run/run-result.d.ts +17 -5
  465. package/dist/types/run/run-state.d.ts +30 -1
  466. package/dist/types/run/run-status.d.ts +2 -2
  467. package/dist/types/run/try-cause.d.ts +10 -7
  468. package/dist/types/syntax/syntax-helpers.d.ts +5 -3
  469. package/package.json +5 -5
  470. package/readme.md +85 -68
  471. package/skills/mootant/SKILL.md +50 -31
  472. package/skills/mootant/references/mutators.md +31 -23
  473. package/dist/adapters/node-test/list-flag-values.js +0 -9
  474. package/dist/core/instrument/get-site-check.d.ts +0 -9
  475. package/dist/core/instrument/get-site-check.js +0 -5
  476. package/dist/core/instrument/get-template-site-check.d.ts +0 -12
  477. package/dist/core/instrument/get-template-site-check.js +0 -5
  478. /package/dist/adapters/{node-test → shared}/loader-flags.d.ts +0 -0
  479. /package/dist/adapters/{node-test → shared}/loader-flags.js +0 -0
  480. /package/dist/cli/{built-in-adapters.d.ts → get-built-in-adapters.d.ts} +0 -0
  481. /package/dist/cli/{built-in-adapters.js → get-built-in-adapters.js} +0 -0
  482. /package/dist/cli/terminal/{colors.d.ts → create-colors.d.ts} +0 -0
  483. /package/dist/cli/terminal/{colors.js → create-colors.js} +0 -0
  484. /package/dist/{adapters/shared → core/files}/list-package-files.d.ts +0 -0
  485. /package/dist/{adapters/shared → core/files}/list-package-files.js +0 -0
  486. /package/dist/{adapters/shared → core/files}/read-package-type.d.ts +0 -0
  487. /package/dist/{adapters/shared → core/files}/read-package-type.js +0 -0
@@ -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,34 +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,
13
+ directory: s.workDirectory,
11
14
  commonjs: a.commonjs,
12
15
  root: s.root,
13
- out: p
14
- }, { onOutput: h } = s;
16
+ out: m
17
+ }, { onOutput: g } = s, _ = JSON.stringify(h);
15
18
  try {
16
19
  return await e({
17
- ...h !== void 0 && { onOutput: (e) => {
18
- h(e, u);
20
+ ...g !== void 0 && { onOutput: (e) => {
21
+ g(e, d);
19
22
  } },
23
+ ...a.pipe && { unit: _ },
24
+ ...u !== void 0 && { spare: u },
20
25
  env: {
21
26
  ...a.env,
22
- MOOTANT_UNIT: JSON.stringify(m)
27
+ ...a.pipe ? { MOOTANT_UNIT_FD: "3" } : { MOOTANT_UNIT: _ }
23
28
  },
24
- args: [...a.args, u],
29
+ args: [...a.args, d],
25
30
  groups: a.groups,
26
31
  node: a.node,
27
32
  cwd: s.root,
28
33
  deadline: l,
29
- out: p
34
+ out: m
30
35
  });
31
36
  } finally {
32
- n(p, { force: !0 });
37
+ n(m, { force: !0 });
33
38
  }
34
39
  }
35
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 };
@@ -0,0 +1,30 @@
1
+ import { ChildProcess } from 'node:child_process';
2
+ /**
3
+ * Starts a test process detached, as the leader of a process group of its own,
4
+ * without stdin. Until the process ends or fails to start, mootant stops its
5
+ * group when it exits or gets a signal that ends it (`trackProcessGroup`), and
6
+ * the session holds the group in `groups`, which it stops when it closes. With
7
+ * a pipe, the process gets file descriptor 3 too, through which mootant sends
8
+ * its unit.
9
+ *
10
+ * @param options - Binary, arguments, environment, working directory, where the
11
+ * output goes, the session's groups and whether the unit comes through a
12
+ * pipe.
13
+ * @param options.output - `pipe` to read stdout and stderr, else `ignore`.
14
+ * @param options.groups - Process groups of the session's test processes.
15
+ * @param options.env - Environment variables of the process.
16
+ * @param options.args - Arguments after the Node binary.
17
+ * @param options.pipe - Whether the process gets file descriptor 3.
18
+ * @param options.node - Node binary.
19
+ * @param options.cwd - Working directory of the process.
20
+ * @returns The child process, which may still be starting.
21
+ */
22
+ export declare function startTestProcess(options: {
23
+ output: 'ignore' | 'pipe';
24
+ env: NodeJS.ProcessEnv;
25
+ groups: Set<number>;
26
+ args: string[];
27
+ pipe: boolean;
28
+ node: string;
29
+ cwd: string;
30
+ }): ChildProcess;
@@ -0,0 +1,27 @@
1
+ import { trackProcessGroup as e } from "../shared/track-process-group.js";
2
+ import { spawn as t } from "node:child_process";
3
+ function n(n) {
4
+ let { output: r, groups: i } = n, a = [
5
+ "ignore",
6
+ r,
7
+ r
8
+ ];
9
+ n.pipe && a.push("pipe");
10
+ let o = t(n.node, n.args, {
11
+ windowsHide: !0,
12
+ cwd: n.cwd,
13
+ env: n.env,
14
+ detached: !0,
15
+ stdio: a
16
+ }), { pid: s } = o;
17
+ if (s !== void 0) {
18
+ let t = e(s);
19
+ i.add(s);
20
+ function n() {
21
+ t(), i.delete(s);
22
+ }
23
+ o.once("exit", n), o.once("error", n);
24
+ }
25
+ return o;
26
+ }
27
+ export { n as startTestProcess };
@@ -20,7 +20,8 @@ export interface NodeTestHandle {
20
20
  context: AdapterContext
21
21
 
22
22
  /**
23
- * Environment variables of every test process, before `MOOTANT_UNIT`.
23
+ * Environment variables of every test process, before `MOOTANT_UNIT` or
24
+ * `MOOTANT_UNIT_FD`.
24
25
  */
25
26
  env: NodeJS.ProcessEnv
26
27
 
@@ -64,6 +65,12 @@ export interface NodeTestHandle {
64
65
  */
65
66
  workers: number
66
67
 
68
+ /**
69
+ * Most spare test processes of an isolated run at once
70
+ * (`createSpareProcesses`), or 0 for none.
71
+ */
72
+ spares: number
73
+
67
74
  /**
68
75
  * Flags of every test process before its test file: mootant's preload first,
69
76
  * unless `NODE_OPTIONS` loads modules and carries it, then the command's
@@ -71,6 +78,12 @@ export interface NodeTestHandle {
71
78
  */
72
79
  args: string[]
73
80
 
81
+ /**
82
+ * Whether test processes get their unit as a line on file descriptor 3 rather
83
+ * than in `MOOTANT_UNIT`; not on Windows.
84
+ */
85
+ pipe: boolean
86
+
74
87
  /**
75
88
  * Whether the test processes load tsx, so `tsconfig.json` files decide how
76
89
  * modules compile.
@@ -174,7 +174,7 @@ export interface NodeTestEnd {
174
174
  concurrent: boolean
175
175
 
176
176
  /**
177
- * Project files and directories the code read and changed itself, sorted.
177
+ * Files and directories among `files` that the code changed itself, sorted.
178
178
  */
179
179
  modified: string[]
180
180
 
@@ -194,8 +194,8 @@ export interface NodeTestEnd {
194
194
  reached: boolean
195
195
 
196
196
  /**
197
- * Project files and directories the code read through `node:fs`, a missing
198
- * one included, sorted.
197
+ * Files and directories the code read through `node:fs` that count as inputs
198
+ * (`createInputFilter`), a missing one included, sorted.
199
199
  */
200
200
  files: string[]
201
201
 
@@ -34,6 +34,11 @@ export interface NodeTestUnit {
34
34
  */
35
35
  commonjs: boolean
36
36
 
37
+ /**
38
+ * Work directory of the run, whose files never count as inputs.
39
+ */
40
+ directory: string
41
+
37
42
  /**
38
43
  * Whether the unit stops starting tests once a test failed after the mutant
39
44
  * was reached. False in a dry run.
@@ -46,7 +51,7 @@ export interface NodeTestUnit {
46
51
  plan: string
47
52
 
48
53
  /**
49
- * Project root; files the test code reads count as inputs only inside it.
54
+ * Project root; reads outside it count too (`createInputFilter`).
50
55
  */
51
56
  root: string
52
57