mootant 0.1.0 → 0.2.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 (244) hide show
  1. package/dist/adapters/jest/build-dry-file.d.ts +12 -12
  2. package/dist/adapters/jest/collect-jest-dependencies.d.ts +8 -7
  3. package/dist/adapters/jest/runner.d.ts +1 -1
  4. package/dist/adapters/jest/runner.js +1 -1
  5. package/dist/adapters/jest/types/jest-record.d.ts +4 -4
  6. package/dist/adapters/jest/types/unit-worker.d.ts +16 -8
  7. package/dist/adapters/jest/types/worker-session.d.ts +6 -7
  8. package/dist/adapters/jest/worker/boot-worker.d.ts +4 -3
  9. package/dist/adapters/jest/worker/run-unit.d.ts +20 -18
  10. package/dist/adapters/jest/worker/vm-setup.js +1 -1
  11. package/dist/adapters/jest/worker/worker.js +1 -1
  12. package/dist/adapters/jest/write-worker-session.d.ts +1 -2
  13. package/dist/adapters/jest/write-worker-session.js +2 -2
  14. package/dist/adapters/node-test/collect-node-dependencies.d.ts +5 -5
  15. package/dist/adapters/node-test/preload/preload.js +4 -1
  16. package/dist/adapters/node-test/run-test-file.js +1 -0
  17. package/dist/adapters/node-test/types/node-test-record.d.ts +3 -3
  18. package/dist/adapters/node-test/types/node-test-unit.d.ts +6 -1
  19. package/dist/adapters/shared/create-input-filter.d.ts +26 -0
  20. package/dist/adapters/shared/create-input-filter.js +32 -0
  21. package/dist/adapters/shared/track-file-inputs.d.ts +7 -3
  22. package/dist/adapters/shared/track-file-inputs.js +16 -7
  23. package/dist/adapters/shared/track-file-reads.d.ts +12 -8
  24. package/dist/adapters/shared/track-file-reads.js +110 -57
  25. package/dist/adapters/shared/track-inputs.d.ts +13 -6
  26. package/dist/adapters/shared/track-inputs.js +7 -7
  27. package/dist/adapters/shared/types/file-input-tracking.d.ts +6 -0
  28. package/dist/adapters/shared/types/input-tracking.d.ts +3 -3
  29. package/dist/adapters/vitest/collect-dependencies.d.ts +4 -3
  30. package/dist/adapters/vitest/collect-dependencies.js +25 -24
  31. package/dist/adapters/vitest/get-cache-inputs.js +3 -1
  32. package/dist/adapters/vitest/is-virtual-module.d.ts +11 -0
  33. package/dist/adapters/vitest/is-virtual-module.js +8 -0
  34. package/dist/adapters/vitest/read-out-files.d.ts +7 -2
  35. package/dist/adapters/vitest/read-out-files.js +5 -5
  36. package/dist/adapters/vitest/read-out-records.d.ts +17 -0
  37. package/dist/adapters/vitest/read-out-records.js +27 -0
  38. package/dist/adapters/vitest/read-strays.d.ts +20 -0
  39. package/dist/adapters/vitest/read-strays.js +53 -0
  40. package/dist/adapters/vitest/read-unit-inputs.d.ts +7 -1
  41. package/dist/adapters/vitest/read-unit-inputs.js +1 -1
  42. package/dist/adapters/vitest/run-dry.js +16 -16
  43. package/dist/adapters/vitest/run-plan.d.ts +3 -1
  44. package/dist/adapters/vitest/run-plan.js +15 -15
  45. package/dist/adapters/vitest/run-specifications.d.ts +3 -2
  46. package/dist/adapters/vitest/runner.d.ts +38 -23
  47. package/dist/adapters/vitest/runner.js +84 -85
  48. package/dist/adapters/vitest/types/stray-decisions.d.ts +8 -0
  49. package/dist/adapters/vitest/types/unit-outcome.d.ts +2 -1
  50. package/dist/adapters/vitest/types/vitest-worker.d.ts +83 -12
  51. package/dist/adapters/vitest/worker/encode-stray.d.ts +16 -0
  52. package/dist/adapters/vitest/worker/encode-stray.js +16 -0
  53. package/dist/adapters/vitest/worker/intercept-strays.d.ts +26 -0
  54. package/dist/adapters/vitest/worker/intercept-strays.js +13 -0
  55. package/dist/adapters/vitest/worker/read-try-facts.d.ts +5 -4
  56. package/dist/adapters/vitest/worker/write-out-record.d.ts +2 -2
  57. package/dist/cli/html/build-html-report.js +1 -1
  58. package/dist/cli/html/client/main.js +1 -1
  59. package/dist/cli/html/client/render-change.d.ts +3 -2
  60. package/dist/cli/html/client/render-code.d.ts +1 -1
  61. package/dist/cli/html/pack-replacement.d.ts +1 -1
  62. package/dist/cli/parse-arguments.js +1 -1
  63. package/dist/cli/report/build-list-report.js +1 -1
  64. package/dist/cli/report/build-run-report.js +1 -1
  65. package/dist/cli/report/format-file-groups.d.ts +1 -1
  66. package/dist/cli/run-mutation.js +31 -31
  67. package/dist/cli/terminal/create-spinner.d.ts +1 -1
  68. package/dist/cli/terminal/get-text-style.js +4 -4
  69. package/dist/core/cache/get-environment-key.js +2 -2
  70. package/dist/core/cache/hash-files.d.ts +7 -3
  71. package/dist/core/cache/hash-files.js +16 -17
  72. package/dist/core/cache/prepare-run-cache.d.ts +29 -7
  73. package/dist/core/cache/prepare-run-cache.js +96 -62
  74. package/dist/core/cache/save-run-cache.d.ts +8 -7
  75. package/dist/core/cache/save-run-cache.js +2 -1
  76. package/dist/core/cache/unknown-hash.d.ts +7 -0
  77. package/dist/core/cache/unknown-hash.js +2 -0
  78. package/dist/core/files/select-changed-mutants.d.ts +11 -6
  79. package/dist/core/files/select-changed-mutants.js +38 -13
  80. package/dist/core/generate/apply-solitary-rule.d.ts +8 -5
  81. package/dist/core/generate/apply-solitary-rule.js +36 -29
  82. package/dist/core/generate/collect-candidates.d.ts +18 -4
  83. package/dist/core/generate/collect-candidates.js +168 -86
  84. package/dist/core/generate/compare-targets.d.ts +14 -0
  85. package/dist/core/generate/compare-targets.js +6 -0
  86. package/dist/core/generate/deduplicate-candidates.d.ts +6 -4
  87. package/dist/core/generate/deduplicate-candidates.js +11 -9
  88. package/dist/core/generate/find-list-removal.d.ts +20 -0
  89. package/dist/core/generate/find-list-removal.js +26 -0
  90. package/dist/core/generate/generate-file-mutants.js +47 -46
  91. package/dist/core/generate/get-mutant-site.d.ts +18 -0
  92. package/dist/core/generate/get-mutant-site.js +4 -0
  93. package/dist/core/generate/get-target.d.ts +14 -0
  94. package/dist/core/generate/get-target.js +4 -0
  95. package/dist/core/generate/pick-host.d.ts +10 -0
  96. package/dist/core/generate/pick-host.js +16 -0
  97. package/dist/core/generate/validate-replacement.d.ts +15 -4
  98. package/dist/core/generate/validate-replacement.js +28 -13
  99. package/dist/core/ignore/find-ignore-rule.d.ts +8 -7
  100. package/dist/core/instrument/find-attribute-values.d.ts +12 -0
  101. package/dist/core/instrument/find-attribute-values.js +13 -0
  102. package/dist/core/instrument/get-site-syntax.d.ts +14 -0
  103. package/dist/core/instrument/get-site-syntax.js +12 -0
  104. package/dist/core/instrument/group-mutant-ranges.d.ts +7 -3
  105. package/dist/core/instrument/group-mutant-ranges.js +25 -19
  106. package/dist/core/instrument/instrument-file.d.ts +5 -3
  107. package/dist/core/instrument/instrument-file.js +10 -9
  108. package/dist/core/instrument/instrumenter-version.d.ts +1 -1
  109. package/dist/core/instrument/render-branch.d.ts +17 -0
  110. package/dist/core/instrument/render-branch.js +81 -0
  111. package/dist/core/instrument/render-mutant-range.d.ts +17 -6
  112. package/dist/core/instrument/render-mutant-range.js +39 -13
  113. package/dist/core/list-mutants.d.ts +7 -5
  114. package/dist/core/list-mutants.js +2 -2
  115. package/dist/core/mutators/array-element.d.ts +7 -6
  116. package/dist/core/mutators/array-element.js +13 -13
  117. package/dist/core/mutators/assignment-operator.js +34 -33
  118. package/dist/core/mutators/boolean-literal.d.ts +3 -2
  119. package/dist/core/mutators/number-literal.d.ts +1 -1
  120. package/dist/core/mutators/object-property.d.ts +4 -3
  121. package/dist/core/mutators/object-property.js +7 -8
  122. package/dist/core/mutators/return-value.js +65 -33
  123. package/dist/core/mutators/shared/get-branch-copy-skip.d.ts +12 -7
  124. package/dist/core/mutators/shared/get-branch-copy-skip.js +34 -35
  125. package/dist/core/mutators/shared/get-canonical-falsy-default.d.ts +32 -0
  126. package/dist/core/mutators/shared/get-canonical-falsy-default.js +11 -0
  127. package/dist/core/mutators/shared/get-comparison-plan.js +86 -85
  128. package/dist/core/mutators/shared/get-condition-constants.d.ts +8 -8
  129. package/dist/core/mutators/shared/get-condition-constants.js +3 -3
  130. package/dist/core/mutators/shared/get-endless-value.d.ts +20 -0
  131. package/dist/core/mutators/shared/get-endless-value.js +25 -0
  132. package/dist/core/mutators/shared/get-forced-test-justifier.d.ts +44 -0
  133. package/dist/core/mutators/shared/get-forced-test-justifier.js +25 -0
  134. package/dist/core/mutators/shared/get-group-constant.d.ts +4 -4
  135. package/dist/core/mutators/shared/get-group-constant.js +2 -2
  136. package/dist/core/mutators/shared/get-literal-skip.d.ts +6 -6
  137. package/dist/core/mutators/shared/get-literal-skip.js +2 -2
  138. package/dist/core/mutators/shared/get-logical-drops.d.ts +8 -8
  139. package/dist/core/mutators/shared/get-logical-drops.js +80 -82
  140. package/dist/core/mutators/shared/get-owner-constant.d.ts +3 -1
  141. package/dist/core/mutators/shared/get-running-value.d.ts +5 -4
  142. package/dist/core/mutators/shared/get-toward-mutant.d.ts +10 -2
  143. package/dist/core/mutators/shared/get-toward-mutant.js +45 -40
  144. package/dist/core/mutators/shared/has-other-exit.js +16 -36
  145. package/dist/core/mutators/shared/is-loop-exit.d.ts +20 -0
  146. package/dist/core/mutators/shared/is-loop-exit.js +32 -0
  147. package/dist/core/mutators/shared/is-read-only.d.ts +26 -0
  148. package/dist/core/mutators/shared/is-read-only.js +53 -0
  149. package/dist/core/mutators/statement-removal.d.ts +4 -3
  150. package/dist/core/mutators/statement-removal.js +69 -73
  151. package/dist/core/mutators/string-literal.d.ts +15 -5
  152. package/dist/core/mutators/string-literal.js +79 -50
  153. package/dist/core/presets/recommended.d.ts +2 -2
  154. package/dist/core/presets/strict.d.ts +4 -2
  155. package/dist/core/run/apply-batch-result.d.ts +23 -22
  156. package/dist/core/run/apply-batch-result.js +5 -5
  157. package/dist/core/run/apply-isolated-result.d.ts +18 -17
  158. package/dist/core/run/apply-isolated-result.js +1 -0
  159. package/dist/core/run/classify-try.d.ts +9 -8
  160. package/dist/core/run/get-test-file-limits.d.ts +13 -0
  161. package/dist/core/run/get-test-file-limits.js +13 -0
  162. package/dist/core/run/get-unit-evidence.d.ts +6 -3
  163. package/dist/core/run/get-unit-evidence.js +1 -1
  164. package/dist/core/run/plan-batch.d.ts +6 -3
  165. package/dist/core/run/plan-batch.js +36 -31
  166. package/dist/core/run/plan-isolated.d.ts +3 -1
  167. package/dist/core/run/plan-isolated.js +8 -14
  168. package/dist/core/run/read-isolated-unit.d.ts +4 -4
  169. package/dist/core/run/run-batch-phases.d.ts +4 -3
  170. package/dist/core/run/run-dry-phase.d.ts +35 -19
  171. package/dist/core/run/run-dry-phase.js +127 -77
  172. package/dist/core/run/run-isolated-rounds.d.ts +6 -5
  173. package/dist/core/run/run-isolated-rounds.js +1 -0
  174. package/dist/core/run-mutants.d.ts +26 -21
  175. package/dist/core/run-mutants.js +72 -64
  176. package/dist/core/runtime/create-hit-limit-error.d.ts +5 -3
  177. package/dist/core/runtime/create-hit-limit-error.js +1 -1
  178. package/dist/core/runtime/install-mutant-runtime.js +23 -6
  179. package/dist/core/runtime/runtime-version.d.ts +4 -4
  180. package/dist/core/skips/skip-rules.d.ts +4 -0
  181. package/dist/core/skips/skip-rules.js +4 -0
  182. package/dist/core/syntax/is-brace-sensitive-attribute.d.ts +18 -0
  183. package/dist/core/syntax/is-brace-sensitive-attribute.js +28 -0
  184. package/dist/core/syntax/is-spread-safe-member.d.ts +18 -0
  185. package/dist/core/syntax/is-spread-safe-member.js +18 -0
  186. package/dist/core/syntax/is-value-position.d.ts +3 -1
  187. package/dist/core/text/get-list-removal-range.d.ts +22 -0
  188. package/dist/core/text/get-list-removal-range.js +46 -0
  189. package/dist/core/text/is-plain-attribute-string.d.ts +10 -0
  190. package/dist/core/text/is-plain-attribute-string.js +5 -0
  191. package/dist/core/text/parse-expression.d.ts +8 -4
  192. package/dist/core/text/parse-expression.js +1 -0
  193. package/dist/core/text/remove-list-element.d.ts +2 -4
  194. package/dist/core/text/remove-list-element.js +4 -45
  195. package/dist/docs/styles/colors.js +1 -1
  196. package/dist/package.js +1 -1
  197. package/dist/types/adapter/dry-file.d.ts +2 -1
  198. package/dist/types/adapter/dry-run-request.d.ts +5 -4
  199. package/dist/types/adapter/mutant-runtime.d.ts +30 -1
  200. package/dist/types/cli/text-style.d.ts +1 -1
  201. package/dist/types/config/preset-settings.d.ts +2 -2
  202. package/dist/types/config/run-config.d.ts +12 -4
  203. package/dist/types/html/indexed-mutant.d.ts +4 -2
  204. package/dist/types/html/shown-change.d.ts +4 -3
  205. package/dist/types/mutant/list-removal.d.ts +37 -0
  206. package/dist/types/mutant/mutant-candidate.d.ts +11 -17
  207. package/dist/types/mutant/mutant-host.d.ts +49 -0
  208. package/dist/types/mutant/mutant-kind.d.ts +18 -0
  209. package/dist/types/mutant/mutant-range.d.ts +15 -8
  210. package/dist/types/mutant/mutant.d.ts +9 -15
  211. package/dist/types/mutant/site-syntax.d.ts +14 -0
  212. package/dist/types/mutant/skip-justifier.d.ts +3 -1
  213. package/dist/types/mutant/skipped-candidate.d.ts +13 -10
  214. package/dist/types/mutant/skipped-mutant.d.ts +9 -6
  215. package/dist/types/mutator/replacement.d.ts +14 -3
  216. package/dist/types/report/html-report.d.ts +10 -7
  217. package/dist/types/report/list-report-focus.d.ts +3 -2
  218. package/dist/types/report/list-report-justifier.d.ts +4 -2
  219. package/dist/types/report/list-report-mutant.d.ts +15 -9
  220. package/dist/types/report/list-report-skipped.d.ts +3 -2
  221. package/dist/types/report/list-report.d.ts +1 -1
  222. package/dist/types/report/run-report.d.ts +2 -2
  223. package/dist/types/report/slim-list-report.d.ts +6 -3
  224. package/dist/types/report/slim-run-report.d.ts +1 -1
  225. package/dist/types/run/isolated-reason.d.ts +4 -3
  226. package/dist/types/run/mutant-state.d.ts +1 -1
  227. package/dist/types/run/run-event.d.ts +1 -1
  228. package/dist/types/run/run-kind.d.ts +3 -2
  229. package/dist/types/run/run-result.d.ts +6 -3
  230. package/dist/types/run/run-state.d.ts +9 -1
  231. package/dist/types/run/run-status.d.ts +2 -2
  232. package/dist/types/run/try-cause.d.ts +8 -6
  233. package/dist/types/syntax/syntax-helpers.d.ts +5 -3
  234. package/package.json +5 -5
  235. package/skills/mootant/SKILL.md +14 -12
  236. package/skills/mootant/references/mutators.md +3 -1
  237. package/dist/core/instrument/get-site-check.d.ts +0 -9
  238. package/dist/core/instrument/get-site-check.js +0 -5
  239. package/dist/core/instrument/get-template-site-check.d.ts +0 -12
  240. package/dist/core/instrument/get-template-site-check.js +0 -5
  241. /package/dist/cli/{built-in-adapters.d.ts → get-built-in-adapters.d.ts} +0 -0
  242. /package/dist/cli/{built-in-adapters.js → get-built-in-adapters.js} +0 -0
  243. /package/dist/cli/terminal/{colors.d.ts → create-colors.d.ts} +0 -0
  244. /package/dist/cli/terminal/{colors.js → create-colors.js} +0 -0
