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
package/bin/mootant.js CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { run } from '../dist/cli/index.js'
3
+ import { ensureExit, run } from '../dist/cli/index.js'
4
4
 
5
- run()
5
+ await run()
6
+ ensureExit()
@@ -4,12 +4,14 @@ import { JestTimedRecord } from './types/jest-timed-record.js';
4
4
  * the unit read, the CommonJS modules its worker loaded in its own realm, such
5
5
  * as a transformer and what it imports, which a warm worker no longer reads,
6
6
  * the `package.json` files that decide the format and the `#` imports of the
7
- * files in the directory of each of them (`listPackageFiles`), and the snapshot
8
- * file Jest resolves for the test file by default, `__snapshots__/<name>.snap`
9
- * beside it, whether it exists or not. The file a custom snapshot resolver
10
- * gives is among the reads, as Jest looks for it when the unit starts. The
11
- * worker leaves out of the reads what is under `node_modules`, which the
12
- * lockfile stands for, mootant's own files and, outside the directories of the
7
+ * files in the directory of each of them (`listPackageFiles`), for a file of an
8
+ * installed package the `package.json` that decides what an import of the
9
+ * package resolves to (`getPackageManifest`), and the snapshot file Jest
10
+ * resolves for the test file by default, `__snapshots__/<name>.snap` beside it,
11
+ * whether it exists or not. The file a custom snapshot resolver gives is among
12
+ * the reads, as Jest looks for it when the unit starts. The worker leaves out
13
+ * of the reads what lies under `node_modules` but the modules Jest's runtime
14
+ * loaded for the vm, mootant's own files and, outside the directories of the
13
15
  * session, the root itself and what `createInputFilter` leaves out, what Jest's
14
16
  * resolver read, as a real load is read anyway, and what only the transformers,
15
17
  * the test environment and the test runner in their own calls, or a project's
