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
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { readOutFile as e } from "../shared/read-out-file.js";
|
|
2
|
+
import { readStrays as t } from "./read-strays.js";
|
|
3
|
+
function n(n, r, i) {
|
|
4
|
+
let a = i.get(r) ?? /* @__PURE__ */ new Map();
|
|
5
|
+
i.set(r, a);
|
|
6
|
+
let o = e(r), s = !n.config.dangerouslyIgnoreUnhandledErrors && !!n.state.onUnhandledError && o.some((e) => e.kind === "late" || (e.kind === "end" ? e.strays.length > 0 : e.tries.some((e) => e.strays.length > 0)));
|
|
7
|
+
return o.flatMap((e) => {
|
|
8
|
+
if (e.kind === "test") return [{
|
|
9
|
+
...e,
|
|
10
|
+
tries: e.tries.map((e) => ({
|
|
11
|
+
...e,
|
|
12
|
+
strays: t(n, e.strays, a)
|
|
13
|
+
}))
|
|
14
|
+
}];
|
|
15
|
+
if (e.kind === "end") return [{
|
|
16
|
+
...e,
|
|
17
|
+
strays: t(n, e.strays, a),
|
|
18
|
+
filtered: s
|
|
19
|
+
}];
|
|
20
|
+
let { stray: r, ...i } = e;
|
|
21
|
+
return t(n, [r], a).map((e) => ({
|
|
22
|
+
...i,
|
|
23
|
+
message: e
|
|
24
|
+
}));
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
export { n as readOutRecords };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Vitest } from 'vitest/node';
|
|
2
|
+
import { VitestStray } from './types/vitest-worker.js';
|
|
3
|
+
/**
|
|
4
|
+
* Reads the unhandled errors a worker recorded (`encodeStray`) and keeps those
|
|
5
|
+
* that fail a plain run, as Vitest's main process decides: none when the root
|
|
6
|
+
* configuration sets `dangerouslyIgnoreUnhandledErrors`; otherwise every error
|
|
7
|
+
* but a skip that a test asked for outside its own flow (`VITEST_PENDING`),
|
|
8
|
+
* which Vitest applies to the test instead, and those that `onUnhandledError`
|
|
9
|
+
* of the root configuration drops (`decideStray`). Each error is decided once:
|
|
10
|
+
* a decision of an earlier read, or of another copy of the error, is reused, so
|
|
11
|
+
* a callback runs once per error, as in Vitest.
|
|
12
|
+
*
|
|
13
|
+
* @param vitest - Vitest instance of the session.
|
|
14
|
+
* @param strays - Unhandled errors as the worker recorded them.
|
|
15
|
+
* @param decisions - Decisions of the errors of the same out file, by number,
|
|
16
|
+
* which receives the new ones.
|
|
17
|
+
* @returns First lines of the errors that count, at most 200 code units each,
|
|
18
|
+
* in order.
|
|
19
|
+
*/
|
|
20
|
+
export declare function readStrays(vitest: Vitest, strays: readonly VitestStray[], decisions: Map<number, string | null>): string[];
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { getErrorMessage as e } from "../shared/get-error-message.js";
|
|
2
|
+
import { deserialize as t, serialize as n } from "node:v8";
|
|
3
|
+
function r(e, t, n) {
|
|
4
|
+
if (e.config.dangerouslyIgnoreUnhandledErrors) return [];
|
|
5
|
+
let r = [];
|
|
6
|
+
for (let i of t) {
|
|
7
|
+
let t = n.get(i.id);
|
|
8
|
+
t === void 0 && (t = a(e.state.onUnhandledError, i), n.set(i.id, t)), t !== null && r.push(t);
|
|
9
|
+
}
|
|
10
|
+
return r;
|
|
11
|
+
}
|
|
12
|
+
function i(r, i) {
|
|
13
|
+
let a;
|
|
14
|
+
try {
|
|
15
|
+
a = t(n(r));
|
|
16
|
+
} catch (t) {
|
|
17
|
+
return e(t);
|
|
18
|
+
}
|
|
19
|
+
if (a instanceof Error) {
|
|
20
|
+
let e = {};
|
|
21
|
+
for (let t = a; t !== null && t !== Object.prototype; t = Reflect.getPrototypeOf(t)) for (let n of Object.getOwnPropertyNames(t)) if (!Object.hasOwn(e, n)) {
|
|
22
|
+
let t = Reflect.get(a, n);
|
|
23
|
+
e[n] = typeof t == "function" ? `Function<${t.name}>` : t;
|
|
24
|
+
}
|
|
25
|
+
a = e;
|
|
26
|
+
}
|
|
27
|
+
return typeof a == "object" && a && Object.assign(a, {
|
|
28
|
+
VITEST_TEST_NAME: i.VITEST_TEST_NAME,
|
|
29
|
+
VITEST_TEST_PATH: i.VITEST_TEST_PATH
|
|
30
|
+
}), o(a, "Unhandled Rejection");
|
|
31
|
+
}
|
|
32
|
+
function a(n, r) {
|
|
33
|
+
let a = t(Buffer.from(r.error, "base64")), s = o(a, r.type), c = e(a);
|
|
34
|
+
for (let t = 0; t < 100; t += 1) {
|
|
35
|
+
if (s.code === "VITEST_PENDING") return null;
|
|
36
|
+
if (!n) return c;
|
|
37
|
+
try {
|
|
38
|
+
return n(s) === !1 ? null : c;
|
|
39
|
+
} catch (t) {
|
|
40
|
+
let n = i(t, s);
|
|
41
|
+
if (typeof n == "string") return n;
|
|
42
|
+
s = n, c = e(t);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
function o(e, t) {
|
|
48
|
+
return typeof e == "object" && e ? Object.assign(e, { type: t }) : {
|
|
49
|
+
message: e,
|
|
50
|
+
type: t
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
export { r as readStrays };
|
|
@@ -2,7 +2,10 @@ import { VitestHandle } from './types/vitest-session-state.js';
|
|
|
2
2
|
import { RunInputs } from '../../types/adapter/run-inputs.js';
|
|
3
3
|
/**
|
|
4
4
|
* Turns what the worker of a batch or isolated unit reported it read into the
|
|
5
|
-
* inputs of the unit, the same way as for a dry run (`collectDependencies`).
|
|
5
|
+
* inputs of the unit, the same way as for a dry run (`collectDependencies`). A
|
|
6
|
+
* unit whose unhandled errors `onUnhandledError` of the root configuration
|
|
7
|
+
* decided has no inputs, as what that callback depends on is out of sight, so
|
|
8
|
+
* the cache never stores its verdicts.
|
|
6
9
|
*
|
|
7
10
|
* @param handle - Live Vitest instance of the session.
|
|
8
11
|
* @param unit - Test file and project of the unit.
|
|
@@ -15,6 +18,8 @@ import { RunInputs } from '../../types/adapter/run-inputs.js';
|
|
|
15
18
|
* @param reported.dependencies - Module ids and paths of `listDependencies`, or
|
|
16
19
|
* null when the worker could not tell.
|
|
17
20
|
* @param reported.environment - Names of the environment variables read.
|
|
21
|
+
* @param reported.filtered - Whether `onUnhandledError` decided an unhandled
|
|
22
|
+
* error of the unit.
|
|
18
23
|
* @returns Inputs of the unit, or null without a report or dependencies.
|
|
19
24
|
*/
|
|
20
25
|
export declare function readUnitInputs(handle: VitestHandle, unit: {
|
|
@@ -24,4 +29,5 @@ export declare function readUnitInputs(handle: VitestHandle, unit: {
|
|
|
24
29
|
}, reported: {
|
|
25
30
|
dependencies: string[] | null;
|
|
26
31
|
environment: string[];
|
|
32
|
+
filtered: boolean;
|
|
27
33
|
} | undefined): Promise<RunInputs | null>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { collectDependencies as e } from "./collect-dependencies.js";
|
|
2
2
|
async function t(t, n, r) {
|
|
3
|
-
if (r === void 0) return null;
|
|
3
|
+
if (r === void 0 || r.filtered) return null;
|
|
4
4
|
let i = await e({
|
|
5
5
|
project: t.vitest.getProjectByName(n.project),
|
|
6
6
|
reported: r.dependencies,
|
|
@@ -44,17 +44,17 @@ async function f(e, n) {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
async function p(t, i, a) {
|
|
47
|
-
let { context: o,
|
|
47
|
+
let { context: o, vitest: c, state: l } = t, u = [...l.mismatched].toSorted(n), f = [...l.outside].toSorted(n), p = [...l.served].toSorted(n), m = /* @__PURE__ */ new Map(), g = new Map(i.map(({ moduleId: e, project: t }) => [s(e, t.name), {
|
|
48
48
|
project: t.name,
|
|
49
49
|
source: t,
|
|
50
50
|
file: e
|
|
51
|
-
}])),
|
|
52
|
-
for (let [e, t] of
|
|
53
|
-
let n = e.split("-", 1)[0], { project: r, source: i, file: o } =
|
|
54
|
-
|
|
51
|
+
}])), _ = /* @__PURE__ */ new Set(), v = [], y = [], b = [], x = d(c, o.workDirectory, /* @__PURE__ */ new Map());
|
|
52
|
+
for (let [e, t] of x) {
|
|
53
|
+
let n = e.split("-", 1)[0], { project: r, source: i, file: o } = g.get(n), s = !1, c = 0;
|
|
54
|
+
_.add(n);
|
|
55
55
|
for (let e of t) if (e.kind === "test") {
|
|
56
56
|
for (let t of e.tries) c += t.duration;
|
|
57
|
-
|
|
57
|
+
b.push({
|
|
58
58
|
id: e.tries[0].test,
|
|
59
59
|
tries: e.tries,
|
|
60
60
|
line: e.line,
|
|
@@ -81,28 +81,28 @@ async function p(t, i, a) {
|
|
|
81
81
|
project: r,
|
|
82
82
|
file: o
|
|
83
83
|
};
|
|
84
|
-
|
|
84
|
+
y.push(t), v.push([t, {
|
|
85
85
|
reported: e.dependencies,
|
|
86
86
|
project: i,
|
|
87
|
-
tsconfigs:
|
|
87
|
+
tsconfigs: m,
|
|
88
88
|
file: o
|
|
89
89
|
}]);
|
|
90
90
|
}
|
|
91
|
-
s ||
|
|
91
|
+
s || y.push(h({
|
|
92
92
|
project: r,
|
|
93
93
|
file: o
|
|
94
94
|
}, a));
|
|
95
95
|
}
|
|
96
|
-
await Promise.all(
|
|
96
|
+
await Promise.all(v.map(async ([e, t]) => {
|
|
97
97
|
e.dependencies = await r(t);
|
|
98
98
|
}));
|
|
99
|
-
for (let [e, t] of
|
|
99
|
+
for (let [e, t] of g) _.has(e) || y.push(h(t, a));
|
|
100
100
|
return {
|
|
101
|
-
tests:
|
|
102
|
-
files:
|
|
103
|
-
mismatched:
|
|
104
|
-
outside:
|
|
105
|
-
served:
|
|
101
|
+
tests: b.toSorted(e),
|
|
102
|
+
files: y.toSorted(e),
|
|
103
|
+
mismatched: u,
|
|
104
|
+
outside: f,
|
|
105
|
+
served: p
|
|
106
106
|
};
|
|
107
107
|
}
|
|
108
108
|
async function m(e, t) {
|
|
@@ -14,7 +14,9 @@ import { UnitOutcome } from './types/unit-outcome.js';
|
|
|
14
14
|
* is over, when a worker claimed it and died or was stopped before it could, so
|
|
15
15
|
* the progress reaches the number of units that ran. The context's `onUnitEnd`
|
|
16
16
|
* gets the index of each finished unit and, for a unit its worker marked done,
|
|
17
|
-
* its facts with `describe`, else how long it ran, from its records.
|
|
17
|
+
* its facts with `describe`, else how long it ran, from its records. The read
|
|
18
|
+
* as a unit ends and the read after the run share their decisions of the
|
|
19
|
+
* unhandled errors, so each error is decided once (`StrayDecisions`).
|
|
18
20
|
*
|
|
19
21
|
* @param handle - Live Vitest instance of the session.
|
|
20
22
|
* @param plan - Kind of the run, units in plan order and the most units at
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { resetRunDirectory as e } from "./reset-run-directory.js";
|
|
2
2
|
import { runSpecifications as t } from "./run-specifications.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { watchHeartbeats as n } from "./watch-heartbeats.js";
|
|
4
|
+
import { readOutRecords as r } from "./read-out-records.js";
|
|
5
5
|
import { stopHungWorker as i } from "./stop-hung-worker.js";
|
|
6
6
|
import { writePlanFiles as a } from "./write-plan-files.js";
|
|
7
7
|
import { watchUnitEnds as o } from "./watch-unit-ends.js";
|
|
@@ -13,12 +13,12 @@ async function d(d, f) {
|
|
|
13
13
|
e(g), d.state.spawns.clear();
|
|
14
14
|
let _ = await a(g, p), v = p.map((e) => h.getProjectByName(e.project).createSpecification(e.file)), y = h.projects.map((e) => e.config), b = y.map((e) => e.maxWorkers);
|
|
15
15
|
if (f.concurrency !== void 0) for (let e of y) e.maxWorkers = Math.min(e.maxWorkers, f.concurrency);
|
|
16
|
-
let x = /* @__PURE__ */ new Map(), S =
|
|
16
|
+
let x = /* @__PURE__ */ new Map(), S = n(g, async (e) => {
|
|
17
17
|
await i(e.pid) && x.set(e.unit, e);
|
|
18
|
-
}), { onUnitEnd: C } = d.context, w = new Map(_.map((e, t) => [e, t])),
|
|
19
|
-
let t =
|
|
18
|
+
}), { onUnitEnd: C } = d.context, w = /* @__PURE__ */ new Map(), T = new Map(_.map((e, t) => [e, t])), E = o(g, C === void 0 ? void 0 : ((e) => {
|
|
19
|
+
let t = T.get(e), n = r(h, u.join(g, "out", `${e}.jsonl`), w);
|
|
20
20
|
if (f.describe === void 0) {
|
|
21
|
-
let e =
|
|
21
|
+
let e = n.find((e) => e.kind === "end");
|
|
22
22
|
C(e === void 0 ? { unit: t } : {
|
|
23
23
|
duration: e.duration,
|
|
24
24
|
unit: t
|
|
@@ -27,34 +27,34 @@ async function d(d, f) {
|
|
|
27
27
|
facts: f.describe(t, {
|
|
28
28
|
pid: Number(c(u.join(g, "claim", e), "utf8")),
|
|
29
29
|
hung: null,
|
|
30
|
-
records:
|
|
30
|
+
records: n
|
|
31
31
|
}),
|
|
32
32
|
unit: t
|
|
33
33
|
});
|
|
34
|
-
})),
|
|
34
|
+
})), D;
|
|
35
35
|
try {
|
|
36
|
-
|
|
36
|
+
D = await t(d, {
|
|
37
37
|
timeouts: null,
|
|
38
38
|
repeat: !1,
|
|
39
39
|
mode: m
|
|
40
40
|
}, v);
|
|
41
41
|
} finally {
|
|
42
|
-
|
|
42
|
+
E.stop(), await S.stop();
|
|
43
43
|
for (let [e, t] of y.entries()) t.maxWorkers = b[e];
|
|
44
44
|
}
|
|
45
|
-
let
|
|
46
|
-
for (let [e, t] of _.entries())
|
|
45
|
+
let O = s(h, g, w), k = new Set(l(u.join(g, "claim"))), A = new Set(l(u.join(g, "done")));
|
|
46
|
+
for (let [e, t] of _.entries()) k.has(t) && !A.has(t) && C?.({ unit: e });
|
|
47
47
|
return {
|
|
48
48
|
units: _.map((e, t) => {
|
|
49
|
-
let n =
|
|
49
|
+
let n = k.has(e);
|
|
50
50
|
return {
|
|
51
51
|
pid: n ? Number(c(u.join(g, "claim", e), "utf8")) : null,
|
|
52
|
-
records:
|
|
52
|
+
records: O.get(e) ?? [],
|
|
53
53
|
hung: x.get(t) ?? null,
|
|
54
54
|
claimed: n
|
|
55
55
|
};
|
|
56
56
|
}),
|
|
57
|
-
error:
|
|
57
|
+
error: D
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
60
|
export { d as runPlan };
|
|
@@ -7,8 +7,9 @@ import { VitestHandle } from './types/vitest-session-state.js';
|
|
|
7
7
|
* them after the run, and a unit's end is recorded only after the worker's
|
|
8
8
|
* teardown, the test environment's teardown included. The caller's watchdog
|
|
9
9
|
* must run until this resolves: the wait relies on it to stop workers that hang
|
|
10
|
-
* in their teardown. Failing tests and
|
|
11
|
-
* runs, so the exit code Vitest sets for them
|
|
10
|
+
* in their teardown. Failing tests and unhandled errors, such as a worker that
|
|
11
|
+
* died, are expected in mootant's runs, so the exit code Vitest sets for them
|
|
12
|
+
* is restored.
|
|
12
13
|
*
|
|
13
14
|
* @param handle - Live Vitest instance of the session.
|
|
14
15
|
* @param worker - Kind of the run the workers perform and, for a dry run, the
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SerializedConfig, RunnerTestSuite, RunnerTestCase, RunnerTestFile, RunnerTask, TestRunner } from 'vitest';
|
|
1
|
+
import { SerializedConfig, RunnerTestSuite, RunnerTestCase, RunnerTestFile, TestTryOptions, RunnerTask, TestRunner } from 'vitest';
|
|
2
2
|
/**
|
|
3
3
|
* Vitest runner of mootant's workers. In a dry run it runs every test once, or
|
|
4
4
|
* twice in a row with `repeat`, and records which mutant sites each try
|
|
@@ -42,9 +42,12 @@ import { SerializedConfig, RunnerTestSuite, RunnerTestCase, RunnerTestFile, Runn
|
|
|
42
42
|
* variable cannot change inside a running worker); switched code reads it on
|
|
43
43
|
* every evaluation. Facts go to out files in the work directory, one line per
|
|
44
44
|
* test; heartbeats let the main process stop a worker that hangs, dry runs
|
|
45
|
-
* included.
|
|
45
|
+
* included. An unhandled error is recorded only as Vitest's own listener
|
|
46
|
+
* reports it to the main process in a plain run, so an error of an event the
|
|
47
|
+
* code listens for itself is left to that code (`interceptStrays`); the main
|
|
48
|
+
* process decides which of the recorded errors count (`readStrays`).
|
|
46
49
|
*/
|
|
47
|
-
export default class
|
|
50
|
+
export default class Runner extends TestRunner {
|
|
48
51
|
/**
|
|
49
52
|
* Coverage the runtime writes to while several tries of a dry run overlap:
|
|
50
53
|
* each site counts for every one of them.
|
|
@@ -72,6 +75,11 @@ export default class MootantRunner extends TestRunner {
|
|
|
72
75
|
* Mutant sites evaluated outside tries in a dry run.
|
|
73
76
|
*/
|
|
74
77
|
private readonly loadCovers;
|
|
78
|
+
/**
|
|
79
|
+
* Unhandled errors Vitest reported outside tries, encoded for the main
|
|
80
|
+
* process (`encodeStray`).
|
|
81
|
+
*/
|
|
82
|
+
private readonly loadStrays;
|
|
75
83
|
/**
|
|
76
84
|
* Site evaluations while tries of a dry run ran, and the count when the
|
|
77
85
|
* current stretch of tries began.
|
|
@@ -104,10 +112,6 @@ export default class MootantRunner extends TestRunner {
|
|
|
104
112
|
* Ids of the tests that run, or null to run every test.
|
|
105
113
|
*/
|
|
106
114
|
private runnable;
|
|
107
|
-
/**
|
|
108
|
-
* Unhandled errors outside tries.
|
|
109
|
-
*/
|
|
110
|
-
private readonly loadStrays;
|
|
111
115
|
/**
|
|
112
116
|
* Coverage sets of the tries that run now, in a dry run.
|
|
113
117
|
*/
|
|
@@ -193,6 +197,10 @@ export default class MootantRunner extends TestRunner {
|
|
|
193
197
|
* Length of the text in the heartbeat file.
|
|
194
198
|
*/
|
|
195
199
|
private beatLength;
|
|
200
|
+
/**
|
|
201
|
+
* Unhandled errors the runner recorded, which numbers the next one.
|
|
202
|
+
*/
|
|
203
|
+
private strayCount;
|
|
196
204
|
/**
|
|
197
205
|
* Index of the unit in the run's plan.
|
|
198
206
|
*/
|
|
@@ -224,9 +232,10 @@ export default class MootantRunner extends TestRunner {
|
|
|
224
232
|
*/
|
|
225
233
|
private file;
|
|
226
234
|
/**
|
|
227
|
-
* Creates the runner of one test file, installs the mutant runtime,
|
|
228
|
-
*
|
|
229
|
-
*
|
|
235
|
+
* Creates the runner of one test file, installs the mutant runtime, takes
|
|
236
|
+
* over Vitest's report of the worker's unhandled errors (`interceptStrays`),
|
|
237
|
+
* records the worker's process id, so the main process waits until the worker
|
|
238
|
+
* is gone, and moves the end of the unit to the end of the worker's teardown,
|
|
230
239
|
* after the test environment's teardown, whose error fails the unit like a
|
|
231
240
|
* failed suite hook.
|
|
232
241
|
*
|
|
@@ -266,13 +275,17 @@ export default class MootantRunner extends TestRunner {
|
|
|
266
275
|
*/
|
|
267
276
|
onBeforeRunTask(test: RunnerTask): Promise<void>;
|
|
268
277
|
/**
|
|
269
|
-
* Records an unhandled error
|
|
270
|
-
*
|
|
278
|
+
* Records an unhandled error as Vitest's listener reports it
|
|
279
|
+
* (`interceptStrays`), encoded and numbered for the main process, which
|
|
280
|
+
* decides once whether it counts (`readStrays`): in every try that runs now,
|
|
281
|
+
* as a late error of the last try in a batch run, or else as an error outside
|
|
271
282
|
* tries.
|
|
272
283
|
*
|
|
273
|
-
* @param error -
|
|
284
|
+
* @param error - Error as Vitest serialized it, or a reason that is not an
|
|
285
|
+
* object.
|
|
286
|
+
* @param type - Event of the error, as Vitest names it.
|
|
274
287
|
*/
|
|
275
|
-
onStray(error: unknown): void;
|
|
288
|
+
onStray(error: unknown, type: string): void;
|
|
276
289
|
/**
|
|
277
290
|
* Records a test that ended with a skip before a suite ends. Once the file
|
|
278
291
|
* suite ends, reads what the test file depended on so far, its snapshot files
|
|
@@ -299,6 +312,14 @@ export default class MootantRunner extends TestRunner {
|
|
|
299
312
|
* @param files - Test files that ran.
|
|
300
313
|
*/
|
|
301
314
|
onAfterRunFiles(files: RunnerTestFile[]): void;
|
|
315
|
+
/**
|
|
316
|
+
* Notes the state of the test after its `afterEach` hooks; the try's facts
|
|
317
|
+
* are read once its teardown finished.
|
|
318
|
+
*
|
|
319
|
+
* @param test - Vitest task of the try.
|
|
320
|
+
* @param options - Retry and repeat numbers of the try.
|
|
321
|
+
*/
|
|
322
|
+
onAfterRetryTask(test: RunnerTestCase, options: TestTryOptions): Promise<void>;
|
|
302
323
|
/**
|
|
303
324
|
* Records a test that ended with a skip before a suite's hooks run. After an
|
|
304
325
|
* isolated unit bailed, a suite that has not started is skipped with its
|
|
@@ -307,13 +328,6 @@ export default class MootantRunner extends TestRunner {
|
|
|
307
328
|
* @param suite - Suite about to run.
|
|
308
329
|
*/
|
|
309
330
|
onBeforeRunSuite(suite: RunnerTestSuite): Promise<void>;
|
|
310
|
-
/**
|
|
311
|
-
* Notes the state of the test after its `afterEach` hooks; the try's facts
|
|
312
|
-
* are read once its teardown finished.
|
|
313
|
-
*
|
|
314
|
-
* @param test - Vitest task of the try.
|
|
315
|
-
*/
|
|
316
|
-
onAfterRetryTask(test: RunnerTestCase): void;
|
|
317
331
|
/**
|
|
318
332
|
* Records the try of a test that ended with its last repeat.
|
|
319
333
|
*
|
|
@@ -359,8 +373,9 @@ export default class MootantRunner extends TestRunner {
|
|
|
359
373
|
*/
|
|
360
374
|
private aroundTry;
|
|
361
375
|
/**
|
|
362
|
-
* Starts recording the
|
|
363
|
-
*
|
|
376
|
+
* Starts recording the files the test code reads through `node:fs` that count
|
|
377
|
+
* as inputs, inside the project root or outside it (`createInputFilter`), and
|
|
378
|
+
* the environment variables it reads, before the test file and its setup
|
|
364
379
|
* files load. The first worker of a project in a dry run also writes the
|
|
365
380
|
* hashes of the worker's environment variables, as Vitest set them up, to
|
|
366
381
|
* `env/<hash>.json` of the work directory, for the main process to tell what
|