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
@@ -11,138 +11,173 @@ async function o(e, t) {
11
11
  let n = /* @__PURE__ */ new Map(), r = [];
12
12
  if (t.switched.length === 0) return {
13
13
  unrepeatableFiles: /* @__PURE__ */ new Set(),
14
- dry: v(),
14
+ dry: S(),
15
15
  diagnostics: r,
16
16
  runs: 0,
17
17
  errors: n
18
18
  };
19
- let i = t.switched.map((e) => e.file);
20
19
  t.report({
21
- files: i.length,
20
+ files: t.switched.length,
22
21
  kind: "dry-start"
23
22
  });
24
- let a = await s(e, i, t), o = [a.dry], u = _(a.dry);
25
- if (u.failing.length > 0 || u.unloaded.length > 0) {
26
- let s = await c(e, t, {
23
+ let i = await s(e, t, {
24
+ related: t.related,
25
+ diagnostics: r
26
+ }), a = [i.dry], o = b(i.dry);
27
+ if (o.failing.length > 0 || o.unloaded.length > 0) {
28
+ let s = await l(e, t, {
29
+ files: i.dry.files,
30
+ tests: i.dry.tests,
27
31
  diagnostics: r,
28
- failures: u,
29
- related: i,
32
+ failures: o,
30
33
  errors: n
31
34
  });
32
- o.push(s.dry), a = {
35
+ a.push(s.dry), i = {
33
36
  ...s,
34
- runs: a.runs + s.runs
37
+ runs: i.runs + s.runs
35
38
  };
36
39
  }
37
- return l(t, {
38
- instrumented: o,
40
+ return d(t, {
41
+ instrumented: a,
39
42
  diagnostics: r,
40
43
  errors: n
41
44
  }), {
42
- ...a,
45
+ ...i,
43
46
  diagnostics: r,
44
47
  errors: n
45
48
  };
46
49
  }
47
50
  async function s(t, r, a) {
48
- let o = await f(t, {
49
- repeat: a.repeat,
51
+ let { diagnostics: o, related: s } = a, c = await p(t, {
52
+ repeat: r.repeat,
50
53
  instrumented: !0,
51
54
  files: null,
52
- related: r
53
- }, a.root), { unloaded: s, failing: c } = _(o);
54
- if (!a.repeat || c.length === 0 && s.length === 0) return {
55
+ related: s
56
+ }, r.root), { unloaded: l, failing: u } = b(c);
57
+ if (u.length === 0 && l.length === 0) return {
55
58
  unrepeatableFiles: /* @__PURE__ */ new Set(),
56
59
  runs: 1,
57
- dry: o
60
+ dry: c
58
61
  };
59
- let l = h([...c, ...s]);
60
- a.report({
61
- message: `${i(l.length, "test file")} failed with each test run twice; running them again with each test once.`,
62
+ let d = v([...u, ...l]), f = d.length === 1 ? "it" : "them";
63
+ r.report({
64
+ message: r.repeat ? `${i(d.length, "test file")} failed with each test run twice; running ${f} again with each test once.` : `${i(d.length, "test file")} failed; running ${f} again to see whether the failures repeat.`,
62
65
  kind: "dry-again"
63
66
  });
64
- let u = await f(t, {
67
+ let h = await p(t, {
65
68
  instrumented: !0,
66
69
  repeat: !1,
67
- related: r,
68
- files: l
69
- }, a.root), d = new Set(l.map((e) => n(e))), { unloaded: p, failing: m } = _(u), g = new Set([...m, ...p].map((e) => n(e)));
70
- function v(e) {
71
- return d.has(n(e));
70
+ related: s,
71
+ files: d
72
+ }, r.root), g = new Set(d.map((e) => n(e))), { unloaded: _, failing: y } = b(h), x = new Set([...y, ..._].map((e) => n(e))), S = new Set([...g].filter((e) => !x.has(e)));
73
+ if (!r.repeat) {
74
+ let e = [...l, ...u].filter((e) => S.has(n(e))).map((e) => m(e, r.root));
75
+ for (let t of e) o.some((e) => e.message === t.message && e.file === t.file && e.line === t.line) || o.push(t);
76
+ }
77
+ function w(e) {
78
+ return g.has(n(e));
72
79
  }
73
80
  return {
74
81
  dry: {
75
- tests: [...o.tests.filter((e) => !v(e)), ...u.tests].toSorted(e),
76
- files: [...o.files.filter((e) => !v(e)), ...u.files].toSorted(e),
77
- mismatched: y(o.mismatched, u.mismatched),
78
- outside: y(o.outside, u.outside),
79
- served: y(o.served, u.served),
80
- ...(o.unserved ?? u.unserved) !== void 0 && { unserved: [...o.unserved ?? [], ...u.unserved ?? []] },
82
+ tests: [...c.tests.filter((e) => !w(e)), ...h.tests].toSorted(e),
83
+ files: [...c.files.filter((e) => !w(e)), ...h.files].toSorted(e),
84
+ mismatched: C(c.mismatched, h.mismatched),
85
+ outside: C(c.outside, h.outside),
86
+ served: C(c.served, h.served),
87
+ ...(c.unserved ?? h.unserved) !== void 0 && { unserved: [...c.unserved ?? [], ...h.unserved ?? []] },
81
88
  hung: []
82
89
  },
83
- unrepeatableFiles: new Set([...d].filter((e) => !g.has(e))),
90
+ unrepeatableFiles: r.repeat ? S : /* @__PURE__ */ new Set(),
84
91
  runs: 2
85
92
  };
86
93
  }
87
- async function c(e, t, n) {
94
+ function c(e, t) {
95
+ let { failures: r, files: i } = t, a = e.switched.map((e) => e.file), o = new Set(a), s = new Map(i.map((e) => [n(e), (e.dependencies ?? []).filter((e) => o.has(e))])), c = /* @__PURE__ */ new Map();
96
+ function l(e, t, n) {
97
+ for (let r of n) c.has(r) || c.set(r, {
98
+ failure: e,
99
+ link: t
100
+ });
101
+ }
102
+ for (let t of r.unloaded) {
103
+ let r = t.covers.map((t) => e.mutantFiles.get(t)), i = s.get(n(t));
104
+ i.length > 0 ? l(t, "dependency", [...r, ...i]) : l(t, "sites", r);
105
+ }
106
+ for (let t of r.failing) {
107
+ let r = (t.tries[0].covers ?? []).map((t) => e.mutantFiles.get(t));
108
+ r.length > 0 ? l(t, "sites", r) : l(t, "dependency", s.get(n(t)) ?? []);
109
+ }
110
+ if (c.size === 0) {
111
+ let [e] = [...r.unloaded, ...r.failing];
112
+ return new Map(a.map((t) => [t, {
113
+ failure: e,
114
+ link: "unknown"
115
+ }]));
116
+ }
117
+ return new Map(a.filter((e) => c.has(e)).map((e) => [e, c.get(e)]));
118
+ }
119
+ async function l(e, t, n) {
88
120
  await u(e, t, n);
89
- let r = p(t, n.failures, n.related);
90
- for (let e of r) {
91
- let r = t.displays.get(e), i = `Tests fail with the switched ${r} and pass without it; its mutants are not run.`;
92
- n.errors.set(r, i), n.diagnostics.push(m("instrumentation-break", r, i));
121
+ let r = c(t, n);
122
+ for (let [e, i] of r) {
123
+ let r = t.displays.get(e), a = h(i, r, t.root);
124
+ n.errors.set(r, a), n.diagnostics.push(g("instrumentation-break", r, a));
93
125
  }
94
126
  let a = t.switched.filter((e) => !r.has(e.file));
95
127
  if (t.switched.splice(0, t.switched.length, ...a), a.length === 0) return {
96
128
  unrepeatableFiles: /* @__PURE__ */ new Set(),
97
- dry: v(),
129
+ dry: S(),
98
130
  runs: 1
99
131
  };
100
132
  t.report({
101
133
  message: `Running the dry run again without ${i(r.size, "file")} that broke tests.`,
102
134
  kind: "dry-again"
103
135
  });
104
- let o = await s(e, a.map((e) => e.file), t), c = _(o.dry);
105
- if (c.failing.length > 0 || c.unloaded.length > 0) throw g(t, [...c.failing, ...c.unloaded]), Error(d("Tests still fail with mootant's switched files after the files that broke them were dropped", {
106
- files: c.unloaded,
107
- tests: c.failing
136
+ let o = await s(e, t, {
137
+ related: t.related.filter((e) => !r.has(e)),
138
+ diagnostics: n.diagnostics
139
+ }), l = b(o.dry);
140
+ if (l.failing.length > 0 || l.unloaded.length > 0) throw y(t, [...l.failing, ...l.unloaded]), Error(f("Tests still fail with mootant's switched files after the files that broke them were dropped", {
141
+ files: l.unloaded,
142
+ tests: l.failing
108
143
  }, t.root));
109
144
  return {
110
145
  ...o,
111
146
  runs: o.runs + 1
112
147
  };
113
148
  }
114
- function l(e, t) {
115
- let n = new Set(t.instrumented.flatMap((e) => e.mismatched)), r = new Set(t.instrumented.flatMap((e) => e.served)), i = new Map(t.instrumented.flatMap((e) => e.unserved ?? []).map((e) => [e.file, e.reason]));
116
- for (let { file: a } of e.switched) {
117
- let o = e.displays.get(a);
118
- if (n.has(a)) {
119
- let e = `The test runner loaded ${o} with a text that differs from the listed one; its mutants are not run.`;
120
- t.errors.set(o, e), t.diagnostics.push(m("instrument-error", o, e));
121
- } else r.has(a) || t.diagnostics.push(m("never-served", o, `No test loaded ${o} through the test runner's transform: ${i.get(a) ?? "no test imports it, or tests import a built copy, an external or a pre-bundled dependency"}.`));
122
- }
123
- }
124
- async function u(e, t, n) {
125
- let { failures: r, related: i } = n, { unloaded: a, failing: o } = r, s = new Set(o.map((e) => e.id)), c = new Set(a.map((e) => e.file));
149
+ async function u(e, t, r) {
150
+ let { failures: i, tests: a } = r, { unloaded: o, failing: s } = i, c = new Set(s.map((e) => e.id)), l = new Set(a.map((e) => e.id)), u = new Set(o.map((e) => n(e))), d = new Set([...o, ...s].map((e) => n(e)));
126
151
  t.report({
127
152
  message: "Some tests failed; running them again without mutants to check.",
128
153
  kind: "dry-again"
129
154
  });
130
- let l = _(await f(e, {
131
- files: h([...o, ...a]),
155
+ let m = b(await p(e, {
156
+ files: v([...s, ...o]),
157
+ related: t.related,
132
158
  instrumented: !1,
133
- repeat: !1,
134
- related: i
135
- }, t.root)), u = l.failing.filter((e) => s.has(e.id)), p = l.unloaded.filter((e) => c.has(e.file));
136
- if (u.length > 0 || p.length > 0) throw g(t, [...u, ...p]), Error(d("Tests fail without mutants; fix them first", {
137
- files: p,
138
- tests: u
159
+ repeat: !1
160
+ }, t.root)), h = m.failing.filter((e) => c.has(e.id) || !l.has(e.id) && u.has(n(e))), g = m.unloaded.filter((e) => d.has(n(e)));
161
+ if (h.length > 0 || g.length > 0) throw y(t, [...h, ...g]), Error(f("Tests fail without mutants; fix them first", {
162
+ files: g,
163
+ tests: h
139
164
  }, t.root));
140
165
  }
141
- function d(e, t, n) {
166
+ function d(e, t) {
167
+ let n = new Set(t.instrumented.flatMap((e) => e.mismatched)), r = new Set(t.instrumented.flatMap((e) => e.served)), i = new Map(t.instrumented.flatMap((e) => e.unserved ?? []).map((e) => [e.file, e.reason]));
168
+ for (let { file: a } of e.switched) {
169
+ let o = e.displays.get(a);
170
+ if (n.has(a)) {
171
+ let e = `The test runner loaded ${o} with a text that differs from the listed one; its mutants are not run.`;
172
+ t.errors.set(o, e), t.diagnostics.push(g("instrument-error", o, e));
173
+ } else r.has(a) || t.diagnostics.push(g("never-served", o, `No test loaded ${o} through the test runner's transform: ${i.get(a) ?? "no test imports it, or tests import a built copy, an external or a pre-bundled dependency"}.`));
174
+ }
175
+ }
176
+ function f(e, t, n) {
142
177
  let { files: a, tests: o } = t, s = [...a.map((e) => ` ${r(e.file, n)}: fails to load: ${e.errors[0] ?? "unknown error"}`), ...o.map((e) => ` ${r(e.file, n)} > ${e.name}: ${e.tries[0].message ?? "failed"}`)], c = `${e} (${[o.length > 0 && i(o.length, "test"), a.length > 0 && i(a.length, "test file")].filter(Boolean).join(", ")}):\n${s.slice(0, 10).join("\n")}`;
143
178
  return s.length > 10 && (c += `\n and ${s.length - 10} more`), s.some((e) => /snapshot/iu.test(e)) && (c += "\nSnapshots may be missing or obsolete: mootant never writes or removes them, so update them with the test runner first."), c;
144
179
  }
145
- async function f(e, t, n) {
180
+ async function p(e, t, n) {
146
181
  let i = await e.dryRun({
147
182
  ...t,
148
183
  timeouts: a
@@ -153,13 +188,20 @@ async function f(e, t, n) {
153
188
  }
154
189
  return i;
155
190
  }
156
- function p(e, t, n) {
157
- let r = new Set([...t.failing.flatMap((e) => e.tries[0].covers ?? []), ...t.unloaded.flatMap((e) => e.covers)].map((t) => e.mutantFiles.get(t)));
158
- return r.size === 0 ? new Set(n) : r;
191
+ function m(e, t) {
192
+ let n = r(e.file, t);
193
+ return "tries" in e ? {
194
+ ...g("unrepeatable-test", n, `"${e.name}" failed${x(e.tries[0].message)} in a run without mutants and passed when run again; it may be flaky and kill mutants by chance.`),
195
+ line: e.line
196
+ } : g("unrepeatable-test", n, `${n} failed outside its tests${x(e.errors[0])} in a run without mutants and passed when run again; its tests may be flaky and kill mutants by chance.`);
197
+ }
198
+ function h(e, t, n) {
199
+ let r = _(e.failure, n);
200
+ return e.link === "sites" ? `Tests that reach mutant sites of ${t} fail only with mootant's switched files, such as ${r}; its mutants are not run.` : e.link === "dependency" ? `Tests that depend on ${t} fail only with mootant's switched files, such as ${r}; its mutants are not run.` : `Tests fail only with mootant's switched files, such as ${r}, and mootant cannot tell which switched file breaks them; the mutants of every switched file are not run.`;
159
201
  }
160
- function m(e, t, n) {
202
+ function g(e, t, n) {
161
203
  return {
162
- severity: e === "never-served" ? "warning" : "error",
204
+ severity: e === "never-served" || e === "unrepeatable-test" ? "warning" : "error",
163
205
  column: null,
164
206
  line: null,
165
207
  message: n,
@@ -167,7 +209,11 @@ function m(e, t, n) {
167
209
  code: e
168
210
  };
169
211
  }
170
- function h(e) {
212
+ function _(e, t) {
213
+ let n = r(e.file, t);
214
+ return "tries" in e ? `"${e.name}" in ${n}${x(e.tries[0].message)}` : `${n}, which fails outside its tests${x(e.errors[0])}`;
215
+ }
216
+ function v(e) {
171
217
  return [...new Map(e.map(({ project: e, file: t }) => [n({
172
218
  project: e,
173
219
  file: t
@@ -176,19 +222,23 @@ function h(e) {
176
222
  file: t
177
223
  }])).values()];
178
224
  }
179
- function g(e, n) {
225
+ function y(e, n) {
180
226
  e.report({
181
227
  files: [...new Set(n.map(({ file: t }) => r(t, e.root)))].toSorted(t),
182
228
  kind: "dry-failed"
183
229
  });
184
230
  }
185
- function _(e) {
231
+ function b(e) {
186
232
  return {
187
233
  failing: e.tests.filter((e) => e.tries[0].failed),
188
234
  unloaded: e.files.filter((e) => e.loadFailed)
189
235
  };
190
236
  }
191
- function v() {
237
+ function x(e) {
238
+ let t = e?.replace(/\.$/u, "") ?? "";
239
+ return t === "" ? "" : ` (${t})`;
240
+ }
241
+ function S() {
192
242
  return {
193
243
  mismatched: [],
194
244
  outside: [],
@@ -198,7 +248,7 @@ function v() {
198
248
  hung: []
199
249
  };
200
250
  }
201
- function y(e, n) {
251
+ function C(e, n) {
202
252
  return [.../* @__PURE__ */ new Set([...e, ...n])].toSorted(t);
203
253
  }
204
254
  export { o as runDryPhase };
@@ -14,11 +14,12 @@ import { AdapterSession } from '../../types/adapter/adapter-session.js';
14
14
  * confirmation takes no new files until the confirmation decides it. The
15
15
  * verdict comes from the first file with evidence (`decideEvidence`), so it
16
16
  * does not depend on the batches or the workers. A round also runs the retries
17
- * and confirmations of the round before. A request lives at most four rounds,
18
- * as a unit missing twice gets an `Error` verdict and a timeout is confirmed
19
- * once, so the rounds end. While a round runs, its units count in the live
20
- * verdict counts as they end (`previewIsolatedUnit`), and every mutant is
21
- * counted again once its result is recorded (`countVerdicts`).
17
+ * and confirmations of the round before. A request lives at most six rounds, as
18
+ * a unit missing twice gets an `Error` verdict and a timeout is confirmed once,
19
+ * or twice when the confirmation of a timer goes over the hit limit, so the
20
+ * rounds end. While a round runs, its units count in the live verdict counts as
21
+ * they end (`previewIsolatedUnit`), and every mutant is counted again once its
22
+ * result is recorded (`countVerdicts`).
22
23
  *
23
24
  * @param session - Live test runner.
24
25
  * @param state - State of the run, updated in place.
@@ -16,6 +16,7 @@ async function s(o, s, c) {
16
16
  mutant: e.mutant.id,
17
17
  confirming: !1,
18
18
  retried: !1,
19
+ raised: !1,
19
20
  file: n
20
21
  });
21
22
  if (d.length === 0) return null;
@@ -56,7 +56,8 @@ interface RunMutantsOptions {
56
56
  cache?: boolean;
57
57
  /**
58
58
  * Git revision given with `--since`: only mutants on lines changed since its
59
- * merge base with `HEAD` run.
59
+ * merge base with `HEAD` run, and the mutants that skipped candidates on
60
+ * those lines are left to.
60
61
  */
61
62
  since?: string;
62
63
  /**
@@ -77,26 +78,30 @@ interface RunMutantsOptions {
77
78
  }
78
79
  /**
79
80
  * Runs the mutants of the given paths against the project's tests: lists the
80
- * mutants, starts the test runner through its adapter, switches the mutated
81
- * files, checking that switched Svelte and Vue components compile, runs the
82
- * related tests without a mutant, then decides every covered mutant on the
83
- * isolated path, where each mutant gets a fresh module graph and its whole
84
- * covering test files. In fast mode, runtime mutants first take the batch path,
85
- * where one test run tries many mutants and kills are accepted as heuristic
86
- * verdicts; its survivors and doubtful tries still run isolated. An adapter
87
- * without batch mode runs fast mode as the default mode, with a note. Mutants
88
- * the test runner ran outside its workers end with `Error` unless a test killed
89
- * them. Unless the cache is off, valid verdicts of earlier runs are reused
90
- * before anything runs, in incremental mode also those whose mutant kept its
91
- * region, with a warning that counts the mutants whose cached evidence only
92
- * their region matched, and the evidence of the run is saved after it, unless
93
- * it has error diagnostics. With `--since`, only the mutants on lines changed
94
- * since the merge base of the revision and `HEAD` run, and when there are none
95
- * the test runner does not start. A run that writes an HTML report also lists
96
- * the candidates its mutators skipped. The adapter is closed and the work
97
- * directory removed whatever happens; what the adapter tells of its close, such
98
- * as a global teardown that failed, joins the diagnostics of a run that went
99
- * through, after its cache was saved.
81
+ * mutants, starts the test runner through its adapter, hosts the mutants of
82
+ * every file of the paths, checking that switched Svelte and Vue components
83
+ * compile, switches the files of the selected mutants, runs the related tests
84
+ * without a mutant, then decides every covered mutant on the isolated path,
85
+ * where each mutant gets a fresh module graph and its whole covering test
86
+ * files. In fast mode, runtime mutants first take the batch path, where one
87
+ * test run tries many mutants and kills are accepted as heuristic verdicts; its
88
+ * survivors and doubtful tries still run isolated. An adapter without batch
89
+ * mode runs fast mode as the default mode, with a note. Mutants the test runner
90
+ * ran outside its workers end with `Error` unless a test killed them. Unless
91
+ * the cache is off, valid verdicts of earlier runs are reused before anything
92
+ * runs, in incremental mode also those whose mutant kept its region, with a
93
+ * warning that counts the mutants whose cached evidence only their region
94
+ * matched, and the evidence of the run is saved after it, unless it has error
95
+ * diagnostics. With `--since`, only the mutants on lines changed since the
96
+ * merge base of the revision and `HEAD` run, with the mutants that skipped
97
+ * candidates on those lines are left to (see `selectChangedMutants`), and when
98
+ * there are none the test runner does not start. With `--since` or `--mutant`,
99
+ * the dry run still relates tests to the same files as a run of every mutant,
100
+ * not only to the files of the mutants that run. A run that writes an HTML
101
+ * report also lists the candidates its mutators skipped. The adapter is closed
102
+ * and the work directory removed whatever happens; what the adapter tells of
103
+ * its close, such as a global teardown that failed, joins the diagnostics of a
104
+ * run that went through, after its cache was saved.
100
105
  *
101
106
  * @param options - Paths, configuration, adapters and run settings.
102
107
  * @returns Verdicts, diagnostics and timings, before they are formatted.