@@ -1,15 +1,21 @@
1
- import { compareCodeUnits as e } from "../../core/compare-code-units.js";
2
- import { listPackageFiles as t } from "../shared/list-package-files.js";
3
- import n from "node:path";
4
- function r(r, i) {
5
- let a = r.find((e) => e.kind === "finish");
6
- if (!a?.tracked) return null;
7
- let o = [
8
- i,
9
- ...a.reads,
10
- ...a.loaded
11
- ], s = /* @__PURE__ */ new Set([...o, n.join(n.dirname(i), "__snapshots__", `${n.basename(i)}.snap`)]), c = new Set(o.map((e) => n.dirname(e))), l = /* @__PURE__ */ new Map();
12
- for (let e of c) for (let n of t(e, l)) s.add(n);
13
- return [...s].toSorted(e);
1
+ import { getPackageManifest as e } from "../../core/files/get-package-manifest.js";
2
+ import { listPackageFiles as t } from "../../core/files/list-package-files.js";
3
+ import { compareCodeUnits as n } from "../../core/compare-code-units.js";
4
+ import r from "node:path";
5
+ function i(i, a) {
6
+ let o = i.find((e) => e.kind === "finish");
7
+ if (!o?.tracked) return null;
8
+ let s = [
9
+ a,
10
+ ...o.reads,
11
+ ...o.loaded
12
+ ], c = /* @__PURE__ */ new Set([...s, r.join(r.dirname(a), "__snapshots__", `${r.basename(a)}.snap`)]);
13
+ for (let t of s) {
14
+ let n = e(t);
15
+ n !== null && c.add(n);
16
+ }
17
+ let l = new Set(s.map((e) => r.dirname(e))), u = /* @__PURE__ */ new Map();
18
+ for (let e of l) for (let n of t(e, u)) c.add(n);
19
+ return [...c].toSorted(n);
14
20
  }
15
- export { r as collectJestDependencies };
21
+ export { i as collectJestDependencies };
@@ -16,19 +16,20 @@ import { JestReady } from './types/jest-ready.js';
16
16
  * worker reads only once, so that a test file whose unit ran after it would
17
17
  * miss it, with the missing files among it only when they are named as
18
18
  * configuration files (`isTransformInput`); and the modules the host loaded, as
19
- * the configuration file imports them and global setup ran, but those under
20
- * `node_modules`, which the lockfile stands for, and mootant's own files.
21
- * Settings, with the root in their strings replaced so that a moved project
22
- * keeps them: per project its configuration without what changes no verdict,
23
- * and the console its tests print to; what of the global configuration picks
24
- * the tests of a file and how they run; the versions of Jest, of the
25
- * `@jest/transform` that strips types and of Node, whose own stripping and
26
- * targets change the code; whether every unit gets a new worker; and the
27
- * variables that change verdicts whether tests read them or not (`TZ`,
28
- * `NODE_ENV`, `LANG`, `LC_*`) with `BABEL_ENV`, which transformers read outside
29
- * the tests, `NODE_OPTIONS`, the Node flags and the variables the command and
30
- * the options set. Environment: the hashes of the variables of the host after
31
- * global setup, which every worker of every project starts from.
19
+ * the configuration file imports them and global setup ran, but mootant's own
20
+ * files and those under `node_modules`, such as Jest's own, which an install
21
+ * that changes them shows in the files that tell what was installed. Settings,
22
+ * with the root in their strings replaced so that a moved project keeps them:
23
+ * per project its configuration without what changes no verdict, and the
24
+ * console its tests print to; what of the global configuration picks the tests
25
+ * of a file and how they run; the versions of Jest, of the `@jest/transform`
26
+ * that strips types and of Node, whose own stripping and targets change the
27
+ * code; whether every unit gets a new worker; and the variables that change
28
+ * verdicts whether tests read them or not (`TZ`, `NODE_ENV`, `LANG`, `LC_*`)
29
+ * with `BABEL_ENV`, which transformers read outside the tests, `NODE_OPTIONS`,
30
+ * the Node flags and the variables the command and the options set.
31
+ * Environment: the hashes of the variables of the host after global setup,
32
+ * which every worker of every project starts from.
32
33
  *
33
34
  * @param input - What the session started with and what its dry runs read.
34
35
  * @param input.transforms - Files the transformers, the test environments, the
@@ -4,7 +4,9 @@ export type { JestAdapterOptions } from './types/jest-adapter-options.js';
4
4
  /**
5
5
  * Creates the adapter that runs mutants with the project's Jest 29.7 or later,
6
6
  * such as `jestAdapter({ command: 'jest --config jest.unit.js' })` in
7
- * `run.runner`.
7
+ * `run.runner`. It has no parallel units: the units of a test file run as one
8
+ * chain on a warm worker, and the check at the end of the chain takes back the
9
+ * facts of its warm units when the file fails only on warm state.
8
10
  *
9
11
  * @param options - Test command, when not the one of the test scripts, extra
10
12
  * environment variables, and whether every unit gets a new worker.
@@ -16,10 +16,10 @@ async function d(e, r) {
16
16
  let d = y(e, r.instrumented);
17
17
  l(u.join(a, "out"), { recursive: !0 });
18
18
  let p = new Set(r.related);
19
- function g(e) {
19
+ function h(e) {
20
20
  return e.some((e) => p.has(e));
21
21
  }
22
- let v = h(e, r, g), b = await f(e, {
22
+ let v = g(e, r, h), b = await f(e, {
23
23
  timeouts: r.timeouts,
24
24
  targets: v,
25
25
  plan: d
@@ -41,7 +41,7 @@ async function d(e, r) {
41
41
  });
42
42
  for (let [e, t] of b.entries()) {
43
43
  let { project: i, file: a } = v[e], l = t.records.find((e) => e.kind === "finish");
44
- if (_(t.records, S, o.outside), l?.outcome === "result" && l.execError === null && t.records.every((e) => e.kind !== "load") && C.push(n(a, c)), w || r.files !== null || !t.done || g(l.reads)) {
44
+ if (_(t.records, S, o.outside), l?.outcome === "result" && l.execError === null && t.records.every((e) => e.kind !== "load") && C.push(n(a, c)), w || r.files !== null || !t.done || h(l.reads)) {
45
45
  let e = s(t, {
46
46
  project: i.name,
47
47
  root: c,
@@ -92,9 +92,9 @@ async function f(e, t) {
92
92
  async function p(e, t) {
93
93
  let { directory: n, state: r, heap: i, pool: o } = e, { timeouts: s, target: l, clean: d, plan: f, last: p } = t;
94
94
  r.units += 1;
95
- let m = o.take(), h;
95
+ let m = o.take(), g;
96
96
  try {
97
- h = await c(o, m, {
97
+ g = await c(o, m, {
98
98
  unit: {
99
99
  out: u.join(n, "out", `${r.units}.jsonl`),
100
100
  project: l.project.config.id,
@@ -110,7 +110,7 @@ async function p(e, t) {
110
110
  } finally {
111
111
  o.release(m);
112
112
  }
113
- return h.outOfMemory !== null && i.raise(h.outOfMemory), (p || !v(h, d)) && g(e, l, h), h;
113
+ return g.outOfMemory !== null && i.raise(g.outOfMemory), (p || !v(g, d)) && h(e, l, g), g;
114
114
  }
115
115
  function m(e, r, i) {
116
116
  if (e.size > 0) throw Error([...e].map(([e, t]) => [n(e, i), t]).toSorted(([e], [n]) => t(e, n)).map(([e, t]) => `The test runner's transformer rejects the text with mutants of ${e}: ${t}; exclude the file.`).join("\n"));
@@ -118,6 +118,20 @@ function m(e, r, i) {
118
118
  if (a !== void 0) throw Error(`Jest ran ${a} with no test framework mootant can follow; jest-circus is required.`);
119
119
  }
120
120
  function h(t, n, r) {
121
+ let { context: i, state: a } = t, { project: o, file: s } = n;
122
+ i.onUnitEnd?.();
123
+ let c = r.records.find((e) => e.kind === "finish"), l = e({
124
+ project: o.name,
125
+ file: s
126
+ });
127
+ if (c === void 0) a.reads.delete(l);
128
+ else {
129
+ a.reads.set(l, c.reads.filter((e) => !/[/\\]node_modules[/\\]/u.test(e)));
130
+ for (let e of c.transforms) a.transforms.add(e);
131
+ for (let e of [c.consoleOutput, c.failureMessage]) e !== null && i.onOutput?.(e, s);
132
+ }
133
+ }
134
+ function g(t, n, r) {
121
135
  let { projects: i, tests: a, state: o } = t;
122
136
  return n.files === null ? a.map((e) => ({
123
137
  project: i.find(({ config: t }) => t.id === e.project),
@@ -133,20 +147,6 @@ function h(t, n, r) {
133
147
  file: t
134
148
  }));
135
149
  }
136
- function g(t, n, r) {
137
- let { context: i, state: a } = t, { project: o, file: s } = n;
138
- i.onUnitEnd?.();
139
- let c = r.records.find((e) => e.kind === "finish"), l = e({
140
- project: o.name,
141
- file: s
142
- });
143
- if (c === void 0) a.reads.delete(l);
144
- else {
145
- a.reads.set(l, c.reads);
146
- for (let e of c.transforms) a.transforms.add(e);
147
- for (let e of [c.consoleOutput, c.failureMessage]) e !== null && i.onOutput?.(e, s);
148
- }
149
- }
150
150
  function _(e, t, n) {
151
151
  for (let r of e) if (r.kind === "served") t.served.add(r.file);
152
152
  else if (r.kind === "mismatched") t.mismatched.add(r.file);
@@ -28,13 +28,17 @@ import { JestAdapterOptions } from './types/jest-adapter-options.js';
28
28
  * joined with what they read in earlier sessions (`keepTransformReads`,
29
29
  * `getJestCacheInputs`). Once the host is ready the session works with the
30
30
  * configuration it ran global setup with (`readHostConfig`), the workers and
31
- * the cache key alike.
31
+ * the cache key alike. Once the run is interrupted (`AdapterContext.signal`),
32
+ * no Jest process starts and the workers stop; the host stops on the signal
33
+ * that interrupted the run, as its group is tracked, or when the session
34
+ * closes.
32
35
  *
33
36
  * @param context - Work directory, concurrency, root and output.
34
37
  * @param options - Options of the adapter.
35
38
  * @returns Session that knows the version, workers, test files and cache
36
39
  * inputs, and runs dry runs and isolated units.
37
40
  * @throws {Error} When Jest is missing, older than 29.7 or fails to start, or
38
- * when its settings or the command are not supported.
41
+ * when its settings or the command are not supported; once the context's
42
+ * signal aborted before the host started, its reason.
39
43
  */
40
44
  export declare function startJestSession(context: AdapterContext, options: JestAdapterOptions): Promise<AdapterSession>;
@@ -29,6 +29,7 @@ async function w(w, T) {
29
29
  ...T.env
30
30
  }).filter(([e]) => !e.startsWith("MOOTANT_")));
