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
@@ -13,14 +13,16 @@ import { SerializedConfig, RunnerTestSuite, RunnerTestCase, RunnerTestFile, Test
13
13
  * the worker's teardown: Vitest cleans up the worker-scoped fixtures, then
14
14
  * tears the test environment down; errors of both count as a failed suite hook,
15
15
  * and the heartbeat covers both, so a hang there stops the worker. What the
16
- * code reads is recorded until the unit ends, so files and environment
17
- * variables read in that teardown are inputs of the unit like those its tests
18
- * read; a teardown step that runs after the unit ended, as the test
19
- * environment's when the worker's teardown cannot be watched, counts for
20
- * neither. A test environment other than Vitest's own loads and sets up before
21
- * the runner exists, out of sight, so its units report no dependencies and are
22
- * never cached. A unit waits until the worker of the unit before it of the same
23
- * test file is gone, so a test file never runs twice at once.
16
+ * code reads is recorded until the unit ends, so files, environment variables
17
+ * and values of `provide` and `define` read in that teardown are inputs of the
18
+ * unit like those its tests read; a teardown step that runs after the unit
19
+ * ended, as the test environment's when the worker's teardown cannot be
20
+ * watched, counts for neither. A test environment other than Vitest's own loads
21
+ * and sets up before the runner exists, out of sight, so its units report no
22
+ * dependencies and are never cached. A unit waits until the worker of the unit
23
+ * before it of the same test file is gone, so a test file never runs twice at
24
+ * once, unless the run is an isolated one with parallel units
25
+ * (`VitestWorkerOptions.parallel`).
24
26
  *
25
27
  * Tests the user marked concurrent stay concurrent in isolated units and in a
26
28
  * dry run that tries each test once, as in a plain run; a batch run and a dry
@@ -62,6 +64,11 @@ export default class Runner extends TestRunner {
62
64
  * when the user's tests run concurrently.
63
65
  */
64
66
  private readonly records;
67
+ /**
68
+ * Defines Vitest ran as a script for the project, by key, with whether each
69
+ * value is code (`listScriptDefines`).
70
+ */
71
+ private readonly scripted;
65
72
  /**
66
73
  * Milliseconds the hooks around each test may take by Vitest's own hook
67
74
  * timeouts, by test id; filled in a dry run.
@@ -108,6 +115,11 @@ export default class Runner extends TestRunner {
108
115
  * Mutants a try of this unit already failed with; they are not tried again.
109
116
  */
110
117
  private readonly killed;
118
+ /**
119
+ * Names of the values of `provide` and `define` the code read since the
120
+ * runner was created (`trackValues`).
121
+ */
122
+ private readonly values;
111
123
  /**
112
124
  * Ids of the tests that run, or null to run every test.
113
125
  */
@@ -232,20 +244,29 @@ export default class Runner extends TestRunner {
232
244
  */
233
245
  private file;
234
246
  /**
235
- * Creates the runner of one test file, installs the mutant runtime, takes
236
- * over Vitest's report of the worker's unhandled errors (`interceptStrays`),
237
- * records the worker's process id, so the main process waits until the worker
238
- * is gone, and moves the end of the unit to the end of the worker's teardown,
239
- * after the test environment's teardown, whose error fails the unit like a
240
- * failed suite hook.
247
+ * Creates the runner of one test file, turns the compile cache of the worker
248
+ * on for the modules it loads from now on (`enableCompileCache`), which
249
+ * Vitest writes when it stops the worker, records the values of `provide` and
250
+ * `define` the code reads from now on, as Vitest loads the modules of the
251
+ * diff and the snapshot serializers after the runner (`trackValues`),
252
+ * installs the mutant runtime, takes over Vitest's report of the worker's
253
+ * unhandled errors (`interceptStrays`), records the worker's process id, so
254
+ * the main process waits until the worker is gone, and moves the end of the
255
+ * unit to the end of the worker's teardown, after the test environment's
256
+ * teardown, whose error fails the unit like a failed suite hook. A dry run
257
+ * turns test locations on, as the report gives the line of each test. Batch
258
+ * and isolated runs keep the project's setting: Vitest finds each location by
259
+ * mapping a stack trace through source maps, which every unit would pay for
260
+ * each test and suite of its file.
241
261
  *
242
262
  * @param config - Serialized configuration of the project.
243
263
  */
244
264
  constructor(config: SerializedConfig);
245
265
  /**
246
- * Claims a unit, waits for the unit before it of the same test file, and
247
- * prepares the runtime before the test file and its setup files load. Vitest
248
- * awaits this hook once per test file.
266
+ * Claims a unit, waits for the unit before it of the same test file unless
267
+ * the run is an isolated one with parallel units, and prepares the runtime
268
+ * before the test file and its setup files load. Vitest awaits this hook once
269
+ * per test file.
249
270
  *
250
271
  * @param paths - Absolute path of the test file.
251
272
  */
@@ -374,29 +395,39 @@ export default class Runner extends TestRunner {
374
395
  private aroundTry;
375
396
  /**
376
397
  * Starts recording the files the test code reads through `node:fs` that count
377
- * as inputs, inside the project root or outside it (`createInputFilter`), and
378
- * the environment variables it reads, before the test file and its setup
379
- * files load. The first worker of a project in a dry run also writes the
380
- * hashes of the worker's environment variables, as Vitest set them up, to
381
- * `env/<hash>.json` of the work directory, for the main process to tell what
382
- * the variables read were.
398
+ * as inputs, inside the project root or outside it (`createInputFilter`), the
399
+ * environment variables it reads and the defines of `import.meta`
400
+ * (`trackMeta`), before the test file and its setup files load. The first
401
+ * worker of a project in a dry run also writes the hashes of the worker's
402
+ * environment variables, as Vitest set them up, to `env/<hash>.json` of the
403
+ * work directory, for the main process to tell what the variables read were.
383
404
  *
384
405
  * @param snapshot - Whether to write the environment of the project.
385
406
  */
386
407
  private startTracking;
408
+ /**
409
+ * Tracks the defines of `import.meta` given as JSON in the modules Vitest
410
+ * evaluates from now on (`trackMetaDefines`), or counts them for the unit at
411
+ * once when Vitest loaded modules of the project before, a snapshot
412
+ * environment, the diff options or snapshot serializers, or when they cannot
413
+ * be tracked.
414
+ */
415
+ private trackMeta;
387
416
  /**
388
417
  * Stops recording what the code reads once the unit ended and lists what it
389
418
  * depended on: what the test file depended on when its file suite ended, with
390
419
  * what the worker evaluated, required and read through `node:fs` until now,
391
- * the environment variables it read, and the files it read and changed
392
- * itself. A test environment other than Vitest's own loads and sets up before
393
- * the runner exists, so what its module and `setup` read, and the references
394
- * to `process.env` and `node:fs` they keep, are out of sight: such a unit
395
- * reports no dependencies, so it is never cached.
420
+ * the environment variables and the values of `provide` and `define` it read,
421
+ * and the files it read and changed itself. A test environment other than
422
+ * Vitest's own loads and sets up before the runner exists, so what its module
423
+ * and `setup` read, and the references to `process.env` and `node:fs` they
424
+ * keep, are out of sight: such a unit reports no dependencies, so it is never
425
+ * cached.
396
426
  *
397
427
  * @returns What the unit depended on, sorted, or null when it cannot tell,
398
428
  * with the names of the environment variables it read, `*` for all of them,
399
- * and the files and directories it read and changed itself, both sorted.
429
+ * and of the values (`trackValues`), and the files and directories it read
430
+ * and changed itself, both sorted.
400
431
  */
401
432
  private stopTracking;
402
433
  /**
@@ -1,39 +1,44 @@
1
1
  import { installMutantRuntime as e } from "../../core/runtime/install-mutant-runtime.js";
2
- import { watchWorkerClose as t } from "./worker/watch-worker-close.js";
3
- import { listDependencies as n } from "./worker/list-dependencies.js";
4
- import { getErrorMessage as r } from "../shared/get-error-message.js";
5
- import { VITEST_VARIABLES as i } from "./worker/vitest-variables.js";
6
- import { interceptStrays as a } from "./worker/intercept-strays.js";
7
- import { readWorkerPlan as o } from "./worker/read-worker-plan.js";
8
- import { raceTryTimeout as s } from "./worker/race-try-timeout.js";
9
- import { writeOutRecord as c } from "./worker/write-out-record.js";
10
- import { installTryHook as l } from "./worker/install-try-hook.js";
11
- import { writeHeartbeat as u } from "./worker/write-heartbeat.js";
12
- import { findHookError as d } from "./worker/find-hook-error.js";
13
- import { getHookBudget as f } from "./worker/get-hook-budget.js";
14
- import { readTryFacts as p } from "./worker/read-try-facts.js";
15
- import { captureClock as m } from "../shared/capture-clock.js";
16
- import { trackInputs as h } from "../shared/track-inputs.js";
17
- import { getFileHash as g } from "./worker/get-file-hash.js";
18
- import { waitForTurn as _ } from "./worker/wait-for-turn.js";
19
- import { encodeStray as v } from "./worker/encode-stray.js";
20
- import { orderTests as y } from "./worker/order-tests.js";
21
- import { claimUnit as b } from "./worker/claim-unit.js";
22
- import { listTests as x } from "./worker/list-tests.js";
23
- import { createRequire as S } from "node:module";
24
- import { closeSync as C, openSync as w, rmSync as T, writeFileSync as E } from "node:fs";
25
- import D from "node:path";
26
- import { createHash as O } from "node:crypto";
27
- import { builtinEnvironments as k } from "vitest/runtime";
28
- import { TestRunner as A } from "vitest";
29
- const j = 2 ** 31 - 1;
30
- let M = m();
31
- var N = class extends A {
2
+ import { enableCompileCache as t } from "../shared/enable-compile-cache.js";
3
+ import { watchWorkerClose as n } from "./worker/watch-worker-close.js";
4
+ import { trackMetaDefines as r } from "./worker/track-meta-defines.js";
5
+ import { listDependencies as i } from "./worker/list-dependencies.js";
6
+ import { getErrorMessage as a } from "../shared/get-error-message.js";
7
+ import { VITEST_VARIABLES as o } from "./worker/vitest-variables.js";
8
+ import { interceptStrays as s } from "./worker/intercept-strays.js";
9
+ import { readWorkerPlan as c } from "./worker/read-worker-plan.js";
10
+ import { raceTryTimeout as l } from "./worker/race-try-timeout.js";
11
+ import { writeOutRecord as u } from "./worker/write-out-record.js";
12
+ import { installTryHook as d } from "./worker/install-try-hook.js";
13
+ import { writeHeartbeat as f } from "./worker/write-heartbeat.js";
14
+ import { findHookError as p } from "./worker/find-hook-error.js";
15
+ import { getHookBudget as m } from "./worker/get-hook-budget.js";
16
+ import { VALUE_PREFIXES as h } from "./worker/value-prefixes.js";
17
+ import { readTryFacts as g } from "./worker/read-try-facts.js";
18
+ import { captureClock as _ } from "../shared/capture-clock.js";
19
+ import { trackInputs as v } from "../shared/track-inputs.js";
20
+ import { getFileHash as y } from "./worker/get-file-hash.js";
21
+ import { waitForTurn as b } from "./worker/wait-for-turn.js";
22
+ import { trackValues as x } from "./worker/track-values.js";
23
+ import { encodeStray as S } from "./worker/encode-stray.js";
24
+ import { orderTests as C } from "./worker/order-tests.js";
25
+ import { claimUnit as w } from "./worker/claim-unit.js";
26
+ import { listTests as T } from "./worker/list-tests.js";
27
+ import * as E from "node:module";
28
+ import { closeSync as D, openSync as O, rmSync as k, writeFileSync as A } from "node:fs";
29
+ import j from "node:path";
30
+ import { createHash as M } from "node:crypto";
31
+ import { builtinEnvironments as N } from "vitest/runtime";
32
+ import { TestRunner as P } from "vitest";
33
+ const F = 2 ** 31 - 1;
34
+ let I = _(), L = Date.now.bind(Date);
35
+ var R = class extends P {
32
36
  coverSink = { add: (e) => {
33
37
  for (let t of this.activeCovers) t.add(e);
34
38
  } };
35
39
  runtime = e();
36
40
  records = /* @__PURE__ */ new Map();
41
+ scripted;
37
42
  hookBudgets = /* @__PURE__ */ new Map();
38
43
  planned = /* @__PURE__ */ new Map();
39
44
  loadCovers = /* @__PURE__ */ new Set();
@@ -47,6 +52,7 @@ var N = class extends A {
47
52
  beatDescriptor = null;
48
53
  inputs = null;
49
54
  killed = /* @__PURE__ */ new Set();
55
+ values = /* @__PURE__ */ new Set();
50
56
  runnable = null;
51
57
  activeCovers = [];
52
58
  lastMutant = null;
@@ -77,43 +83,49 @@ var N = class extends A {
77
83
  file = "";
78
84
  constructor(e) {
79
85
  super(e), this.options = this.injectValue("mootant");
80
- let { directory: n, repeat: i, mode: o } = this.options;
81
- this.sequential = o === "batch" || o === "dry" && i, this.beatFile = D.join(n, "beat", `${process.pid}.json`), C(w(D.join(n, "worker", String(process.pid)), "w")), a(Reflect.get(this, "workerState"), (e, t) => {
86
+ let { directory: r, repeat: i, mode: o } = this.options;
87
+ t(E, r), this.scripted = this.options.defines?.[e.name ?? ""] ?? {}, x(Reflect.get(this, "workerState"), {
88
+ snapshotEnvironment: e.snapshotEnvironment,
89
+ scripted: this.scripted,
90
+ defines: e.defines
91
+ }, (e) => {
92
+ this.values.add(e);
93
+ }), this.sequential = o === "batch" || o === "dry" && i, o === "dry" && (this.config.includeTaskLocation = !0), this.beatFile = j.join(r, "beat", `${process.pid}.json`), D(O(j.join(r, "worker", String(process.pid)), "w")), s(Reflect.get(this, "workerState"), (e, t) => {
82
94
  this.onStray(e, t);
83
95
  });
84
- let s = this.onCleanupWorkerContext;
85
- if (s !== void 0) {
86
- let e = Reflect.get(this, "workerState"), n = t(Reflect.get(e.ctx, "traces"));
96
+ let c = this.onCleanupWorkerContext;
97
+ if (c !== void 0) {
98
+ let e = Reflect.get(this, "workerState"), t = n(Reflect.get(e.ctx, "traces"));
87
99
  this.onCleanupWorkerContext = (e) => {
88
- this.endsInTeardown = !0, n !== null && (this.endsOnClose = !0, n((e) => {
89
- e !== null && (this.hookError ??= r(e.error)), this.finishUnit();
90
- })), s(() => this.tearDown(e));
100
+ this.endsInTeardown = !0, t !== null && (this.endsOnClose = !0, t((e) => {
101
+ e !== null && (this.hookError ??= a(e.error)), this.finishUnit();
102
+ })), c(() => this.tearDown(e));
91
103
  };
92
104
  }
93
105
  }
94
106
  async onBeforeCollect(e) {
95
107
  let { runtime: t, options: n } = this, r = e[0];
96
- this.file = r, this.started = M.now(), this.booted = performance.timeOrigin + this.started, t.hitLimit = Infinity, t.coverage = null, t.reached = !1, t.active = null, t.hits = 0;
97
- let i = g(r, this.config.name ?? ""), a = D.join(n.directory, "out");
108
+ this.file = r, this.started = I.now(), this.booted = L(), t.hitLimit = Infinity, t.coverage = null, t.reached = !1, t.active = null, t.hits = 0;
109
+ let i = y(r, this.config.name ?? ""), a = j.join(n.directory, "out");
98
110
  if (n.mode === "dry") {
99
- t.coverage = this.loadCovers, this.outName = `${i}-${process.pid}`, this.out = w(D.join(a, `${this.outName}.jsonl`), "a"), this.beat(n.timeouts.file, null), this.startTracking(!0);
111
+ t.coverage = this.loadCovers, this.outName = `${i}-${process.pid}`, this.out = O(j.join(a, `${this.outName}.jsonl`), "a"), this.beat(n.timeouts.file, null), this.startTracking(!0);
100
112
  return;
101
113
  }
102
- let s = o(n.directory, i), c = s === null ? null : b(n.directory, i, s.units.length);
103
- if (c === null) {
114
+ let o = c(n.directory, i), s = o === null ? null : w(n.directory, i, o.units.length);
115
+ if (s === null) {
104
116
  this.runnable = /* @__PURE__ */ new Set();
105
117
  return;
106
118
  }
107
- await _(n.directory, {
108
- index: c,
119
+ (n.parallel !== !0 || n.mode !== "isolated") && await b(n.directory, {
120
+ index: s,
109
121
  hash: i
110
- }, M), this.started = M.now(), this.unitIndex = s.indexes[c], this.outName = `${i}-${c}`, this.out = w(D.join(a, `${this.outName}.jsonl`), "a");
122
+ }, I), this.started = I.now(), this.unitIndex = o.indexes[s], this.outName = `${i}-${s}`, this.out = O(j.join(a, `${this.outName}.jsonl`), "a");
111
123
  let l = this.config.hookTimeout > 0 ? this.config.hookTimeout : Infinity;
112
124
  if (n.mode === "isolated") {
113
- let e = s.units[c];
125
+ let e = o.units[s];
114
126
  t.active = e.mutant, t.hitLimit = e.limits.hitLimit, this.budget = e.limits.timeout, this.config.hookTimeout = Math.min(l, e.limits.timeout);
115
127
  } else {
116
- let e = s.units[c];
128
+ let e = o.units[s];
117
129
  this.batch = e;
118
130
  for (let t of e.tests) this.planned.set(t.id, t);
119
131
  t.hitLimit = e.limits.load.hitLimit, this.budget = e.limits.total, this.config.hookTimeout = Math.min(l, e.tests.reduce((e, t) => Math.max(e, t.timeout), e.limits.load.timeout));
@@ -121,19 +133,19 @@ var N = class extends A {
121
133
  this.beat(this.budget, null), this.startTracking(!1);
122
134
  }
123
135
  onCollected(e) {
124
- this.loadDuration = M.now() - this.started;
136
+ this.loadDuration = I.now() - this.started;
125
137
  let { options: t } = this;
126
138
  for (let n of e) {
127
139
  if (t.mode === "dry") {
128
140
  let { hookTimeout: e } = this.config;
129
- for (let t of x(n)) this.hookBudgets.set(t.id, f(t, e));
130
- this.outsideBudget = t.timeouts.file + f(n, e), this.beat(this.outsideBudget, null);
141
+ for (let t of T(n)) this.hookBudgets.set(t.id, m(t, e));
142
+ this.outsideBudget = t.timeouts.file + m(n, e), this.beat(this.outsideBudget, null);
131
143
  }
132
- this.concurrent = y(n, this.sequential) || this.concurrent, l(n, (e, t) => this.aroundTry(e, t)), n.result?.state === "fail" && (this.loadError ??= r(n.result.errors?.[0]));
144
+ this.concurrent = C(n, this.sequential) || this.concurrent, d(n, (e, t) => this.aroundTry(e, t)), n.result?.state === "fail" && (this.loadError ??= a(n.result.errors?.[0]));
133
145
  }
134
146
  if (this.batch === null || this.runnable !== null) return;
135
- let n = e.flatMap((e) => x(e)), i = n.findLastIndex((e) => this.planned.has(e.id));
136
- this.runnable = new Set(n.slice(0, i + 1).map((e) => e.id));
147
+ let n = e.flatMap((e) => T(e)), r = n.findLastIndex((e) => this.planned.has(e.id));
148
+ this.runnable = new Set(n.slice(0, r + 1).map((e) => e.id));
137
149
  }
138
150
  async onBeforeRunTask(e) {
139
151
  if (this.finishEnded(), await super.onBeforeRunTask(e), e.mode !== "run" || e.type !== "test") return;
@@ -153,11 +165,11 @@ var N = class extends A {
153
165
  });
154
166
  }
155
167
  onStray(e, t) {
156
- let n = v(e, t, this.strayCount);
168
+ let n = S(e, t, this.strayCount);
157
169
  this.strayCount += 1;
158
170
  let r = this.listActive();
159
171
  if (r.length > 0) for (let e of r) e.strays.push(n);
160
- else this.options.mode === "batch" && this.lastTest !== null && this.out !== null ? c(this.out, {
172
+ else this.options.mode === "batch" && this.lastTest !== null && this.out !== null ? u(this.out, {
161
173
  mutant: this.lastMutant,
162
174
  test: this.lastTest,
163
175
  kind: "late",
@@ -174,12 +186,12 @@ var N = class extends A {
174
186
  async runTask(e) {
175
187
  let t = this.records.get(e)?.current ?? null;
176
188
  t === null && e.context.skip();
177
- let n = A.getTestFn(e), { deadline: r } = t;
178
- r === null ? await n() : t.timedOut = await s(n, Math.max(0, r - M.now()), M);
189
+ let n = P.getTestFn(e), { deadline: r } = t;
190
+ r === null ? await n() : t.timedOut = await l(n, Math.max(0, r - I.now()), I);
179
191
  }
180
192
  onAfterRunFiles(e) {
181
193
  for (let e of this.records.values()) this.finishTest(e);
182
- if (this.loadError === null) for (let t of e) this.hookError ??= d(t);
194
+ if (this.loadError === null) for (let t of e) this.hookError ??= p(t);
183
195
  this.filesEnded = !0, this.endsInTeardown || this.finishUnit(), super.onAfterRunFiles(e);
184
196
  }
185
197
  async onAfterRetryTask(e, t) {
@@ -196,7 +208,7 @@ var N = class extends A {
196
208
  if (this.finishTry(e), this.abandoned) return;
197
209
  let { runtime: t } = this, { mode: n } = this.options, { test: r } = e, i = e.next;
198
210
  e.next += 1;
199
- let a = M.now(), o = {
211
+ let a = I.now(), o = {
200
212
  attempt: r.result.errors?.length ?? 0,
201
213
  covers: n === "dry" ? /* @__PURE__ */ new Set() : null,
202
214
  retries: r.result.retryCount ?? 0,
@@ -221,10 +233,10 @@ var N = class extends A {
221
233
  finishTry(e) {
222
234
  let { current: t } = e;
223
235
  if (t === null) return;
224
- e.current = null, P(t);
225
- let { runtime: n } = this, { mode: r } = this.options, { test: i } = t, a = p(i, n, {
236
+ e.current = null, z(t);
237
+ let { runtime: n } = this, { mode: r } = this.options, { test: i } = t, a = g(i, n, {
226
238
  covers: t.covers === null ? null : [...t.covers].toSorted(),
227
- duration: M.now() - t.started,
239
+ duration: I.now() - t.started,
228
240
  hits: n.hits - t.hits,
229
241
  timedOut: t.timedOut,
230
242
  strays: t.strays,
@@ -239,9 +251,9 @@ var N = class extends A {
239
251
  let { hits: n } = e;
240
252
  t === "batch" ? n += this.outsideHits : t === "dry" && (n -= this.inside.hits);
241
253
  let { dependencies: r, ...i } = this.stopTracking();
242
- c(this.out, {
254
+ u(this.out, {
243
255
  covers: [...this.loadCovers].toSorted(),
244
- duration: M.now() - this.started,
256
+ duration: I.now() - this.started,
245
257
  loadDuration: this.loadDuration,
246
258
  environment: i.environment,
247
259
  concurrent: this.concurrent,
@@ -256,52 +268,63 @@ var N = class extends A {
256
268
  dependencies: r,
257
269
  kind: "end",
258
270
  hits: n
259
- }), C(w(D.join(this.options.directory, "done", this.outName), "w"));
271
+ }), D(O(j.join(this.options.directory, "done", this.outName), "w"));
260
272
  }
261
- this.beatDescriptor !== null && (C(this.beatDescriptor), this.beatDescriptor = null), T(this.beatFile, { force: !0 }), e.hitLimit = Infinity, e.coverage = null, e.active = null;
273
+ this.beatDescriptor !== null && (D(this.beatDescriptor), this.beatDescriptor = null), k(this.beatFile, { force: !0 }), e.hitLimit = Infinity, e.coverage = null, e.active = null;
262
274
  }
263
275
  async aroundTry(e, t) {
264
276
  let n = this.records.get(e), { current: r } = n, i = e.result.retryCount ?? 0;
265
- if (r === null || r.timedOut ? this.startTry(n) : i > r.retries ? (r.attempt = e.result.errors.length, r.state = void 0, r.retries = i) : r.repetitions + 1 === n.group ? this.startTry(n) : P(r), this.options.mode === "dry") {
266
- let t = e.timeout > 0 ? e.timeout : Infinity, r = M.now();
277
+ if (r === null || r.timedOut ? this.startTry(n) : i > r.retries ? (r.attempt = e.result.errors.length, r.state = void 0, r.retries = i) : r.repetitions + 1 === n.group ? this.startTry(n) : z(r), this.options.mode === "dry") {
278
+ let t = e.timeout > 0 ? e.timeout : Infinity, r = I.now();
267
279
  n.current.watch = r + this.options.timeouts.test + t + this.hookBudgets.get(e.id), this.beatDry(r);
268
280
  }
269
281
  await t(), await new Promise((e) => {
270
- M.setImmediate(e);
282
+ I.setImmediate(e);
271
283
  });
272
284
  }
273
285
  startTracking(e) {
274
- let { directory: t, root: n } = this.options, r = h({
286
+ let { directory: t, root: n } = this.options, r = v({
275
287
  directory: t,
276
288
  root: n
277
289
  }, {
278
290
  holder: Reflect.get(this, "workerState"),
279
- ignored: i
291
+ ignored: o
280
292
  });
281
- if (this.inputs = r, e) {
293
+ if (this.inputs = r, this.trackMeta(), e) {
282
294
  let e = {};
283
- for (let [t, n = ""] of Object.entries(r.real)) e[t] = O("sha256").update(n).digest("hex");
295
+ for (let [t, n = ""] of Object.entries(r.real)) e[t] = M("sha256").update(n).digest("hex");
284
296
  try {
285
- E(D.join(t, "env", `${g("", this.config.name ?? "")}.json`), JSON.stringify({
297
+ A(j.join(t, "env", `${y("", this.config.name ?? "")}.json`), JSON.stringify({
286
298
  project: this.config.name ?? "",
287
299
  variables: e
288
300
  }), { flag: "wx" });
289
301
  } catch {}
290
302
  }
291
303
  }
304
+ trackMeta() {
305
+ let e = Object.keys(this.scripted).filter((e) => e.startsWith("import.meta.") && !this.scripted[e]);
306
+ if (e.length === 0) return;
307
+ let { snapshotSerializers: t, snapshotEnvironment: n, diff: i } = this.config;
308
+ if (n !== void 0 || typeof i == "string" || t.length > 0 || !r(Reflect.get(this, "workerState"), Reflect.get(this, "moduleRunner"), {
309
+ record: (e) => {
310
+ this.values.add(e);
311
+ },
312
+ keys: e
313
+ })) for (let t of e) this.values.add(`${h.define}${t}`);
314
+ }
292
315
  stopTracking() {
293
316
  let e = /* @__PURE__ */ new Set([...this.dependencies ?? [], ...this.listDependencies(void 0)]), { environment: t, modified: n } = this.inputs.stop();
294
317
  this.inputs = null;
295
318
  let r = Reflect.get(this, "workerState"), i = [...e].toSorted();
296
319
  return {
297
- dependencies: Object.hasOwn(k, r.ctx.environment.name) ? i : null,
298
- environment: t,
320
+ dependencies: Object.hasOwn(N, r.ctx.environment.name) ? i : null,
321
+ environment: [...t, ...this.values].toSorted(),
299
322
  modified: n
300
323
  };
301
324
  }
302
325
  beat(e, t) {
303
- this.sequence += 1, this.beatDescriptor ??= w(this.beatFile, "w"), this.beatLength = u(this.beatDescriptor, {
304
- budget: Math.min(Math.max(0, e), j) + 1e3,
326
+ this.sequence += 1, this.beatDescriptor ??= O(this.beatFile, "w"), this.beatLength = f(this.beatDescriptor, {
327
+ budget: Math.min(Math.max(0, e), F) + 1e3,
305
328
  name: t?.fullTestName ?? null,
306
329
  mutant: this.runtime.active,
307
330
  sequence: this.sequence,
@@ -314,12 +337,12 @@ var N = class extends A {
314
337
  finishTest(e) {
315
338
  this.finishTry(e);
316
339
  let { test: t } = e;
317
- this.records.delete(t), c(this.out, {
340
+ this.records.delete(t), u(this.out, {
318
341
  line: t.location?.line ?? null,
319
342
  name: t.fullTestName,
320
343
  tries: e.tries,
321
344
  kind: "test"
322
- }), delete t.result.errors, this.options.mode === "dry" ? this.beatDry() : this.beat(this.budget - (M.now() - this.started), null);
345
+ }), delete t.result.errors, this.options.mode === "dry" ? this.beatDry() : this.beat(this.budget - (I.now() - this.started), null);
323
346
  }
324
347
  routeCoverage() {
325
348
  let { runtime: e } = this;
@@ -327,19 +350,19 @@ var N = class extends A {
327
350
  let [t] = this.activeCovers;
328
351
  e.coverage = t === void 0 ? this.loadCovers : this.activeCovers.length === 1 ? t : this.coverSink;
329
352
  }
330
- beatDry(e = M.now()) {
353
+ beatDry(e = I.now()) {
331
354
  let t = null;
332
355
  for (let e of this.listActive()) (t === null || e.watch > t.watch) && (t = e);
333
356
  t === null ? this.beat(this.outsideBudget, null) : this.beat(t.watch - e, t.test);
334
357
  }
335
358
  listDependencies(e) {
336
- return n(Reflect.get(this, "workerState"), [...Object.keys(S(import.meta.url).cache), ...this.inputs.files], e);
359
+ return i(Reflect.get(this, "workerState"), [...Object.keys(E.createRequire(import.meta.url).cache), ...this.inputs.files], e);
337
360
  }
338
361
  async tearDown(e) {
339
362
  try {
340
363
  await e();
341
364
  } catch (e) {
342
- throw this.hookError ??= r(e), e;
365
+ throw this.hookError ??= a(e), e;
343
366
  } finally {
344
367
  this.endsOnClose || this.finishUnit();
345
368
  }
@@ -353,8 +376,8 @@ var N = class extends A {
353
376
  for (let e of this.records.values()) (this.sequential || e.test.mode === "skip") && this.finishTest(e);
354
377
  }
355
378
  };
356
- function P(e) {
379
+ function z(e) {
357
380
  let t = e.test.result.errors ?? [];
358
381
  e.errors.push(...t.slice(e.attempt)), (e.state === "fail" || e.state === "skip") && (e.outcome = e.state), e.repetitions += 1, e.attempt = t.length, e.state = void 0;
359
382
  }
360
- export { N as default };
383
+ export { R as default };
@@ -10,7 +10,11 @@ import { AdapterContext } from '../../types/adapter/adapter-context.js';
10
10
  * context's `onOutput` when there is one. Its sequencer spreads out the units
11
11
  * of one test file (`createInterleavedSequencer`). The mutant runtime of this
12
12
  * process records the mutant sites switched code evaluates here, outside the
13
- * workers, such as in a `globalSetup` file, until the session closes.
13
+ * workers, such as in a `globalSetup` file, until the session closes. The
14
+ * listeners of SIGINT and SIGTERM that Vitest adds as it starts are dropped
15
+ * (`dropSignalListeners`), and once the run is interrupted the pool stops its
16
+ * workers and starts none (`MootantForksPool.interrupt`), so an interrupted run
17
+ * closes Vitest, which removes its temporary files, before the process ends.
14
18
  *
15
19
  * @param context - Switched files, work directory, concurrency and root.
16
20
  * @param options - Options of the adapter.