mootant 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (313) hide show
  1. package/bin/mootant.js +3 -2
  2. package/dist/adapters/jest/collect-jest-dependencies.d.ts +8 -6
  3. package/dist/adapters/jest/collect-jest-dependencies.js +20 -14
  4. package/dist/adapters/jest/get-jest-cache-inputs.d.ts +14 -13
  5. package/dist/adapters/jest/index.d.ts +3 -1
  6. package/dist/adapters/jest/run-dry.js +20 -20
  7. package/dist/adapters/jest/start-jest-session.d.ts +6 -2
  8. package/dist/adapters/jest/start-jest-session.js +9 -2
  9. package/dist/adapters/jest/types/jest-handle.d.ts +2 -1
  10. package/dist/adapters/jest/types/jest-record.d.ts +4 -3
  11. package/dist/adapters/jest/types/worker-channel.d.ts +7 -0
  12. package/dist/adapters/jest/worker/boot-worker.d.ts +5 -4
  13. package/dist/adapters/jest/worker/create-test-runner.d.ts +4 -1
  14. package/dist/adapters/jest/worker/keep-reset-loads.d.ts +13 -0
  15. package/dist/adapters/jest/worker/list-runtime-files.d.ts +13 -0
  16. package/dist/adapters/jest/worker/run-unit.d.ts +25 -20
  17. package/dist/adapters/jest/worker/vm-setup.js +1 -1
  18. package/dist/adapters/jest/worker/worker.js +1 -1
  19. package/dist/adapters/node-test/check-typescript.js +2 -2
  20. package/dist/adapters/node-test/collect-node-dependencies.d.ts +7 -5
  21. package/dist/adapters/node-test/collect-node-dependencies.js +26 -20
  22. package/dist/adapters/node-test/create-spare-processes.d.ts +26 -0
  23. package/dist/adapters/node-test/create-spare-processes.js +53 -0
  24. package/dist/adapters/node-test/filter-exec-argv.d.ts +2 -1
  25. package/dist/adapters/node-test/filter-exec-argv.js +13 -12
  26. package/dist/adapters/node-test/get-node-cache-inputs.js +1 -1
  27. package/dist/adapters/node-test/get-unit-deadline.d.ts +6 -5
  28. package/dist/adapters/node-test/index.d.ts +2 -2
  29. package/dist/adapters/node-test/index.js +1 -0
  30. package/dist/adapters/node-test/is-group-alive.d.ts +8 -0
  31. package/dist/adapters/node-test/is-group-alive.js +8 -0
  32. package/dist/adapters/node-test/list-setup-files.js +2 -2
  33. package/dist/adapters/node-test/place-preload.d.ts +2 -1
  34. package/dist/adapters/node-test/place-preload.js +24 -18
  35. package/dist/adapters/node-test/preload/create-commonjs-route.js +1 -1
  36. package/dist/adapters/node-test/preload/preload.js +54 -52
  37. package/dist/adapters/node-test/preload/read-line-sync.d.ts +11 -0
  38. package/dist/adapters/node-test/preload/read-line-sync.js +25 -0
  39. package/dist/adapters/node-test/preload/read-unit.d.ts +11 -5
  40. package/dist/adapters/node-test/preload/read-unit.js +5 -4
  41. package/dist/adapters/node-test/run-isolated.d.ts +19 -10
  42. package/dist/adapters/node-test/run-isolated.js +68 -52
  43. package/dist/adapters/node-test/run-test-file.d.ts +12 -4
  44. package/dist/adapters/node-test/run-test-file.js +18 -14
  45. package/dist/adapters/node-test/run-test-process.d.ts +30 -13
  46. package/dist/adapters/node-test/run-test-process.js +38 -40
  47. package/dist/adapters/node-test/start-node-test-session.d.ts +10 -2
  48. package/dist/adapters/node-test/start-node-test-session.js +90 -84
  49. package/dist/adapters/node-test/start-test-process.d.ts +30 -0
  50. package/dist/adapters/node-test/start-test-process.js +27 -0
  51. package/dist/adapters/node-test/types/node-test-handle.d.ts +14 -1
  52. package/dist/adapters/node-test/types/process-watch.d.ts +4 -3
  53. package/dist/adapters/node-test/types/spare-processes.d.ts +20 -0
  54. package/dist/adapters/node-test/types/test-process-outcome.d.ts +8 -1
  55. package/dist/adapters/shared/allows-spares.d.ts +11 -0
  56. package/dist/adapters/shared/allows-spares.js +23 -0
  57. package/dist/adapters/shared/create-environment-proxy.d.ts +4 -3
  58. package/dist/adapters/shared/create-input-filter.d.ts +17 -14
  59. package/dist/adapters/shared/create-input-filter.js +2 -2
  60. package/dist/adapters/shared/enable-compile-cache.d.ts +32 -0
  61. package/dist/adapters/shared/enable-compile-cache.js +7 -0
  62. package/dist/adapters/shared/find-tsconfig-property.d.ts +13 -0
  63. package/dist/adapters/shared/find-tsconfig-property.js +6 -0
  64. package/dist/adapters/shared/get-spare-limit.d.ts +10 -0
  65. package/dist/adapters/shared/get-spare-limit.js +5 -0
  66. package/dist/adapters/shared/index-environment-hashes.d.ts +2 -2
  67. package/dist/adapters/shared/index-environment-hashes.js +5 -13
  68. package/dist/adapters/{node-test → shared}/list-flag-values.d.ts +2 -1
  69. package/dist/adapters/shared/list-flag-values.js +10 -0
  70. package/dist/adapters/shared/list-tsconfig-files.d.ts +14 -5
  71. package/dist/adapters/shared/list-tsconfig-files.js +15 -13
  72. package/dist/adapters/shared/parse-tsconfig.d.ts +10 -0
  73. package/dist/adapters/shared/parse-tsconfig.js +19 -0
  74. package/dist/adapters/shared/read-flag-name.d.ts +9 -0
  75. package/dist/adapters/shared/read-flag-name.js +5 -0
  76. package/dist/adapters/shared/read-node-options.d.ts +11 -0
  77. package/dist/adapters/shared/read-node-options.js +6 -0
  78. package/dist/adapters/shared/read-prefork-switch.d.ts +10 -0
  79. package/dist/adapters/shared/read-prefork-switch.js +5 -0
  80. package/dist/adapters/shared/read-tsconfig-extends.d.ts +2 -5
  81. package/dist/adapters/shared/read-tsconfig-extends.js +16 -31
  82. package/dist/adapters/shared/read-tsconfig-references.d.ts +12 -0
  83. package/dist/adapters/shared/read-tsconfig-references.js +13 -0
  84. package/dist/adapters/shared/track-file-reads.d.ts +13 -12
  85. package/dist/adapters/shared/track-file-reads.js +71 -71
  86. package/dist/adapters/shared/track-process-group.d.ts +2 -1
  87. package/dist/adapters/shared/track-process-group.js +7 -2
  88. package/dist/adapters/vitest/build-isolated-facts.d.ts +4 -3
  89. package/dist/adapters/vitest/collect-dependencies.d.ts +11 -5
  90. package/dist/adapters/vitest/collect-dependencies.js +36 -27
  91. package/dist/adapters/vitest/configure-project.d.ts +3 -2
  92. package/dist/adapters/vitest/configure-project.js +1 -1
  93. package/dist/adapters/vitest/create-forks-pool.d.ts +34 -7
  94. package/dist/adapters/vitest/create-forks-pool.js +102 -24
  95. package/dist/adapters/vitest/create-interleaved-sequencer.d.ts +3 -2
  96. package/dist/adapters/vitest/drop-signal-listeners.d.ts +14 -0
  97. package/dist/adapters/vitest/drop-signal-listeners.js +15 -0
  98. package/dist/adapters/vitest/get-cache-inputs.d.ts +3 -1
  99. package/dist/adapters/vitest/get-cache-inputs.js +43 -28
  100. package/dist/adapters/vitest/get-module-file.d.ts +3 -5
  101. package/dist/adapters/vitest/get-module-file.js +1 -1
  102. package/dist/adapters/vitest/get-spare-key.d.ts +15 -0
  103. package/dist/adapters/vitest/get-spare-key.js +15 -0
  104. package/dist/adapters/vitest/index.d.ts +2 -1
  105. package/dist/adapters/vitest/index.js +1 -0
  106. package/dist/adapters/vitest/is-virtual-module.d.ts +1 -2
  107. package/dist/adapters/vitest/is-virtual-module.js +1 -1
  108. package/dist/adapters/vitest/list-script-defines.d.ts +13 -0
  109. package/dist/adapters/vitest/list-script-defines.js +22 -0
  110. package/dist/adapters/vitest/read-unit-inputs.d.ts +2 -1
  111. package/dist/adapters/vitest/run-dry.js +1 -1
  112. package/dist/adapters/vitest/run-plan.d.ts +10 -8
  113. package/dist/adapters/vitest/run-plan.js +1 -1
  114. package/dist/adapters/vitest/run-specifications.d.ts +9 -2
  115. package/dist/adapters/vitest/run-specifications.js +22 -12
  116. package/dist/adapters/vitest/runner.d.ts +60 -29
  117. package/dist/adapters/vitest/runner.js +109 -86
  118. package/dist/adapters/vitest/start-vitest-session.d.ts +5 -1
  119. package/dist/adapters/vitest/start-vitest-session.js +64 -59
  120. package/dist/adapters/vitest/stop-hung-worker.d.ts +11 -4
  121. package/dist/adapters/vitest/stop-hung-worker.js +20 -7
  122. package/dist/adapters/vitest/types/mootant-forks-pool.d.ts +47 -0
  123. package/dist/adapters/vitest/types/vitest-session-state.d.ts +9 -8
  124. package/dist/adapters/vitest/types/vitest-worker.d.ts +48 -33
  125. package/dist/adapters/vitest/wait-for-workers.d.ts +5 -2
  126. package/dist/adapters/vitest/wait-for-workers.js +15 -15
  127. package/dist/adapters/vitest/worker/track-meta-defines.d.ts +39 -0
  128. package/dist/adapters/vitest/worker/track-meta-defines.js +23 -0
  129. package/dist/adapters/vitest/worker/track-values.d.ts +38 -0
  130. package/dist/adapters/vitest/worker/track-values.js +45 -0
  131. package/dist/adapters/vitest/worker/value-prefixes.d.ts +12 -0
  132. package/dist/adapters/vitest/worker/value-prefixes.js +6 -0
  133. package/dist/adapters/vitest/worker/wait-for-turn.d.ts +8 -6
  134. package/dist/adapters/vitest/worker/watch-property.d.ts +17 -0
  135. package/dist/adapters/vitest/worker/watch-property.js +27 -0
  136. package/dist/cli/create-run-progress.d.ts +8 -1
  137. package/dist/cli/create-run-progress.js +4 -1
  138. package/dist/cli/ensure-exit.d.ts +11 -0
  139. package/dist/cli/ensure-exit.js +15 -0
  140. package/dist/cli/html/build-html-report.js +1 -0
  141. package/dist/cli/html/client/main.js +1 -1
  142. package/dist/cli/html/client/render-overview.d.ts +3 -3
  143. package/dist/cli/index.d.ts +1 -0
  144. package/dist/cli/index.js +3 -2
  145. package/dist/cli/parse-arguments.d.ts +4 -0
  146. package/dist/cli/parse-arguments.js +4 -1
  147. package/dist/cli/report/build-run-report.js +1 -0
  148. package/dist/cli/report/format-command.d.ts +5 -0
  149. package/dist/cli/report/format-command.js +1 -1
  150. package/dist/cli/report/format-run-text-report.d.ts +5 -4
  151. package/dist/cli/report/format-run-text-report.js +10 -10
  152. package/dist/cli/report/slim-run-report.d.ts +10 -10
  153. package/dist/cli/report/slim-run-report.js +1 -0
  154. package/dist/cli/run-mutation.d.ts +5 -1
  155. package/dist/cli/run-mutation.js +32 -24
  156. package/dist/cli/terminal/create-spinner.d.ts +1 -2
  157. package/dist/cli/terminal/create-spinner.js +23 -32
  158. package/dist/cli/watch-interrupts.d.ts +41 -0
  159. package/dist/cli/watch-interrupts.js +32 -0
  160. package/dist/core/cache/apply-cached-units.d.ts +8 -7
  161. package/dist/core/cache/build-hash.d.ts +9 -0
  162. package/dist/core/cache/build-hash.js +2 -0
  163. package/dist/core/cache/cache-version.d.ts +4 -4
  164. package/dist/core/cache/check-dry-snapshot.d.ts +25 -0
  165. package/dist/core/cache/check-dry-snapshot.js +13 -0
  166. package/dist/core/cache/create-dry-reuse-miss.d.ts +12 -0
  167. package/dist/core/cache/create-dry-reuse-miss.js +7 -0
  168. package/dist/core/cache/create-dry-snapshot.d.ts +71 -0
  169. package/dist/core/cache/create-dry-snapshot.js +27 -0
  170. package/dist/core/cache/create-run-cache.d.ts +20 -2
  171. package/dist/core/cache/create-run-cache.js +31 -22
  172. package/dist/core/cache/create-snapshot-session.d.ts +12 -0
  173. package/dist/core/cache/create-snapshot-session.js +19 -0
  174. package/dist/core/cache/get-build-id.d.ts +11 -0
  175. package/dist/core/cache/get-build-id.js +7 -0
  176. package/dist/core/cache/get-cache-path.d.ts +1 -1
  177. package/dist/core/cache/get-cache-path.js +1 -1
  178. package/dist/core/cache/get-dry-snapshot-key.d.ts +47 -0
  179. package/dist/core/cache/get-dry-snapshot-key.js +43 -0
  180. package/dist/core/cache/get-dry-snapshot-path.d.ts +9 -0
  181. package/dist/core/cache/get-dry-snapshot-path.js +5 -0
  182. package/dist/core/cache/get-environment-key.d.ts +9 -4
  183. package/dist/core/cache/get-environment-key.js +3 -2
  184. package/dist/core/cache/get-test-file-keys.d.ts +2 -1
  185. package/dist/core/cache/get-test-file-keys.js +11 -10
  186. package/dist/core/cache/hash-files.d.ts +8 -7
  187. package/dist/core/cache/hash-files.js +17 -11
  188. package/dist/core/cache/hash-project-tree.d.ts +22 -0
  189. package/dist/core/cache/hash-project-tree.js +69 -0
  190. package/dist/core/cache/is-dry-reuse-miss.d.ts +8 -0
  191. package/dist/core/cache/is-dry-reuse-miss.js +4 -0
  192. package/dist/core/cache/list-file-hashes.d.ts +4 -0
  193. package/dist/core/cache/list-file-hashes.js +5 -2
  194. package/dist/core/cache/list-install-states.d.ts +12 -0
  195. package/dist/core/cache/list-install-states.js +19 -0
  196. package/dist/core/cache/list-variable-hashes.d.ts +15 -0
  197. package/dist/core/cache/list-variable-hashes.js +14 -0
  198. package/dist/core/cache/prepare-run-cache.d.ts +48 -22
  199. package/dist/core/cache/prepare-run-cache.js +86 -73
  200. package/dist/core/cache/read-dry-snapshot.d.ts +10 -0
  201. package/dist/core/cache/read-dry-snapshot.js +15 -0
  202. package/dist/core/cache/read-run-cache.js +6 -2
  203. package/dist/core/cache/save-dry-snapshot.d.ts +34 -0
  204. package/dist/core/cache/save-dry-snapshot.js +32 -0
  205. package/dist/core/cache/volatile-variables.d.ts +7 -0
  206. package/dist/core/cache/volatile-variables.js +11 -0
  207. package/dist/core/cache/write-run-cache.js +1 -1
  208. package/dist/core/config/load-typescript-config.d.ts +6 -1
  209. package/dist/core/config/load-typescript-config.js +26 -10
  210. package/dist/core/config/prepare-run.d.ts +7 -3
  211. package/dist/core/config/prepare-run.js +1 -0
  212. package/dist/core/config/resolve-run-settings.d.ts +3 -2
  213. package/dist/core/config/resolve-run-settings.js +1 -0
  214. package/dist/core/config/validate-config.js +3 -2
  215. package/dist/core/files/get-package-manifest.d.ts +12 -0
  216. package/dist/core/files/get-package-manifest.js +7 -0
  217. package/dist/core/generate/collect-candidates.d.ts +5 -1
  218. package/dist/core/generate/collect-candidates.js +125 -97
  219. package/dist/core/generate/generate-file-mutants.js +6 -5
  220. package/dist/core/index.d.ts +18 -0
  221. package/dist/core/mutators/shared/get-branch-copy-skip.d.ts +2 -2
  222. package/dist/core/mutators/shared/get-comparison-plan.d.ts +2 -2
  223. package/dist/core/mutators/shared/get-default-option-skip.d.ts +2 -2
  224. package/dist/core/mutators/shared/get-group-constant.d.ts +2 -2
  225. package/dist/core/mutators/shared/get-literal-skip.d.ts +3 -3
  226. package/dist/core/mutators/shared/get-loop-running-skip.d.ts +2 -2
  227. package/dist/core/mutators/shared/get-nullish-swap-skip.d.ts +2 -2
  228. package/dist/core/mutators/shared/get-or-default-skip.d.ts +2 -2
  229. package/dist/core/mutators/shared/get-owned-constants.d.ts +2 -2
  230. package/dist/core/mutators/shared/leave-now-skip.d.ts +2 -2
  231. package/dist/core/mutators/shared/no-op-callback-skip.d.ts +2 -2
  232. package/dist/core/plugins/create-mutator-registry.d.ts +4 -2
  233. package/dist/core/plugins/create-mutator-registry.js +15 -5
  234. package/dist/core/plugins/validate-plugin.d.ts +3 -3
  235. package/dist/core/plugins/validate-plugin.js +32 -10
  236. package/dist/core/regex/collect-pattern-changes.d.ts +2 -2
  237. package/dist/core/regex/create-regex-replacement.d.ts +2 -2
  238. package/dist/core/run/apply-isolated-result.d.ts +22 -14
  239. package/dist/core/run/apply-isolated-result.js +45 -26
  240. package/dist/core/run/count-run.d.ts +2 -1
  241. package/dist/core/run/create-run-state.d.ts +5 -0
  242. package/dist/core/run/create-run-state.js +1 -0
  243. package/dist/core/run/create-work-directory.d.ts +4 -1
  244. package/dist/core/run/create-work-directory.js +15 -12
  245. package/dist/core/run/decide-evidence.d.ts +4 -3
  246. package/dist/core/run/get-unit-evidence.d.ts +13 -7
  247. package/dist/core/run/get-unit-evidence.js +1 -1
  248. package/dist/core/run/guard-session.d.ts +18 -0
  249. package/dist/core/run/guard-session.js +30 -0
  250. package/dist/core/run/live-work-directories.d.ts +5 -0
  251. package/dist/core/run/live-work-directories.js +2 -0
  252. package/dist/core/run/read-isolated-unit.d.ts +6 -3
  253. package/dist/core/run/read-isolated-unit.js +77 -38
  254. package/dist/core/run/remove-live-work-directories.d.ts +7 -0
  255. package/dist/core/run/remove-live-work-directories.js +12 -0
  256. package/dist/core/run/run-isolated-rounds.d.ts +16 -12
  257. package/dist/core/run/run-isolated-rounds.js +3 -2
  258. package/dist/core/run/validate-adapter.d.ts +1 -1
  259. package/dist/core/run/validate-adapter.js +1 -1
  260. package/dist/core/run-mutants.d.ts +34 -2
  261. package/dist/core/run-mutants.js +356 -216
  262. package/dist/core/skips/skip-rules.d.ts +3 -1
  263. package/dist/package.js +1 -1
  264. package/dist/types/adapter/adapter-context.d.ts +20 -0
  265. package/dist/types/adapter/adapter-session.d.ts +2 -1
  266. package/dist/types/adapter/cache-inputs.d.ts +3 -2
  267. package/dist/types/adapter/dry-file.d.ts +4 -2
  268. package/dist/types/adapter/isolated-plan.d.ts +2 -1
  269. package/dist/types/adapter/isolated-result.d.ts +3 -1
  270. package/dist/types/adapter/run-inputs.d.ts +5 -4
  271. package/dist/types/adapter/test-adapter.d.ts +7 -0
  272. package/dist/types/cache/cache-entry.d.ts +9 -7
  273. package/dist/types/cache/cached-inputs.d.ts +2 -2
  274. package/dist/types/cache/dry-snapshot.d.ts +76 -0
  275. package/dist/types/cache/project-tree.d.ts +16 -0
  276. package/dist/types/cache/run-cache-file.d.ts +1 -1
  277. package/dist/types/cache/run-cache.d.ts +6 -5
  278. package/dist/types/config/plugin.d.ts +11 -2
  279. package/dist/types/config/run-config.d.ts +10 -0
  280. package/dist/types/config/run-settings.d.ts +6 -0
  281. package/dist/types/mutant/core-note.d.ts +12 -0
  282. package/dist/types/mutant/diagnostic.d.ts +1 -0
  283. package/dist/types/mutant/registered-skip-rule.d.ts +11 -0
  284. package/dist/types/mutant/skip-note.d.ts +7 -6
  285. package/dist/types/mutant/skip-rule-id.d.ts +3 -2
  286. package/dist/types/mutant/skip-rule.d.ts +2 -1
  287. package/dist/types/mutant/skipped-candidate.d.ts +14 -7
  288. package/dist/types/mutant/skipped-mutant.d.ts +6 -6
  289. package/dist/types/mutator/mutator.d.ts +3 -2
  290. package/dist/types/mutator/registered-mutator.d.ts +8 -0
  291. package/dist/types/regex/regex-change.d.ts +2 -2
  292. package/dist/types/report/html-report.d.ts +3 -2
  293. package/dist/types/report/list-report-skipped.d.ts +3 -2
  294. package/dist/types/report/run-report.d.ts +11 -2
  295. package/dist/types/report/slim-run-report.d.ts +1 -1
  296. package/dist/types/run/isolated-evidence.d.ts +3 -2
  297. package/dist/types/run/isolated-reason.d.ts +2 -1
  298. package/dist/types/run/run-durations.d.ts +8 -3
  299. package/dist/types/run/run-event.d.ts +10 -7
  300. package/dist/types/run/run-result.d.ts +11 -2
  301. package/dist/types/run/run-state.d.ts +21 -0
  302. package/dist/types/run/try-cause.d.ts +2 -1
  303. package/package.json +1 -1
  304. package/readme.md +85 -68
  305. package/skills/mootant/SKILL.md +36 -19
  306. package/skills/mootant/references/mutators.md +29 -23
  307. package/dist/adapters/node-test/list-flag-values.js +0 -9
  308. /package/dist/adapters/{node-test → shared}/loader-flags.d.ts +0 -0
  309. /package/dist/adapters/{node-test → shared}/loader-flags.js +0 -0
  310. /package/dist/{adapters/shared → core/files}/list-package-files.d.ts +0 -0
  311. /package/dist/{adapters/shared → core/files}/list-package-files.js +0 -0
  312. /package/dist/{adapters/shared → core/files}/read-package-type.d.ts +0 -0
  313. /package/dist/{adapters/shared → core/files}/read-package-type.js +0 -0
