mootant 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (313) hide show
  1. package/bin/mootant.js +3 -2
  2. package/dist/adapters/jest/collect-jest-dependencies.d.ts +8 -6
  3. package/dist/adapters/jest/collect-jest-dependencies.js +20 -14
  4. package/dist/adapters/jest/get-jest-cache-inputs.d.ts +14 -13
  5. package/dist/adapters/jest/index.d.ts +3 -1
  6. package/dist/adapters/jest/run-dry.js +20 -20
  7. package/dist/adapters/jest/start-jest-session.d.ts +6 -2
  8. package/dist/adapters/jest/start-jest-session.js +9 -2
  9. package/dist/adapters/jest/types/jest-handle.d.ts +2 -1
  10. package/dist/adapters/jest/types/jest-record.d.ts +4 -3
  11. package/dist/adapters/jest/types/worker-channel.d.ts +7 -0
  12. package/dist/adapters/jest/worker/boot-worker.d.ts +5 -4
  13. package/dist/adapters/jest/worker/create-test-runner.d.ts +4 -1
  14. package/dist/adapters/jest/worker/keep-reset-loads.d.ts +13 -0
  15. package/dist/adapters/jest/worker/list-runtime-files.d.ts +13 -0
  16. package/dist/adapters/jest/worker/run-unit.d.ts +25 -20
  17. package/dist/adapters/jest/worker/vm-setup.js +1 -1
  18. package/dist/adapters/jest/worker/worker.js +1 -1
  19. package/dist/adapters/node-test/check-typescript.js +2 -2
  20. package/dist/adapters/node-test/collect-node-dependencies.d.ts +7 -5
  21. package/dist/adapters/node-test/collect-node-dependencies.js +26 -20
  22. package/dist/adapters/node-test/create-spare-processes.d.ts +26 -0
  23. package/dist/adapters/node-test/create-spare-processes.js +53 -0
  24. package/dist/adapters/node-test/filter-exec-argv.d.ts +2 -1
  25. package/dist/adapters/node-test/filter-exec-argv.js +13 -12
  26. package/dist/adapters/node-test/get-node-cache-inputs.js +1 -1
  27. package/dist/adapters/node-test/get-unit-deadline.d.ts +6 -5
  28. package/dist/adapters/node-test/index.d.ts +2 -2
  29. package/dist/adapters/node-test/index.js +1 -0
  30. package/dist/adapters/node-test/is-group-alive.d.ts +8 -0
  31. package/dist/adapters/node-test/is-group-alive.js +8 -0
  32. package/dist/adapters/node-test/list-setup-files.js +2 -2
  33. package/dist/adapters/node-test/place-preload.d.ts +2 -1
  34. package/dist/adapters/node-test/place-preload.js +24 -18
  35. package/dist/adapters/node-test/preload/create-commonjs-route.js +1 -1
  36. package/dist/adapters/node-test/preload/preload.js +54 -52
  37. package/dist/adapters/node-test/preload/read-line-sync.d.ts +11 -0
  38. package/dist/adapters/node-test/preload/read-line-sync.js +25 -0
  39. package/dist/adapters/node-test/preload/read-unit.d.ts +11 -5
  40. package/dist/adapters/node-test/preload/read-unit.js +5 -4
  41. package/dist/adapters/node-test/run-isolated.d.ts +19 -10
  42. package/dist/adapters/node-test/run-isolated.js +68 -52
  43. package/dist/adapters/node-test/run-test-file.d.ts +12 -4
  44. package/dist/adapters/node-test/run-test-file.js +18 -14
  45. package/dist/adapters/node-test/run-test-process.d.ts +30 -13
  46. package/dist/adapters/node-test/run-test-process.js +38 -40
  47. package/dist/adapters/node-test/start-node-test-session.d.ts +10 -2
  48. package/dist/adapters/node-test/start-node-test-session.js +90 -84
  49. package/dist/adapters/node-test/start-test-process.d.ts +30 -0
  50. package/dist/adapters/node-test/start-test-process.js +27 -0
  51. package/dist/adapters/node-test/types/node-test-handle.d.ts +14 -1
  52. package/dist/adapters/node-test/types/process-watch.d.ts +4 -3
  53. package/dist/adapters/node-test/types/spare-processes.d.ts +20 -0
  54. package/dist/adapters/node-test/types/test-process-outcome.d.ts +8 -1
  55. package/dist/adapters/shared/allows-spares.d.ts +11 -0
  56. package/dist/adapters/shared/allows-spares.js +23 -0
  57. package/dist/adapters/shared/create-environment-proxy.d.ts +4 -3
  58. package/dist/adapters/shared/create-input-filter.d.ts +17 -14
  59. package/dist/adapters/shared/create-input-filter.js +2 -2
  60. package/dist/adapters/shared/enable-compile-cache.d.ts +32 -0
  61. package/dist/adapters/shared/enable-compile-cache.js +7 -0
  62. package/dist/adapters/shared/find-tsconfig-property.d.ts +13 -0
  63. package/dist/adapters/shared/find-tsconfig-property.js +6 -0
  64. package/dist/adapters/shared/get-spare-limit.d.ts +10 -0
  65. package/dist/adapters/shared/get-spare-limit.js +5 -0
  66. package/dist/adapters/shared/index-environment-hashes.d.ts +2 -2
  67. package/dist/adapters/shared/index-environment-hashes.js +5 -13
  68. package/dist/adapters/{node-test → shared}/list-flag-values.d.ts +2 -1
  69. package/dist/adapters/shared/list-flag-values.js +10 -0
  70. package/dist/adapters/shared/list-tsconfig-files.d.ts +14 -5
  71. package/dist/adapters/shared/list-tsconfig-files.js +15 -13
  72. package/dist/adapters/shared/parse-tsconfig.d.ts +10 -0
  73. package/dist/adapters/shared/parse-tsconfig.js +19 -0
  74. package/dist/adapters/shared/read-flag-name.d.ts +9 -0
  75. package/dist/adapters/shared/read-flag-name.js +5 -0
  76. package/dist/adapters/shared/read-node-options.d.ts +11 -0
  77. package/dist/adapters/shared/read-node-options.js +6 -0
  78. package/dist/adapters/shared/read-prefork-switch.d.ts +10 -0
  79. package/dist/adapters/shared/read-prefork-switch.js +5 -0
  80. package/dist/adapters/shared/read-tsconfig-extends.d.ts +2 -5
  81. package/dist/adapters/shared/read-tsconfig-extends.js +16 -31
  82. package/dist/adapters/shared/read-tsconfig-references.d.ts +12 -0
  83. package/dist/adapters/shared/read-tsconfig-references.js +13 -0
  84. package/dist/adapters/shared/track-file-reads.d.ts +13 -12
  85. package/dist/adapters/shared/track-file-reads.js +71 -71
  86. package/dist/adapters/shared/track-process-group.d.ts +2 -1
  87. package/dist/adapters/shared/track-process-group.js +7 -2
  88. package/dist/adapters/vitest/build-isolated-facts.d.ts +4 -3
  89. package/dist/adapters/vitest/collect-dependencies.d.ts +11 -5
  90. package/dist/adapters/vitest/collect-dependencies.js +36 -27
  91. package/dist/adapters/vitest/configure-project.d.ts +3 -2
  92. package/dist/adapters/vitest/configure-project.js +1 -1
  93. package/dist/adapters/vitest/create-forks-pool.d.ts +34 -7
  94. package/dist/adapters/vitest/create-forks-pool.js +102 -24
  95. package/dist/adapters/vitest/create-interleaved-sequencer.d.ts +3 -2
  96. package/dist/adapters/vitest/drop-signal-listeners.d.ts +14 -0
  97. package/dist/adapters/vitest/drop-signal-listeners.js +15 -0
  98. package/dist/adapters/vitest/get-cache-inputs.d.ts +3 -1
  99. package/dist/adapters/vitest/get-cache-inputs.js +43 -28
  100. package/dist/adapters/vitest/get-module-file.d.ts +3 -5
  101. package/dist/adapters/vitest/get-module-file.js +1 -1
  102. package/dist/adapters/vitest/get-spare-key.d.ts +15 -0
  103. package/dist/adapters/vitest/get-spare-key.js +15 -0
  104. package/dist/adapters/vitest/index.d.ts +2 -1
  105. package/dist/adapters/vitest/index.js +1 -0
  106. package/dist/adapters/vitest/is-virtual-module.d.ts +1 -2
  107. package/dist/adapters/vitest/is-virtual-module.js +1 -1
  108. package/dist/adapters/vitest/list-script-defines.d.ts +13 -0
  109. package/dist/adapters/vitest/list-script-defines.js +22 -0
  110. package/dist/adapters/vitest/read-unit-inputs.d.ts +2 -1
  111. package/dist/adapters/vitest/run-dry.js +1 -1
  112. package/dist/adapters/vitest/run-plan.d.ts +10 -8
  113. package/dist/adapters/vitest/run-plan.js +1 -1
  114. package/dist/adapters/vitest/run-specifications.d.ts +9 -2
  115. package/dist/adapters/vitest/run-specifications.js +22 -12
  116. package/dist/adapters/vitest/runner.d.ts +60 -29
  117. package/dist/adapters/vitest/runner.js +109 -86
  118. package/dist/adapters/vitest/start-vitest-session.d.ts +5 -1
  119. package/dist/adapters/vitest/start-vitest-session.js +64 -59
  120. package/dist/adapters/vitest/stop-hung-worker.d.ts +11 -4
  121. package/dist/adapters/vitest/stop-hung-worker.js +20 -7
  122. package/dist/adapters/vitest/types/mootant-forks-pool.d.ts +47 -0
  123. package/dist/adapters/vitest/types/vitest-session-state.d.ts +9 -8
  124. package/dist/adapters/vitest/types/vitest-worker.d.ts +48 -33
  125. package/dist/adapters/vitest/wait-for-workers.d.ts +5 -2
  126. package/dist/adapters/vitest/wait-for-workers.js +15 -15
  127. package/dist/adapters/vitest/worker/track-meta-defines.d.ts +39 -0
  128. package/dist/adapters/vitest/worker/track-meta-defines.js +23 -0
  129. package/dist/adapters/vitest/worker/track-values.d.ts +38 -0
  130. package/dist/adapters/vitest/worker/track-values.js +45 -0
  131. package/dist/adapters/vitest/worker/value-prefixes.d.ts +12 -0
  132. package/dist/adapters/vitest/worker/value-prefixes.js +6 -0
  133. package/dist/adapters/vitest/worker/wait-for-turn.d.ts +8 -6
  134. package/dist/adapters/vitest/worker/watch-property.d.ts +17 -0
  135. package/dist/adapters/vitest/worker/watch-property.js +27 -0
  136. package/dist/cli/create-run-progress.d.ts +8 -1
  137. package/dist/cli/create-run-progress.js +4 -1
  138. package/dist/cli/ensure-exit.d.ts +11 -0
  139. package/dist/cli/ensure-exit.js +15 -0
  140. package/dist/cli/html/build-html-report.js +1 -0
  141. package/dist/cli/html/client/main.js +1 -1
  142. package/dist/cli/html/client/render-overview.d.ts +3 -3
  143. package/dist/cli/index.d.ts +1 -0
  144. package/dist/cli/index.js +3 -2
  145. package/dist/cli/parse-arguments.d.ts +4 -0
  146. package/dist/cli/parse-arguments.js +4 -1
  147. package/dist/cli/report/build-run-report.js +1 -0
  148. package/dist/cli/report/format-command.d.ts +5 -0
  149. package/dist/cli/report/format-command.js +1 -1
  150. package/dist/cli/report/format-run-text-report.d.ts +5 -4
  151. package/dist/cli/report/format-run-text-report.js +10 -10
  152. package/dist/cli/report/slim-run-report.d.ts +10 -10
  153. package/dist/cli/report/slim-run-report.js +1 -0
  154. package/dist/cli/run-mutation.d.ts +5 -1
  155. package/dist/cli/run-mutation.js +32 -24
  156. package/dist/cli/terminal/create-spinner.d.ts +1 -2
  157. package/dist/cli/terminal/create-spinner.js +23 -32
  158. package/dist/cli/watch-interrupts.d.ts +41 -0
  159. package/dist/cli/watch-interrupts.js +32 -0
  160. package/dist/core/cache/apply-cached-units.d.ts +8 -7
  161. package/dist/core/cache/build-hash.d.ts +9 -0
  162. package/dist/core/cache/build-hash.js +2 -0
  163. package/dist/core/cache/cache-version.d.ts +4 -4
  164. package/dist/core/cache/check-dry-snapshot.d.ts +25 -0
  165. package/dist/core/cache/check-dry-snapshot.js +13 -0
  166. package/dist/core/cache/create-dry-reuse-miss.d.ts +12 -0
  167. package/dist/core/cache/create-dry-reuse-miss.js +7 -0
  168. package/dist/core/cache/create-dry-snapshot.d.ts +71 -0
  169. package/dist/core/cache/create-dry-snapshot.js +27 -0
  170. package/dist/core/cache/create-run-cache.d.ts +20 -2
  171. package/dist/core/cache/create-run-cache.js +31 -22
  172. package/dist/core/cache/create-snapshot-session.d.ts +12 -0
  173. package/dist/core/cache/create-snapshot-session.js +19 -0
  174. package/dist/core/cache/get-build-id.d.ts +11 -0
  175. package/dist/core/cache/get-build-id.js +7 -0
  176. package/dist/core/cache/get-cache-path.d.ts +1 -1
  177. package/dist/core/cache/get-cache-path.js +1 -1
  178. package/dist/core/cache/get-dry-snapshot-key.d.ts +47 -0
  179. package/dist/core/cache/get-dry-snapshot-key.js +43 -0
  180. package/dist/core/cache/get-dry-snapshot-path.d.ts +9 -0
  181. package/dist/core/cache/get-dry-snapshot-path.js +5 -0
  182. package/dist/core/cache/get-environment-key.d.ts +9 -4
  183. package/dist/core/cache/get-environment-key.js +3 -2
  184. package/dist/core/cache/get-test-file-keys.d.ts +2 -1
  185. package/dist/core/cache/get-test-file-keys.js +11 -10
  186. package/dist/core/cache/hash-files.d.ts +8 -7
  187. package/dist/core/cache/hash-files.js +17 -11
  188. package/dist/core/cache/hash-project-tree.d.ts +22 -0
  189. package/dist/core/cache/hash-project-tree.js +69 -0
  190. package/dist/core/cache/is-dry-reuse-miss.d.ts +8 -0
  191. package/dist/core/cache/is-dry-reuse-miss.js +4 -0
  192. package/dist/core/cache/list-file-hashes.d.ts +4 -0
  193. package/dist/core/cache/list-file-hashes.js +5 -2
  194. package/dist/core/cache/list-install-states.d.ts +12 -0
  195. package/dist/core/cache/list-install-states.js +19 -0
  196. package/dist/core/cache/list-variable-hashes.d.ts +15 -0
  197. package/dist/core/cache/list-variable-hashes.js +14 -0
  198. package/dist/core/cache/prepare-run-cache.d.ts +48 -22
  199. package/dist/core/cache/prepare-run-cache.js +86 -73
  200. package/dist/core/cache/read-dry-snapshot.d.ts +10 -0
  201. package/dist/core/cache/read-dry-snapshot.js +15 -0
  202. package/dist/core/cache/read-run-cache.js +6 -2
  203. package/dist/core/cache/save-dry-snapshot.d.ts +34 -0
  204. package/dist/core/cache/save-dry-snapshot.js +32 -0
  205. package/dist/core/cache/volatile-variables.d.ts +7 -0
  206. package/dist/core/cache/volatile-variables.js +11 -0
  207. package/dist/core/cache/write-run-cache.js +1 -1
  208. package/dist/core/config/load-typescript-config.d.ts +6 -1
  209. package/dist/core/config/load-typescript-config.js +26 -10
  210. package/dist/core/config/prepare-run.d.ts +7 -3
  211. package/dist/core/config/prepare-run.js +1 -0
  212. package/dist/core/config/resolve-run-settings.d.ts +3 -2
  213. package/dist/core/config/resolve-run-settings.js +1 -0
  214. package/dist/core/config/validate-config.js +3 -2
  215. package/dist/core/files/get-package-manifest.d.ts +12 -0
  216. package/dist/core/files/get-package-manifest.js +7 -0
  217. package/dist/core/generate/collect-candidates.d.ts +5 -1
  218. package/dist/core/generate/collect-candidates.js +125 -97
  219. package/dist/core/generate/generate-file-mutants.js +6 -5
  220. package/dist/core/index.d.ts +18 -0
  221. package/dist/core/mutators/shared/get-branch-copy-skip.d.ts +2 -2
  222. package/dist/core/mutators/shared/get-comparison-plan.d.ts +2 -2
  223. package/dist/core/mutators/shared/get-default-option-skip.d.ts +2 -2
  224. package/dist/core/mutators/shared/get-group-constant.d.ts +2 -2
  225. package/dist/core/mutators/shared/get-literal-skip.d.ts +3 -3
  226. package/dist/core/mutators/shared/get-loop-running-skip.d.ts +2 -2
  227. package/dist/core/mutators/shared/get-nullish-swap-skip.d.ts +2 -2
  228. package/dist/core/mutators/shared/get-or-default-skip.d.ts +2 -2
  229. package/dist/core/mutators/shared/get-owned-constants.d.ts +2 -2
  230. package/dist/core/mutators/shared/leave-now-skip.d.ts +2 -2
  231. package/dist/core/mutators/shared/no-op-callback-skip.d.ts +2 -2
  232. package/dist/core/plugins/create-mutator-registry.d.ts +4 -2
  233. package/dist/core/plugins/create-mutator-registry.js +15 -5
  234. package/dist/core/plugins/validate-plugin.d.ts +3 -3
  235. package/dist/core/plugins/validate-plugin.js +32 -10
  236. package/dist/core/regex/collect-pattern-changes.d.ts +2 -2
  237. package/dist/core/regex/create-regex-replacement.d.ts +2 -2
  238. package/dist/core/run/apply-isolated-result.d.ts +22 -14
  239. package/dist/core/run/apply-isolated-result.js +45 -26
  240. package/dist/core/run/count-run.d.ts +2 -1
  241. package/dist/core/run/create-run-state.d.ts +5 -0
  242. package/dist/core/run/create-run-state.js +1 -0
  243. package/dist/core/run/create-work-directory.d.ts +4 -1
  244. package/dist/core/run/create-work-directory.js +15 -12
  245. package/dist/core/run/decide-evidence.d.ts +4 -3
  246. package/dist/core/run/get-unit-evidence.d.ts +13 -7
  247. package/dist/core/run/get-unit-evidence.js +1 -1
  248. package/dist/core/run/guard-session.d.ts +18 -0
  249. package/dist/core/run/guard-session.js +30 -0
  250. package/dist/core/run/live-work-directories.d.ts +5 -0
  251. package/dist/core/run/live-work-directories.js +2 -0
  252. package/dist/core/run/read-isolated-unit.d.ts +6 -3
  253. package/dist/core/run/read-isolated-unit.js +77 -38
  254. package/dist/core/run/remove-live-work-directories.d.ts +7 -0
  255. package/dist/core/run/remove-live-work-directories.js +12 -0
  256. package/dist/core/run/run-isolated-rounds.d.ts +16 -12
  257. package/dist/core/run/run-isolated-rounds.js +3 -2
  258. package/dist/core/run/validate-adapter.d.ts +1 -1
  259. package/dist/core/run/validate-adapter.js +1 -1
  260. package/dist/core/run-mutants.d.ts +34 -2
  261. package/dist/core/run-mutants.js +356 -216
  262. package/dist/core/skips/skip-rules.d.ts +3 -1
  263. package/dist/package.js +1 -1
  264. package/dist/types/adapter/adapter-context.d.ts +20 -0
  265. package/dist/types/adapter/adapter-session.d.ts +2 -1
  266. package/dist/types/adapter/cache-inputs.d.ts +3 -2
  267. package/dist/types/adapter/dry-file.d.ts +4 -2
  268. package/dist/types/adapter/isolated-plan.d.ts +2 -1
  269. package/dist/types/adapter/isolated-result.d.ts +3 -1
  270. package/dist/types/adapter/run-inputs.d.ts +5 -4
  271. package/dist/types/adapter/test-adapter.d.ts +7 -0
  272. package/dist/types/cache/cache-entry.d.ts +9 -7
  273. package/dist/types/cache/cached-inputs.d.ts +2 -2
  274. package/dist/types/cache/dry-snapshot.d.ts +76 -0
  275. package/dist/types/cache/project-tree.d.ts +16 -0
  276. package/dist/types/cache/run-cache-file.d.ts +1 -1
  277. package/dist/types/cache/run-cache.d.ts +6 -5
  278. package/dist/types/config/plugin.d.ts +11 -2
  279. package/dist/types/config/run-config.d.ts +10 -0
  280. package/dist/types/config/run-settings.d.ts +6 -0
  281. package/dist/types/mutant/core-note.d.ts +12 -0
  282. package/dist/types/mutant/diagnostic.d.ts +1 -0
  283. package/dist/types/mutant/registered-skip-rule.d.ts +11 -0
  284. package/dist/types/mutant/skip-note.d.ts +7 -6
  285. package/dist/types/mutant/skip-rule-id.d.ts +3 -2
  286. package/dist/types/mutant/skip-rule.d.ts +2 -1
  287. package/dist/types/mutant/skipped-candidate.d.ts +14 -7
  288. package/dist/types/mutant/skipped-mutant.d.ts +6 -6
  289. package/dist/types/mutator/mutator.d.ts +3 -2
  290. package/dist/types/mutator/registered-mutator.d.ts +8 -0
  291. package/dist/types/regex/regex-change.d.ts +2 -2
  292. package/dist/types/report/html-report.d.ts +3 -2
  293. package/dist/types/report/list-report-skipped.d.ts +3 -2
  294. package/dist/types/report/run-report.d.ts +11 -2
  295. package/dist/types/report/slim-run-report.d.ts +1 -1
  296. package/dist/types/run/isolated-evidence.d.ts +3 -2
  297. package/dist/types/run/isolated-reason.d.ts +2 -1
  298. package/dist/types/run/run-durations.d.ts +8 -3
  299. package/dist/types/run/run-event.d.ts +10 -7
  300. package/dist/types/run/run-result.d.ts +11 -2
  301. package/dist/types/run/run-state.d.ts +21 -0
  302. package/dist/types/run/try-cause.d.ts +2 -1
  303. package/package.json +1 -1
  304. package/readme.md +85 -68
  305. package/skills/mootant/SKILL.md +36 -19
  306. package/skills/mootant/references/mutators.md +29 -23
  307. package/dist/adapters/node-test/list-flag-values.js +0 -9
  308. /package/dist/adapters/{node-test → shared}/loader-flags.d.ts +0 -0
  309. /package/dist/adapters/{node-test → shared}/loader-flags.js +0 -0
  310. /package/dist/{adapters/shared → core/files}/list-package-files.d.ts +0 -0
  311. /package/dist/{adapters/shared → core/files}/list-package-files.js +0 -0
  312. /package/dist/{adapters/shared → core/files}/read-package-type.d.ts +0 -0
  313. /package/dist/{adapters/shared → core/files}/read-package-type.js +0 -0
