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.
- package/dist/adapters/jest/build-dry-file.d.ts +12 -12
- package/dist/adapters/jest/collect-jest-dependencies.d.ts +8 -7
- package/dist/adapters/jest/runner.d.ts +1 -1
- package/dist/adapters/jest/runner.js +1 -1
- package/dist/adapters/jest/types/jest-record.d.ts +4 -4
- package/dist/adapters/jest/types/unit-worker.d.ts +16 -8
- package/dist/adapters/jest/types/worker-session.d.ts +6 -7
- package/dist/adapters/jest/worker/boot-worker.d.ts +4 -3
- package/dist/adapters/jest/worker/run-unit.d.ts +20 -18
- package/dist/adapters/jest/worker/vm-setup.js +1 -1
- package/dist/adapters/jest/worker/worker.js +1 -1
- package/dist/adapters/jest/write-worker-session.d.ts +1 -2
- package/dist/adapters/jest/write-worker-session.js +2 -2
- package/dist/adapters/node-test/collect-node-dependencies.d.ts +5 -5
- package/dist/adapters/node-test/preload/preload.js +4 -1
- package/dist/adapters/node-test/run-test-file.js +1 -0
- package/dist/adapters/node-test/types/node-test-record.d.ts +3 -3
- package/dist/adapters/node-test/types/node-test-unit.d.ts +6 -1
- package/dist/adapters/shared/create-input-filter.d.ts +26 -0
- package/dist/adapters/shared/create-input-filter.js +32 -0
- package/dist/adapters/shared/track-file-inputs.d.ts +7 -3
- package/dist/adapters/shared/track-file-inputs.js +16 -7
- package/dist/adapters/shared/track-file-reads.d.ts +12 -8
- package/dist/adapters/shared/track-file-reads.js +110 -57
- package/dist/adapters/shared/track-inputs.d.ts +13 -6
- package/dist/adapters/shared/track-inputs.js +7 -7
- package/dist/adapters/shared/types/file-input-tracking.d.ts +6 -0
- package/dist/adapters/shared/types/input-tracking.d.ts +3 -3
- package/dist/adapters/vitest/collect-dependencies.d.ts +4 -3
- package/dist/adapters/vitest/collect-dependencies.js +25 -24
- package/dist/adapters/vitest/get-cache-inputs.js +3 -1
- package/dist/adapters/vitest/is-virtual-module.d.ts +11 -0
- package/dist/adapters/vitest/is-virtual-module.js +8 -0
- package/dist/adapters/vitest/read-out-files.d.ts +7 -2
- package/dist/adapters/vitest/read-out-files.js +5 -5
- package/dist/adapters/vitest/read-out-records.d.ts +17 -0
- package/dist/adapters/vitest/read-out-records.js +27 -0
- package/dist/adapters/vitest/read-strays.d.ts +20 -0
- package/dist/adapters/vitest/read-strays.js +53 -0
- package/dist/adapters/vitest/read-unit-inputs.d.ts +7 -1
- package/dist/adapters/vitest/read-unit-inputs.js +1 -1
- package/dist/adapters/vitest/run-dry.js +16 -16
- package/dist/adapters/vitest/run-plan.d.ts +3 -1
- package/dist/adapters/vitest/run-plan.js +15 -15
- package/dist/adapters/vitest/run-specifications.d.ts +3 -2
- package/dist/adapters/vitest/runner.d.ts +38 -23
- package/dist/adapters/vitest/runner.js +84 -85
- package/dist/adapters/vitest/types/stray-decisions.d.ts +8 -0
- package/dist/adapters/vitest/types/unit-outcome.d.ts +2 -1
- package/dist/adapters/vitest/types/vitest-worker.d.ts +83 -12
- package/dist/adapters/vitest/worker/encode-stray.d.ts +16 -0
- package/dist/adapters/vitest/worker/encode-stray.js +16 -0
- package/dist/adapters/vitest/worker/intercept-strays.d.ts +26 -0
- package/dist/adapters/vitest/worker/intercept-strays.js +13 -0
- package/dist/adapters/vitest/worker/read-try-facts.d.ts +5 -4
- package/dist/adapters/vitest/worker/write-out-record.d.ts +2 -2
- package/dist/cli/html/build-html-report.js +1 -1
- package/dist/cli/html/client/main.js +1 -1
- package/dist/cli/html/client/render-change.d.ts +3 -2
- package/dist/cli/html/client/render-code.d.ts +1 -1
- package/dist/cli/html/pack-replacement.d.ts +1 -1
- package/dist/cli/parse-arguments.js +1 -1
- package/dist/cli/report/build-list-report.js +1 -1
- package/dist/cli/report/build-run-report.js +1 -1
- package/dist/cli/report/format-file-groups.d.ts +1 -1
- package/dist/cli/run-mutation.js +31 -31
- package/dist/cli/terminal/create-spinner.d.ts +1 -1
- package/dist/cli/terminal/get-text-style.js +4 -4
- package/dist/core/cache/get-environment-key.js +2 -2
- package/dist/core/cache/hash-files.d.ts +7 -3
- package/dist/core/cache/hash-files.js +16 -17
- package/dist/core/cache/prepare-run-cache.d.ts +29 -7
- package/dist/core/cache/prepare-run-cache.js +96 -62
- package/dist/core/cache/save-run-cache.d.ts +8 -7
- package/dist/core/cache/save-run-cache.js +2 -1
- package/dist/core/cache/unknown-hash.d.ts +7 -0
- package/dist/core/cache/unknown-hash.js +2 -0
- package/dist/core/files/select-changed-mutants.d.ts +11 -6
- package/dist/core/files/select-changed-mutants.js +38 -13
- package/dist/core/generate/apply-solitary-rule.d.ts +8 -5
- package/dist/core/generate/apply-solitary-rule.js +36 -29
- package/dist/core/generate/collect-candidates.d.ts +18 -4
- package/dist/core/generate/collect-candidates.js +168 -86
- package/dist/core/generate/compare-targets.d.ts +14 -0
- package/dist/core/generate/compare-targets.js +6 -0
- package/dist/core/generate/deduplicate-candidates.d.ts +6 -4
- package/dist/core/generate/deduplicate-candidates.js +11 -9
- package/dist/core/generate/find-list-removal.d.ts +20 -0
- package/dist/core/generate/find-list-removal.js +26 -0
- package/dist/core/generate/generate-file-mutants.js +47 -46
- package/dist/core/generate/get-mutant-site.d.ts +18 -0
- package/dist/core/generate/get-mutant-site.js +4 -0
- package/dist/core/generate/get-target.d.ts +14 -0
- package/dist/core/generate/get-target.js +4 -0
- package/dist/core/generate/pick-host.d.ts +10 -0
- package/dist/core/generate/pick-host.js +16 -0
- package/dist/core/generate/validate-replacement.d.ts +15 -4
- package/dist/core/generate/validate-replacement.js +28 -13
- package/dist/core/ignore/find-ignore-rule.d.ts +8 -7
- package/dist/core/instrument/find-attribute-values.d.ts +12 -0
- package/dist/core/instrument/find-attribute-values.js +13 -0
- package/dist/core/instrument/get-site-syntax.d.ts +14 -0
- package/dist/core/instrument/get-site-syntax.js +12 -0
- package/dist/core/instrument/group-mutant-ranges.d.ts +7 -3
- package/dist/core/instrument/group-mutant-ranges.js +25 -19
- package/dist/core/instrument/instrument-file.d.ts +5 -3
- package/dist/core/instrument/instrument-file.js +10 -9
- package/dist/core/instrument/instrumenter-version.d.ts +1 -1
- package/dist/core/instrument/render-branch.d.ts +17 -0
- package/dist/core/instrument/render-branch.js +81 -0
- package/dist/core/instrument/render-mutant-range.d.ts +17 -6
- package/dist/core/instrument/render-mutant-range.js +39 -13
- package/dist/core/list-mutants.d.ts +7 -5
- package/dist/core/list-mutants.js +2 -2
- package/dist/core/mutators/array-element.d.ts +7 -6
- package/dist/core/mutators/array-element.js +13 -13
- package/dist/core/mutators/assignment-operator.js +34 -33
- package/dist/core/mutators/boolean-literal.d.ts +3 -2
- package/dist/core/mutators/number-literal.d.ts +1 -1
- package/dist/core/mutators/object-property.d.ts +4 -3
- package/dist/core/mutators/object-property.js +7 -8
- package/dist/core/mutators/return-value.js +65 -33
- package/dist/core/mutators/shared/get-branch-copy-skip.d.ts +12 -7
- package/dist/core/mutators/shared/get-branch-copy-skip.js +34 -35
- package/dist/core/mutators/shared/get-canonical-falsy-default.d.ts +32 -0
- package/dist/core/mutators/shared/get-canonical-falsy-default.js +11 -0
- package/dist/core/mutators/shared/get-comparison-plan.js +86 -85
- package/dist/core/mutators/shared/get-condition-constants.d.ts +8 -8
- package/dist/core/mutators/shared/get-condition-constants.js +3 -3
- package/dist/core/mutators/shared/get-endless-value.d.ts +20 -0
- package/dist/core/mutators/shared/get-endless-value.js +25 -0
- package/dist/core/mutators/shared/get-forced-test-justifier.d.ts +44 -0
- package/dist/core/mutators/shared/get-forced-test-justifier.js +25 -0
- package/dist/core/mutators/shared/get-group-constant.d.ts +4 -4
- package/dist/core/mutators/shared/get-group-constant.js +2 -2
- package/dist/core/mutators/shared/get-literal-skip.d.ts +6 -6
- package/dist/core/mutators/shared/get-literal-skip.js +2 -2
- package/dist/core/mutators/shared/get-logical-drops.d.ts +8 -8
- package/dist/core/mutators/shared/get-logical-drops.js +80 -82
- package/dist/core/mutators/shared/get-owner-constant.d.ts +3 -1
- package/dist/core/mutators/shared/get-running-value.d.ts +5 -4
- package/dist/core/mutators/shared/get-toward-mutant.d.ts +10 -2
- package/dist/core/mutators/shared/get-toward-mutant.js +45 -40
- package/dist/core/mutators/shared/has-other-exit.js +16 -36
- package/dist/core/mutators/shared/is-loop-exit.d.ts +20 -0
- package/dist/core/mutators/shared/is-loop-exit.js +32 -0
- package/dist/core/mutators/shared/is-read-only.d.ts +26 -0
- package/dist/core/mutators/shared/is-read-only.js +53 -0
- package/dist/core/mutators/statement-removal.d.ts +4 -3
- package/dist/core/mutators/statement-removal.js +69 -73
- package/dist/core/mutators/string-literal.d.ts +15 -5
- package/dist/core/mutators/string-literal.js +79 -50
- package/dist/core/presets/recommended.d.ts +2 -2
- package/dist/core/presets/strict.d.ts +4 -2
- package/dist/core/run/apply-batch-result.d.ts +23 -22
- package/dist/core/run/apply-batch-result.js +5 -5
- package/dist/core/run/apply-isolated-result.d.ts +18 -17
- package/dist/core/run/apply-isolated-result.js +1 -0
- package/dist/core/run/classify-try.d.ts +9 -8
- package/dist/core/run/get-test-file-limits.d.ts +13 -0
- package/dist/core/run/get-test-file-limits.js +13 -0
- package/dist/core/run/get-unit-evidence.d.ts +6 -3
- package/dist/core/run/get-unit-evidence.js +1 -1
- package/dist/core/run/plan-batch.d.ts +6 -3
- package/dist/core/run/plan-batch.js +36 -31
- package/dist/core/run/plan-isolated.d.ts +3 -1
- package/dist/core/run/plan-isolated.js +8 -14
- package/dist/core/run/read-isolated-unit.d.ts +4 -4
- package/dist/core/run/run-batch-phases.d.ts +4 -3
- package/dist/core/run/run-dry-phase.d.ts +35 -19
- package/dist/core/run/run-dry-phase.js +127 -77
- package/dist/core/run/run-isolated-rounds.d.ts +6 -5
- package/dist/core/run/run-isolated-rounds.js +1 -0
- package/dist/core/run-mutants.d.ts +26 -21
- package/dist/core/run-mutants.js +72 -64
- package/dist/core/runtime/create-hit-limit-error.d.ts +5 -3
- package/dist/core/runtime/create-hit-limit-error.js +1 -1
- package/dist/core/runtime/install-mutant-runtime.js +23 -6
- package/dist/core/runtime/runtime-version.d.ts +4 -4
- package/dist/core/skips/skip-rules.d.ts +4 -0
- package/dist/core/skips/skip-rules.js +4 -0
- package/dist/core/syntax/is-brace-sensitive-attribute.d.ts +18 -0
- package/dist/core/syntax/is-brace-sensitive-attribute.js +28 -0
- package/dist/core/syntax/is-spread-safe-member.d.ts +18 -0
- package/dist/core/syntax/is-spread-safe-member.js +18 -0
- package/dist/core/syntax/is-value-position.d.ts +3 -1
- package/dist/core/text/get-list-removal-range.d.ts +22 -0
- package/dist/core/text/get-list-removal-range.js +46 -0
- package/dist/core/text/is-plain-attribute-string.d.ts +10 -0
- package/dist/core/text/is-plain-attribute-string.js +5 -0
- package/dist/core/text/parse-expression.d.ts +8 -4
- package/dist/core/text/parse-expression.js +1 -0
- package/dist/core/text/remove-list-element.d.ts +2 -4
- package/dist/core/text/remove-list-element.js +4 -45
- package/dist/docs/styles/colors.js +1 -1
- package/dist/package.js +1 -1
- package/dist/types/adapter/dry-file.d.ts +2 -1
- package/dist/types/adapter/dry-run-request.d.ts +5 -4
- package/dist/types/adapter/mutant-runtime.d.ts +30 -1
- package/dist/types/cli/text-style.d.ts +1 -1
- package/dist/types/config/preset-settings.d.ts +2 -2
- package/dist/types/config/run-config.d.ts +12 -4
- package/dist/types/html/indexed-mutant.d.ts +4 -2
- package/dist/types/html/shown-change.d.ts +4 -3
- package/dist/types/mutant/list-removal.d.ts +37 -0
- package/dist/types/mutant/mutant-candidate.d.ts +11 -17
- package/dist/types/mutant/mutant-host.d.ts +49 -0
- package/dist/types/mutant/mutant-kind.d.ts +18 -0
- package/dist/types/mutant/mutant-range.d.ts +15 -8
- package/dist/types/mutant/mutant.d.ts +9 -15
- package/dist/types/mutant/site-syntax.d.ts +14 -0
- package/dist/types/mutant/skip-justifier.d.ts +3 -1
- package/dist/types/mutant/skipped-candidate.d.ts +13 -10
- package/dist/types/mutant/skipped-mutant.d.ts +9 -6
- package/dist/types/mutator/replacement.d.ts +14 -3
- package/dist/types/report/html-report.d.ts +10 -7
- package/dist/types/report/list-report-focus.d.ts +3 -2
- package/dist/types/report/list-report-justifier.d.ts +4 -2
- package/dist/types/report/list-report-mutant.d.ts +15 -9
- package/dist/types/report/list-report-skipped.d.ts +3 -2
- package/dist/types/report/list-report.d.ts +1 -1
- package/dist/types/report/run-report.d.ts +2 -2
- package/dist/types/report/slim-list-report.d.ts +6 -3
- package/dist/types/report/slim-run-report.d.ts +1 -1
- package/dist/types/run/isolated-reason.d.ts +4 -3
- package/dist/types/run/mutant-state.d.ts +1 -1
- package/dist/types/run/run-event.d.ts +1 -1
- package/dist/types/run/run-kind.d.ts +3 -2
- package/dist/types/run/run-result.d.ts +6 -3
- package/dist/types/run/run-state.d.ts +9 -1
- package/dist/types/run/run-status.d.ts +2 -2
- package/dist/types/run/try-cause.d.ts +8 -6
- package/dist/types/syntax/syntax-helpers.d.ts +5 -3
- package/package.json +5 -5
- package/skills/mootant/SKILL.md +14 -12
- package/skills/mootant/references/mutators.md +3 -1
- package/dist/core/instrument/get-site-check.d.ts +0 -9
- package/dist/core/instrument/get-site-check.js +0 -5
- package/dist/core/instrument/get-template-site-check.d.ts +0 -12
- package/dist/core/instrument/get-template-site-check.js +0 -5
- /package/dist/cli/{built-in-adapters.d.ts → get-built-in-adapters.d.ts} +0 -0
- /package/dist/cli/{built-in-adapters.js → get-built-in-adapters.js} +0 -0
- /package/dist/cli/terminal/{colors.d.ts → create-colors.d.ts} +0 -0
- /package/dist/cli/terminal/{colors.js → create-colors.js} +0 -0
package/dist/cli/run-mutation.js
CHANGED
|
@@ -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 {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
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(
|
|
17
|
-
let { verbose:
|
|
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
|
|
19
|
+
let c = await f({
|
|
20
20
|
onProgress: (e) => {
|
|
21
21
|
_.handle(e);
|
|
22
22
|
},
|
|
23
|
-
builtIns:
|
|
23
|
+
builtIns: r(),
|
|
24
24
|
...m,
|
|
25
25
|
cwd: process.cwd()
|
|
26
26
|
});
|
|
27
27
|
_.finish();
|
|
28
28
|
let v = d("run", {
|
|
29
|
-
incremental:
|
|
30
|
-
config:
|
|
31
|
-
preset:
|
|
32
|
-
paths:
|
|
33
|
-
fast:
|
|
34
|
-
}), y =
|
|
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
|
-
|
|
39
|
-
...!
|
|
40
|
-
idLength: e(
|
|
41
|
-
command: d("run",
|
|
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:
|
|
43
|
+
verbose: a,
|
|
44
44
|
recheck: v
|
|
45
|
-
})), y.summary.passed || (process.exitCode = 1),
|
|
46
|
-
command: `${d("run",
|
|
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,
|
|
57
|
-
let { colors: s } =
|
|
56
|
+
async function g(t, n, r) {
|
|
57
|
+
let { colors: s } = r.style, c = /* @__PURE__ */ new Date();
|
|
58
58
|
try {
|
|
59
|
-
let l =
|
|
59
|
+
let l = i(t, {
|
|
60
60
|
idLength: e(t.listedIds),
|
|
61
|
-
project:
|
|
62
|
-
recheck:
|
|
63
|
-
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
|
|
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,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
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(
|
|
6
|
+
colors: e(t({
|
|
7
7
|
stdout: r,
|
|
8
8
|
platform: i,
|
|
9
9
|
argv: a,
|
|
10
10
|
env: o
|
|
11
11
|
})),
|
|
12
|
-
unicode:
|
|
12
|
+
unicode: n(),
|
|
13
13
|
width: s
|
|
14
14
|
};
|
|
15
15
|
}
|
|
@@ -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,
|
|
9
|
-
*
|
|
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 {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}),
|
|
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
|
|
12
|
+
async function c(n) {
|
|
13
13
|
try {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if (
|
|
17
|
-
|
|
18
|
-
|
|
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 {
|
|
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.
|
|
82
|
-
*
|
|
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
|
|
88
|
-
* depend on
|
|
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<
|
|
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 {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
let
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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:
|
|
25
|
-
settings:
|
|
26
|
-
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:
|
|
30
|
-
runner:
|
|
31
|
-
adapter:
|
|
53
|
+
version: f.adapter.version ?? null,
|
|
54
|
+
runner: p.version ?? null,
|
|
55
|
+
adapter: f.adapter.name
|
|
32
56
|
},
|
|
33
|
-
build: (await
|
|
34
|
-
settings:
|
|
35
|
-
limits:
|
|
36
|
-
hashes:
|
|
37
|
-
files:
|
|
38
|
-
root:
|
|
39
|
-
}),
|
|
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:
|
|
42
|
-
environment:
|
|
43
|
-
variables:
|
|
44
|
-
hashes:
|
|
45
|
-
root:
|
|
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 {
|
|
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
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* they
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
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";
|
|
@@ -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
|
-
*
|
|
8
|
-
*
|
|
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
|
-
* @
|
|
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
|
-
|
|
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
|
|
5
|
-
if (
|
|
6
|
-
let { source:
|
|
7
|
-
if (
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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(
|
|
18
|
-
skipped:
|
|
22
|
+
mutants: t.mutants.filter((e) => l(e) || d.has(e)),
|
|
23
|
+
skipped: i ? u : []
|
|
19
24
|
}];
|
|
20
25
|
});
|
|
21
26
|
}
|
|
22
|
-
|
|
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
|
-
*
|
|
20
|
-
* unless its mutator opts out with `countsForSolitary: false`, it is a
|
|
21
|
-
* of the same mutator on the same range, it
|
|
22
|
-
*
|
|
23
|
-
*
|
|
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
|