@@ -1,6 +1,7 @@
1
1
  import { AdapterSession } from '../../types/adapter/adapter-session.js';
2
2
  import { ActiveMutator } from '../../types/mutator/active-mutator.js';
3
3
  import { DryRunResult } from '../../types/adapter/dry-run-result.js';
4
+ import { CacheInputs } from '../../types/adapter/cache-inputs.js';
4
5
  import { TestAdapter } from '../../types/adapter/test-adapter.js';
5
6
  import { FileMutants } from '../../types/mutant/file-mutants.js';
6
7
  import { StoredCache } from '../../types/cache/stored-cache.js';
@@ -30,10 +31,23 @@ interface PrepareInput {
30
31
  * Entries and inputs of the cache file, read while the dry run went on.
31
32
  */
32
33
  stored: Promise<StoredCache>;
34
+ /**
35
+ * Absolute paths of the files the dry run switched, those it dropped as
36
+ * broken left out: the hit counts of a unit cover only their sites, so a
37
+ * timeout by the hit limit holds only for runs that switch the same files.
38
+ */
39
+ switched: readonly string[];
33
40
  /**
34
41
  * Live test runner after the dry run.
35
42
  */
36
43
  session: AdapterSession;
44
+ /**
45
+ * Whether isolated units of one test file run at the same time; such runs
46
+ * never reuse the verdicts of other runs, nor other runs theirs, since tests
47
+ * that rely on a test file never running twice at once may give other
48
+ * verdicts. False when omitted.
49
+ */
50
+ parallelUnits?: boolean;
37
51
  /**
38
52
  * Coverage and tests of the dry run.
39
53
  */
@@ -59,6 +73,11 @@ interface PrepareInput {
59
73
  * listed.
60
74
  */
61
75
  started: number;
76
+ /**
77
+ * Whether the run is in fast mode, which neither stores nor reuses timeouts
78
+ * by the hit limit (`RunCacheInput.timeouts`).
79
+ */
80
+ fast: boolean;
62
81
  /**
63
82
  * Project root.
64
83
  */
@@ -77,6 +96,11 @@ interface PreparedCache {
77
96
  * has unknown content, or null.
78
97
  */
79
98
  warning: Diagnostic | null;
99
+ /**
100
+ * What the session said every verdict depends on (`cacheInputs`), asked once,
101
+ * or null when the adapter cannot tell.
102
+ */
103
+ inputs: CacheInputs | null;
80
104
  /**
81
105
  * Cache of the run, or null.
82
106
  */
@@ -85,30 +109,32 @@ interface PreparedCache {
85
109
  /**
86
110
  * Prepares the cache of a run after its dry run: asks the adapter what every
87
111
  * verdict depends on, hashes those files together with the `.env` files, the
88
- * lockfile, `package.json` and the `tsconfig` and `jsconfig` files of the root,
89
- * every file a test file depended on and every file stored entries read beyond
90
- * that, each file once, then builds the environment key and the key of every
91
- * test file, which takes in the environment variables it read, and the key of
92
- * every test file over what it reads outside the files mutants are listed from,
93
- * for the incremental keys. Files modified since the run started may have
94
- * changed after the test runner read them, so their hash may not be what
95
- * verdicts came from: a test file that depends on one gets no key, and no test
96
- * file gets one when a file of the environment changed. The same goes for a
97
- * path whose content is unknown, such as a device or a pipe (`UNKNOWN_HASH`),
98
- * whatever its time. Files the test code of the dry run changed itself
99
- * (`DryFile.modified`), files of the environment among them, are hashed as they
100
- * are now, which is what the next run starts from; `saveRunCache` checks that
101
- * their contents stayed so. A test runner that read such a file before the test
102
- * code wrote it, as Vitest loads the `.env` files of its mode when it starts,
103
- * may have run with an earlier text than the keys show, whether the test code
104
- * or the user changed it.
112
+ * lockfile with the files that tell what was installed (`listInstallStates`),
113
+ * `package.json` and the `tsconfig` and `jsconfig` files of the root, every
114
+ * file a test file depended on and every file stored entries read beyond that,
115
+ * each file once, then builds the environment key and the key of every test
116
+ * file, which takes in the environment variables it read, and the key of every
117
+ * test file over what it reads outside the files mutants are listed from, for
118
+ * the incremental keys. Files modified since the run started may have changed
119
+ * after the test runner read them, so their hash may not be what verdicts came
120
+ * from: a test file that depends on one gets no key, and no test file gets one
121
+ * when a file of the environment changed. The same goes for a path whose
122
+ * content is unknown, such as a device or a pipe (`UNKNOWN_HASH`), whatever its
123
+ * time. Files the test code of the dry run changed itself (`DryFile.modified`),
124
+ * files of the environment among them, are hashed as they are now, which is
125
+ * what the next run starts from; `saveRunCache` checks that their contents
126
+ * stayed so. A test runner that read such a file before the test code wrote it,
127
+ * as Vitest loads the `.env` files of its mode when it starts, may have run
128
+ * with an earlier text than the keys show, whether the test code or the user
129
+ * changed it. A run with parallel units has an environment key of its own.
130
+ * Outside fast mode, the cache keeps timeouts by the hit limit too.
105
131
  *
106
132
  * @param input - Session, dry run, settings and the stored entries.
107
- * @returns Cache of the run. No cache when the adapter cannot tell what
108
- * verdicts depend on or no test file has a key; when a file of the
109
- * environment, or a dependency while no test file has a key, changed during
110
- * the run or has unknown content, with a `cache-skipped` warning that names
111
- * the first such file.
133
+ * @returns Cache of the run, with what the session said verdicts depend on. No
134
+ * cache when the adapter cannot tell what verdicts depend on or no test file
135
+ * has a key; when a file of the environment, or a dependency while no test
136
+ * file has a key, changed during the run or has unknown content, with a
137
+ * `cache-skipped` warning that names the first such file.
112
138
  */
113
139
  export declare function prepareRunCache(input: PrepareInput): Promise<PreparedCache>;
114
140
  export {};
@@ -1,105 +1,118 @@
1
1
  import { getTestFileKey as e } from "../run/get-test-file-key.js";
2
2
  import { getEnvironmentKey as t } from "./get-environment-key.js";
3
- import { getDisplayPath as n } from "../run/get-display-path.js";
4
- import { findChangedFiles as r } from "./find-changed-files.js";
5
- import { getTestFileKeys as i } from "./get-test-file-keys.js";
6
- import { createRunCache as a } from "./create-run-cache.js";
7
- import { findLockfile as o } from "./find-lockfile.js";
3
+ import { listInstallStates as n } from "./list-install-states.js";
4
+ import { compareCodeUnits as r } from "../compare-code-units.js";
5
+ import { getDisplayPath as i } from "../run/get-display-path.js";
6
+ import { findChangedFiles as a } from "./find-changed-files.js";
7
+ import { getTestFileKeys as o } from "./get-test-file-keys.js";
8
+ import { getPortablePath as s } from "./get-portable-path.js";
9
+ import { createRunCache as c } from "./create-run-cache.js";
10
+ import { findLockfile as l } from "./find-lockfile.js";
11
+ import { createDigest as u } from "./create-digest.js";
8
12
  import "./unknown-hash.js";
9
- import { hashFiles as s } from "./hash-files.js";
10
- import c from "node:path";
11
- import { createHash as l } from "node:crypto";
12
- import { readdir as u, stat as d } from "node:fs/promises";
13
- async function f(f) {
14
- let { session: p, setup: m, root: h, dry: g } = f;
15
- if (p.cacheInputs === void 0) return {
13
+ import { getBuildId as d } from "./get-build-id.js";
14
+ import { hashFiles as f } from "./hash-files.js";
15
+ import p from "node:path";
16
+ import { createHash as m } from "node:crypto";
17
+ import { readdir as h } from "node:fs/promises";
18
+ async function g(g) {
19
+ let { session: _, setup: v, root: y, dry: b } = g;
20
+ if (_.cacheInputs === void 0) return {
16
21
  warning: null,
22
+ inputs: null,
17
23
  cache: null
18
24
  };
19
- let _ = await p.cacheInputs(), v = o(h), y = [
20
- ..._.files,
21
- ...v === null ? [] : [v],
22
- c.join(h, "package.json"),
23
- ...(await u(h)).filter((e) => /^(?:\.env|(?:jsconfig|tsconfig).*\.json$)/u.test(e)).map((e) => c.join(h, e))
24
- ], b = new Map(g.files.flatMap((t) => Array.isArray(t.dependencies) ? [[e(t), [t.file, ...t.dependencies]]] : [])), x = [...y, ...[...b.values()].flat()], S = new Set(g.files.flatMap((e) => e.modified ?? [])), C = await r(x, f.started);
25
- for (let e of S) C.delete(e);
26
- let w = await f.stored, T = await s([...x, ...[...w.inputs.values()].flatMap((e) => e.files.map(([e]) => c.resolve(h, e)))]);
27
- function E(e) {
28
- return C.has(e) || T.get(e) === "unknown";
25
+ let x = await _.cacheInputs(), S = l(y), C = [
26
+ ...x.files,
27
+ ...S === null ? [] : [S],
28
+ ...n(y),
29
+ p.join(y, "package.json"),
30
+ ...(await h(y)).filter((e) => /^(?:\.env|(?:jsconfig|tsconfig).*\.json$)/u.test(e)).map((e) => p.join(y, e))
31
+ ], w = new Map(b.files.flatMap((t) => Array.isArray(t.dependencies) ? [[e(t), [t.file, ...t.dependencies]]] : [])), T = [...C, ...[...w.values()].flat()], E = new Set(b.files.flatMap((e) => e.modified ?? [])), D = await a(T, g.started);
32
+ for (let e of E) D.delete(e);
33
+ let O = await g.stored, k = await f([...T, ...[...O.inputs.values()].flatMap((e) => e.files.map(([e]) => p.resolve(y, e)))]);
34
+ function A(e) {
35
+ return D.has(e) || k.get(e) === "unknown";
29
36
  }
30
- function D(e) {
31
- let t = n(e, h), r = t === "" ? "the root of the project" : t;
37
+ function j(e) {
38
+ let t = i(e, y), n = t === "" ? "the root of the project" : t;
32
39
  return {
33
40
  warning: {
34
- message: T.get(e) === "unknown" ? `Verdicts were neither reused nor cached because ${r} is a device, a pipe or a socket, so mootant cannot tell whether it changed.` : `Verdicts were neither reused nor cached because ${r} has a modification time at or after the start of the run, so it may have changed while the run went on.`,
41
+ message: k.get(e) === "unknown" ? `Verdicts were neither reused nor cached because ${n} is a device, a pipe or a socket, so mootant cannot tell whether it changed.` : `Verdicts were neither reused nor cached because ${n} has a modification time at or after the start of the run, so it may have changed while the run went on.`,
35
42
  code: "cache-skipped",
36
43
  severity: "warning",
37
44
  column: null,
38
45
  file: null,
39
46
  line: null
40
47
  },
41
- cache: null
48
+ cache: null,
49
+ inputs: x
42
50
  };
43
51
  }
44
- let O = y.find((e) => E(e));
45
- if (O !== void 0) return D(O);
46
- let k = _.environment ?? {}, A = t({
52
+ let M = C.find((e) => A(e));
53
+ if (M !== void 0) return j(M);
54
+ let N = x.environment ?? {}, P = t({
47
55
  mutators: {
48
- mutators: m.mutators.map((e) => [e.id, e.options]),
49
- settings: m.settings,
50
- preset: m.preset
56
+ mutators: v.mutators.map((e) => [e.id, e.options]),
57
+ settings: v.settings,
58
+ preset: v.preset
51
59
  },
52
60
  runner: {
53
- version: f.adapter.version ?? null,
54
- runner: p.version ?? null,
55
- adapter: f.adapter.name
61
+ version: g.adapter.version ?? null,
62
+ runner: _.version ?? null,
63
+ adapter: g.adapter.name
56
64
  },
57
- build: (await d(import.meta.filename)).mtimeMs,
58
- settings: _.settings,
59
- limits: f.limits,
60
- hashes: T,
61
- files: y,
62
- root: h
63
- }), j = g.files.filter((t) => (b.get(e(t)) ?? []).every((e) => !E(e))), M = i({
65
+ parallelUnits: g.parallelUnits === !0,
66
+ settings: x.settings,
67
+ limits: g.limits,
68
+ build: d(),
69
+ hashes: k,
70
+ files: C,
71
+ root: y
72
+ }), F = b.files.filter((t) => (w.get(e(t)) ?? []).every((e) => !A(e))), I = o({
64
73
  mutated: /* @__PURE__ */ new Set(),
65
- files: j,
66
- environment: A,
67
- variables: k,
68
- hashes: T,
69
- root: h
74
+ files: F,
75
+ environment: P,
76
+ variables: N,
77
+ hashes: k,
78
+ root: y
70
79
  });
71
- if (M.size === 0) {
72
- let e = [...b.values()].flat().find((e) => E(e));
80
+ if (I.size === 0) {
81
+ let e = [...w.values()].flat().find((e) => A(e));
73
82
  return e === void 0 ? {
74
83
  warning: null,
75
- cache: null
76
- } : D(e);
84
+ cache: null,
85
+ inputs: x
86
+ } : j(e);
77
87
  }
78
88
  return {
79
89
  warning: null,
80
- cache: a({
81
- sources: new Map(f.files.flatMap((e) => e.source === null ? [] : [[e.file, l("sha256").update(e.source).digest("hex")]])),
82
- outsideKeys: i({
83
- mutated: new Set(f.files.map((e) => e.absolute)),
84
- files: j,
85
- environment: A,
86
- variables: k,
87
- hashes: T,
88
- root: h
90
+ inputs: x,
91
+ cache: c({
92
+ sources: new Map(g.files.flatMap((e) => e.source === null ? [] : [[e.file, m("sha256").update(e.source).digest("hex")]])),
93
+ outsideKeys: o({
94
+ mutated: new Set(g.files.map((e) => e.absolute)),
95
+ files: F,
96
+ environment: P,
97
+ variables: N,
98
+ hashes: k,
99
+ root: y
89
100
  }),
90
- reads: new Map(g.files.map((t) => [e(t), t.environment ?? []])),
91
- dependencies: new Map([...b].filter(([e]) => M.has(e))),
92
- regions: new Map(f.files.flatMap((e) => [...e.regions ?? []])),
93
- incremental: f.incremental,
94
- analysis: f.analysis,
95
- environment: y,
96
- now: f.now,
97
- variables: k,
98
- fileKeys: M,
99
- stored: w,
100
- hashes: T,
101
- root: h
101
+ switched: u(g.switched.map((e) => s(e, y)).toSorted(r)),
102
+ reads: new Map(b.files.map((t) => [e(t), t.environment ?? []])),
103
+ dependencies: new Map([...w].filter(([e]) => I.has(e))),
104
+ regions: new Map(g.files.flatMap((e) => [...e.regions ?? []])),
105
+ incremental: g.incremental,
106
+ analysis: g.analysis,
107
+ timeouts: !g.fast,
108
+ environment: C,
109
+ now: g.now,
110
+ variables: N,
111
+ fileKeys: I,
112
+ stored: O,
113
+ hashes: k,
114
+ root: y
102
115
  })
103
116
  };
104
117
  }
105
- export { f as prepareRunCache };
118
+ export { g as prepareRunCache };
@@ -0,0 +1,10 @@
1
+ import { DrySnapshot } from '../../types/cache/dry-snapshot.js';
2
+ /**
3
+ * Reads the saved dry run of a project (`DrySnapshot`). A missing or unreadable
4
+ * file, invalid JSON, another version or a value without the parts of a saved
5
+ * dry run gives none: it only ever makes a run faster.
6
+ *
7
+ * @param file - Absolute path of the file (`getDrySnapshotPath`).
8
+ * @returns The saved dry run, or null.
9
+ */
10
+ export declare function readDrySnapshot(file: string): Promise<DrySnapshot | null>;
@@ -0,0 +1,15 @@
1
+ import { isRecord as e } from "../plugins/is-record.js";
2
+ import { readFile as t } from "node:fs/promises";
3
+ async function n(e) {
4
+ let n;
5
+ try {
6
+ n = JSON.parse(await t(e, "utf8"));
7
+ } catch {
8
+ return null;
9
+ }
10
+ return r(n) ? n : null;
11
+ }
12
+ function r(t) {
13
+ return e(t) && t.version === 8 && typeof t.key == "string" && typeof t.tree == "string" && Array.isArray(t.files) && Array.isArray(t.variables) && Array.isArray(t.testFiles) && e(t.session) && e(t.phase) && e(t.phase.dry);
14
+ }
15
+ export { n as readDrySnapshot };
@@ -1,6 +1,10 @@
1
1
  import { isRecord as e } from "../plugins/is-record.js";
2
2
  import { readFile as t } from "node:fs/promises";
3
- const n = /* @__PURE__ */ new Set(["Survived", "Killed"]), r = /* @__PURE__ */ new Set(["isolated", "batch"]);
3
+ const n = /* @__PURE__ */ new Set([
4
+ "Survived",
5
+ "Timeout",
6
+ "Killed"
7
+ ]), r = /* @__PURE__ */ new Set(["isolated", "batch"]);
4
8
  async function i(n) {
5
9
  let r = {
6
10
  entries: /* @__PURE__ */ new Map(),
@@ -11,7 +15,7 @@ async function i(n) {
11
15
  } catch {
12
16
  return r;
13
17
  }
14
- if (!e(i) || i.version !== 3 || !e(i.entries) || !e(i.inputs)) return r;
18
+ if (!e(i) || i.version !== 8 || !e(i.entries) || !e(i.inputs)) return r;
15
19
  let o = Object.entries(i.inputs);
16
20
  for (let [e, t] of o) s(t) && r.inputs.set(e, t);
17
21
  let c = Object.entries(i.entries);
@@ -0,0 +1,34 @@
1
+ import { ProjectTree } from '../../types/cache/project-tree.js';
2
+ import { DrySnapshot } from '../../types/cache/dry-snapshot.js';
3
+ /**
4
+ * Saves the dry run of a run for later runs (`DrySnapshot`), or removes the
5
+ * saved one when the run cannot be replayed. Before saving, the files of the
6
+ * saved dry run and everything under the project root are hashed again: when
7
+ * any of them changed during the run, such as a test file added while mutants
8
+ * ran, which the dry run never saw, nothing is saved and the saved one is
9
+ * removed too, and the first path that changed is named, against the tree the
10
+ * run hashed before the test runner started. A tree that can no longer be read
11
+ * is not saved either, with nothing to name. The file is written to a temporary
12
+ * file and renamed, so a reader never sees half of it. Failures are ignored, as
13
+ * a saved dry run only ever makes a run faster.
14
+ *
15
+ * @param input - What to save, and where.
16
+ * @param input.snapshot - Saved dry run of the run (`createDrySnapshot`), or
17
+ * null when the run cannot be replayed.
18
+ * @param input.tree - Project tree the run hashed before the test runner
19
+ * started, or null when it could not be read.
20
+ * @param input.outputs - Absolute paths mootant writes into the project during
21
+ * or after a run, such as the HTML report and the work directory, which are
22
+ * left out.
23
+ * @param input.file - Absolute path of the file (`getDrySnapshotPath`).
24
+ * @param input.root - Project root.
25
+ * @returns Null, or the end of a sentence that names a path that changed during
26
+ * the run, such as `logs was added during the run`.
27
+ */
28
+ export declare function saveDrySnapshot(input: {
29
+ snapshot: DrySnapshot | null;
30
+ outputs: readonly string[];
31
+ tree: ProjectTree | null;
32
+ file: string;
33
+ root: string;
34
+ }): Promise<string | null>;
@@ -0,0 +1,32 @@
1
+ import { getDisplayPath as e } from "../run/get-display-path.js";
2
+ import { compareCodeUnits as t } from "../compare-code-units.js";
3
+ import { hashProjectTree as n } from "./hash-project-tree.js";
4
+ import { hashFiles as r } from "./hash-files.js";
5
+ import i from "node:path";
6
+ import { mkdir as a, rename as o, rm as s, writeFile as c } from "node:fs/promises";
7
+ async function l(t) {
8
+ let { snapshot: i, tree: a, file: o, root: s } = t;
9
+ if (i === null || a === null) return await f(o), null;
10
+ let c = await r(i.files.map(([e]) => e)), l = i.files.find(([e, t]) => c.get(e) !== t);
11
+ if (l !== void 0) return await f(o), `${e(l[0], s)} changed during the run`;
12
+ let p = await n(s, t.outputs);
13
+ return p?.hash === a.hash ? (await d(i, o), null) : (await f(o), p === null ? null : u(a, p));
14
+ }
15
+ function u(e, n) {
16
+ let r = [.../* @__PURE__ */ new Set([...e.entries.keys(), ...n.entries.keys()])].toSorted(t).find((t) => e.entries.get(t) !== n.entries.get(t));
17
+ return e.entries.has(r) ? n.entries.has(r) ? `${r} changed during the run` : `${r} was removed during the run` : `${r} was added during the run`;
18
+ }
19
+ async function d(e, t) {
20
+ let n = `${t}.${process.pid}.tmp`;
21
+ try {
22
+ await a(i.dirname(t), { recursive: !0 }), await c(n, JSON.stringify(e)), await o(n, t);
23
+ } catch {
24
+ await f(n), await f(t);
25
+ }
26
+ }
27
+ async function f(e) {
28
+ try {
29
+ await s(e, { force: !0 });
30
+ } catch {}
31
+ }
32
+ export { l as saveDrySnapshot };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Environment variables that change from one shell or terminal to another
3
+ * without changing what tests do, and mootant's switch of spare test processes
4
+ * (`readPreforkSwitch`), which tests never see; left out of the hash of all
5
+ * variables, which stands for code that lists them.
6
+ */
7
+ export declare const VOLATILE_VARIABLES: ReadonlySet<string>;
@@ -0,0 +1,11 @@
1
+ const e = /* @__PURE__ */ new Set([
2
+ "ITERM_SESSION_ID",
3
+ "MOOTANT_PREFORK",
4
+ "TERM_SESSION_ID",
5
+ "WINDOWID",
6
+ "OLDPWD",
7
+ "SHLVL",
8
+ "PWD",
9
+ "_"
10
+ ]);
11
+ export { e as VOLATILE_VARIABLES };
@@ -9,7 +9,7 @@ async function s(s, c, l) {
9
9
  let d = e(u.entries, l), f = new Set([...d.values()].map((e) => e.inputs)), p = {
10
10
  inputs: Object.fromEntries([...u.inputs].filter(([e]) => f.has(e))),
11
11
  entries: Object.fromEntries(d),
12
- version: 3
12
+ version: 8
13
13
  }, m = `${s}.${process.pid}.tmp`;
14
14
  try {
15
15
  await r(n.dirname(s), { recursive: !0 }), await o(m, JSON.stringify(p)), await i(m, s);
@@ -2,7 +2,12 @@
2
2
  * Loads a TypeScript configuration file and returns its default export: the
3
3
  * `export default` of an ES module, or the `module.exports` of a CommonJS
4
4
  * module. Node.js imports it directly when it can strip types (22.18 and
5
- * later); older versions need the optional `jiti` package.
5
+ * later); older versions need the optional `jiti` package, where version 1,
6
+ * without `createJiti`, counts as missing. A `.ts` file of a package whose
7
+ * `type` is not `module` loads with `jiti` too when it is installed: Node.js
8
+ * reads it as CommonJS, where `import` and `export` fail or, without a `type`
9
+ * field, draw a warning. A link counts as the file it points to, as in
10
+ * Node.js.
6
11
  *
7
12
  * @param file - Absolute path of the configuration file.
8
13
  * @returns The default export of the file, or undefined when it has none.
@@ -1,13 +1,29 @@
1
- import { importConfig as e } from "./import-config.js";
2
- async function t(t) {
3
- if (process.features.typescript) return e(t);
4
- let n;
1
+ import { listPackageFiles as e } from "../files/list-package-files.js";
2
+ import { readPackageType as t } from "../files/read-package-type.js";
3
+ import { importConfig as n } from "./import-config.js";
4
+ import { realpathSync as r } from "node:fs";
5
+ import i from "node:path";
6
+ async function a(a) {
7
+ let s = !!process.features.typescript;
8
+ if (s && !a.endsWith(".ts")) return n(a);
9
+ let c = r(a), l = s ? t(e(i.dirname(c), /* @__PURE__ */ new Map()).at(-1), /* @__PURE__ */ new Map()) : null;
10
+ if (l === "module") return n(a);
11
+ let u = {};
5
12
  try {
6
- n = await import("jiti");
7
- } catch {
8
- throw Error("TypeScript configuration files need Node.js 22.18 or later, or the jiti package.");
13
+ u = await import("jiti");
14
+ } catch {}
15
+ if (u.createJiti) {
16
+ let e = await u.createJiti(import.meta.url, { interopDefault: !1 }).import(c);
17
+ return e.__esModule === !0 ? e.default : e;
9
18
  }
10
- let r = await n.createJiti(import.meta.url, { interopDefault: !1 }).import(t);
11
- return r.__esModule === !0 ? r.default : r;
19
+ if (!s) throw Error("TypeScript configuration files need Node.js 22.18 or later, or the jiti package.");
20
+ return l === "commonjs" ? o(a) : n(a);
12
21
  }
13
- export { t as loadTypescriptConfig };
22
+ async function o(e) {
23
+ try {
24
+ return await n(e);
25
+ } catch (t) {
26
+ throw t instanceof SyntaxError && !("code" in t) ? Error(`${t.message}. Node.js reads the file as CommonJS because its package.json has "type": "commonjs"; to use import and export, install jiti or rename it to ${i.basename(e, ".ts")}.mts.`, { cause: t }) : t;
27
+ }
28
+ }
29
+ export { a as loadTypescriptConfig };
@@ -2,7 +2,7 @@ import { PresetSettings } from '../../types/config/preset-settings.js';
2
2
  import { ActiveMutator } from '../../types/mutator/active-mutator.js';
3
3
  import { RunConfig } from '../../types/config/run-config.js';
4
4
  /**
5
- * Mutators, settings, root and run settings of a run.
5
+ * Mutators, settings, root, configuration file and run settings of a run.
6
6
  */
7
7
  interface RunSetup {
8
8
  /**
@@ -17,6 +17,10 @@ interface RunSetup {
17
17
  * Mutators turned on, in rank order.
18
18
  */
19
19
  mutators: ActiveMutator[];
20
+ /**
21
+ * Absolute path of the configuration file, or null without one.
22
+ */
23
+ file: string | null;
20
24
  /**
21
25
  * Presets the run extends, joined for reports.
22
26
  */
@@ -58,8 +62,8 @@ interface RunOptions {
58
62
  * win.
59
63
  *
60
64
  * @param options - Configuration path, preset and working directory.
61
- * @returns Active mutators, settings, known ids, presets, root and run settings
62
- * of the run.
65
+ * @returns Active mutators, settings, known ids, presets, root, configuration
66
+ * file and run settings of the run.
63
67
  * @throws Error - When the configuration or a plugin cannot be loaded or is
64
68
  * invalid, or a preset or mutator id is unknown.
65
69
  */
@@ -28,6 +28,7 @@ async function l(l) {
28
28
  knownMutatorIds: new Set(g),
29
29
  root: d?.directory ?? u,
30
30
  preset: h.join(", "),
31
+ file: d?.file ?? null,
31
32
  run: f.run ?? {},
32
33
  mutators: _,
33
34
  settings: v
@@ -5,11 +5,12 @@ import { RunConfig } from '../../types/config/run-config.js';
5
5
  * configuration, which wins over the default. The defaults are those
6
6
  * `RunConfig` documents: the runner's own concurrency, no threshold, a timeout
7
7
  * factor of 3 with a constant of 250, a hit limit factor of 100 with a floor of
8
- * 100000, the cache on, and incremental and fast mode off.
8
+ * 100000, the cache on, and incremental mode, fast mode and parallel units
9
+ * off.
9
10
  *
10
11
  * @param options - Settings given on the command line, undefined when not
11
12
  * given.
12
13
  * @param run - Run settings of the configuration, or an empty object.
13
14
  * @returns Settings of the run with the defaults filled in.
14
15
  */
15
- export declare function resolveRunSettings(options: Pick<RunConfig, 'concurrency' | 'incremental' | 'threshold' | 'cache' | 'fast'>, run: RunConfig): RunSettings;
16
+ export declare function resolveRunSettings(options: Pick<RunConfig, 'parallelUnits' | 'concurrency' | 'incremental' | 'threshold' | 'cache' | 'fast'>, run: RunConfig): RunSettings;
@@ -10,6 +10,7 @@ function e(e, t) {
10
10
  factor: t.timeout?.factor ?? 3
11
11
  }
12
12
  },
13
+ parallelUnits: e.parallelUnits ?? t.parallelUnits ?? !1,
13
14
  incremental: e.incremental ?? t.incremental ?? !1,
14
15
  concurrency: e.concurrency ?? t.concurrency ?? null,
15
16
  threshold: e.threshold ?? t.threshold ?? null,
@@ -15,6 +15,7 @@ let i = [
15
15
  "hitLimit",
16
16
  "html",
17
17
  "incremental",
18
+ "parallelUnits",
18
19
  "paths",
19
20
  "runner",
20
21
  "threshold",
@@ -31,8 +32,8 @@ function s(e) {
31
32
  let e = n(t, a);
32
33
  return `"${t}" is not a run setting${e === null ? "" : ` (did you mean "${e}"?)`}`;
33
34
  }
34
- let { incremental: t, concurrency: i, threshold: o, runner: s, paths: c, cache: u, fast: d, html: f } = e;
35
- return o !== void 0 && (typeof o != "number" || !(o >= 0) || !(o <= 100)) ? "\"threshold\" must be a number from 0 to 100" : i !== void 0 && (!Number.isSafeInteger(i) || i < 1) ? "\"concurrency\" must be a positive integer" : d !== void 0 && typeof d != "boolean" ? "\"fast\" must be true or false" : u !== void 0 && typeof u != "boolean" ? "\"cache\" must be true or false" : t !== void 0 && typeof t != "boolean" ? "\"incremental\" must be true or false" : f !== void 0 && typeof f != "boolean" && (typeof f != "string" || f === "") ? "\"html\" must be true, false or a path" : s !== void 0 && !r(s) && (typeof s != "string" || s === "") ? "\"runner\" must be a built-in adapter name or an adapter object" : c !== void 0 && (!Array.isArray(c) || c.some((e) => typeof e != "string" || e === "")) ? "\"paths\" must be a list of non-empty paths" : l(e, "timeout", ["constant", "factor"]) ?? l(e, "hitLimit", ["factor", "floor"]);
35
+ let { parallelUnits: t, incremental: i, concurrency: o, threshold: s, runner: c, paths: u, cache: d, fast: f, html: p } = e;
36
+ return s !== void 0 && (typeof s != "number" || !(s >= 0) || !(s <= 100)) ? "\"threshold\" must be a number from 0 to 100" : o !== void 0 && (!Number.isSafeInteger(o) || o < 1) ? "\"concurrency\" must be a positive integer" : f !== void 0 && typeof f != "boolean" ? "\"fast\" must be true or false" : d !== void 0 && typeof d != "boolean" ? "\"cache\" must be true or false" : i !== void 0 && typeof i != "boolean" ? "\"incremental\" must be true or false" : t !== void 0 && typeof t != "boolean" ? "\"parallelUnits\" must be true or false" : p !== void 0 && typeof p != "boolean" && (typeof p != "string" || p === "") ? "\"html\" must be true, false or a path" : c !== void 0 && !r(c) && (typeof c != "string" || c === "") ? "\"runner\" must be a built-in adapter name or an adapter object" : u !== void 0 && (!Array.isArray(u) || u.some((e) => typeof e != "string" || e === "")) ? "\"paths\" must be a list of non-empty paths" : l(e, "timeout", ["constant", "factor"]) ?? l(e, "hitLimit", ["factor", "floor"]);
36
37
  }
37
38
  function c(a) {
38
39
  if (a === void 0) return "it must have a default export";
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Gives the `package.json` of the installed package a file lies in: the one in
3
+ * the directory under the last `node_modules` of its path, `@scope/name`
4
+ * included, whose `main` and `exports` decide what an import of the package
5
+ * resolves to, also when a `package.json` closer to the file only decides its
6
+ * format.
7
+ *
8
+ * @param file - Absolute path.
9
+ * @returns Absolute path of the manifest, or null for a file that lies in no
10
+ * package under `node_modules`.
11
+ */
12
+ export declare function getPackageManifest(file: string): string | null;
@@ -0,0 +1,7 @@
1
+ import e from "node:path";
2
+ const t = /^(?<root>.*[/\\]node_modules[/\\](?:@[^/\\]+[/\\])?[^/\\]+)[/\\]/u;
3
+ function n(n) {
4
+ let r = t.exec(n)?.groups?.root;
5
+ return r === void 0 ? null : e.join(r, "package.json");
6
+ }
7
+ export { n as getPackageManifest };