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
@@ -0,0 +1,71 @@
1
+ import { AdapterSession } from '../../types/adapter/adapter-session.js';
2
+ import { DryRunResult } from '../../types/adapter/dry-run-result.js';
3
+ import { CacheInputs } from '../../types/adapter/cache-inputs.js';
4
+ import { ProjectTree } from '../../types/cache/project-tree.js';
5
+ import { DrySnapshot } from '../../types/cache/dry-snapshot.js';
6
+ import { Diagnostic } from '../../types/mutant/diagnostic.js';
7
+ import { RunCache } from '../../types/cache/run-cache.js';
8
+ /**
9
+ * What a saved dry run is built from.
10
+ */
11
+ interface SnapshotInput {
12
+ /**
13
+ * Outcome of the dry phase: the final dry run, the messages of the files
14
+ * whose mutants get no verdict, by display path, its diagnostics and its runs
15
+ * of the test runner.
16
+ */
17
+ phase: {
18
+ errors: ReadonlyMap<string, string>;
19
+ diagnostics: Diagnostic[];
20
+ dry: DryRunResult;
21
+ runs: number;
22
+ };
23
+ /**
24
+ * Environment variables of the main process as the run started, before the
25
+ * test runner could set any, such as `NODE_ENV`.
26
+ */
27
+ environment: NodeJS.ProcessEnv;
28
+ /**
29
+ * Everything under the project root before the test runner started
30
+ * (`hashProjectTree`), or null when a directory or link could not be read.
31
+ */
32
+ tree: ProjectTree | null;
33
+ /**
34
+ * Live session of the run.
35
+ */
36
+ session: AdapterSession;
37
+ /**
38
+ * What the session said every verdict depends on, as `prepareRunCache` asked
39
+ * it once.
40
+ */
41
+ inputs: CacheInputs;
42
+ /**
43
+ * Test files and setup files of the session.
44
+ */
45
+ testFiles: string[];
46
+ /**
47
+ * Cache of the run after it was saved.
48
+ */
49
+ cache: RunCache;
50
+ /**
51
+ * Key of the run (`getDrySnapshotKey`).
52
+ */
53
+ key: string;
54
+ }
55
+ /**
56
+ * Builds the saved dry run of a run whose cache was saved (`DrySnapshot`), with
57
+ * the hashes the cache keys took in after the dry run, and each environment
58
+ * variable that test code read in the dry run or in a unit whose evidence the
59
+ * cache reused or stored. A run gets none when a test file of the dry run has
60
+ * no key: the adapter cannot tell what it depended on, or one of its
61
+ * dependencies changed during the run or has unknown content (`UNKNOWN_HASH`),
62
+ * so the saved files never name such a file. Nor does a run whose dry phase ran
63
+ * the tests more than once, as after a test file that failed and passed when it
64
+ * ran again, since a fresh dry run may not repeat what it kept, and nor does
65
+ * one with a directory or link of the project it could not read.
66
+ *
67
+ * @param input - Dry phase, session, cache, environment, tree and key.
68
+ * @returns The saved dry run, or null when the run cannot be replayed.
69
+ */
70
+ export declare function createDrySnapshot(input: SnapshotInput): DrySnapshot | null;
71
+ export {};
@@ -0,0 +1,27 @@
1
+ import { listVariableHashes as e } from "./list-variable-hashes.js";
2
+ import { compareCodeUnits as t } from "../compare-code-units.js";
3
+ function n(n) {
4
+ let { session: r, phase: i, cache: a, tree: o } = n;
5
+ if (o === null || a.dependencies.size !== i.dry.files.length || i.runs !== 1) return null;
6
+ let s = /* @__PURE__ */ new Set([...a.environment, ...[...a.dependencies.values()].flat()]);
7
+ return {
8
+ variables: e([...i.dry.files.flatMap((e) => e.environment ?? []), ...[...a.inputs.values(), ...a.pending.values()].flatMap((e) => e.environment.map(([e]) => e))], n.environment),
9
+ session: {
10
+ diagnostics: [...r.diagnostics ?? []],
11
+ version: r.version ?? null,
12
+ workers: r.workers ?? null,
13
+ inputs: n.inputs
14
+ },
15
+ files: [...s].toSorted(t).map((e) => [e, a.hashes.get(e) ?? null]),
16
+ phase: {
17
+ diagnostics: i.diagnostics,
18
+ errors: [...i.errors],
19
+ dry: i.dry
20
+ },
21
+ testFiles: n.testFiles,
22
+ version: 8,
23
+ tree: o.hash,
24
+ key: n.key
25
+ };
26
+ }
27
+ export { n as createDrySnapshot };
@@ -58,6 +58,21 @@ interface RunCacheInput {
58
58
  * Entries and inputs read from the cache file.
59
59
  */
60
60
  stored: StoredCache;
61
+ /**
62
+ * Whether isolated timeouts by the hit limit are stored and reused: the count
63
+ * of site evaluations does not depend on the load of the machine, so such a
64
+ * timeout is as repeatable as a kill among runs that switch the same files
65
+ * (`switched`). False in fast mode, whose dry run tries each test twice and
66
+ * so gives other limits.
67
+ */
68
+ timeouts: boolean;
69
+ /**
70
+ * Digest of the files the run switched. The hit counts of a unit and its
71
+ * limits cover only their sites, so the keys of a timeout by the hit limit
72
+ * take it in: a run that switches other files, as a run of only some mutants
73
+ * does, never reuses it.
74
+ */
75
+ switched: string;
61
76
  /**
62
77
  * Project root; slots name test files relative to it.
63
78
  */
@@ -81,8 +96,11 @@ interface RunCacheInput {
81
96
  * than the dry run of its test file, such as a module only the mutant loads or
82
97
  * an environment variable only it reads: evidence stores those inputs, and is
83
98
  * valid only while each of them is unchanged too. Evidence of a run whose
84
- * inputs are unknown is not stored. Kills by a crash depend on the load of the
85
- * machine and are never stored, and neither are timeouts and errors.
99
+ * inputs are unknown is not stored. Kills by a crash and timeouts by the timer
100
+ * or a hang depend on the load of the machine and are never stored, and neither
101
+ * are errors; an isolated timeout by the hit limit does not and is stored and
102
+ * reused outside fast mode (`timeouts`), by runs that switch the same files
103
+ * (`switched`), whose sites its hit counts cover.
86
104
  *
87
105
  * @param input - Stored entries, test file keys, source hashes, mutant regions,
88
106
  * the mode and the dry run.
@@ -44,53 +44,62 @@ function a(a) {
44
44
  return e.key === t.key || a.incremental && t.incremental !== null && e.incremental === t.incremental;
45
45
  }
46
46
  function C(e) {
47
+ return {
48
+ ...e,
49
+ incremental: e.incremental === null ? null : r([e.incremental, a.switched]),
50
+ key: r([e.key, a.switched])
51
+ };
52
+ }
53
+ function w(e) {
47
54
  if (e === null) return null;
48
- let t = u.entries.get(e.slot);
49
- return t === void 0 || !S(t, e) || t.test !== null && !c.tests.has(t.test) || t.inputs !== null && !b(e.file, u.inputs.get(t.inputs)) ? null : (t.inputs !== null && _.set(t.inputs, u.inputs.get(t.inputs)), t.key !== e.key && h.add(e.mutant), m.set(e.slot, {
55
+ let t = u.entries.get(e.slot), n = t?.status === "Timeout" ? C(e) : e;
56
+ return t === void 0 || t.status === "Timeout" && !a.timeouts || !S(t, n) || t.test !== null && !c.tests.has(t.test) || t.inputs !== null && !b(e.file, u.inputs.get(t.inputs)) ? null : (t.inputs !== null && _.set(t.inputs, u.inputs.get(t.inputs)), t.key !== n.key && h.add(e.mutant), m.set(e.slot, {
50
57
  ...t,
51
58
  used: p
52
59
  }), v.set(e.slot, e.file), t.status === "Survived" ? "survived" : {
53
60
  file: c.testFiles.get(e.file).file,
54
61
  message: t.message,
62
+ status: t.status,
55
63
  cause: t.cause,
56
- test: t.test,
57
- status: "Killed"
64
+ test: t.test
58
65
  });
59
66
  }
60
- function w(e, n, r) {
61
- let { verdict: i, inputs: o } = r;
62
- if (e === null || !o || i !== "survived" && (i.status !== "Killed" || i.cause === "crash")) return;
63
- let s = new Set(a.dependencies.get(e.file)), c = new Set(a.reads.get(e.file)), l = {
64
- environment: [...new Set(o.environment)].filter((e) => !c.has(e)).toSorted(t).map((t) => [t, y(e.file, t)]),
65
- files: [...new Set(o.dependencies)].filter((e) => !s.has(e)).toSorted(t)
67
+ function T(e, n, r) {
68
+ let { verdict: i, inputs: o } = r, s = i === "survived" || i.status === "Killed" && i.cause !== "crash" || a.timeouts && n.path === "isolated" && i.status === "Timeout" && i.cause === "hit-limit";
69
+ if (e === null || !o || !s) return;
70
+ let c = new Set(a.dependencies.get(e.file)), l = new Set(a.reads.get(e.file)), u = {
71
+ environment: [...new Set(o.environment)].filter((e) => !l.has(e)).toSorted(t).map((t) => [t, y(e.file, t)]),
72
+ files: [...new Set(o.dependencies)].filter((e) => !c.has(e)).toSorted(t)
66
73
  };
67
- l.files.length > 0 || l.environment.length > 0 ? g.set(e.slot, l) : g.delete(e.slot), v.set(e.slot, e.file), m.set(e.slot, i === "survived" ? {
68
- incremental: e.incremental,
74
+ u.files.length > 0 || u.environment.length > 0 ? g.set(e.slot, u) : g.delete(e.slot), v.set(e.slot, e.file);
75
+ let { incremental: d, key: f } = i !== "survived" && i.status === "Timeout" ? C(e) : e;
76
+ m.set(e.slot, i === "survived" ? {
69
77
  status: "Survived",
70
78
  path: n.path,
71
- key: e.key,
72
79
  message: null,
73
80
  inputs: null,
74
81
  first: !1,
82
+ incremental: d,
75
83
  cause: null,
76
84
  test: null,
77
- used: p
85
+ used: p,
86
+ key: f
78
87
  } : {
79
- incremental: e.incremental,
88
+ status: i.status === "Timeout" ? "Timeout" : "Killed",
80
89
  message: i.message,
81
90
  cause: i.cause,
82
91
  first: n.first,
83
92
  test: i.test,
84
93
  path: n.path,
85
- key: e.key,
86
- status: "Killed",
87
94
  inputs: null,
88
- used: p
95
+ incremental: d,
96
+ used: p,
97
+ key: f
89
98
  });
90
99
  }
91
100
  return {
92
101
  lookupBatch: (t, n) => {
93
- let r = x(t, e(c.tests.get(n)), n), i = C(r);
102
+ let r = x(t, e(c.tests.get(n)), n), i = w(r);
94
103
  return i === null || i === "survived" ? i : {
95
104
  first: u.entries.get(r.slot).first,
96
105
  verdict: i
@@ -102,18 +111,18 @@ function a(a) {
102
111
  },
103
112
  recordBatch: (t, n, r) => {
104
113
  let i = e(c.tests.get(n)), a = t.coveredBy[0] === n;
105
- w(x(t, i, n), {
114
+ T(x(t, i, n), {
106
115
  path: "batch",
107
116
  first: a
108
117
  }, r);
109
118
  },
110
119
  recordUnit: (e, t, n) => {
111
- w(x(e, t, null), {
120
+ T(x(e, t, null), {
112
121
  path: "isolated",
113
122
  first: !1
114
123
  }, n);
115
124
  },
116
- lookupUnit: (e, t) => C(x(e, t, null)),
125
+ lookupUnit: (e, t) => w(x(e, t, null)),
117
126
  dependencies: a.dependencies,
118
127
  environment: a.environment,
119
128
  regional: h,
@@ -0,0 +1,12 @@
1
+ import { AdapterSession } from '../../types/adapter/adapter-session.js';
2
+ import { DrySnapshot } from '../../types/cache/dry-snapshot.js';
3
+ /**
4
+ * Stands in for the session of the test runner in a run that replays a saved
5
+ * dry run: it lists the test files and tells the cache inputs, version, workers
6
+ * and warnings of the session that saved it, and refuses to run anything, so a
7
+ * run that needs the test runner starts over with it (`createDryReuseMiss`).
8
+ *
9
+ * @param snapshot - Saved dry run of an earlier run that still holds.
10
+ * @returns Session without a test runner.
11
+ */
12
+ export declare function createSnapshotSession(snapshot: DrySnapshot): AdapterSession;
@@ -0,0 +1,19 @@
1
+ import { createDryReuseMiss as e } from "./create-dry-reuse-miss.js";
2
+ function t(t) {
3
+ let { session: n } = t;
4
+ function r() {
5
+ return Promise.reject(e("some mutants have no cached verdict"));
6
+ }
7
+ return {
8
+ listTestFiles: () => Promise.resolve([...t.testFiles]),
9
+ cacheInputs: () => Promise.resolve(n.inputs),
10
+ ...n.version !== null && { version: n.version },
11
+ ...n.workers !== null && { workers: n.workers },
12
+ diagnostics: n.diagnostics,
13
+ close: () => Promise.resolve(),
14
+ runIsolated: r,
15
+ runBatch: r,
16
+ dryRun: r
17
+ };
18
+ }
19
+ export { t as createSnapshotSession };
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Gives the id of mootant's own code that the cache keys take in: the hash the
3
+ * build wrote (`BUILD_HASH`), or, when mootant runs from its sources, a random
4
+ * id made once per process, so a later process, whose sources may differ, never
5
+ * reuses verdicts of this one.
6
+ *
7
+ * @param file - Path of the module, a `.ts` file in the sources; this module's
8
+ * path when omitted.
9
+ * @returns Hash of the build, or the id of the sources in this process.
10
+ */
11
+ export declare function getBuildId(file?: string): string;
@@ -0,0 +1,7 @@
1
+ import { BUILD_HASH as e } from "./build-hash.js";
2
+ import { randomUUID as t } from "node:crypto";
3
+ let n = null;
4
+ function r(r = import.meta.filename) {
5
+ return r.endsWith(".ts") ? (n ??= t(), n) : e;
6
+ }
7
+ export { r as getBuildId };
@@ -4,6 +4,6 @@
4
4
  *
5
5
  * @param root - Project root.
6
6
  * @returns Absolute path of the cache file, such as
7
- * `<root>/node_modules/.cache/mootant/run-v2.json`.
7
+ * `<root>/node_modules/.cache/mootant/run-v8.json`.
8
8
  */
9
9
  export declare function getCachePath(root: string): string;
@@ -1,5 +1,5 @@
1
1
  import e from "node:path";
2
2
  function t(t) {
3
- return e.join(t, "node_modules", ".cache", "mootant", "run-v3.json");
3
+ return e.join(t, "node_modules", ".cache", "mootant", "run-v8.json");
4
4
  }
5
5
  export { t as getCachePath };
@@ -0,0 +1,47 @@
1
+ import { ActiveMutator } from '../../types/mutator/active-mutator.js';
2
+ import { SwitchedFile } from '../../types/adapter/switched-file.js';
3
+ import { TestAdapter } from '../../types/adapter/test-adapter.js';
4
+ import { LimitSettings } from '../../types/run/run-state.js';
5
+ /**
6
+ * Builds the key of a saved dry run (`DrySnapshot`) over what the dry run was
7
+ * asked to do and how the run reads it: the versions of mootant, its build, the
8
+ * cache, the instrumenter and the runtime; the adapter; the version of Node.js
9
+ * with the platform; the project root and the configuration file, whose text
10
+ * the hash of the project tree takes in, so a run of another configuration in
11
+ * the same root never replays it; the working directory, which configuration
12
+ * and tests may read; what the test runner starts with: the concurrency, which
13
+ * a global setup may read, the number of cores a default one comes from, and
14
+ * whether units run in parallel; the try limits; the preset and its mutators;
15
+ * the switched files given to the dry run with their texts, which name every
16
+ * hosted mutant; and the files it relates tests to.
17
+ *
18
+ * @param input - Settings, adapter and files of the dry run.
19
+ * @param input.setup - Preset, active mutators, preset settings and the
20
+ * configuration file.
21
+ * @param input.context - Concurrency and parallel units the test runner starts
22
+ * with (`AdapterContext`).
23
+ * @param input.switched - Switched files given to the dry run, in order.
24
+ * @param input.related - Absolute paths of the files the dry run relates tests
25
+ * to, in order.
26
+ * @param input.limits - How try limits grow from the dry run.
27
+ * @param input.adapter - Adapter of the run.
28
+ * @param input.root - Project root.
29
+ * @returns SHA-256 in hex.
30
+ */
31
+ export declare function getDrySnapshotKey(input: {
32
+ setup: {
33
+ mutators: ActiveMutator[];
34
+ file: string | null;
35
+ settings: unknown;
36
+ preset: string;
37
+ };
38
+ context: {
39
+ concurrency: number | null;
40
+ parallelUnits: boolean;
41
+ };
42
+ switched: readonly SwitchedFile[];
43
+ related: readonly string[];
44
+ limits: LimitSettings;
45
+ adapter: TestAdapter;
46
+ root: string;
47
+ }): string;
@@ -0,0 +1,43 @@
1
+ import { getPortablePath as e } from "./get-portable-path.js";
2
+ import { createDigest as t } from "./create-digest.js";
3
+ import { version as n } from "../../package.js";
4
+ import { getBuildId as r } from "./get-build-id.js";
5
+ import { availableParallelism as i } from "node:os";
6
+ import { createHash as a } from "node:crypto";
7
+ function o(o) {
8
+ let { context: s, setup: c, root: l } = o;
9
+ return t([
10
+ 8,
11
+ n,
12
+ r(),
13
+ 2,
14
+ 2,
15
+ [o.adapter.name, o.adapter.version ?? null],
16
+ [
17
+ process.version,
18
+ process.platform,
19
+ process.arch
20
+ ],
21
+ l,
22
+ c.file === null ? null : e(c.file, l),
23
+ process.cwd(),
24
+ [
25
+ s.concurrency,
26
+ i(),
27
+ s.parallelUnits
28
+ ],
29
+ o.limits,
30
+ [
31
+ c.mutators.map((e) => [e.id, e.options]),
32
+ c.settings,
33
+ c.preset
34
+ ],
35
+ o.switched.map((t) => [
36
+ e(t.file, l),
37
+ a("sha256").update(t.switched).digest("hex"),
38
+ a("sha256").update(t.original).digest("hex")
39
+ ]),
40
+ o.related.map((t) => e(t, l))
41
+ ]);
42
+ }
43
+ export { o as getDrySnapshotKey };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Builds the path of the saved dry run of a project (`DrySnapshot`), next to
3
+ * the cache file.
4
+ *
5
+ * @param root - Project root.
6
+ * @returns Absolute path, such as
7
+ * `<root>/node_modules/.cache/mootant/dry-v8.json`.
8
+ */
9
+ export declare function getDrySnapshotPath(root: string): string;
@@ -0,0 +1,5 @@
1
+ import e from "node:path";
2
+ function t(t) {
3
+ return e.join(t, "node_modules", ".cache", "mootant", "dry-v8.json");
4
+ }
5
+ export { t as getDrySnapshotPath };
@@ -25,6 +25,11 @@ interface EnvironmentInput {
25
25
  * Hashes of the files by absolute path, null for a missing one.
26
26
  */
27
27
  hashes: ReadonlyMap<string, string | null>;
28
+ /**
29
+ * Whether isolated units of one test file run at the same time, false when
30
+ * omitted.
31
+ */
32
+ parallelUnits?: boolean;
28
33
  /**
29
34
  * How try limits grow from the dry run.
30
35
  */
@@ -39,10 +44,9 @@ interface EnvironmentInput {
39
44
  */
40
45
  files: string[];
41
46
  /**
42
- * Stamp of mootant's own build, so a rebuild of an unreleased version does
43
- * not reuse verdicts of the previous build.
47
+ * Id of mootant's own code (`getBuildId`).
44
48
  */
45
- build: number;
49
+ build: string;
46
50
  /**
47
51
  * Project root; paths are hashed relative to it.
48
52
  */
@@ -54,7 +58,8 @@ interface EnvironmentInput {
54
58
  * runner, the hashes of the files every verdict depends on, the settings of the
55
59
  * test runner, the try limits, the preset and its mutators, and the major
56
60
  * version of Node.js with the platform. Concurrency and fast mode are not part
57
- * of it.
61
+ * of it. Parallel units are part of it only when on, since their verdicts may
62
+ * differ where tests rely on a test file never running twice at once.
58
63
  *
59
64
  * @param input - Versions, files, hashes and settings of the run.
60
65
  * @returns SHA-256 in hex.
@@ -7,11 +7,11 @@ function r(r) {
7
7
  root: a
8
8
  });
9
9
  return t([
10
- 3,
10
+ 8,
11
11
  n,
12
12
  r.build,
13
- 1,
14
- 1,
13
+ 2,
14
+ 2,
15
15
  r.runner,
16
16
  o,
17
17
  r.settings ?? null,
@@ -19,7 +19,8 @@ function r(r) {
19
19
  r.mutators,
20
20
  process.versions.node.split(".", 1)[0],
21
21
  process.platform,
22
- process.arch
22
+ process.arch,
23
+ ...r.parallelUnits === !0 ? ["parallel-units"] : []
23
24
  ]);
24
25
  }
25
26
  export { r as getEnvironmentKey };
@@ -7,7 +7,8 @@ import { DryFile } from '../../types/adapter/dry-file.js';
7
7
  * is not set included. Incremental keys leave out the files mutants are listed
8
8
  * from, for which the region of a mutant stands (see `getMutantRegions`). Test
9
9
  * files without dependencies get no key, so their verdicts are neither reused
10
- * nor stored.
10
+ * nor stored. Each file is made portable once for all test files, which share
11
+ * most of what they load, such as the files of a test environment like jsdom.
11
12
  *
12
13
  * @param input - Test files of the dry run, file hashes and environment.
13
14
  * @param input.files - Test files of the dry run.
@@ -4,21 +4,22 @@ import { getPortablePath as n } from "./get-portable-path.js";
4
4
  import { listFileHashes as r } from "./list-file-hashes.js";
5
5
  import { createDigest as i } from "./create-digest.js";
6
6
  function a(a) {
7
- let { environment: o, variables: s, mutated: c, hashes: l, root: u } = a, d = /* @__PURE__ */ new Map();
8
- for (let f of a.files) {
9
- if (!Array.isArray(f.dependencies)) continue;
10
- let a = r([f.file, ...f.dependencies.filter((e) => !c.has(e))], {
7
+ let { environment: o, variables: s, mutated: c, hashes: l, root: u } = a, d = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map();
8
+ for (let p of a.files) {
9
+ if (!Array.isArray(p.dependencies)) continue;
10
+ let a = r([p.file, ...p.dependencies.filter((e) => !c.has(e))], {
11
11
  hashes: l,
12
+ paths: d,
12
13
  root: u
13
- }), p = Object.hasOwn(s, f.project) ? s[f.project] : {}, m = [...new Set(f.environment)].toSorted(t).map((e) => [e, Object.hasOwn(p, e) ? p[e] : null]);
14
- d.set(e(f), i([
14
+ }), m = Object.hasOwn(s, p.project) ? s[p.project] : {}, h = [...new Set(p.environment)].toSorted(t).map((e) => [e, Object.hasOwn(m, e) ? m[e] : null]);
15
+ f.set(e(p), i([
15
16
  o,
16
- n(f.file, u),
17
- f.project,
17
+ n(p.file, u),
18
+ p.project,
18
19
  a,
19
- m
20
+ h
20
21
  ]));
21
22
  }
22
- return d;
23
+ return f;
23
24
  }
24
25
  export { a as getTestFileKeys };
@@ -1,11 +1,16 @@
1
1
  /**
2
- * Hashes the contents of files, each file once, a few at a time; a directory is
3
- * hashed by the names in it, those of directories marked, so adding, removing
4
- * or replacing a file with a directory changes it, while a change inside a
5
- * directory in it does not.
2
+ * Hashes the contents of files, each file once, a few at a time, a large one as
3
+ * a stream (`STREAM_SIZE`); a directory is hashed by the names in it, those of
4
+ * directories marked, so adding, removing or replacing a file with a directory
5
+ * changes it, while a change inside a directory in it does not. A path that is
6
+ * neither a file nor a directory, such as a device, a pipe or a socket, is
7
+ * never read, as reading `/dev/stdin` or a pipe would wait for its writer and
8
+ * `/dev/zero` never ends: its content is unknown, which differs from a missing
9
+ * file.
6
10
  *
7
11
  * @param paths - Absolute paths, duplicates allowed.
8
- * @returns SHA-256 of each file in hex by path, or null for a file that cannot
9
- * be read, such as a missing one.
12
+ * @returns SHA-256 of each file in hex by path, `UNKNOWN_HASH` for a path that
13
+ * is neither a file nor a directory, or null for a file that cannot be read,
14
+ * such as a missing one.
10
15
  */
11
16
  export declare function hashFiles(paths: Iterable<string>): Promise<Map<string, string | null>>;
@@ -1,24 +1,29 @@
1
1
  import { compareCodeUnits as e } from "../compare-code-units.js";
2
- import { runInChunks as t } from "./run-in-chunks.js";
3
- import { createHash as n } from "node:crypto";
4
- import { readFile as r, readdir as i } from "node:fs/promises";
5
- async function a(e) {
6
- let r = /* @__PURE__ */ new Map();
7
- return await t([...new Set(e)], 32, async (e) => {
8
- let t = await o(e);
9
- r.set(e, t === null ? null : n("sha256").update(t).digest("hex"));
10
- }), r;
2
+ import { UNKNOWN_HASH as t } from "./unknown-hash.js";
3
+ import { runInChunks as n } from "./run-in-chunks.js";
4
+ import { createReadStream as r } from "node:fs";
5
+ import { createHash as i } from "node:crypto";
6
+ import { readFile as a, readdir as o, stat as s } from "node:fs/promises";
7
+ async function c(e) {
8
+ let t = /* @__PURE__ */ new Map();
9
+ return await n([...new Set(e)], 32, async (e) => {
10
+ t.set(e, await l(e));
11
+ }), t;
11
12
  }
12
- async function o(t) {
13
+ async function l(n) {
13
14
  try {
14
- return await r(t);
15
- } catch (e) {
16
- if (e.code !== "EISDIR") return null;
17
- }
18
- try {
19
- return `directory\0${(await i(t, { withFileTypes: !0 })).map((e) => e.isDirectory() ? `${e.name}/` : e.name).toSorted(e).join("\0")}`;
15
+ let c = await s(n);
16
+ if (c.isFile() && c.size <= 16777216) return i("sha256").update(await a(n)).digest("hex");
17
+ if (c.isFile()) {
18
+ let e = i("sha256");
19
+ for await (let t of r(n)) e.update(t);
20
+ return e.digest("hex");
21
+ }
22
+ if (!c.isDirectory()) return t;
23
+ let l = (await o(n, { withFileTypes: !0 })).map((e) => e.isDirectory() ? `${e.name}/` : e.name).toSorted(e);
24
+ return i("sha256").update(`directory\0${l.join("\0")}`).digest("hex");
20
25
  } catch {
21
26
  return null;
22
27
  }
23
28
  }
24
- export { a as hashFiles };
29
+ export { c as hashFiles };
@@ -0,0 +1,22 @@
1
+ import { ProjectTree } from '../../types/cache/project-tree.js';
2
+ /**
3
+ * Hashes everything under the project root with its contents, so that adding,
4
+ * removing, renaming or changing any file, directory or symbolic link changes
5
+ * the hash: a new test file, a test file the dry run did not run that now
6
+ * imports a mutated file, or a file that now shadows a module a test imports.
7
+ * Directories in `SKIPPED` and the given outputs of mootant are left out. A
8
+ * symbolic link counts by its target, never followed, and a path that is
9
+ * neither a file nor a directory by its name, as `hashFiles` cannot read it. A
10
+ * directory that cannot be listed may still hold files a test loads by their
11
+ * paths, so the tree then has no hash. The entries go into the hash one at a
12
+ * time, so a large tree never makes one long text, and come back by path, so a
13
+ * later tree can name what changed.
14
+ *
15
+ * @param root - Directory whose contents are hashed: the project root.
16
+ * @param outputs - Absolute paths mootant writes into the project during or
17
+ * after a run, such as the HTML report and the work directory, which are left
18
+ * out.
19
+ * @returns The hash with the entry of every path, or null when a directory
20
+ * cannot be listed or a link cannot be read.
21
+ */
22
+ export declare function hashProjectTree(root: string, outputs: readonly string[]): Promise<ProjectTree | null>;