31
31
  async function M(e) {
32
+ w.signal?.throwIfAborted();
32
33
  let r = n(k.args, e), i = {
33
34
  onOutput(e) {
34
35
  w.onOutput?.(e, null);
@@ -56,7 +57,9 @@ async function w(w, T) {
56
57
  let L = await C(D), R = d({
57
58
  root: L,
58
59
  config: F
59
- }), z = await u(w.workDirectory), B = await g({
60
+ }), z = await u(w.workDirectory);
61
+ w.signal?.throwIfAborted();
62
+ let B = await g({
60
63
  ...I,
61
64
  projects: R.projects,
62
65
  files: z
@@ -99,7 +102,11 @@ async function w(w, T) {
99
102
  slot: e
100
103
  }),
101
104
  size: V.maxWorkers
102
- }), Y = {
105
+ });
106
+ w.signal?.addEventListener("abort", () => {
107
+ J.close();
108
+ }, { once: !0 });
109
+ let Y = {
103
110
  state: {
104
111
  lateTransforms: /* @__PURE__ */ new Set(),
105
112
  transforms: /* @__PURE__ */ new Set(),
@@ -19,7 +19,8 @@ export interface JestHandle {
19
19
  timeouts: DryRunRequest['timeouts'] | null
20
20
 
21
21
  /**
22
- * Files each test file read in its last dry run, by `getTestFileKey`; a
22
+ * Files each test file read in its last dry run, by `getTestFileKey`, but
23
+ * those under `node_modules`, which no file mutants come from is among; a
23
24
  * test file with no `finish` has no entry, so it runs again.
24
25
  */
25
26
  reads: Map<string, readonly string[]>
@@ -106,9 +106,10 @@ export type JestRecord =
106
106
  /**
107
107
  * Files and directories the code read that count, sorted: under the
108
108
  * project root or a project's directories, and elsewhere as
109
- * `createInputFilter` tells, never under `node_modules` or in mootant's
110
- * files, nor as the root itself outside those directories. Neither what
111
- * the resolver read nor what only a transformer read is among them.
109
+ * `createInputFilter` tells, never in mootant's files, nor as the root
110
+ * itself outside those directories, and under `node_modules` only the
111
+ * modules Jest's runtime loaded for the vm. Neither what the resolver
112
+ * read nor what only a transformer read is among them.
112
113
  */
113
114
  reads: string[]
114
115
 
@@ -34,6 +34,13 @@ export interface WorkerChannel {
34
34
  */
35
35
  unit: JestUnit | null
36
36
 
37
+ /**
38
+ * Files Jest's runtime of the current unit read as the sources of the modules
39
+ * of the vm (`listRuntimeFiles`): what its file cache held before each reset
40
+ * of its modules (`keepResetLoads`) and once the test framework returned.
41
+ */
42
+ loads: Set<string>
43
+
37
44
  /**
38
45
  * What the vm's setup registered for the current unit, or null while it has
39
46
  * not run.
@@ -14,10 +14,11 @@ import { WorkerProcess } from '../types/worker-process.js';
14
14
  * what it gets in plain Jest. Types are stripped only where the project's Jest
15
15
  * strips them, which needs Node's function. One count of the calls into the
16
16
  * resolvers and transformers of the projects serves every unit, which tells
17
- * what they read apart from what tests read. Which reads count outside the
18
- * directories of the session is decided by the work directory, the one that
19
- * holds the directory of `session.json`, and the project root
20
- * (`createInputFilter`), taken here, before any unit runs.
17
+ * what they read apart from what tests read. Every reset of the modules of a
18
+ * runtime first gives the unit what the runtime loaded (`keepResetLoads`).
19
+ * Which reads count outside the directories of the session is decided by the
20
+ * work directory, the one that holds the directory of `session.json`, and the
21
+ * project root (`createInputFilter`), taken here, before any unit runs.
21
22
  *
22
23
  * @param input - What the worker runs with.
23
24
  * @param input.process - The worker's process, with `MOOTANT_SESSION`, the
@@ -65,7 +65,10 @@ type TestRunnerParameters = [
65
65
  * runs out of the store of the test environment's calls
66
66
  * (`WorkerCalls.environment`), which the last setup file may have entered for
67
67
  * `environment.setup()` and the load of the real test framework, and what
68
- * follows it, `environment.teardown()` among it, is back in it.
68
+ * follows it, `environment.teardown()` among it, is back in it. Once the
69
+ * framework returned, before Jest tears its runtime down, the channel takes the
70
+ * files that runtime loaded for the vm since its last reset of the modules
71
+ * (`listRuntimeFiles`), as it took those before each reset (`keepResetLoads`).
69
72
  *
70
73
  * @param input - What the wrapper works with.
71
74
  * @returns The function Jest calls as `(globalConfig, config, environment,
@@ -0,0 +1,13 @@
1
+ import { WorkerChannel } from '../types/worker-channel.js';
2
+ /**
3
+ * Wraps the `resetModules` of Jest's runtime class so that the files a runtime
4
+ * holds in its file cache (`listRuntimeFiles`) join those of the current unit
5
+ * (`WorkerChannel.loads`) before each reset empties the cache: whoever resets,
6
+ * a setup file, a test through `jest.resetModules()` or the test framework
7
+ * under the `resetModules` setting, calls that method of the runtime, which a
8
+ * project's own runtime gets from the class too.
9
+ *
10
+ * @param Runtime - Jest's runtime class, as `jest-runtime` exports it.
11
+ * @param channel - Channel of the worker.
12
+ */
13
+ export declare function keepResetLoads(Runtime: unknown, channel: WorkerChannel): void;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Lists the files Jest's runtime of a unit read as the sources of the modules
3
+ * of its vm, the setup files and the parts of the test framework that run in
4
+ * the vm among them: the keys of the file cache the runtime fills for one test
5
+ * file and empties at its teardown, `fileCache` on Jest 30, `_cacheFS` and
6
+ * `_cacheFSBuffer` on Jest 29.7. A runtime that keeps none of them, such as a
7
+ * project's own, gives none.
8
+ *
9
+ * @param runtime - Jest's runtime of the unit, as Jest hands it to the test
10
+ * framework.
11
+ * @returns Absolute paths.
12
+ */
13
+ export declare function listRuntimeFiles(runtime: unknown): Set<string>;
@@ -24,26 +24,31 @@ import { JestUnit } from '../types/jest-unit.js';
24
24
  * `finish` is written, since with `--experimental-vm-modules` the vm of every
25
25
  * unit, its console with it, stays in the worker. A read counts under the
26
26
  * directories of the session, and elsewhere as `createInputFilter` tells, but
27
- * never under `node_modules`, which the lockfile stands for, in mootant's
28
- * files, as a `node:` name that a stack frame gave and the tracker made a path
29
- * of, or as the project root itself outside the directories of the session,
30
- * which Babel and Browserslist look through in every worker, while its names
31
- * change with whatever appears beside the project's own files. What Jest's
32
- * resolver reads does not count, as it keeps what it found across units and a
33
- * real load is read anyway, but what a project's own resolver reads, a file it
34
- * only looks for too, decides what it gives, Jest's default one aside when it
35
- * hands that a request (`WorkerCalls.defaultResolver`); that and what a
36
- * transformer reads go apart, as the session's, since a warm worker reads them
37
- * only once, and stay among the reads too when code outside the transformers
38
- * read them, as a test file loads a source the language service of ts-jest read
39
- * first. The CommonJS modules the own realm of the worker loaded so far count
40
- * as reads do, since a warm worker does not read a transformer, a test
41
- * environment or a resolver again, nor what they import, but not one that this
42
- * or an earlier unit of the worker wrote itself (`UnitWorker.reads.own`); ES
43
- * modules are not in `require.cache`, so one of those counts only in the unit
44
- * that loaded it. A transform still running when the run ended, of an import
45
- * the unit never awaited, ends the worker: what it reads from then on reaches
46
- * no unit, and a later unit would get the module from the worker's memory.
27
+ * never in mootant's files, as a `node:` name that a stack frame gave and the
28
+ * tracker made a path of, or as the project root itself outside the directories
29
+ * of the session, which Babel and Browserslist look through in every worker,
30
+ * while its names change with whatever appears beside the project's own files.
31
+ * Under `node_modules` only the modules Jest's runtime of the unit loaded for
32
+ * the vm count (`WorkerChannel.loads`), its setup files and test framework
33
+ * among them: what else is read there is the test runner's own, as Jest, a test
34
+ * environment or a transformer and what they import load once in a warm worker
35
+ * and are read again for stack traces, while an install that changes them shows
36
+ * in the files that tell what was installed. What Jest's resolver reads does
37
+ * not count, as it keeps what it found across units and a real load is read
38
+ * anyway, but what a project's own resolver reads, a file it only looks for
39
+ * too, decides what it gives, Jest's default one aside when it hands that a
40
+ * request (`WorkerCalls.defaultResolver`); that and what a transformer reads go
41
+ * apart, as the session's, since a warm worker reads them only once, and stay
42
+ * among the reads too when code outside the transformers read them, as a test
43
+ * file loads a source the language service of ts-jest read first. The CommonJS
44
+ * modules the own realm of the worker loaded so far count as reads do, since a
45
+ * warm worker does not read a transformer, a test environment or a resolver
46
+ * again, nor what they import, but not one that this or an earlier unit of the
47
+ * worker wrote itself (`UnitWorker.reads.own`); ES modules are not in
48
+ * `require.cache`, so one of those counts only in the unit that loaded it. A
49
+ * transform still running when the run ended, of an import the unit never
50
+ * awaited, ends the worker: what it reads from then on reaches no unit, and a
51
+ * later unit would get the module from the worker's memory.
47
52
  *
48
53
  * @param unit - Test file, project, mutant, switch plan and out file.
49
54
  * @param worker - What the boot of the worker made.
@@ -1,2 +1,2 @@
1
- var e = "// core/runtime/create-hit-limit-error.ts\n/**\n* Error that stops a try whose code evaluated more mutant sites than allowed.\n*/\nvar MootantHitLimitError = class extends Error {\n /**\n * Name that tells the error apart, even across realms.\n */\n name = \"MootantHitLimitError\";\n};\n/**\n* Creates the error that stops a batch try, or a test file run with a mutant,\n* whose code evaluated more mutant sites than allowed: a loop that a mutant\n* made endless, or code that a mutant made far hotter, such as a cache turned\n* off.\n*\n* @param id - Id of the mutant whose site went over the limit.\n* @param limit - Site evaluations allowed.\n* @returns Error named `MootantHitLimitError`.\n*/\nfunction createHitLimitError(id, limit) {\n return new MootantHitLimitError(`mootant stopped the test after ${limit} evaluations of mutant sites, at mutant ${id}; the code may loop endlessly or do far more work than without mutants (see run.hitLimit).`);\n}\n// core/runtime/runtime-symbol-key.ts\n/**\n* Key of the registered symbol under which `Math` holds the mutant runtime:\n* `Math[Symbol.for('mootant')]`. Vue templates reach the runtime there, since\n* the Vue compiler reads every other global name, `globalThis` included, as a\n* property of the component, but leaves `Math` and `Symbol` alone.\n*/\nvar RUNTIME_SYMBOL_KEY = \"mootant\";\n// core/runtime/runtime-global.ts\n/**\n* Name of the global through which switched code reaches the mutant runtime:\n* `globalThis.__mootant`.\n*/\nvar RUNTIME_GLOBAL = \"__mootant\";\n// core/runtime/install-mutant-runtime.ts\n/**\n* Installs the mutant runtime as `globalThis.__mootant`, where switched code\n* calls `hit` at every mutant site, and as `Math[Symbol.for('mootant')]`, where\n* switched Vue templates call it. The property of `Math` is not enumerable, and\n* `Object.getOwnPropertyNames(Math)` does not list a symbol key, so code that\n* walks `Math` does not see it. A runtime already installed in the process is\n* returned as is, since switched code may already hold it. A new runtime starts\n* with the original code active, no coverage and no hit limit.\n*\n* @returns The runtime of the process.\n*/\nfunction installMutantRuntime() {\n let runtime = Reflect.get(globalThis, \"__mootant\") ?? createRuntime();\n Reflect.set(globalThis, RUNTIME_GLOBAL, runtime);\n Object.defineProperty(Math, Symbol.for(RUNTIME_SYMBOL_KEY), {\n configurable: true,\n enumerable: false,\n value: runtime,\n writable: true\n });\n return runtime;\n}\n/**\n* Creates a runtime with the original code active, no coverage and no hit\n* limit. Its helpers for the removal of array elements use index loops over\n* arrays the switched code builds, never an array iterator or a method of the\n* array prototype, which tests may replace.\n*\n* @returns The new runtime.\n*/\nfunction createRuntime() {\n let gap = Symbol(\"mootant gap\");\n let runtime = {\n hit(id) {\n runtime.hits += 1;\n if (runtime.hits > runtime.hitLimit) throw createHitLimitError(id, runtime.hitLimit);\n if (runtime.coverage !== null) runtime.coverage.add(id);\n if (runtime.active === id) {\n runtime.reached = true;\n return true;\n }\n return false;\n },\n hitAny(ids) {\n for (let index = 0; index < ids.length; index++) if (runtime.hit(ids[index])) return true;\n return false;\n },\n cut(array) {\n let kept = 0;\n for (let index = 0; index < array.length; index++) {\n let value = array[index];\n if (value !== gap) {\n array[kept] = value;\n kept += 1;\n }\n }\n array.length = kept;\n return array;\n },\n none: { [Symbol.iterator]: () => ({ next: () => ({\n value: void 0,\n done: true\n }) }) },\n hitLimit: Infinity,\n coverage: null,\n reached: false,\n active: null,\n hits: 0,\n gap\n };\n return runtime;\n}\n// adapters/shared/environment-slot.ts\n/**\n* Global slot of the tracking state of the process; a tracking proxy answers\n* that it has this key, which tells it from a plain object.\n*/\nvar ENVIRONMENT_SLOT = Symbol.for(\"mootant.environment\");\n// adapters/shared/create-environment-proxy.ts\n/**\n* Wraps an object of environment variables in a proxy that reports to the\n* receiver of the state the names read and `*` when they are listed. The fields\n* of the state are read at every trap, since their owner replaces them later.\n*\n* @param target - Object to wrap.\n* @param state - Tracking state; `listing` is written here too.\n* @returns The proxy; it answers that it has `ENVIRONMENT_SLOT`, so a caller\n* can tell it from a plain object.\n*/\nfunction createEnvironmentProxy(target, state) {\n /**\n * A test's fake timers replace the global after this.\n */\n let schedule = queueMicrotask;\n /**\n * Reports a variable read by its name.\n *\n * @param name - Property key read.\n */\n function report(name) {\n if (typeof name === \"string\" && !state.listing && !state.ignored.has(name)) state.record?.(name);\n }\n return new Proxy(target, {\n ownKeys: (object) => {\n state.record?.(\"*\");\n if (!state.listing) {\n state.listing = true;\n schedule(() => {\n state.listing = false;\n });\n }\n return Reflect.ownKeys(object);\n },\n getOwnPropertyDescriptor: (object, name) => {\n report(name);\n return Reflect.getOwnPropertyDescriptor(object, name);\n },\n has: (object, name) => {\n report(name);\n return name === ENVIRONMENT_SLOT || Reflect.has(object, name);\n },\n get: (object, name) => {\n report(name);\n return Reflect.get(object, name);\n },\n set: (object, name, value) => Reflect.set(object, name, value)\n });\n}\n// adapters/jest/worker/install-vm-side.ts\n/**\n* Timer functions of a vm, each with the function that clears its handles.\n*/\nvar TIMERS = [\n [\"setTimeout\", \"clearTimeout\"],\n [\"setInterval\", \"clearInterval\"],\n [\"setImmediate\", \"clearImmediate\"]\n];\n/**\n* Sets up a test's vm before any project code, and registers on the channel\n* what the worker reads and stops once the unit ended; it registers last, so a\n* worker that sees no side knows the setup never ran. The file does not change\n* how a timer behaves, and fake timers pass around the wrappers. Nothing is\n* ignored in the environment: Node's loader reads the real `process.env`, not\n* this one.\n*\n* @param input - What the setup works with.\n*/\nfunction installVmSide(input) {\n let { channel, install, target } = input;\n let { token } = channel;\n let unit = channel.unit;\n /**\n * Jest's node environment copies the worker's globals as it loads, the stub\n * in `__mootant` too, and `install` would keep that as a runtime.\n */\n Reflect.deleteProperty(target, RUNTIME_GLOBAL);\n let runtime = install();\n Object.defineProperty(target, RUNTIME_GLOBAL, {\n configurable: true,\n enumerable: false,\n value: runtime,\n writable: true\n });\n /**\n * Jest 30's cleanup of a vm's globals spares what carries this mark.\n */\n Reflect.set(runtime, Symbol.for(\"$$jest-protect-from-deletion\"), true);\n let { hit } = runtime;\n let reached = false;\n let closed = false;\n runtime.hit = (id) => {\n if (closed) return false;\n let active = hit(id);\n if (active && !reached) {\n reached = true;\n /**\n * The only durable proof of a reach, so it cannot wait.\n */\n channel.write(token, {\n hits: runtime.hits,\n kind: \"reached\"\n });\n }\n return active;\n };\n let stops = [];\n for (let names of TIMERS) wrapTimer(target, names, stops);\n let seen = /* @__PURE__ */ new Set();\n target.process.env = createEnvironmentProxy(target.process.env, {\n record: (name) => {\n seen.add(name);\n },\n ignored: /* @__PURE__ */ new Set(),\n listing: false\n });\n runtime.active = unit.mutant;\n runtime.hitLimit = unit.hitLimit ?? Infinity;\n runtime.coverage = unit.mutant === null ? /* @__PURE__ */ new Set() : null;\n channel.vm = {\n stopTimers() {\n for (let stop of stops.splice(0)) stop();\n },\n addVariable(name) {\n seen.add(name);\n },\n close() {\n closed = true;\n },\n listVariables: () => [...seen],\n realmError: target.Error,\n isReached: () => reached,\n runtime\n };\n}\n/**\n* Replaces a timer function of the vm, if it has it (jsdom has no\n* `setImmediate`) and the function that clears its handles, with one that\n* remembers how to clear each handle and keeps the original's own properties,\n* above all `util.promisify.custom`.\n*\n* @param target - The vm's `globalThis`.\n* @param names - Names of the function and of the one that clears its handles.\n* @param stops - Receives a function that clears each handle.\n*/\nfunction wrapTimer(target, names, stops) {\n let [startName, clearName] = names;\n let start = Reflect.get(target, startName);\n let clear = Reflect.get(target, clearName);\n if (start === void 0 || clear === void 0) return;\n /**\n * Starts the timer and remembers its handle.\n *\n * @param parameters - Arguments of the call.\n * @returns The handle.\n */\n function wrapper(...parameters) {\n let handle = start.apply(this, parameters);\n stops.push(() => {\n clear.call(target, handle);\n });\n return handle;\n }\n let { prototype, length, name, ...own } = Object.getOwnPropertyDescriptors(start);\n Object.defineProperties(wrapper, own);\n Reflect.set(target, startName, wrapper);\n}\n// adapters/jest/worker/channel-slot.ts\n/**\n* Key of the worker's channel on `process`: a test's vm gets a copy of it that\n* holds what a symbol key holds as it is, so the vm reaches the same object,\n* and the bundle of the vm's setup has no module in common with the worker's.\n*/\nvar CHANNEL_SLOT = Symbol.for(\"mootant.channel\");\n// adapters/jest/worker/vm-setup.ts\n/**\n* First of a project's `setupFiles`. It runs inside the test's vm, where\n* `require` goes through `moduleNameMapper` and automock, so neither this file\n* nor what it imports has a `node:` import. The channel comes on the vm's\n* `process`, since Jest 30.5 sends `process.getBuiltinModule` through\n* `moduleNameMapper` as well.\n*/\ninstallVmSide({\n channel: Reflect.get(process, CHANNEL_SLOT),\n install: installMutantRuntime,\n target: globalThis\n});\n";
1
+ var e = "// core/runtime/create-hit-limit-error.ts\n/**\n* Error that stops a try whose code evaluated more mutant sites than allowed.\n*/\nvar MootantHitLimitError = class extends Error {\n /**\n * Name that tells the error apart, even across realms.\n */\n name = \"MootantHitLimitError\";\n};\n/**\n* Creates the error that stops a batch try, or a test file run with a mutant,\n* whose code evaluated more mutant sites than allowed: a loop that a mutant\n* made endless, or code that a mutant made far hotter, such as a cache turned\n* off.\n*\n* @param id - Id of the mutant whose site went over the limit.\n* @param limit - Site evaluations allowed.\n* @returns Error named `MootantHitLimitError`.\n*/\nfunction createHitLimitError(id, limit) {\n return new MootantHitLimitError(`mootant stopped the test after ${limit} evaluations of mutant sites, at mutant ${id}; the code may loop endlessly or do far more work than without mutants (see run.hitLimit).`);\n}\n// core/runtime/runtime-symbol-key.ts\n/**\n* Key of the registered symbol under which `Math` holds the mutant runtime:\n* `Math[Symbol.for('mootant')]`. Vue templates reach the runtime there, since\n* the Vue compiler reads every other global name, `globalThis` included, as a\n* property of the component, but leaves `Math` and `Symbol` alone.\n*/\nvar RUNTIME_SYMBOL_KEY = \"mootant\";\n// core/runtime/runtime-global.ts\n/**\n* Name of the global through which switched code reaches the mutant runtime:\n* `globalThis.__mootant`.\n*/\nvar RUNTIME_GLOBAL = \"__mootant\";\n// core/runtime/install-mutant-runtime.ts\n/**\n* Installs the mutant runtime as `globalThis.__mootant`, where switched code\n* calls `hit` at every mutant site, and as `Math[Symbol.for('mootant')]`, where\n* switched Vue templates call it. The property of `Math` is not enumerable, and\n* `Object.getOwnPropertyNames(Math)` does not list a symbol key, so code that\n* walks `Math` does not see it. A runtime already installed in the process is\n* returned as is, since switched code may already hold it. A new runtime starts\n* with the original code active, no coverage and no hit limit.\n*\n* @returns The runtime of the process.\n*/\nfunction installMutantRuntime() {\n let runtime = Reflect.get(globalThis, \"__mootant\") ?? createRuntime();\n Reflect.set(globalThis, RUNTIME_GLOBAL, runtime);\n Object.defineProperty(Math, Symbol.for(RUNTIME_SYMBOL_KEY), {\n configurable: true,\n enumerable: false,\n value: runtime,\n writable: true\n });\n return runtime;\n}\n/**\n* Creates a runtime with the original code active, no coverage and no hit\n* limit. Its helpers for the removal of array elements use index loops over\n* arrays the switched code builds, never an array iterator or a method of the\n* array prototype, which tests may replace.\n*\n* @returns The new runtime.\n*/\nfunction createRuntime() {\n let gap = Symbol(\"mootant gap\");\n let runtime = {\n hit(id) {\n runtime.hits += 1;\n if (runtime.hits > runtime.hitLimit) throw createHitLimitError(id, runtime.hitLimit);\n if (runtime.coverage !== null) runtime.coverage.add(id);\n if (runtime.active === id) {\n runtime.reached = true;\n return true;\n }\n return false;\n },\n hitAny(ids) {\n for (let index = 0; index < ids.length; index++) if (runtime.hit(ids[index])) return true;\n return false;\n },\n cut(array) {\n let kept = 0;\n for (let index = 0; index < array.length; index++) {\n let value = array[index];\n if (value !== gap) {\n array[kept] = value;\n kept += 1;\n }\n }\n array.length = kept;\n return array;\n },\n none: { [Symbol.iterator]: () => ({ next: () => ({\n value: void 0,\n done: true\n }) }) },\n hitLimit: Infinity,\n coverage: null,\n reached: false,\n active: null,\n hits: 0,\n gap\n };\n return runtime;\n}\n// adapters/shared/environment-slot.ts\n/**\n* Global slot of the tracking state of the process; a tracking proxy answers\n* that it has this key, which tells it from a plain object.\n*/\nvar ENVIRONMENT_SLOT = Symbol.for(\"mootant.environment\");\n// adapters/shared/create-environment-proxy.ts\n/**\n* Wraps an object of environment variables, or of other values code reads by\n* name, in a proxy that reports to the receiver of the state the names read and\n* `*` when they are listed. The fields of the state are read at every trap,\n* since their owner replaces them later.\n*\n* @param target - Object to wrap.\n* @param state - Tracking state; `listing` is written here too.\n* @returns The proxy; it answers that it has `ENVIRONMENT_SLOT`, so a caller\n* can tell it from a plain object.\n*/\nfunction createEnvironmentProxy(target, state) {\n /**\n * A test's fake timers replace the global after this.\n */\n let schedule = queueMicrotask;\n /**\n * Reports a variable read by its name.\n *\n * @param name - Property key read.\n */\n function report(name) {\n if (typeof name === \"string\" && !state.listing && !state.ignored.has(name)) state.record?.(name);\n }\n return new Proxy(target, {\n ownKeys: (object) => {\n state.record?.(\"*\");\n if (!state.listing) {\n state.listing = true;\n schedule(() => {\n state.listing = false;\n });\n }\n return Reflect.ownKeys(object);\n },\n getOwnPropertyDescriptor: (object, name) => {\n report(name);\n return Reflect.getOwnPropertyDescriptor(object, name);\n },\n has: (object, name) => {\n report(name);\n return name === ENVIRONMENT_SLOT || Reflect.has(object, name);\n },\n get: (object, name) => {\n report(name);\n return Reflect.get(object, name);\n },\n set: (object, name, value) => Reflect.set(object, name, value)\n });\n}\n// adapters/jest/worker/install-vm-side.ts\n/**\n* Timer functions of a vm, each with the function that clears its handles.\n*/\nvar TIMERS = [\n [\"setTimeout\", \"clearTimeout\"],\n [\"setInterval\", \"clearInterval\"],\n [\"setImmediate\", \"clearImmediate\"]\n];\n/**\n* Sets up a test's vm before any project code, and registers on the channel\n* what the worker reads and stops once the unit ended; it registers last, so a\n* worker that sees no side knows the setup never ran. The file does not change\n* how a timer behaves, and fake timers pass around the wrappers. Nothing is\n* ignored in the environment: Node's loader reads the real `process.env`, not\n* this one.\n*\n* @param input - What the setup works with.\n*/\nfunction installVmSide(input) {\n let { channel, install, target } = input;\n let { token } = channel;\n let unit = channel.unit;\n /**\n * Jest's node environment copies the worker's globals as it loads, the stub\n * in `__mootant` too, and `install` would keep that as a runtime.\n */\n Reflect.deleteProperty(target, RUNTIME_GLOBAL);\n let runtime = install();\n Object.defineProperty(target, RUNTIME_GLOBAL, {\n configurable: true,\n enumerable: false,\n value: runtime,\n writable: true\n });\n /**\n * Jest 30's cleanup of a vm's globals spares what carries this mark.\n */\n Reflect.set(runtime, Symbol.for(\"$$jest-protect-from-deletion\"), true);\n let { hit } = runtime;\n let reached = false;\n let closed = false;\n runtime.hit = (id) => {\n if (closed) return false;\n let active = hit(id);\n if (active && !reached) {\n reached = true;\n /**\n * The only durable proof of a reach, so it cannot wait.\n */\n channel.write(token, {\n hits: runtime.hits,\n kind: \"reached\"\n });\n }\n return active;\n };\n let stops = [];\n for (let names of TIMERS) wrapTimer(target, names, stops);\n let seen = /* @__PURE__ */ new Set();\n target.process.env = createEnvironmentProxy(target.process.env, {\n record: (name) => {\n seen.add(name);\n },\n ignored: /* @__PURE__ */ new Set(),\n listing: false\n });\n runtime.active = unit.mutant;\n runtime.hitLimit = unit.hitLimit ?? Infinity;\n runtime.coverage = unit.mutant === null ? /* @__PURE__ */ new Set() : null;\n channel.vm = {\n stopTimers() {\n for (let stop of stops.splice(0)) stop();\n },\n addVariable(name) {\n seen.add(name);\n },\n close() {\n closed = true;\n },\n listVariables: () => [...seen],\n realmError: target.Error,\n isReached: () => reached,\n runtime\n };\n}\n/**\n* Replaces a timer function of the vm, if it has it (jsdom has no\n* `setImmediate`) and the function that clears its handles, with one that\n* remembers how to clear each handle and keeps the original's own properties,\n* above all `util.promisify.custom`.\n*\n* @param target - The vm's `globalThis`.\n* @param names - Names of the function and of the one that clears its handles.\n* @param stops - Receives a function that clears each handle.\n*/\nfunction wrapTimer(target, names, stops) {\n let [startName, clearName] = names;\n let start = Reflect.get(target, startName);\n let clear = Reflect.get(target, clearName);\n if (start === void 0 || clear === void 0) return;\n /**\n * Starts the timer and remembers its handle.\n *\n * @param parameters - Arguments of the call.\n * @returns The handle.\n */\n function wrapper(...parameters) {\n let handle = start.apply(this, parameters);\n stops.push(() => {\n clear.call(target, handle);\n });\n return handle;\n }\n let { prototype, length, name, ...own } = Object.getOwnPropertyDescriptors(start);\n Object.defineProperties(wrapper, own);\n Reflect.set(target, startName, wrapper);\n}\n// adapters/jest/worker/channel-slot.ts\n/**\n* Key of the worker's channel on `process`: a test's vm gets a copy of it that\n* holds what a symbol key holds as it is, so the vm reaches the same object,\n* and the bundle of the vm's setup has no module in common with the worker's.\n*/\nvar CHANNEL_SLOT = Symbol.for(\"mootant.channel\");\n// adapters/jest/worker/vm-setup.ts\n/**\n* First of a project's `setupFiles`. It runs inside the test's vm, where\n* `require` goes through `moduleNameMapper` and automock, so neither this file\n* nor what it imports has a `node:` import. The channel comes on the vm's\n* `process`, since Jest 30.5 sends `process.getBuiltinModule` through\n* `moduleNameMapper` as well.\n*/\ninstallVmSide({\n channel: Reflect.get(process, CHANNEL_SLOT),\n install: installMutantRuntime,\n target: globalThis\n});\n";
2
2
  export { e as default };