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
@@ -1,49 +1,49 @@
1
1
  import { getShortIdLength as e } from "./report/get-short-id-length.js";
2
2
  import { printDiagnostics as t } from "./report/print-diagnostics.js";
3
3
  import { formatRunReport as n } from "./report/format-run-report.js";
4
- import { buildHtmlReport as r } from "./html/build-html-report.js";
5
- import { writeHtmlReport as i } from "./html/write-html-report.js";
6
- import { readProjectName as a } from "./html/read-project-name.js";
7
- import { buildRunReport as o } from "./report/build-run-report.js";
8
- import { createRunProgress as s } from "./create-run-progress.js";
9
- import { getFileScores as c } from "./report/get-file-scores.js";
10
- import { getBuiltInAdapters as l } from "./built-in-adapters.js";
4
+ import { getBuiltInAdapters as r } from "./get-built-in-adapters.js";
5
+ import { buildHtmlReport as i } from "./html/build-html-report.js";
6
+ import { writeHtmlReport as a } from "./html/write-html-report.js";
7
+ import { readProjectName as o } from "./html/read-project-name.js";
8
+ import { buildRunReport as s } from "./report/build-run-report.js";
9
+ import { createRunProgress as c } from "./create-run-progress.js";
10
+ import { getFileScores as l } from "./report/get-file-scores.js";
11
11
  import { getTextStyle as u } from "./terminal/get-text-style.js";
12
12
  import { formatCommand as d } from "./report/format-command.js";
13
13
  import { runMutants as f } from "../core/run-mutants.js";
14
14
  import { version as p } from "../package.js";
15
15
  import m from "node:path";