@@ -1,70 +1,109 @@
1
- import { classifyTry as e } from "./classify-try.js";
2
- function t(t, n, r) {
3
- let { request: i, facts: a, unit: o } = r, { analysis: s } = t, c = a.tests.filter((e) => e.failed || e.timedOut), [l] = c;
4
- if (a.hits > o.limits.hitLimit) {
5
- let [e] = c.toSorted((e, t) => t.hits - e.hits);
1
+ import { getTestFileKey as e } from "./get-test-file-key.js";
2
+ import { getDisplayPath as t } from "./get-display-path.js";
3
+ import { pluralize as n } from "../text/pluralize.js";
4
+ import { classifyTry as r } from "./classify-try.js";
5
+ function i(e, t, n) {
6
+ let { request: i, facts: o, unit: s } = n, { analysis: c } = e, l = o.tests.filter((e) => e.failed || e.timedOut), [u] = l;
7
+ if (o.hits > s.limits.hitLimit) {
8
+ let [e] = l.toSorted((e, t) => t.hits - e.hits);
6
9
  return {
7
- message: e?.message ?? a.loadError ?? a.hookError,
10
+ message: e?.message ?? o.loadError ?? o.hookError,
8
11
  test: e?.test ?? null,
9
12
  cause: "hit-limit",
10
13
  status: "Timeout",
11
- file: o.file
14
+ file: s.file
12
15
  };
13
16
  }
14
- if (a.incomplete === "hang") return {
17
+ if (o.incomplete === "hang") return {
15
18
  status: "Timeout",
16
- file: o.file,
19
+ file: s.file,
17
20
  message: null,
18
21
  cause: "hang",
19
22
  test: null
20
23
  };
21
- if (a.incomplete === "crash") return {
22
- test: l?.test ?? null,
24
+ if (o.incomplete === "crash") return {
25
+ test: u?.test ?? null,
23
26
  status: "Killed",
24
- file: o.file,
27
+ file: s.file,
25
28
  cause: "crash",
26
29
  message: null
27
30
  };
28
- let u = n.static && a.reached;
29
- for (let t of a.tests) {
30
- u ||= t.reached;
31
- let n = s.strayTests.has(t.test) ? [] : t.strays, { outcome: r, cause: i } = e({
32
- ...t,
33
- reached: u,
34
- strays: n
35
- }, o.limits, "isolated");
36
- if (r === "killed" || r === "timeout") return {
37
- message: i === "stray-error" ? n[0] : t.message,
38
- status: r === "killed" ? "Killed" : "Timeout",
39
- file: o.file,
40
- test: t.test,
31
+ let d = t.static && o.reached;
32
+ for (let e of o.tests) {
33
+ d ||= e.reached;
34
+ let t = c.strayTests.has(e.test) ? [] : e.strays, { outcome: n, cause: i } = r({
35
+ ...e,
36
+ reached: d,
37
+ strays: t
38
+ }, s.limits, "isolated");
39
+ if (n === "killed" || n === "timeout") return {
40
+ message: i === "stray-error" ? t[0] : e.message,
41
+ status: n === "killed" ? "Killed" : "Timeout",
42
+ file: s.file,
43
+ test: e.test,
41
44
  cause: i
42
45
  };
43
46
  }
44
- return a.timedOut ? a.reached ? {
45
- message: a.hookError,
47
+ return o.timedOut ? o.reached ? {
48
+ message: o.hookError,
46
49
  cause: "time-limit",
47
50
  status: "Timeout",
48
- file: o.file,
51
+ file: s.file,
49
52
  test: null
50
- } : null : a.loadError === null ? a.reached && a.hookError !== null ? {
51
- message: a.hookError,
53
+ } : a(e, t, n) : o.loadError === null ? o.reached && o.hookError !== null ? {
54
+ message: o.hookError,
52
55
  cause: "hook-error",
53
56
  status: "Killed",
54
- file: o.file,
57
+ file: s.file,
55
58
  test: null
56
- } : a.reached && a.strays.length > 0 && !s.strayFiles.has(i.file) ? {
57
- message: a.strays[0],
59
+ } : o.reached && o.strays.length > 0 && !c.strayFiles.has(i.file) ? {
60
+ message: o.strays[0],
58
61
  cause: "stray-error",
59
62
  status: "Killed",
60
- file: o.file,
63
+ file: s.file,
61
64
  test: null
62
- } : a.reached ? "survived" : null : {
63
- message: a.loadError,
65
+ } : a(e, t, n) : {
66
+ message: o.loadError,
64
67
  cause: "load-error",
65
68
  status: "Killed",
66
- file: o.file,
69
+ file: s.file,
67
70
  test: null
68
71
  };
69
72
  }
70
- export { t as readIsolatedUnit };
73
+ function a(t, n, r) {
74
+ let { request: i, facts: a, unit: s } = r, { analysis: c } = t, l = a.tests.filter((e) => e.failed || e.timedOut), u = a.hookError ?? (a.strays.length > 0 && !c.strayFiles.has(i.file) ? a.strays[0] : null);
75
+ if (u !== null || l.length > 0) {
76
+ let r = a.tests.filter((e) => !e.failed && !e.timedOut), d = new Set(r.map((e) => e.test)), f = new Set(a.tests.map((e) => e.test)), p = r.some((e) => !c.tests.has(e.test)), m = n.coveredBy.filter((t) => !d.has(t) && (!p || f.has(t)) && e(c.tests.get(t)) === i.file);
77
+ if (m.length > 0) return {
78
+ message: o(t, s.file, {
79
+ stopped: l,
80
+ outside: u,
81
+ missed: m
82
+ }),
83
+ status: "Error",
84
+ cause: null,
85
+ file: null,
86
+ test: null
87
+ };
88
+ }
89
+ return a.reached ? "survived" : null;
90
+ }
91
+ function o(e, r, i) {
92
+ let a = t(r, e.root), o = i.stopped.find((e) => i.missed.includes(e.test));
93
+ if (o !== void 0) {
94
+ let [t, n] = s(o);
95
+ return `"${c(e, o.test)}" in ${a} ${t} before it reached this mutant${n}`;
96
+ }
97
+ let l = i.missed.length, u = `${n(l, "test")} in ${a} that ${l === 1 ? "reaches" : "reach"} this mutant did not run`;
98
+ if (i.outside !== null) return `${u}: ${i.outside}`;
99
+ let d = i.stopped[0], [f, p] = s(d);
100
+ return `${u} after "${c(e, d.test)}" ${f}${p}`;
101
+ }
102
+ function s(e) {
103
+ let t = e.message === null ? "." : `: ${e.message}`;
104
+ return e.timedOut ? [e.message === null ? "ran past the time limit of its test file" : "ran out of time", t] : ["failed", t];
105
+ }
106
+ function c(e, t) {
107
+ return e.analysis.tests.get(t)?.name ?? t;
108
+ }
109
+ export { i as readIsolatedUnit };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Removes the work directories of runs of this process that are not removed
3
+ * yet, at once and with everything in them, and forgets them, as the last
4
+ * cleanup before the process ends: a directory that cannot be removed is left
5
+ * as it is, so the process still ends.
6
+ */
7
+ export declare function removeLiveWorkDirectories(): void;
@@ -0,0 +1,12 @@
1
+ import { LIVE_WORK_DIRECTORIES as e } from "./live-work-directories.js";
2
+ import { rmSync as t } from "node:fs";
3
+ function n() {
4
+ for (let n of e) try {
5
+ t(n, {
6
+ recursive: !0,
7
+ force: !0
8
+ });
9
+ } catch {}
10
+ e.clear();
11
+ }
12
+ export { n as removeLiveWorkDirectories };
@@ -8,18 +8,22 @@ import { AdapterSession } from '../../types/adapter/adapter-session.js';
8
8
  * and the second round, then twice as many as in the round before (2, 4, 8, and
9
9
  * so on), so a mutant stops at the batch of the file that killed it, and a
10
10
  * survivor, which must run every file, needs only a few rounds. Idle workers
11
- * take no extra files: a unit can wait for another of its test file, and the
12
- * pool runs units in order, so extra files may make a round longer, and
13
- * measurements showed no gain. A mutant whose timeout waits for its
14
- * confirmation takes no new files until the confirmation decides it. The
15
- * verdict comes from the first file with evidence (`decideEvidence`), so it
16
- * does not depend on the batches or the workers. A round also runs the retries
17
- * and confirmations of the round before. A request lives at most six rounds, as
18
- * a unit missing twice gets an `Error` verdict and a timeout is confirmed once,
19
- * or twice when the confirmation of a timer goes over the hit limit, so the
20
- * rounds end. While a round runs, its units count in the live verdict counts as
21
- * they end (`previewIsolatedUnit`), and every mutant is counted again once its
22
- * result is recorded (`countVerdicts`).
11
+ * take no extra files: without parallel units a unit can wait for another of
12
+ * its test file, and the pool runs units in order, so extra files may make a
13
+ * round longer, and measurements showed no gain. A mutant whose timeout waits
14
+ * for its confirmation, or whose crash waits for one more run of its unit,
15
+ * takes no new files until that run decides it. The verdict comes from the
16
+ * first file with evidence (`decideEvidence`), so it does not depend on the
17
+ * batches or the workers. A round also runs the retries and confirmations of
18
+ * the round before. A request lives at most eight rounds, as a unit missing
19
+ * twice gets an `Error` verdict, and so does a second inconclusive unit of the
20
+ * mutant in the test file, a second crash of it kills, and a timeout is
21
+ * confirmed once, or twice when the confirmation of a timer goes over the hit
22
+ * limit, so the rounds end. While a round runs, its units count in the live
23
+ * verdict counts as they end (`previewIsolatedUnit`), and every mutant is
24
+ * counted again once its result is recorded (`countVerdicts`). With parallel
25
+ * units (`RunState.parallelUnits`) the units of one test file form no serial
26
+ * chain in the estimate of a round.
23
27
  *
24
28
  * @param session - Live test runner.
25
29
  * @param state - State of the run, updated in place.
@@ -15,6 +15,7 @@ async function s(o, s, c) {
15
15
  for (let [e, t] of m) for (let n of t) d.push({
16
16
  mutant: e.mutant.id,
17
17
  confirming: !1,
18
+ crashed: !1,
18
19
  retried: !1,
19
20
  raised: !1,
20
21
  file: n
@@ -25,12 +26,12 @@ async function s(o, s, c) {
25
26
  survivors: /* @__PURE__ */ new Set(),
26
27
  retrying: /* @__PURE__ */ new Set()
27
28
  };
28
- for (let e of d) e.confirming ? _.confirming.add(e.mutant) : e.retried ? _.retrying.add(e.mutant) : u > 0 && _.survivors.add(e.mutant);
29
+ for (let e of d) e.confirming ? _.confirming.add(e.mutant) : e.retried || e.crashed || e.inconclusive === !0 ? _.retrying.add(e.mutant) : u > 0 && _.survivors.add(e.mutant);
29
30
  for (let e of _.confirming) _.retrying.delete(e);
30
31
  for (let e of [..._.confirming, ..._.retrying]) _.survivors.delete(e);
31
32
  a(s, "isolated", {
32
33
  costs: d.map((e, t) => e.confirming ? h.units[t].limits.timeout : i(s, e.file)),
33
- chains: n(d.map((e) => e.file)),
34
+ chains: s.parallelUnits === !0 ? d.map((e, t) => t) : n(d.map((e) => e.file)),
34
35
  confirming: _.confirming.size,
35
36
  survivors: _.survivors.size,
36
37
  retrying: _.retrying.size,
@@ -2,7 +2,7 @@ import { TestAdapter } from '../../types/adapter/test-adapter.js';
2
2
  /**
3
3
  * Checks the shape of a test runner adapter given in the configuration: an
4
4
  * object with a kebab-case `name`, a boolean `batch`, a `start` function and,
5
- * when present, a string `version`.
5
+ * when present, a string `version` and a boolean `parallelUnits`.
6
6
  *
7
7
  * @param value - Adapter object of the configuration.
8
8
  * @param source - Where it came from, for messages, such as `run.runner`.
@@ -6,6 +6,6 @@ function n(e, t) {
6
6
  return e;
7
7
  }
8
8
  function r(n) {
9
- return t(n) ? typeof n.name != "string" || !e(n.name) ? "\"name\" must be a kebab-case name" : typeof n.batch == "boolean" ? typeof n.start == "function" ? n.version !== void 0 && typeof n.version != "string" ? "\"version\" must be a string" : null : "\"start\" must be a function" : "\"batch\" must be true or false" : "it must be an object";
9
+ return t(n) ? typeof n.name != "string" || !e(n.name) ? "\"name\" must be a kebab-case name" : typeof n.batch == "boolean" ? typeof n.start == "function" ? n.version !== void 0 && typeof n.version != "string" ? "\"version\" must be a string" : n.parallelUnits !== void 0 && typeof n.parallelUnits != "boolean" ? "\"parallelUnits\" must be true or false" : null : "\"start\" must be a function" : "\"batch\" must be true or false" : "it must be an object";
10
10
  }
11
11
  export { n as validateAdapter };
@@ -16,6 +16,12 @@ interface RunMutantsOptions {
16
16
  * never names a test runner.
17
17
  */
18
18
  builtIns: BuiltInAdapters;
19
+ /**
20
+ * Parallel units (`--parallel-units`): isolated units of one test file may
21
+ * run at the same time; over `run.parallelUnits`. With an adapter that cannot
22
+ * run them so, the run notes it and runs them one after another.
23
+ */
24
+ parallelUnits?: boolean;
19
25
  /**
20
26
  * Incremental mode (`--incremental`): a cached verdict is reused while the
21
27
  * region of its mutant (see `getMutantRegions`) and what its test file reads
@@ -27,6 +33,15 @@ interface RunMutantsOptions {
27
33
  * Ids of the only mutants to run (`--mutant`); every mutant when omitted.
28
34
  */
29
35
  mutantIds?: string[];
36
+ /**
37
+ * Interrupts the run once aborted, such as on a signal to the command line:
38
+ * no further run of the test runner starts, the adapter stops the running one
39
+ * (`AdapterContext.signal`), what that run gave is dropped, the session
40
+ * closes, the work directory is removed and the run rejects with the signal's
41
+ * reason. A signal that comes after the last run of the test runner ended
42
+ * lets the run end as without it, saving its cache.
43
+ */
44
+ signal?: AbortSignal;
30
45
  /**
31
46
  * Most test files at once; over `run.concurrency`.
32
47
  */
@@ -101,13 +116,30 @@ interface RunMutantsOptions {
101
116
  * report also lists the candidates its mutators skipped. The adapter is closed
102
117
  * and the work directory removed whatever happens; what the adapter tells of
103
118
  * its close, such as a global teardown that failed, joins the diagnostics of a
104
- * run that went through, after its cache was saved.
119
+ * run that went through, after its cache was saved. Unless the cache is off, in
120
+ * fast mode, or with `--since` or `--mutant`, a run first tries to decide its
121
+ * mutants from the dry run an earlier run saved and cached verdicts, without
122
+ * starting the test runner (`replayDrySnapshot`); a run that starts it hashes
123
+ * everything under the project root first, and once its session closed with
124
+ * nothing to tell, saves its own dry run, leaving out its work directory, which
125
+ * may lie in the project, or removes the saved one when it cannot be replayed
126
+ * (`saveDrySnapshot`), with a note that names a path that changed during the
127
+ * run; the time it takes counts in the isolated phase. With parallel units, an
128
+ * adapter that runs them may run the isolated units of one test file at the
129
+ * same time, and their verdicts are cached apart from those of other runs; an
130
+ * adapter that cannot runs them one after another, with a note. Once the signal
131
+ * of the options aborts, nothing more starts: a signal while the mutants are
132
+ * listed or a saved dry run is checked starts no test runner, and the session
133
+ * asks nothing more of a started one (`guardSession`), whose adapter stops what
134
+ * runs; the session still closes and the work directory is still removed.
105
135
  *
106
136
  * @param options - Paths, configuration, adapters and run settings.
107
137
  * @returns Verdicts, diagnostics and timings, before they are formatted.
108
138
  * @throws Error - When the configuration, the paths, a `--mutant` id or the
109
139
  * adapter is invalid, when the changed lines cannot be read from git, when
110
- * the test runner cannot start, or when tests fail without mutants.
140
+ * the test runner cannot start, or when tests fail without mutants; the
141
+ * reason of the signal of the options once it aborted before the last run of
142
+ * the test runner ended.
111
143
  */
112
144
  export declare function runMutants(options: RunMutantsOptions): Promise<RunResult>;
113
145
  export {};