@@ -0,0 +1,32 @@
1
+ import { realpathSync as e } from "node:fs";
2
+ import t from "node:path";
3
+ import { tmpdir as n, userInfo as r } from "node:os";
4
+ let { sep: i } = t;
5
+ function a(e) {
6
+ let { root: a } = e, u = l(t.resolve(n())), d = c(l(e.directory)), { geteuid: f } = process, p = f === void 0 ? r().username : f(), m = c(u.flatMap((e) => [t.join(e, `tsx-${p}`), t.join(e, "tsx")])), h = new Set(o(a, u).flatMap((e) => [...s(e)])), g = `${i}node_modules`, _ = `${g}${i}`;
7
+ return (e) => !e.includes(_) && !e.endsWith(g) && !h.has(e) && !d(e) && !m(e);
8
+ }
9
+ function o(e, t) {
10
+ let n = l(e), r = n.flatMap((e) => {
11
+ let n = t.find((t) => c([t])(e));
12
+ return n === void 0 ? [] : t.map((t) => `${t}${e.slice(n.length)}`);
13
+ });
14
+ return [.../* @__PURE__ */ new Set([...n, ...r])];
15
+ }
16
+ function s(e) {
17
+ let n = /* @__PURE__ */ new Set(), r = e, i = t.dirname(r);
18
+ for (; i !== r;) n.add(i), r = i, i = t.dirname(r);
19
+ return n;
20
+ }
21
+ function c(e) {
22
+ let t = e.map((e) => `${e}${i}`);
23
+ return (n) => e.includes(n) || t.some((e) => n.startsWith(e));
24
+ }
25
+ function l(t) {
26
+ try {
27
+ return [t, e(t)];
28
+ } catch {
29
+ return [t];
30
+ }
31
+ }
32
+ export { a as createInputFilter };
@@ -3,10 +3,14 @@ import { FileInputTracking } from './types/file-input-tracking.js';
3
3
  * Starts recording the files and directories code reads through `node:fs`, and