16
- async function h(r) {
17
- let { verbose: i, json: a, all: p, ...m } = r, h = u(process.stderr), _ = s(h, i);
16
+ async function h(i) {
17
+ let { verbose: a, json: o, all: p, ...m } = i, h = u(process.stderr), _ = c(h, a);
18
18
  try {
19
- let s = await f({
19
+ let c = await f({
20
20
  onProgress: (e) => {
21
21
  _.handle(e);
22
22
  },
23
- builtIns: l(),
23
+ builtIns: r(),
24
24
  ...m,
25
25
  cwd: process.cwd()
26
26
  });
27
27
  _.finish();
28
28
  let v = d("run", {
29
- incremental: r.incremental,
30
- config: r.config,
31
- preset: r.preset,
32
- paths: r.paths,
33
- fast: r.fast
34
- }), y = o(s, {
29
+ incremental: i.incremental,
30
+ config: i.config,
31
+ preset: i.preset,
32
+ paths: i.paths,
33
+ fast: i.fast
34
+ }), y = s(c, {
35
35
  recheck: v,
36
36
  all: p
37
37
  });
38
- a || t(y.diagnostics, h), console.info(n(y, a ? "json" : "text", {
39
- ...!a && process.stdout.isTTY && { files: c(s) },
40
- idLength: e(s.listedIds),
41
- command: d("run", r),
38
+ o || t(y.diagnostics, h), console.info(n(y, o ? "json" : "text", {
39
+ ...!o && process.stdout.isTTY && { files: l(c) },
40
+ idLength: e(c.listedIds),
41
+ command: d("run", i),
42
42
  style: u(process.stdout),
43
- verbose: i,
43
+ verbose: a,
44
44
  recheck: v
45
- })), y.summary.passed || (process.exitCode = 1), s.html !== null && await g(s, s.html, {
46
- command: `${d("run", r)}${r.html ? " --html" : ""}`,
45
+ })), y.summary.passed || (process.exitCode = 1), c.html !== null && await g(c, c.html, {
46
+ command: `${d("run", i)}${i.html ? " --html" : ""}`,
47
47
  style: h,
48
48
  recheck: v
49
49
  });
@@ -53,18 +53,18 @@ async function h(r) {
53
53
  t.trim() !== "" && console.error(`${n.gray("Output of the tests:")}\n${t.replace(/\n$/u, "")}\n`), console.error(`${n.red("Error:")} ${e.message}`), process.exitCode = 1;
54
54
  }
55
55
  }
56
- async function g(t, n, o) {
57
- let { colors: s } = o.style, c = /* @__PURE__ */ new Date();
56
+ async function g(t, n, r) {
57
+ let { colors: s } = r.style, c = /* @__PURE__ */ new Date();
58
58
  try {
59
- let l = r(t, {
59
+ let l = i(t, {
60
60
  idLength: e(t.listedIds),
61
- project: a(t.root),
62
- recheck: o.recheck,
63
- command: o.command,
61
+ project: o(t.root),
62
+ recheck: r.recheck,
63
+ command: r.command,
64
64
  date: c.toISOString(),
65
65
  version: p
66
66
  }), { formatHtmlReport: u } = await import("./html/format-html-report.js");
67
- await i(n, u(l)), console.error(`${s.gray("html report:")} ${m.relative(process.cwd(), n)}`);
67
+ await a(n, u(l)), console.error(`${s.gray("html report:")} ${m.relative(process.cwd(), n)}`);
68
68
  } catch (e) {
69
69
  console.error(`${s.red("Error:")} The HTML report could not be written to ${n}: ${e.message}`), process.exitCode = 1;
70
70
  }
@@ -1,4 +1,4 @@
1
- import { ColorName, Color } from './colors.js';
1
+ import { ColorName, Color } from './create-colors.js';
2
2
  /**
3
3
  * Progress line that the CLI shows on standard error while a command works.
4
4
  */
@@ -1,15 +1,15 @@
1
- import { isUnicodeSupported as e } from "./is-unicode-supported.js";
2
- import { createColors as t, isColorSupported as n } from "./colors.js";
1
+ import { createColors as e, isColorSupported as t } from "./create-colors.js";
2
+ import { isUnicodeSupported as n } from "./is-unicode-supported.js";
3
3
  function r(r) {
4
4
  let { platform: i, argv: a, env: o } = process, s = Infinity;
5
5
  return r.isTTY === !0 && (s = (r.columns ?? 0) > 0 ? r.columns : 80), {
6
- colors: t(n({
6
+ colors: e(t({
7
7
  stdout: r,
8
8
  platform: i,
9
9
  argv: a,
10
10
  env: o
11
11
  })),
12
- unicode: e(),
12
+ unicode: n(),
13
13
  width: s
14
14
  };
15
15
  }
@@ -10,8 +10,8 @@ function r(r) {
10
10
  3,
11
11
  n,
12
12
  r.build,
13
- 1,
14
- 1,
13
+ 2,
14
+ 2,
15
15
  r.runner,
16
16
  o,
17
17
  r.settings ?? null,
@@ -2,10 +2,14 @@
2
2
  * Hashes the contents of files, each file once, a few at a time; a directory is
3
3
  * hashed by the names in it, those of directories marked, so adding, removing
4
4
  * or replacing a file with a directory changes it, while a change inside a
5
- * directory in it does not.
5
+ * directory in it does not. A path that is neither a file nor a directory, such
6
+ * as a device, a pipe or a socket, is never read, as reading `/dev/stdin` or a
7
+ * pipe would wait for its writer and `/dev/zero` never ends: its content is
8
+ * unknown, which differs from a missing file.
6
9
  *
7
10
  * @param paths - Absolute paths, duplicates allowed.
8
- * @returns SHA-256 of each file in hex by path, or null for a file that cannot
9
- * be read, such as a missing one.
11
+ * @returns SHA-256 of each file in hex by path, `UNKNOWN_HASH` for a path that
12
+ * is neither a file nor a directory, or null for a file that cannot be read,
13
+ * such as a missing one.
10
14
  */
11
15
  export declare function hashFiles(paths: Iterable<string>): Promise<Map<string, string | null>>;
@@ -1,24 +1,23 @@
1
1
  import { compareCodeUnits as e } from "../compare-code-units.js";
2
- import { runInChunks as t } from "./run-in-chunks.js";
3
- import { createHash as n } from "node:crypto";
4
- import { readFile as r, readdir as i } from "node:fs/promises";
5
- async function a(e) {
6
- let r = /* @__PURE__ */ new Map();
7
- return await t([...new Set(e)], 32, async (e) => {
8
- let t = await o(e);
9
- r.set(e, t === null ? null : n("sha256").update(t).digest("hex"));
10
- }), r;
2
+ import { UNKNOWN_HASH as t } from "./unknown-hash.js";
3
+ import { runInChunks as n } from "./run-in-chunks.js";
4
+ import { createHash as r } from "node:crypto";
5
+ import { readFile as i, readdir as a, stat as o } from "node:fs/promises";
6
+ async function s(e) {
7
+ let t = /* @__PURE__ */ new Map();
8
+ return await n([...new Set(e)], 32, async (e) => {
9
+ t.set(e, await c(e));
10
+ }), t;
11
11
  }
12
- async function o(t) {
12
+ async function c(n) {
13
13
  try {
14
- return await r(t);
15
- } catch (e) {
16
- if (e.code !== "EISDIR") return null;
17
- }
18
- try {
19
- return `directory\0${(await i(t, { withFileTypes: !0 })).map((e) => e.isDirectory() ? `${e.name}/` : e.name).toSorted(e).join("\0")}`;
14
+ let s = await o(n);
15
+ if (s.isFile()) return r("sha256").update(await i(n)).digest("hex");
16
+ if (!s.isDirectory()) return t;
17
+ let c = (await a(n, { withFileTypes: !0 })).map((e) => e.isDirectory() ? `${e.name}/` : e.name).toSorted(e);
18
+ return r("sha256").update(`directory\0${c.join("\0")}`).digest("hex");
20
19
  } catch {
21
20
  return null;
22
21
  }
23
22
  }
24
- export { a as hashFiles };
23
+ export { s as hashFiles };
@@ -4,6 +4,7 @@ import { DryRunResult } from '../../types/adapter/dry-run-result.js';
4
4
  import { TestAdapter } from '../../types/adapter/test-adapter.js';
5
5
  import { FileMutants } from '../../types/mutant/file-mutants.js';
6
6
  import { StoredCache } from '../../types/cache/stored-cache.js';
7
+ import { Diagnostic } from '../../types/mutant/diagnostic.js';
7
8
  import { DryAnalysis } from '../../types/run/dry-analysis.js';
8
9
  import { LimitSettings } from '../../types/run/run-state.js';
9
10
  import { RunCache } from '../../types/cache/run-cache.js';
@@ -67,6 +68,20 @@ interface PrepareInput {
67
68
  */
68
69
  now: number;
69
70
  }
71
+ /**
72
+ * Cache of a run, or what left the run without one.
73
+ */
74
+ interface PreparedCache {
75
+ /**
76
+ * A `cache-skipped` warning that names a file which changed during the run or
77
+ * has unknown content, or null.
78
+ */
79
+ warning: Diagnostic | null;
80
+ /**
81
+ * Cache of the run, or null.
82
+ */
83
+ cache: RunCache | null;
84
+ }
70
85
  /**
71
86
  * Prepares the cache of a run after its dry run: asks the adapter what every
72
87
  * verdict depends on, hashes those files together with the `.env` files, the
@@ -78,15 +93,22 @@ interface PrepareInput {
78
93
  * for the incremental keys. Files modified since the run started may have
79
94
  * changed after the test runner read them, so their hash may not be what
80
95
  * verdicts came from: a test file that depends on one gets no key, and no test
81
- * file gets one when a file of the environment changed. Dependencies the test
82
- * code of the dry run changed itself (`DryFile.modified`) are hashed as they
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
83
100
  * are now, which is what the next run starts from; `saveRunCache` checks that
84
- * their contents stayed so.
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.
85
105
  *
86
106
  * @param input - Session, dry run, settings and the stored entries.
87
- * @returns Cache of the run, or null when the adapter cannot tell what verdicts
88
- * depend on, a file of the environment changed during the run, or no test
89
- * file has a key.
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.
90
112
  */
91
- export declare function prepareRunCache(input: PrepareInput): Promise<RunCache | null>;
113
+ export declare function prepareRunCache(input: PrepareInput): Promise<PreparedCache>;
92
114
  export {};
@@ -1,71 +1,105 @@
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 { findChangedFiles as n } from "./find-changed-files.js";
4
- import { getTestFileKeys as r } from "./get-test-file-keys.js";
5
- import { createRunCache as i } from "./create-run-cache.js";
6
- import { findLockfile as a } from "./find-lockfile.js";
7
- import { hashFiles as o } from "./hash-files.js";
8
- import s from "node:path";
9
- import { createHash as c } from "node:crypto";
10
- import { readdir as l, stat as u } from "node:fs/promises";
11
- async function d(d) {
12
- let { session: f, setup: p, root: m, dry: h } = d;
13
- if (f.cacheInputs === void 0) return null;
14
- let g = await f.cacheInputs(), _ = a(m), v = [
15
- ...g.files,
16
- ..._ === null ? [] : [_],
17
- s.join(m, "package.json"),
18
- ...(await l(m)).filter((e) => /^(?:\.env|(?:jsconfig|tsconfig).*\.json$)/u.test(e)).map((e) => s.join(m, e))
19
- ], y = new Map(h.files.flatMap((t) => Array.isArray(t.dependencies) ? [[e(t), [t.file, ...t.dependencies]]] : [])), b = [...v, ...[...y.values()].flat()], x = new Set(h.files.flatMap((e) => e.modified ?? [])), S = await n(b, d.started);
20
- if (v.some((e) => S.has(e))) return null;
21
- for (let e of x) S.delete(e);
22
- let C = await d.stored, w = await o([...b, ...[...C.inputs.values()].flatMap((e) => e.files.map(([e]) => s.resolve(m, e)))]), T = g.environment ?? {}, E = t({
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";
8
+ 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 {
16
+ warning: null,
17
+ cache: null
18
+ };
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";
29
+ }
30
+ function D(e) {
31
+ let t = n(e, h), r = t === "" ? "the root of the project" : t;
32
+ return {
33
+ 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.`,
35
+ code: "cache-skipped",
36
+ severity: "warning",
37
+ column: null,
38
+ file: null,
39
+ line: null
40
+ },
41
+ cache: null
42
+ };
43
+ }
44
+ let O = y.find((e) => E(e));
45
+ if (O !== void 0) return D(O);
46
+ let k = _.environment ?? {}, A = t({
23
47
  mutators: {
24
- mutators: p.mutators.map((e) => [e.id, e.options]),
25
- settings: p.settings,
26
- preset: p.preset
48
+ mutators: m.mutators.map((e) => [e.id, e.options]),
49
+ settings: m.settings,
50
+ preset: m.preset
27
51
  },
28
52
  runner: {
29
- version: d.adapter.version ?? null,
30
- runner: f.version ?? null,
31
- adapter: d.adapter.name
53
+ version: f.adapter.version ?? null,
54
+ runner: p.version ?? null,
55
+ adapter: f.adapter.name
32
56
  },
33
- build: (await u(import.meta.filename)).mtimeMs,
34
- settings: g.settings,
35
- limits: d.limits,
36
- hashes: w,
37
- files: v,
38
- root: m
39
- }), D = h.files.filter((t) => (y.get(e(t)) ?? []).every((e) => !S.has(e))), O = r({
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({
40
64
  mutated: /* @__PURE__ */ new Set(),
41
- files: D,
42
- environment: E,
43
- variables: T,
44
- hashes: w,
45
- root: m
46
- });
47
- return O.size === 0 ? null : i({
48
- sources: new Map(d.files.flatMap((e) => e.source === null ? [] : [[e.file, c("sha256").update(e.source).digest("hex")]])),
49
- outsideKeys: r({
50
- mutated: new Set(d.files.map((e) => e.absolute)),
51
- files: D,
52
- environment: E,
53
- variables: T,
54
- hashes: w,
55
- root: m
56
- }),
57
- reads: new Map(h.files.map((t) => [e(t), t.environment ?? []])),
58
- dependencies: new Map([...y].filter(([e]) => O.has(e))),
59
- regions: new Map(d.files.flatMap((e) => [...e.regions ?? []])),
60
- incremental: d.incremental,
61
- analysis: d.analysis,
62
- environment: v,
63
- now: d.now,
64
- variables: T,
65
- fileKeys: O,
66
- stored: C,
67
- hashes: w,
68
- root: m
65
+ files: j,
66
+ environment: A,
67
+ variables: k,
68
+ hashes: T,
69
+ root: h
69
70
  });
71
+ if (M.size === 0) {
72
+ let e = [...b.values()].flat().find((e) => E(e));
73
+ return e === void 0 ? {
74
+ warning: null,
75
+ cache: null
76
+ } : D(e);
77
+ }
78
+ return {
79
+ 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
89
+ }),
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
102
+ })
103
+ };
70
104
  }
71
- export { d as prepareRunCache };
105
+ export { f as prepareRunCache };
@@ -5,13 +5,14 @@ import { RunCache } from '../../types/cache/run-cache.js';
5
5
  * diagnostics or a file of the environment changed while it went on; evidence
6
6
  * from a test file whose dependencies changed while the run went on is left
7
7
  * out, since it may come from the old texts, and so is evidence whose run read
8
- * a file beyond them that changed. A file modified during the run that was
9
- * hashed for the keys counts as changed only when its content differs now, so
10
- * tests that write back what they read, or add and remove files of a directory
11
- * they list, keep their evidence; a file beyond the dependencies modified
12
- * during the run has no earlier hash and counts as changed. The files evidence
13
- * read beyond the dependencies of its test file are hashed now, and evidence
14
- * that shares such inputs names one stored copy of them.
8
+ * a file beyond them that changed or whose content is unknown, such as a device
9
+ * or a pipe (`UNKNOWN_HASH`). A file modified during the run that was hashed
10
+ * for the keys counts as changed only when its content differs now, so tests
11
+ * that write back what they read, or add and remove files of a directory they
12
+ * list, keep their evidence; a file beyond the dependencies modified during the
13
+ * run has no earlier hash and counts as changed. The files evidence read beyond
14
+ * the dependencies of its test file are hashed now, and evidence that shares
15
+ * such inputs names one stored copy of them.
15
16
  *
16
17
  * @param input - Cache of the run, where to save it and what happened.
17
18
  * @param input.cache - Lookups, entries and watched files of the run.
@@ -3,6 +3,7 @@ import { findChangedFiles as t } from "./find-changed-files.js";
3
3
  import { getPortablePath as n } from "./get-portable-path.js";
4
4
  import { writeRunCache as r } from "./write-run-cache.js";
5
5
  import { createDigest as i } from "./create-digest.js";
6
+ import "./unknown-hash.js";
6
7
  import { hashFiles as a } from "./hash-files.js";
7
8
  async function o(o) {
8
9
  let { started: s, cache: c, file: l, root: u } = o;
@@ -28,7 +29,7 @@ async function o(o) {
28
29
  for (let [e, t] of c.dependencies) t.some((e) => p.has(e)) && c.forget(e);
29
30
  let g = await a(f), _ = new Map(c.inputs);
30
31
  for (let [e, t] of c.pending) {
31
- if (t.files.some((e) => p.has(e))) {
32
+ if (t.files.some((e) => p.has(e) || g.get(e) === "unknown")) {
32
33
  c.entries.delete(e);
33
34
  continue;
34
35
  }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Hash of a path that is neither a file nor a directory, such as a device, a
3
+ * pipe or a socket, whose content cannot be read without waiting for it to end.
4
+ * It differs from every hash and from the null of a missing file, and a verdict
5
+ * that depends on such a path is neither reused nor stored.
6
+ */
7
+ export declare const UNKNOWN_HASH = "unknown";
@@ -0,0 +1,2 @@
1
+ const e = "unknown";
2
+ export { e as UNKNOWN_HASH };
@@ -3,13 +3,18 @@ import { ChangedLines } from '../../types/git/changed-lines.js';
3
3
  /**
4
4
  * Keeps the mutants on changed lines, for `--since`: only the files that
5
5
  * changed, with their diagnostics, and in them the mutants and skipped
6
- * candidates whose lines, from the first to the last, include a changed one.
7
- * Every mutant of a file git does not track is kept. Lines are counted as git
8
- * counts them, by line feeds only, so a lone carriage return or a line
6
+ * candidates whose lines, from the first to the last, include a changed one. A
7
+ * skipped candidate kept this way also keeps the mutants it is left to, on
8
+ * whatever line (see `findJustifiers`), so that a change skipped in favor of a
9
+ * mutant on an unchanged line is still tested, as a run of every mutant tests
10
+ * it. Every mutant of a file git does not track is kept. Lines are counted as
11
+ * git counts them, by line feeds only, so a lone carriage return or a line
9
12
  * separator in a string does not shift them.
10
13
  *
11
- * @param files - Listed files.
14
+ * @param files - Listed files with their skipped candidates.
12
15
  * @param changed - Changed lines by real absolute path.
13
- * @returns The changed files with their mutants on changed lines.
16
+ * @param skipped - Whether the skipped candidates are listed; when not, they
17
+ * only select the mutants they are left to and are dropped.
18
+ * @returns The changed files with the mutants and skipped candidates kept.
14
19
  */
15
- export declare function selectChangedMutants(files: FileMutants[], changed: ChangedLines['files']): FileMutants[];
20
+ export declare function selectChangedMutants(files: FileMutants[], changed: ChangedLines['files'], skipped: boolean): FileMutants[];
@@ -1,22 +1,47 @@
1
1
  import { getSourcePosition as e } from "../text/get-source-position.js";
2
- function t(t, n) {
2
+ import { getMutantSite as t } from "../generate/get-mutant-site.js";
3
+ function n(t, n, i) {
3
4
  return t.flatMap((t) => {
4
- let r = n.get(t.absolute);
5
- if (r === void 0) return [];
6
- let { source: i } = t;
7
- if (r === "all" || i === null) return [t];
8
- let a = r, o = [0];
9
- for (let e = i.indexOf("\n"); e !== -1; e = i.indexOf("\n", e + 1)) o.push(e + 1);
10
- function s(t) {
11
- let n = e(o, t.start).line, r = e(o, t.end).line;
12
- for (let e = n; e <= r; e++) if (a.has(e)) return !0;
5
+ let a = n.get(t.absolute);
6
+ if (a === void 0) return [];
7
+ let { source: o } = t;
8
+ if (a === "all" || o === null) return [i ? t : {
9
+ ...t,
10
+ skipped: []
11
+ }];
12
+ let s = a, c = [0];
13
+ for (let e = o.indexOf("\n"); e !== -1; e = o.indexOf("\n", e + 1)) c.push(e + 1);
14
+ function l(t) {
15
+ let n = e(c, t.start).line, r = e(c, t.end).line;
16
+ for (let e = n; e <= r; e++) if (s.has(e)) return !0;
13
17
  return !1;
14
18
  }
19
+ let u = t.skipped.filter(l), d = r(t, u);
15
20
  return [{
16
21
  ...t,
17
- mutants: t.mutants.filter(s),
18
- skipped: t.skipped.filter(s)
22
+ mutants: t.mutants.filter((e) => l(e) || d.has(e)),
23
+ skipped: i ? u : []
19
24
  }];
20
25
  });
21
26
  }
22
- export { t as selectChangedMutants };
27
+ function r(e, n) {
28
+ let r = new Map(e.mutants.map((e) => [e.id, e])), a = /* @__PURE__ */ new Map();
29
+ for (let n of [...e.mutants, ...e.skipped]) {
30
+ let e = i(n.mutator, t(n));
31
+ a.set(e, [...a.get(e) ?? [], n]);
32
+ }
33
+ let o = /* @__PURE__ */ new Set(), s = new Set(n), c = [...n];
34
+ for (; c.length > 0;) {
35
+ let { by: e } = c.pop();
36
+ if (e !== null && e.id !== null) o.add(r.get(e.id));
37
+ else if (e !== null) {
38
+ let t = a.get(i(e.mutator, e.start));
39
+ if (t) for (let e of t) "id" in e ? o.add(e) : s.has(e) || (s.add(e), c.push(e));
40
+ }
41
+ }
42
+ return o;
43
+ }
44
+ function i(e, t) {
45
+ return `${t} ${e}`;
46
+ }
47
+ export { n as selectChangedMutants };
@@ -16,11 +16,14 @@ interface SolitaryOutcome {
16
16
  /**
17
17
  * Drops coarse candidates, such as a removed statement, when a finer candidate
18
18
  * lies inside one of their solitary ranges: a test that kills the finer mutant
19
- * must observe the effect the coarse mutant erases. A finer candidate counts
20
- * unless its mutator opts out with `countsForSolitary: false`, it is a variant
21
- * of the same mutator on the same range, it was dropped itself, or it is
22
- * ignored while the coarse candidate will run. Coarse candidates are decided
23
- * innermost first.
19
+ * is likely to observe the effect the coarse mutant erases. A finer candidate
20
+ * counts unless its mutator opts out with `countsForSolitary: false`, it is a
21
+ * variant of the same mutator on the same range, it is the empty string that
22
+ * string-literal writes over a whole element that array-element removes (see
23
+ * `isEmptiedElement`), it was dropped itself, or it is ignored while the coarse
24
+ * candidate will run. Candidates are placed, ordered and told apart by their
25
+ * targets (see `getTarget`), so the removal of an element lies where its whole
26
+ * literal does. Coarse candidates are decided innermost first.
24
27
  *
25
28
  * @param candidates - Candidates of one file in canonical order.
26
29
  * @returns The candidates that are kept, in canonical order, and the dropped