4
4
  * which of them it changed itself: the path it wrote or the directory that path
5
5
  * is in. A read counts unless the code wrote that path earlier, since then it
6
- * reads its own output and not an input.
6
+ * reads its own output and not an input, as with a directory `mkdtemp` made or
7
+ * a copy `cp` wrote; anything else in a directory the code made counts, as it
8
+ * may come from what no read names, such as a child process or a link. A path
9
+ * written is taken as given and by the real path of its directory, so a read or
10
+ * a module that names it by that path, as `require` does, is the same.
7
11
  *
8
12
  * @param accept - Tells whether a path counts when it is read.
9
- * @returns The files read so far and the function that stops recording and
10
- * returns what was read.
13
+ * @returns The files read so far, whether a path is one the code wrote, and the
14
+ * function that stops recording and returns what was read.
11
15
  */
12
16
  export declare function trackFileInputs(accept: (file: string) => boolean): FileInputTracking;
@@ -1,21 +1,30 @@
1
1
  import { trackFileReads as e } from "./track-file-reads.js";
2
- import t from "node:path";
3
- let n = t.dirname;
4
- function r(t) {
5
- let r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set();
2
+ import { realpathSync as t } from "node:fs";
3
+ import n from "node:path";
4
+ let r = n.dirname, i = n.basename, a = n.join, o = t;
5
+ function s(t) {
6
+ let n = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set();
6
7
  return e({
7
8
  write: (e) => {
8
- r.add(e), i.add(e), i.add(n(e));
9
+ for (let t of [e, c(e)]) n.add(t), i.add(t), i.add(r(t));
9
10
  },
10
11
  read: (e) => {
11
- t(e) && !r.has(e) && a.add(e);
12
+ t(e) && !n.has(e) && a.add(e);
12
13
  }
13
14
  }), {
14
15
  stop: () => (e(null), {
15
16
  modified: [...a].filter((e) => i.has(e)).toSorted(),
16
17
  files: [...a].toSorted()
17
18
  }),
19
+ owns: (e) => n.has(e),
18
20
  files: a
19
21
  };
20
22
  }
21
- export { r as trackFileInputs };
23
+ function c(e) {
24
+ try {
25
+ return a(o(r(e)), i(e));
26
+ } catch {
27
+ return e;
28
+ }
29
+ }
30
+ export { s as trackFileInputs };
@@ -23,14 +23,18 @@ export interface FileAccessReceiver {
23
23
  * `open` reads unless its flags create, empty or append to the file, as `w`,
24
24
  * `a` or `O_CREAT` do; `r+` reads. The source of a copy, a move or a link is
25
25
  * read, and so is every file and directory in a directory `cp` copies, outside
26
- * `node_modules` and `.git`; `mkdir` writes only the directories that did not
27
- * exist. A recursive `readdir` or `opendir` reads the directory and every
28
- * directory in it, each listed by its own names, so adding a file anywhere in
29
- * the tree changes what was read; `readdir` also reads the directories behind
30
- * the links it follows. `glob` reads the same of the directory where each
31
- * pattern's fixed part ends. Calls of `node:fs` that a wrapped function makes
32
- * while it runs report nothing, and neither do those of the asynchronous work
33
- * of `glob`. Descriptors and file handles are not paths and are not reported.
26
+ * `node_modules` and `.git`, whose copies it writes once it succeeded, unless a
27
+ * `filter`, `force: false` or `verbatimSymlinks` may make a copy other than its
28
+ * source (`listCopies`); `mkdir` writes only the directories that did not
29
+ * exist. `mkdtemp` and `mkdtempDisposable` write the directory they made once
30
+ * they give it. A recursive `readdir` or `opendir` reads the directory and
31
+ * every directory in it, each listed by its own names, so adding a file
32
+ * anywhere in the tree changes what was read; `readdir` also reads the
33
+ * directories behind the links it follows. `glob` reads the same of the
34
+ * directory where each pattern's fixed part ends. Calls of `node:fs` that a
35
+ * wrapped function makes while it runs report nothing, and neither do those of
36
+ * the asynchronous work of `glob` and `cp`, but those of their callbacks do.
37
+ * Descriptors and file handles are not paths and are not reported.
34
38
  *
35
39
  * @param receiver - Receives the paths while it is the current receiver; the
36
40
  * next call replaces it, and null stops recording.
@@ -26,18 +26,18 @@ const a = /* @__PURE__ */ new Set([
26
26
  rmdir: [0],
27
27
  mkdir: [0],
28
28
  link: [1],
29
- cp: [1],
30
- rm: [0]
29
+ rm: [0],
30
+ cp: []
31
31
  }, s = /* @__PURE__ */ new Set([
32
32
  "copyFile",
33
33
  "symlink",
34
34
  "rename",
35
35
  "link",
36
36
  "cp"
37
- ]), c = /* @__PURE__ */ new Set(["node_modules", ".git"]), l = /[!()*+?@[\\\]{}]/u, u = t.constants.O_WRONLY | t.constants.O_APPEND | t.constants.O_CREAT | t.constants.O_TRUNC, d = Symbol.for("mootant.file-reads");
38
- let f = n.resolve, p = n.dirname, m = n.join, h = r;
39
- function g(n) {
40
- let r = globalThis, s = r[d];
37
+ ]), c = /* @__PURE__ */ new Set(["mkdtempDisposable", "mkdtemp"]), l = /* @__PURE__ */ new Set(["glob", "cp"]), u = /* @__PURE__ */ new Set(["node_modules", ".git"]), d = /[!()*+?@[\\\]{}]/u, f = t.constants.O_WRONLY | t.constants.O_APPEND | t.constants.O_CREAT | t.constants.O_TRUNC, p = Symbol.for("mootant.file-reads");
38
+ let m = n.resolve, h = n.dirname, g = n.join, _ = r;
39
+ function v(n) {
40
+ let r = globalThis, s = r[p];
41
41
  if (s === void 0) {
42
42
  s = {
43
43
  original: {
@@ -46,39 +46,78 @@ function g(n) {
46
46
  existsSync: t.existsSync,
47
47
  statSync: t.statSync
48
48
  },
49
- globbing: new i(),
49
+ walking: new i(),
50
50
  receiver: null,
51
51
  inside: !1
52
- }, r[d] = s;
53
- let n = [...a, ...Object.keys(o)].flatMap((e) => [e, `${e}Sync`]);
52
+ }, r[p] = s;
53
+ let n = [
54
+ ...a,
55
+ ...Object.keys(o),
56
+ ...c
57
+ ].flatMap((e) => [e, `${e}Sync`]);
54
58
  for (let e of [t, t.promises]) for (let t of n) {
55
59
  let n = Reflect.get(e, t);
56
- typeof n == "function" && Reflect.set(e, t, _(n, t, s));
60
+ typeof n == "function" && Reflect.set(e, t, y(n, t, s));
57
61
  }
58
62
  e();
59
63
  }
60
64
  s.receiver = n;
61
65
  }
62
- function _(e, t, n) {
66
+ function y(e, t, n) {
63
67
  let r = t.replace(/Sync$/u, "");
64
68
  function i(...i) {
65
- if (n.inside || n.globbing.getStore() === !0) return e.apply(this, i);
66
- let a = n.receiver;
67
- if (a !== null) try {
68
- let e = E(r, i, n);
69
- for (let t of e.read) a.read(t);
70
- for (let t of e.written) a.write(t);
71
- } catch {}
69
+ if (n.inside || n.walking.getStore() === !0) return e.apply(this, i);
70
+ let a = n.receiver, o = null;
71
+ if (a !== null) {
72
+ let e = a;
73
+ try {
74
+ if (c.has(r)) o = (t) => {
75
+ let n = t.path ?? t, r = m(Buffer.isBuffer(n) ? n.toString() : String(n));
76
+ e.write(r);
77
+ };
78
+ else {
79
+ let t = A(r, i, n);
80
+ for (let n of t.read) e.read(n);
81
+ for (let n of t.written) e.write(n);
82
+ let a = r === "cp" ? S(i, t.read, n) : [];
83
+ a.length > 0 && (o = () => {
84
+ for (let t of a) e.write(t);
85
+ });
86
+ }
87
+ } catch {}
88
+ }
89
+ let s = (t) => o === null ? e.apply(this, t) : b((...t) => e.apply(this, t), t, o);
72
90
  n.inside = !0;
73
91
  try {
74
- return t === "glob" ? w(n.globbing.run(!0, () => e.apply(this, i)), n) : e.apply(this, i);
92
+ if (!l.has(t)) return s(i);
93
+ let e = j(i, n), r = n.walking.run(!0, () => s(e));
94
+ return t === "glob" ? O(r, n) : r;
75
95
  } finally {
76
96
  n.inside = !1;
77
97
  }
78
98
  }
79
99
  return Object.defineProperties(i, Object.getOwnPropertyDescriptors(e)), i;
80
100
  }
81
- function v(e, t, n) {
101
+ function b(e, t, n) {
102
+ function r(e) {
103
+ try {
104
+ n(e);
105
+ } catch {}
106
+ }
107
+ let i = t.at(-1);
108
+ if (typeof i == "function") return e(...t.slice(0, -1), (e, t, ...n) => (e ?? r(t), Reflect.apply(i, void 0, [
109
+ e,
110
+ t,
111
+ ...n
112
+ ])));
113
+ async function a(e) {
114
+ let t = await e;
115
+ return r(t), t;
116
+ }
117
+ let o = e(...t);
118
+ return o instanceof Promise ? a(o) : (r(o), o);
119
+ }
120
+ function x(e, t, n) {
82
121
  let r = [e], i = /* @__PURE__ */ new Set(), a = [e];
83
122
  for (; a.length > 0;) {
84
123
  let e = a.shift(), o = [];
@@ -86,7 +125,7 @@ function v(e, t, n) {
86
125
  i.add(t.original.realpathSync(e)), o = t.original.readdirSync(e, { withFileTypes: !0 });
87
126
  } catch {}
88
127
  for (let s of o) {
89
- let o = m(e, s.name), c = s.isDirectory();
128
+ let o = g(e, s.name), c = s.isDirectory();
90
129
  if (n && s.isSymbolicLink()) try {
91
130
  if (c = t.original.statSync(o).isDirectory(), c && i.has(t.original.realpathSync(o))) {
92
131
  r.push(o);
@@ -98,7 +137,17 @@ function v(e, t, n) {
98
137
  }
99
138
  return r;
100
139
  }
101
- function y(e, t, n) {
140
+ function S(e, t, n) {
141
+ let [r] = t, i = M(e[1]), a = e[2] ?? {};
142
+ return r === void 0 || i === null || a.filter !== void 0 || a.force === !1 || a.verbatimSymlinks === !0 ? [] : t.map((e) => `${i}${e.slice(r.length)}`).filter((e) => {
143
+ try {
144
+ return !n.original.statSync(e).isDirectory();
145
+ } catch {
146
+ return !0;
147
+ }
148
+ });
149
+ }
150
+ function C(e, t, n) {
102
151
  n.push(e);
103
152
  let r = [];
104
153
  try {
@@ -109,82 +158,86 @@ function y(e, t, n) {
109
158
  try {
110
159
  i = t.original.readdirSync(e, { withFileTypes: !0 });
111
160
  } catch {}
112
- for (let t of i) if (!c.has(t.name)) {
113
- let i = m(e, t.name);
161
+ for (let t of i) if (!u.has(t.name)) {
162
+ let i = g(e, t.name);
114
163
  n.push(i), t.isDirectory() && r.push(i);
115
164
  }
116
165
  }
117
166
  }
118
- function b(e, t, n) {
167
+ function w(e, t, n) {
119
168
  let r = {
120
169
  written: [],
121
170
  read: []
122
- }, i = D(t[0]);
123
- return i === null || (e === "open" && !k(t[1]) ? r.written.push(i) : (e === "readdir" || e === "opendir") && t[1]?.recursive ? r.read.push(...v(i, n, e === "readdir")) : r.read.push(i)), r;
171
+ }, i = M(t[0]);
172
+ return i === null || (e === "open" && !P(t[1]) ? r.written.push(i) : (e === "readdir" || e === "opendir") && t[1]?.recursive ? r.read.push(...x(i, n, e === "readdir")) : r.read.push(i)), r;
124
173
  }
125
- function x(e, t, n) {
126
- let r = D(t[0]);
174
+ function T(e, t, n) {
175
+ let r = M(t[0]);
127
176
  if (r === null || !s.has(e)) return [];
128
177
  if (e === "symlink") {
129
- let e = D(t[1]);
130
- return [e === null || typeof t[0] != "string" ? r : f(p(e), t[0])];
178
+ let e = M(t[1]);
179
+ return [e === null || typeof t[0] != "string" ? r : m(h(e), t[0])];
131
180
  }
132
181
  if (e === "cp") {
133
182
  let e = [];
134
- return y(r, n, e), e;
183
+ return C(r, n, e), e;
135
184
  }
136
185
  return [r];
137
186
  }
138
- function S(e, t) {
139
- let n = [], r = [e[0]].flat(), i = e[1], a = typeof i == "object" ? D(i.cwd) : null;
140
- for (let e of r) typeof e == "string" && n.push(...v(T(e, a ?? process.cwd()), t, !1));
187
+ function E(e, t) {
188
+ let n = [], r = [e[0]].flat(), i = e[1], a = typeof i == "object" ? M(i.cwd) : null;
189
+ for (let e of r) typeof e == "string" && n.push(...x(k(e, a ?? process.cwd()), t, !1));
141
190
  return n;
142
191
  }
143
- function C(e, t, n) {
192
+ function D(e, t, n) {
144
193
  let r = [], i = o[e];
145
194
  for (let a of i) {
146
- let i = D(t[a]);
195
+ let i = M(t[a]);
147
196
  if (i !== null) {
148
- if (e === "mkdir") for (; !n.original.existsSync(i);) r.push(i), i = p(i);
197
+ if (e === "mkdir") for (; !n.original.existsSync(i);) r.push(i), i = h(i);
149
198
  else r.push(i);
150
199
  }
151
200
  }
152
201
  return r;
153
202
  }
154
- function w(e, t) {
203
+ function O(e, t) {
155
204
  if (e === void 0) return e;
156
205
  let n = e, r = {
157
- return: (e) => t.globbing.run(!0, () => n.return(e)),
158
- next: () => t.globbing.run(!0, () => n.next()),
206
+ return: (e) => t.walking.run(!0, () => n.return(e)),
207
+ next: () => t.walking.run(!0, () => n.next()),
159
208
  [Symbol.asyncIterator]: () => r
160
209
  };
161
210
  return r;
162
211
  }
163
- function T(e, t) {
164
- let n = e.split("/"), r = n.findIndex((e) => l.test(e));
165
- if (r === -1) return f(t, e);
166
- let i = f(t, n.slice(0, r).join("/"));
167
- for (let e of n.slice(r)) e === ".." && (i = p(i));
212
+ function k(e, t) {
213
+ let n = e.split("/"), r = n.findIndex((e) => d.test(e));
214
+ if (r === -1) return m(t, e);
215
+ let i = m(t, n.slice(0, r).join("/"));
216
+ for (let e of n.slice(r)) e === ".." && (i = h(i));
168
217
  return i;
169
218
  }
170
- function E(e, t, n) {
219
+ function A(e, t, n) {
171
220
  return e === "glob" ? {
172
- read: S(t, n),
221
+ read: E(t, n),
173
222
  written: []
174
- } : a.has(e) ? b(e, t, n) : {
175
- read: x(e, t, n),
176
- written: C(e, t, n)
223
+ } : a.has(e) ? w(e, t, n) : {
224
+ read: T(e, t, n),
225
+ written: D(e, t, n)
177
226
  };
178
227
  }
179
- function D(e) {
228
+ function j(e, t) {
229
+ let n = e.at(-1);
230
+ return typeof n == "function" ? [...e.slice(0, -1), (...e) => t.walking.exit(() => Reflect.apply(n, void 0, e))] : e;
231
+ }
232
+ function M(e) {
180
233
  let t = null;
181
- return typeof e == "string" ? t = e : O(e) ? t = e.protocol === "file:" ? h(e) : null : e instanceof Buffer && (t = e.toString()), t === null ? null : f(t);
234
+ return typeof e == "string" ? t = e : N(e) ? t = e.protocol === "file:" ? _(e) : null : e instanceof Buffer && (t = e.toString()), t === null ? null : m(t);
182
235
  }
183
- function O(e) {
236
+ function N(e) {
184
237
  let t = e;
185
238
  return !!t?.href && !!t?.protocol && t?.auth === void 0 && t?.path === void 0;
186
239
  }
187
- function k(e) {
188
- return typeof e == "number" ? (e & u) === 0 : typeof e != "string" || !/[aw]/u.test(e);
240
+ function P(e) {
241
+ return typeof e == "number" ? (e & f) === 0 : typeof e != "string" || !/[aw]/u.test(e);
189
242
  }
190
- export { g as trackFileReads };
243
+ export { v as trackFileReads };
@@ -1,16 +1,23 @@
1
1
  import { InputTracking } from './types/input-tracking.js';
2
2
  import { trackEnvironment } from './track-environment.js';
3
3
  /**
4
- * Starts recording what the code of a test process or worker reads: the project
5
- * files and directories read through `node:fs`, those it changed itself, and
6
- * the environment variables, apart from those the test runner reads on its
7
- * own.
4
+ * Starts recording what the code of a test process or worker reads: the files
5
+ * and directories read through `node:fs` that count as inputs, inside the
6
+ * project root or outside it (`createInputFilter`), those of them it changed
7
+ * itself, and the environment variables, apart from those the test runner reads
8
+ * on its own.
8
9
  *
9
- * @param root - Project root; only files in it, outside `node_modules`, count.
10
+ * @param places - Project root and work directory of the run, which decide what
11
+ * counts.
12
+ * @param places.directory - Work directory of the run.
13
+ * @param places.root - Project root.
10
14
  * @param environment - Variables the test runner reads on its own and the
11
15
  * holder of its `metaEnv`, if any, as `trackEnvironment` takes them; passed
12
16
  * to both of its calls.
13
17
  * @returns The files read so far, `process.env` as Node made it, and the
14
18
  * function that stops recording and returns what was read.
15
19
  */
16
- export declare function trackInputs(root: string, environment: Parameters<typeof trackEnvironment>[0]): InputTracking;
20
+ export declare function trackInputs(places: {
21
+ directory: string;
22
+ root: string;
23
+ }, environment: Parameters<typeof trackEnvironment>[0]): InputTracking;
@@ -1,16 +1,16 @@
1
- import { trackEnvironment as e } from "./track-environment.js";
2
- import { trackFileInputs as t } from "./track-file-inputs.js";
3
- import n from "node:path";
1
+ import { createInputFilter as e } from "./create-input-filter.js";
2
+ import { trackEnvironment as t } from "./track-environment.js";
3
+ import { trackFileInputs as n } from "./track-file-inputs.js";
4
4
  function r(r, i) {
5
- let a = /* @__PURE__ */ new Set(), o = t((e) => (e === r || e.startsWith(r + n.sep)) && !e.includes(`${n.sep}node_modules${n.sep}`)), s = e(i, (e) => {
5
+ let a = /* @__PURE__ */ new Set(), o = n(e(r)), s = t(i, (e) => {
6
6
  a.add(e);
7
7
  });
8
8
  return {
9
9
  stop: () => {
10
- let { modified: t, files: n } = o.stop();
11
- return e(i, null), {
10
+ let { modified: e, files: n } = o.stop();
11
+ return t(i, null), {
12
12
  environment: [...a].toSorted(),
13
- modified: t,
13
+ modified: e,
14
14
  files: n
15
15
  };
16
16
  },
@@ -11,6 +11,12 @@ export interface FileInputTracking {
11
11
  */
12
12
  stop(): { modified: string[]; files: string[] }
13
13
 
14
+ /**
15
+ * Tells whether the code wrote a path itself, by the path it gave or by the
16
+ * real path of its directory, also after `stop`.
17
+ */
18
+ owns(file: string): boolean
19
+
14
20
  /**
15
21
  * Files and directories read so far, a missing one included, that the filter
16
22
  * accepted and the code had not written before; the set stays live until
@@ -13,9 +13,9 @@ export interface InputTracking {
13
13
  stop(): { environment: string[]; modified: string[]; files: string[] }
14
14
 
15
15
  /**
16
- * Project files and directories read so far through `node:fs`, a missing one
17
- * included, that the code had not written before; the set stays live until
18
- * `stop`.
16
+ * Files and directories read so far through `node:fs` that count as inputs
17
+ * (`createInputFilter`), a missing one included, that the code had not
18
+ * written before; the set stays live until `stop`.
19
19
  */
20
20
  files: ReadonlySet<string>
21
21
 
@@ -7,9 +7,10 @@ import { TestProject } from 'vitest/node';
7
7
  * dynamic imports that did not run, with all they import: modules that were
8
8
  * never transformed are transformed first, so their imports are known. Each
9
9
  * directory of those files adds the `tsconfig.json` files that may decide how
10
- * Vite transforms it (`listTsconfigFiles`). Virtual modules and files under
11
- * `node_modules`, which the lockfile stands for, are left out; the test file
12
- * itself is always in.
10
+ * Vite transforms it (`listTsconfigFiles`). Virtual modules (`isVirtualModule`)
11
+ * are followed but not listed, so the files plugins watch for them are in;
12
+ * files under `node_modules`, which the lockfile stands for, are left out with
13
+ * what they import. The test file itself is always in.
13
14
  *
14
15
  * @param input - Test file, its project and what its worker reported.
15
16
  * @param input.project - Project the test file ran in.
@@ -1,38 +1,39 @@
1
1
  import { listTsconfigFiles as e } from "../shared/list-tsconfig-files.js";
2
2
  import { compareCodeUnits as t } from "../../core/compare-code-units.js";
3
- import { getModuleFile as n } from "./get-module-file.js";
4
- import r from "node:path";
5
- async function i(i) {
6
- let { reported: a, project: o } = i;
7
- if (a == null) return null;
8
- let s = /* @__PURE__ */ new Set([i.file]);
9
- function c(e) {
10
- let t = n(e);
11
- return t !== null && (s.add(t), !0);
3
+ import { isVirtualModule as n } from "./is-virtual-module.js";
4
+ import { getModuleFile as r } from "./get-module-file.js";
5
+ import i from "node:path";
6
+ async function a(a) {
7
+ let { reported: o, project: s } = a;
8
+ if (o == null) return null;
9
+ let c = /* @__PURE__ */ new Set([a.file]);
10
+ function l(e) {
11
+ let t = r(e);
12
+ return t === null ? n(e) : (c.add(t), !0);
12
13
  }
13
- let l = Object.values(o.vite.environments), u = /* @__PURE__ */ new Set();
14
- async function d(e, t) {
14
+ let u = Object.values(s.vite.environments), d = /* @__PURE__ */ new Set();
15
+ async function f(e, t) {
15
16
  if (e.transformResult === null) try {
16
17
  await t.transformRequest(e.url);
17
18
  } catch {}
18
- let n = [...e.importedModules].filter((e) => !u.has(e) && c(e.file ?? e.id ?? ""));
19
- for (let e of n) u.add(e);
20
- await Promise.all(n.map((e) => d(e, t)));
19
+ let n = [...e.importedModules].filter((e) => !d.has(e) && l(e.file ?? e.id ?? ""));
20
+ for (let e of n) d.add(e);
21
+ await Promise.all(n.map((e) => f(e, t)));
21
22
  }
22
- let f = [];
23
- for (let e of a) if (c(e)) for (let t of l) {
23
+ let p = [];
24
+ for (let e of o) if (l(e)) for (let t of u) {
24
25
  let n = t.moduleGraph.getModuleById(e);
25
26
  if (n !== void 0) {
26
- u.has(n) || (u.add(n), f.push(d(n, t)));
27
+ d.has(n) || (d.add(n), p.push(f(n, t)));
27
28
  break;
28
29
  }
29
30
  }
30
- await Promise.all(f);
31
- let p = new Set([...s].map(r.dirname));
32
- for (let t of p) {
33
- let n = e(t, i.tsconfigs);
34
- for (let e of n) s.add(e);
31
+ await Promise.all(p);
32
+ let m = new Set([...c].map(i.dirname));
33
+ for (let t of m) {
34
+ let n = e(t, a.tsconfigs);
35
+ for (let e of n) c.add(e);
35
36
  }
36
- return [...s].toSorted(t);
37
+ return [...c].toSorted(t);
37
38
  }
38
- export { i as collectDependencies };
39
+ export { a as collectDependencies };
@@ -23,7 +23,7 @@ function c(e, r) {
23
23
  };
24
24
  }
25
25
  function l(t, n) {
26
- let { config: r } = t;
26
+ let { config: r } = t, i = t.vitest.state.onUnhandledError;
27
27
  return {
28
28
  values: a([
29
29
  t.vite.config.define ?? null,
@@ -38,6 +38,8 @@ function l(t, n) {
38
38
  hooks: r.sequence.hooks
39
39
  },
40
40
  variables: Object.entries(n).filter(([t]) => e.test(t)),
41
+ dangerouslyIgnoreUnhandledErrors: t.globalConfig.dangerouslyIgnoreUnhandledErrors,
42
+ onUnhandledError: i ? String(i) : null,
41
43
  environmentOptions: r.environmentOptions,
42
44
  update: r.snapshotOptions.updateSnapshot,
43
45
  maxConcurrency: r.maxConcurrency,
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Tells whether a Vite module id names a virtual module, which a plugin makes
3
+ * up instead of loading a file, such as `\0virtual:limits` or `virtual:limits`:
4
+ * an id that, without its query or hash, is neither empty, nor an absolute
5
+ * path, nor a Node built-in, nor under `node_modules`, which the lockfile
6
+ * stands for.
7
+ *
8
+ * @param id - Module id, as a worker reports it or Vite's module graph has it.
9
+ * @returns Whether the id names a virtual module.
10
+ */
11
+ export declare function isVirtualModule(id: string): boolean;
@@ -0,0 +1,8 @@
1
+ import { isBuiltin as e } from "node:module";
2
+ import t from "node:path";
3
+ const n = /[#?].*$/u;
4
+ function r(r) {
5
+ let i = r.replace(n, "");
6
+ return i !== "" && !t.isAbsolute(i) && !e(i) && !i.includes("/node_modules/");
7
+ }
8
+ export { r as isVirtualModule };
@@ -1,9 +1,14 @@
1
+ import { Vitest } from 'vitest/node';
2
+ import { StrayDecisions } from './types/stray-decisions.js';
1
3
  import { VitestOutRecord } from './types/vitest-worker.js';
2
4
  /**
3
- * Reads the records workers wrote in a run (`readOutFile`).
5
+ * Reads the records workers wrote in a run (`readOutRecords`).
4
6
  *
7
+ * @param vitest - Vitest instance of the session.
5
8
  * @param directory - Work directory of the session.
9
+ * @param decisions - Decisions of the unhandled errors of the run, which
10
+ * receives the new ones.
6
11
  * @returns Records of each out file in the order they were written, by file
7
12
  * name without the extension (`<hash>-<n>`).
8
13
  */
9
- export declare function readOutFiles(directory: string): Map<string, VitestOutRecord[]>;
14
+ export declare function readOutFiles(vitest: Vitest, directory: string, decisions: StrayDecisions): Map<string, VitestOutRecord[]>;
@@ -1,9 +1,9 @@
1
- import { readOutFile as e } from "../shared/read-out-file.js";
1
+ import { readOutRecords as e } from "./read-out-records.js";
2
2
  import { readdirSync as t } from "node:fs";
3
3
  import n from "node:path";
4
- function r(r) {
5
- let i = n.join(r, "out"), a = /* @__PURE__ */ new Map();
6
- for (let r of t(i).toSorted()) a.set(n.basename(r, ".jsonl"), e(n.join(i, r)));
7
- return a;
4
+ function r(r, i, a) {
5
+ let o = n.join(i, "out"), s = /* @__PURE__ */ new Map();
6
+ for (let i of t(o).toSorted()) s.set(n.basename(i, ".jsonl"), e(r, n.join(o, i), a));
7
+ return s;
8
8
  }
9
9
  export { r as readOutFiles };
@@ -0,0 +1,17 @@
1
+ import { Vitest } from 'vitest/node';
2
+ import { VitestOutRecord } from './types/vitest-worker.js';
3
+ import { StrayDecisions } from './types/stray-decisions.js';
4
+ /**
5
+ * Reads the records a worker wrote in one out file (`readOutFile`), with the
6
+ * first lines of only those unhandled errors that count (`readStrays`); a late
7
+ * error that does not count leaves no record. An end record tells whether
8
+ * `onUnhandledError` of the root configuration decided an unhandled error of
9
+ * the file.
10
+ *
11
+ * @param vitest - Vitest instance of the session.
12
+ * @param file - Absolute path of the out file.
13
+ * @param decisions - Decisions of the unhandled errors of the run, which
14
+ * receives those of this file.
15
+ * @returns Records in the order they were written.
16
+ */
17
+ export declare function readOutRecords(vitest: Vitest, file: string, decisions: StrayDecisions): VitestOutRecord[];