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
|
@@ -3,30 +3,32 @@ import { watchWorkerClose as t } from "./worker/watch-worker-close.js";
|
|
|
3
3
|
import { listDependencies as n } from "./worker/list-dependencies.js";
|
|
4
4
|
import { getErrorMessage as r } from "../shared/get-error-message.js";
|
|
5
5
|
import { VITEST_VARIABLES as i } from "./worker/vitest-variables.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import
|
|
24
|
-
import {
|
|
25
|
-
import
|
|
26
|
-
import {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
6
|
+
import { interceptStrays as a } from "./worker/intercept-strays.js";
|
|
7
|
+
import { readWorkerPlan as o } from "./worker/read-worker-plan.js";
|
|
8
|
+
import { raceTryTimeout as s } from "./worker/race-try-timeout.js";
|
|
9
|
+
import { writeOutRecord as c } from "./worker/write-out-record.js";
|
|
10
|
+
import { installTryHook as l } from "./worker/install-try-hook.js";
|
|
11
|
+
import { writeHeartbeat as u } from "./worker/write-heartbeat.js";
|
|
12
|
+
import { findHookError as d } from "./worker/find-hook-error.js";
|
|
13
|
+
import { getHookBudget as f } from "./worker/get-hook-budget.js";
|
|
14
|
+
import { readTryFacts as p } from "./worker/read-try-facts.js";
|
|
15
|
+
import { captureClock as m } from "../shared/capture-clock.js";
|
|
16
|
+
import { trackInputs as h } from "../shared/track-inputs.js";
|
|
17
|
+
import { getFileHash as g } from "./worker/get-file-hash.js";
|
|
18
|
+
import { waitForTurn as _ } from "./worker/wait-for-turn.js";
|
|
19
|
+
import { encodeStray as v } from "./worker/encode-stray.js";
|
|
20
|
+
import { orderTests as y } from "./worker/order-tests.js";
|
|
21
|
+
import { claimUnit as b } from "./worker/claim-unit.js";
|
|
22
|
+
import { listTests as x } from "./worker/list-tests.js";
|
|
23
|
+
import { createRequire as S } from "node:module";
|
|
24
|
+
import { closeSync as C, openSync as w, rmSync as T, writeFileSync as E } from "node:fs";
|
|
25
|
+
import D from "node:path";
|
|
26
|
+
import { createHash as O } from "node:crypto";
|
|
27
|
+
import { builtinEnvironments as k } from "vitest/runtime";
|
|
28
|
+
import { TestRunner as A } from "vitest";
|
|
29
|
+
const j = 2 ** 31 - 1;
|
|
30
|
+
let M = m();
|
|
31
|
+
var N = class extends A {
|
|
30
32
|
coverSink = { add: (e) => {
|
|
31
33
|
for (let t of this.activeCovers) t.add(e);
|
|
32
34
|
} };
|
|
@@ -35,6 +37,7 @@ var M = class extends O {
|
|
|
35
37
|
hookBudgets = /* @__PURE__ */ new Map();
|
|
36
38
|
planned = /* @__PURE__ */ new Map();
|
|
37
39
|
loadCovers = /* @__PURE__ */ new Set();
|
|
40
|
+
loadStrays = [];
|
|
38
41
|
inside = {
|
|
39
42
|
hits: 0,
|
|
40
43
|
from: 0
|
|
@@ -45,7 +48,6 @@ var M = class extends O {
|
|
|
45
48
|
inputs = null;
|
|
46
49
|
killed = /* @__PURE__ */ new Set();
|
|
47
50
|
runnable = null;
|
|
48
|
-
loadStrays = [];
|
|
49
51
|
activeCovers = [];
|
|
50
52
|
lastMutant = null;
|
|
51
53
|
hookError = null;
|
|
@@ -65,6 +67,7 @@ var M = class extends O {
|
|
|
65
67
|
outsideHits = 0;
|
|
66
68
|
bailed = !1;
|
|
67
69
|
beatLength = 0;
|
|
70
|
+
strayCount = 0;
|
|
68
71
|
unitIndex = 0;
|
|
69
72
|
outName = "";
|
|
70
73
|
sequence = 0;
|
|
@@ -74,35 +77,37 @@ var M = class extends O {
|
|
|
74
77
|
file = "";
|
|
75
78
|
constructor(e) {
|
|
76
79
|
super(e), this.options = this.injectValue("mootant");
|
|
77
|
-
let { directory: n, repeat: i, mode:
|
|
78
|
-
this.sequential =
|
|
79
|
-
|
|
80
|
-
|
|
80
|
+
let { directory: n, repeat: i, mode: o } = this.options;
|
|
81
|
+
this.sequential = o === "batch" || o === "dry" && i, this.beatFile = D.join(n, "beat", `${process.pid}.json`), C(w(D.join(n, "worker", String(process.pid)), "w")), a(Reflect.get(this, "workerState"), (e, t) => {
|
|
82
|
+
this.onStray(e, t);
|
|
83
|
+
});
|
|
84
|
+
let s = this.onCleanupWorkerContext;
|
|
85
|
+
if (s !== void 0) {
|
|
81
86
|
let e = Reflect.get(this, "workerState"), n = t(Reflect.get(e.ctx, "traces"));
|
|
82
87
|
this.onCleanupWorkerContext = (e) => {
|
|
83
88
|
this.endsInTeardown = !0, n !== null && (this.endsOnClose = !0, n((e) => {
|
|
84
89
|
e !== null && (this.hookError ??= r(e.error)), this.finishUnit();
|
|
85
|
-
})),
|
|
90
|
+
})), s(() => this.tearDown(e));
|
|
86
91
|
};
|
|
87
92
|
}
|
|
88
93
|
}
|
|
89
94
|
async onBeforeCollect(e) {
|
|
90
95
|
let { runtime: t, options: n } = this, r = e[0];
|
|
91
|
-
this.file = r, this.started =
|
|
92
|
-
let i =
|
|
96
|
+
this.file = r, this.started = M.now(), this.booted = performance.timeOrigin + this.started, t.hitLimit = Infinity, t.coverage = null, t.reached = !1, t.active = null, t.hits = 0;
|
|
97
|
+
let i = g(r, this.config.name ?? ""), a = D.join(n.directory, "out");
|
|
93
98
|
if (n.mode === "dry") {
|
|
94
|
-
t.coverage = this.loadCovers, this.outName = `${i}-${process.pid}`, this.out =
|
|
99
|
+
t.coverage = this.loadCovers, this.outName = `${i}-${process.pid}`, this.out = w(D.join(a, `${this.outName}.jsonl`), "a"), this.beat(n.timeouts.file, null), this.startTracking(!0);
|
|
95
100
|
return;
|
|
96
101
|
}
|
|
97
|
-
let s =
|
|
102
|
+
let s = o(n.directory, i), c = s === null ? null : b(n.directory, i, s.units.length);
|
|
98
103
|
if (c === null) {
|
|
99
104
|
this.runnable = /* @__PURE__ */ new Set();
|
|
100
105
|
return;
|
|
101
106
|
}
|
|
102
|
-
await
|
|
107
|
+
await _(n.directory, {
|
|
103
108
|
index: c,
|
|
104
109
|
hash: i
|
|
105
|
-
},
|
|
110
|
+
}, M), this.started = M.now(), this.unitIndex = s.indexes[c], this.outName = `${i}-${c}`, this.out = w(D.join(a, `${this.outName}.jsonl`), "a");
|
|
106
111
|
let l = this.config.hookTimeout > 0 ? this.config.hookTimeout : Infinity;
|
|
107
112
|
if (n.mode === "isolated") {
|
|
108
113
|
let e = s.units[c];
|
|
@@ -116,18 +121,18 @@ var M = class extends O {
|
|
|
116
121
|
this.beat(this.budget, null), this.startTracking(!1);
|
|
117
122
|
}
|
|
118
123
|
onCollected(e) {
|
|
119
|
-
this.loadDuration =
|
|
124
|
+
this.loadDuration = M.now() - this.started;
|
|
120
125
|
let { options: t } = this;
|
|
121
126
|
for (let n of e) {
|
|
122
127
|
if (t.mode === "dry") {
|
|
123
128
|
let { hookTimeout: e } = this.config;
|
|
124
|
-
for (let t of
|
|
125
|
-
this.outsideBudget = t.timeouts.file +
|
|
129
|
+
for (let t of x(n)) this.hookBudgets.set(t.id, f(t, e));
|
|
130
|
+
this.outsideBudget = t.timeouts.file + f(n, e), this.beat(this.outsideBudget, null);
|
|
126
131
|
}
|
|
127
|
-
this.concurrent =
|
|
132
|
+
this.concurrent = y(n, this.sequential) || this.concurrent, l(n, (e, t) => this.aroundTry(e, t)), n.result?.state === "fail" && (this.loadError ??= r(n.result.errors?.[0]));
|
|
128
133
|
}
|
|
129
134
|
if (this.batch === null || this.runnable !== null) return;
|
|
130
|
-
let n = e.flatMap((e) =>
|
|
135
|
+
let n = e.flatMap((e) => x(e)), i = n.findLastIndex((e) => this.planned.has(e.id));
|
|
131
136
|
this.runnable = new Set(n.slice(0, i + 1).map((e) => e.id));
|
|
132
137
|
}
|
|
133
138
|
async onBeforeRunTask(e) {
|
|
@@ -147,15 +152,17 @@ var M = class extends O {
|
|
|
147
152
|
test: e
|
|
148
153
|
});
|
|
149
154
|
}
|
|
150
|
-
onStray(e) {
|
|
151
|
-
let
|
|
152
|
-
|
|
153
|
-
|
|
155
|
+
onStray(e, t) {
|
|
156
|
+
let n = v(e, t, this.strayCount);
|
|
157
|
+
this.strayCount += 1;
|
|
158
|
+
let r = this.listActive();
|
|
159
|
+
if (r.length > 0) for (let e of r) e.strays.push(n);
|
|
160
|
+
else this.options.mode === "batch" && this.lastTest !== null && this.out !== null ? c(this.out, {
|
|
154
161
|
mutant: this.lastMutant,
|
|
155
162
|
test: this.lastTest,
|
|
156
163
|
kind: "late",
|
|
157
|
-
|
|
158
|
-
}) : this.loadStrays.push(
|
|
164
|
+
stray: n
|
|
165
|
+
}) : this.loadStrays.push(n);
|
|
159
166
|
}
|
|
160
167
|
async onAfterRunSuite(e) {
|
|
161
168
|
if (this.finishEnded(), e.file === e && this.inputs !== null) {
|
|
@@ -167,21 +174,21 @@ var M = class extends O {
|
|
|
167
174
|
async runTask(e) {
|
|
168
175
|
let t = this.records.get(e)?.current ?? null;
|
|
169
176
|
t === null && e.context.skip();
|
|
170
|
-
let n =
|
|
171
|
-
r === null ? await n() : t.timedOut = await
|
|
177
|
+
let n = A.getTestFn(e), { deadline: r } = t;
|
|
178
|
+
r === null ? await n() : t.timedOut = await s(n, Math.max(0, r - M.now()), M);
|
|
172
179
|
}
|
|
173
180
|
onAfterRunFiles(e) {
|
|
174
181
|
for (let e of this.records.values()) this.finishTest(e);
|
|
175
|
-
if (this.loadError === null) for (let t of e) this.hookError ??=
|
|
182
|
+
if (this.loadError === null) for (let t of e) this.hookError ??= d(t);
|
|
176
183
|
this.filesEnded = !0, this.endsInTeardown || this.finishUnit(), super.onAfterRunFiles(e);
|
|
177
184
|
}
|
|
185
|
+
async onAfterRetryTask(e, t) {
|
|
186
|
+
let n = this.records.get(e)?.current;
|
|
187
|
+
n && (n.state = e.result.state), await super.onAfterRetryTask?.(e, t);
|
|
188
|
+
}
|
|
178
189
|
async onBeforeRunSuite(e) {
|
|
179
190
|
this.finishEnded(), this.bailed && (e.mode = "skip"), await super.onBeforeRunSuite(e);
|
|
180
191
|
}
|
|
181
|
-
onAfterRetryTask(e) {
|
|
182
|
-
let t = this.records.get(e)?.current;
|
|
183
|
-
t && (t.state = e.result.state);
|
|
184
|
-
}
|
|
185
192
|
onAfterRunTask(e) {
|
|
186
193
|
this.finishTest(this.records.get(e)), super.onAfterRunTask(e);
|
|
187
194
|
}
|
|
@@ -189,7 +196,7 @@ var M = class extends O {
|
|
|
189
196
|
if (this.finishTry(e), this.abandoned) return;
|
|
190
197
|
let { runtime: t } = this, { mode: n } = this.options, { test: r } = e, i = e.next;
|
|
191
198
|
e.next += 1;
|
|
192
|
-
let a =
|
|
199
|
+
let a = M.now(), o = {
|
|
193
200
|
attempt: r.result.errors?.length ?? 0,
|
|
194
201
|
covers: n === "dry" ? /* @__PURE__ */ new Set() : null,
|
|
195
202
|
retries: r.result.retryCount ?? 0,
|
|
@@ -215,9 +222,9 @@ var M = class extends O {
|
|
|
215
222
|
let { current: t } = e;
|
|
216
223
|
if (t === null) return;
|
|
217
224
|
e.current = null, P(t);
|
|
218
|
-
let { runtime: n } = this, { mode: r } = this.options, { test: i } = t, a =
|
|
225
|
+
let { runtime: n } = this, { mode: r } = this.options, { test: i } = t, a = p(i, n, {
|
|
219
226
|
covers: t.covers === null ? null : [...t.covers].toSorted(),
|
|
220
|
-
duration:
|
|
227
|
+
duration: M.now() - t.started,
|
|
221
228
|
hits: n.hits - t.hits,
|
|
222
229
|
timedOut: t.timedOut,
|
|
223
230
|
strays: t.strays,
|
|
@@ -232,9 +239,9 @@ var M = class extends O {
|
|
|
232
239
|
let { hits: n } = e;
|
|
233
240
|
t === "batch" ? n += this.outsideHits : t === "dry" && (n -= this.inside.hits);
|
|
234
241
|
let { dependencies: r, ...i } = this.stopTracking();
|
|
235
|
-
|
|
242
|
+
c(this.out, {
|
|
236
243
|
covers: [...this.loadCovers].toSorted(),
|
|
237
|
-
duration:
|
|
244
|
+
duration: M.now() - this.started,
|
|
238
245
|
loadDuration: this.loadDuration,
|
|
239
246
|
environment: i.environment,
|
|
240
247
|
concurrent: this.concurrent,
|
|
@@ -249,30 +256,33 @@ var M = class extends O {
|
|
|
249
256
|
dependencies: r,
|
|
250
257
|
kind: "end",
|
|
251
258
|
hits: n
|
|
252
|
-
}),
|
|
259
|
+
}), C(w(D.join(this.options.directory, "done", this.outName), "w"));
|
|
253
260
|
}
|
|
254
|
-
this.beatDescriptor !== null && (
|
|
261
|
+
this.beatDescriptor !== null && (C(this.beatDescriptor), this.beatDescriptor = null), T(this.beatFile, { force: !0 }), e.hitLimit = Infinity, e.coverage = null, e.active = null;
|
|
255
262
|
}
|
|
256
263
|
async aroundTry(e, t) {
|
|
257
264
|
let n = this.records.get(e), { current: r } = n, i = e.result.retryCount ?? 0;
|
|
258
265
|
if (r === null || r.timedOut ? this.startTry(n) : i > r.retries ? (r.attempt = e.result.errors.length, r.state = void 0, r.retries = i) : r.repetitions + 1 === n.group ? this.startTry(n) : P(r), this.options.mode === "dry") {
|
|
259
|
-
let t = e.timeout > 0 ? e.timeout : Infinity, r =
|
|
266
|
+
let t = e.timeout > 0 ? e.timeout : Infinity, r = M.now();
|
|
260
267
|
n.current.watch = r + this.options.timeouts.test + t + this.hookBudgets.get(e.id), this.beatDry(r);
|
|
261
268
|
}
|
|
262
269
|
await t(), await new Promise((e) => {
|
|
263
|
-
|
|
270
|
+
M.setImmediate(e);
|
|
264
271
|
});
|
|
265
272
|
}
|
|
266
273
|
startTracking(e) {
|
|
267
|
-
let { directory: t, root: n } = this.options, r =
|
|
274
|
+
let { directory: t, root: n } = this.options, r = h({
|
|
275
|
+
directory: t,
|
|
276
|
+
root: n
|
|
277
|
+
}, {
|
|
268
278
|
holder: Reflect.get(this, "workerState"),
|
|
269
279
|
ignored: i
|
|
270
280
|
});
|
|
271
281
|
if (this.inputs = r, e) {
|
|
272
282
|
let e = {};
|
|
273
|
-
for (let [t, n = ""] of Object.entries(r.real)) e[t] =
|
|
283
|
+
for (let [t, n = ""] of Object.entries(r.real)) e[t] = O("sha256").update(n).digest("hex");
|
|
274
284
|
try {
|
|
275
|
-
|
|
285
|
+
E(D.join(t, "env", `${g("", this.config.name ?? "")}.json`), JSON.stringify({
|
|
276
286
|
project: this.config.name ?? "",
|
|
277
287
|
variables: e
|
|
278
288
|
}), { flag: "wx" });
|
|
@@ -284,14 +294,14 @@ var M = class extends O {
|
|
|
284
294
|
this.inputs = null;
|
|
285
295
|
let r = Reflect.get(this, "workerState"), i = [...e].toSorted();
|
|
286
296
|
return {
|
|
287
|
-
dependencies: Object.hasOwn(
|
|
297
|
+
dependencies: Object.hasOwn(k, r.ctx.environment.name) ? i : null,
|
|
288
298
|
environment: t,
|
|
289
299
|
modified: n
|
|
290
300
|
};
|
|
291
301
|
}
|
|
292
302
|
beat(e, t) {
|
|
293
|
-
this.sequence += 1, this.beatDescriptor ??=
|
|
294
|
-
budget: Math.min(Math.max(0, e),
|
|
303
|
+
this.sequence += 1, this.beatDescriptor ??= w(this.beatFile, "w"), this.beatLength = u(this.beatDescriptor, {
|
|
304
|
+
budget: Math.min(Math.max(0, e), j) + 1e3,
|
|
295
305
|
name: t?.fullTestName ?? null,
|
|
296
306
|
mutant: this.runtime.active,
|
|
297
307
|
sequence: this.sequence,
|
|
@@ -304,12 +314,12 @@ var M = class extends O {
|
|
|
304
314
|
finishTest(e) {
|
|
305
315
|
this.finishTry(e);
|
|
306
316
|
let { test: t } = e;
|
|
307
|
-
this.records.delete(t),
|
|
317
|
+
this.records.delete(t), c(this.out, {
|
|
308
318
|
line: t.location?.line ?? null,
|
|
309
319
|
name: t.fullTestName,
|
|
310
320
|
tries: e.tries,
|
|
311
321
|
kind: "test"
|
|
312
|
-
}), delete t.result.errors, this.options.mode === "dry" ? this.beatDry() : this.beat(this.budget - (
|
|
322
|
+
}), delete t.result.errors, this.options.mode === "dry" ? this.beatDry() : this.beat(this.budget - (M.now() - this.started), null);
|
|
313
323
|
}
|
|
314
324
|
routeCoverage() {
|
|
315
325
|
let { runtime: e } = this;
|
|
@@ -317,13 +327,13 @@ var M = class extends O {
|
|
|
317
327
|
let [t] = this.activeCovers;
|
|
318
328
|
e.coverage = t === void 0 ? this.loadCovers : this.activeCovers.length === 1 ? t : this.coverSink;
|
|
319
329
|
}
|
|
320
|
-
beatDry(e =
|
|
330
|
+
beatDry(e = M.now()) {
|
|
321
331
|
let t = null;
|
|
322
332
|
for (let e of this.listActive()) (t === null || e.watch > t.watch) && (t = e);
|
|
323
333
|
t === null ? this.beat(this.outsideBudget, null) : this.beat(t.watch - e, t.test);
|
|
324
334
|
}
|
|
325
335
|
listDependencies(e) {
|
|
326
|
-
return n(Reflect.get(this, "workerState"), [...Object.keys(
|
|
336
|
+
return n(Reflect.get(this, "workerState"), [...Object.keys(S(import.meta.url).cache), ...this.inputs.files], e);
|
|
327
337
|
}
|
|
328
338
|
async tearDown(e) {
|
|
329
339
|
try {
|
|
@@ -343,19 +353,8 @@ var M = class extends O {
|
|
|
343
353
|
for (let e of this.records.values()) (this.sequential || e.test.mode === "skip") && this.finishTest(e);
|
|
344
354
|
}
|
|
345
355
|
};
|
|
346
|
-
function N(e) {
|
|
347
|
-
let t = Reflect.get(globalThis, A);
|
|
348
|
-
if (t === void 0) {
|
|
349
|
-
let n = { current: e };
|
|
350
|
-
function r(e) {
|
|
351
|
-
n.current.onStray(e);
|
|
352
|
-
}
|
|
353
|
-
process.on("unhandledRejection", r), process.on("uncaughtException", r), Reflect.set(globalThis, A, n), t = n;
|
|
354
|
-
}
|
|
355
|
-
t.current = e;
|
|
356
|
-
}
|
|
357
356
|
function P(e) {
|
|
358
357
|
let t = e.test.result.errors ?? [];
|
|
359
358
|
e.errors.push(...t.slice(e.attempt)), (e.state === "fail" || e.state === "skip") && (e.outcome = e.state), e.repetitions += 1, e.attempt = t.length, e.state = void 0;
|
|
360
359
|
}
|
|
361
|
-
export {
|
|
360
|
+
export { N as default };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the main process decided for the unhandled errors workers recorded in a
|
|
3
|
+
* run (`readStrays`): the first line of an error that counts, or null for one
|
|
4
|
+
* that does not, by the number of the error (`VitestStray.id`), by the path of
|
|
5
|
+
* its out file. Each error is decided once, however often its out file is read
|
|
6
|
+
* and however many tries recorded it.
|
|
7
|
+
*/
|
|
8
|
+
export type StrayDecisions = Map<string, Map<number, string | null>>
|
|
@@ -2,17 +2,19 @@ import { IsolatedUnit } from '../../../types/adapter/isolated-plan.js';
|
|
|
2
2
|
import { BatchUnit } from '../../../types/adapter/batch-plan.js';
|
|
3
3
|
import { TryFacts } from '../../../types/adapter/try-facts.js';
|
|
4
4
|
/**
|
|
5
|
-
* One line of `out/<hash>-<n>.jsonl
|
|
6
|
-
*
|
|
5
|
+
* One line of `out/<hash>-<n>.jsonl` as the main process reads it
|
|
6
|
+
* (`readOutRecords`): the tries of one test, an unhandled error after a try, or
|
|
7
|
+
* the end of a unit, with the first lines of only those unhandled errors that
|
|
8
|
+
* count (`readStrays`).
|
|
7
9
|
*/
|
|
8
10
|
export type VitestOutRecord =
|
|
9
11
|
| {
|
|
10
12
|
/**
|
|
11
13
|
* Ids of the modules the worker evaluated, the files Node's `require`
|
|
12
|
-
* loaded, the
|
|
13
|
-
* snapshot files of the test file
|
|
14
|
-
* worker cannot tell, as with a
|
|
15
|
-
* own.
|
|
14
|
+
* loaded, the files the test code read through `node:fs` that count as
|
|
15
|
+
* inputs (`createInputFilter`) and the snapshot files of the test file
|
|
16
|
+
* (`listDependencies`), or null when the worker cannot tell, as with a
|
|
17
|
+
* test environment other than Vitest's own.
|
|
16
18
|
*/
|
|
17
19
|
dependencies: string[] | null
|
|
18
20
|
|
|
@@ -45,9 +47,9 @@ export type VitestOutRecord =
|
|
|
45
47
|
concurrent: boolean
|
|
46
48
|
|
|
47
49
|
/**
|
|
48
|
-
*
|
|
49
|
-
* changed itself, by writing, creating, removing or moving
|
|
50
|
-
* entries of a directory, sorted.
|
|
50
|
+
* Files and directories the test code read through `node:fs` that count
|
|
51
|
+
* as inputs and changed itself, by writing, creating, removing or moving
|
|
52
|
+
* them or the entries of a directory, sorted.
|
|
51
53
|
*/
|
|
52
54
|
modified: string[]
|
|
53
55
|
|
|
@@ -56,6 +58,13 @@ export type VitestOutRecord =
|
|
|
56
58
|
*/
|
|
57
59
|
abandoned: boolean
|
|
58
60
|
|
|
61
|
+
/**
|
|
62
|
+
* Whether `onUnhandledError` of the root configuration decided an
|
|
63
|
+
* unhandled error of the unit; what that callback depends on is out of
|
|
64
|
+
* sight, so the unit's inputs cannot be told (`readUnitInputs`).
|
|
65
|
+
*/
|
|
66
|
+
filtered: boolean
|
|
67
|
+
|
|
59
68
|
/**
|
|
60
69
|
* Milliseconds from the start of loading to the end of the file.
|
|
61
70
|
*/
|
|
@@ -72,7 +81,7 @@ export type VitestOutRecord =
|
|
|
72
81
|
reached: boolean
|
|
73
82
|
|
|
74
83
|
/**
|
|
75
|
-
*
|
|
84
|
+
* First lines of the unhandled errors outside tries that count.
|
|
76
85
|
*/
|
|
77
86
|
strays: string[]
|
|
78
87
|
|
|
@@ -104,7 +113,7 @@ export type VitestOutRecord =
|
|
|
104
113
|
mutant: string | null
|
|
105
114
|
|
|
106
115
|
/**
|
|
107
|
-
* First line of the error.
|
|
116
|
+
* First line of the error, which counts.
|
|
108
117
|
*/
|
|
109
118
|
message: string
|
|
110
119
|
|
|
@@ -213,11 +222,62 @@ export interface VitestWorkerOptions {
|
|
|
213
222
|
repeat: boolean
|
|
214
223
|
|
|
215
224
|
/**
|
|
216
|
-
* Project root;
|
|
225
|
+
* Project root; reads outside it count too (`createInputFilter`).
|
|
217
226
|
*/
|
|
218
227
|
root: string
|
|
219
228
|
}
|
|
220
229
|
|
|
230
|
+
/**
|
|
231
|
+
* Unhandled error as a worker recorded it: what Vitest's listener passed to the
|
|
232
|
+
* worker's RPC (`interceptStrays`), encoded (`encodeStray`), before the main
|
|
233
|
+
* process decides whether it counts (`readStrays`).
|
|
234
|
+
*/
|
|
235
|
+
export interface VitestStray {
|
|
236
|
+
/**
|
|
237
|
+
* Base64 of the `node:v8` serialization of the error as Vitest serialized it,
|
|
238
|
+
* with the name of the running test and the path of the test file, or of a
|
|
239
|
+
* reason that is not an object.
|
|
240
|
+
*/
|
|
241
|
+
error: string
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Event of the error, as Vitest names it: `Uncaught Exception` or `Unhandled
|
|
245
|
+
* Rejection`.
|
|
246
|
+
*/
|
|
247
|
+
type: string
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Number of the error among those the worker recorded, from 0; its copies in
|
|
251
|
+
* tries that ran at once share it, so the main process decides it once.
|
|
252
|
+
*/
|
|
253
|
+
id: number
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* One line of `out/<hash>-<n>.jsonl` as the worker writes it, with the
|
|
258
|
+
* unhandled errors as it recorded them; the main process reads it into a
|
|
259
|
+
* `VitestOutRecord` (`readOutRecords`).
|
|
260
|
+
*/
|
|
261
|
+
export type VitestOutLine =
|
|
262
|
+
| ({
|
|
263
|
+
/**
|
|
264
|
+
* Unhandled errors outside tries.
|
|
265
|
+
*/
|
|
266
|
+
strays: VitestStray[]
|
|
267
|
+
} & Omit<Extract<VitestOutRecord, { kind: 'end' }>, 'filtered' | 'strays'>)
|
|
268
|
+
| ({
|
|
269
|
+
/**
|
|
270
|
+
* Tries of the test in the order they ran.
|
|
271
|
+
*/
|
|
272
|
+
tries: VitestTryFacts[]
|
|
273
|
+
} & Omit<Extract<VitestOutRecord, { kind: 'test' }>, 'tries'>)
|
|
274
|
+
| ({
|
|
275
|
+
/**
|
|
276
|
+
* Unhandled error after the try.
|
|
277
|
+
*/
|
|
278
|
+
stray: VitestStray
|
|
279
|
+
} & Omit<Extract<VitestOutRecord, { kind: 'late' }>, 'message'>)
|
|
280
|
+
|
|
221
281
|
/**
|
|
222
282
|
* Plan file of one test file: `plan/<hash of the path>.json`.
|
|
223
283
|
*/
|
|
@@ -233,6 +293,17 @@ export interface VitestPlanFile {
|
|
|
233
293
|
indexes: number[]
|
|
234
294
|
}
|
|
235
295
|
|
|
296
|
+
/**
|
|
297
|
+
* Facts of a try as the worker writes them, with its unhandled errors as it
|
|
298
|
+
* recorded them.
|
|
299
|
+
*/
|
|
300
|
+
export interface VitestTryFacts extends Omit<TryFacts, 'strays'> {
|
|
301
|
+
/**
|
|
302
|
+
* Unhandled errors while the try ran.
|
|
303
|
+
*/
|
|
304
|
+
strays: VitestStray[]
|
|
305
|
+
}
|
|
306
|
+
|
|
236
307
|
declare module 'vitest' {
|
|
237
308
|
/**
|
|
238
309
|
* Values the main process provides to test workers.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { VitestStray } from '../types/vitest-worker.js';
|
|
2
|
+
/**
|
|
3
|
+
* Encodes an unhandled error for an out file the way Vitest's forks pool sends
|
|
4
|
+
* it to the main process: serialized by `node:v8`, which keeps the big
|
|
5
|
+
* integers, cycles and undefined values that JSON drops or cannot write, as
|
|
6
|
+
* base64. A value `node:v8` cannot serialize keeps only its first line
|
|
7
|
+
* (`getErrorMessage`), so recording an error never throws in Vitest's
|
|
8
|
+
* listener.
|
|
9
|
+
*
|
|
10
|
+
* @param error - Error as Vitest serialized it, or a reason that is not an
|
|
11
|
+
* object.
|
|
12
|
+
* @param type - Event of the error, as Vitest names it.
|
|
13
|
+
* @param id - Number of the error among those the worker recorded.
|
|
14
|
+
* @returns Unhandled error as the out file keeps it.
|
|
15
|
+
*/
|
|
16
|
+
export declare function encodeStray(error: unknown, type: string, id: number): VitestStray;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { getErrorMessage as e } from "../../shared/get-error-message.js";
|
|
2
|
+
import { serialize as t } from "node:v8";
|
|
3
|
+
function n(n, r, i) {
|
|
4
|
+
let a;
|
|
5
|
+
try {
|
|
6
|
+
a = t(n);
|
|
7
|
+
} catch {
|
|
8
|
+
a = t(e(n));
|
|
9
|
+
}
|
|
10
|
+
return {
|
|
11
|
+
error: a.toString("base64"),
|
|
12
|
+
type: r,
|
|
13
|
+
id: i
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export { n as encodeStray };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Records an unhandled error as Vitest's listener reports it.
|
|
3
|
+
*
|
|
4
|
+
* @param error - Error as Vitest serialized it, or a reason that is not an
|
|
5
|
+
* object.
|
|
6
|
+
* @param type - Event of the error, as Vitest names it.
|
|
7
|
+
*/
|
|
8
|
+
type StrayReceiver = (error: unknown, type: string) => void;
|
|
9
|
+
/**
|
|
10
|
+
* Takes over Vitest's report of a worker's unhandled errors. Vitest's own
|
|
11
|
+
* listener of the process leaves an error to the code when another listener of
|
|
12
|
+
* its event exists, as in a plain run; otherwise it serializes the error and
|
|
13
|
+
* passes it to `onUnhandledError` of the RPC it reads from the worker state at
|
|
14
|
+
* that moment. That RPC is wrapped once per worker state: the call goes to the
|
|
15
|
+
* receiver instead of the main process, synchronously, so the error lands in
|
|
16
|
+
* the try that runs at that moment, and every other call passes through. A
|
|
17
|
+
* later receiver on the same state takes the wrapper over. No listener of the
|
|
18
|
+
* process is added, which would make Vitest's step aside.
|
|
19
|
+
*
|
|
20
|
+
* @param state - Vitest's worker state.
|
|
21
|
+
* @param receive - Records an unhandled error.
|
|
22
|
+
*/
|
|
23
|
+
export declare function interceptStrays(state: {
|
|
24
|
+
rpc: object;
|
|
25
|
+
}, receive: StrayReceiver): void;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const e = Symbol.for("mootant.vitest.strays");
|
|
2
|
+
function t(t, n) {
|
|
3
|
+
let r = Reflect.get(t, e);
|
|
4
|
+
if (r === void 0) {
|
|
5
|
+
let i = { receive: n };
|
|
6
|
+
function a(e, t) {
|
|
7
|
+
i.receive(e, t);
|
|
8
|
+
}
|
|
9
|
+
t.rpc = new Proxy(t.rpc, { get: (e, t) => t === "onUnhandledError" ? a : Reflect.get(e, t) }), Reflect.set(t, e, i), r = i;
|
|
10
|
+
}
|
|
11
|
+
r.receive = n;
|
|
12
|
+
}
|
|
13
|
+
export { t as interceptStrays };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { RunnerTestCase } from 'vitest';
|
|
2
2
|
import { MutantRuntime } from '../../../types/adapter/mutant-runtime.js';
|
|
3
|
-
import {
|
|
3
|
+
import { VitestTryFacts } from '../types/vitest-worker.js';
|
|
4
4
|
/**
|
|
5
5
|
* What the worker runner observed of a try besides the runtime's counters.
|
|
6
6
|
*/
|
|
7
|
-
interface TryObservation extends Pick<
|
|
7
|
+
interface TryObservation extends Pick<VitestTryFacts, 'timedOut' | 'duration' | 'strays' | 'covers' | 'hits'> {
|
|
8
8
|
/**
|
|
9
9
|
* Errors the try added to the test's result: those of its body, its hooks,
|
|
10
10
|
* its `aroundEach` teardown and fixture cleanup, after Vitest's "expected to
|
|
@@ -30,7 +30,8 @@ interface TryObservation extends Pick<TryFacts, 'timedOut' | 'duration' | 'stray
|
|
|
30
30
|
* @param runtime - Switch and counters the switched code updated.
|
|
31
31
|
* @param observed - Errors and state of the try, its duration, hits, coverage,
|
|
32
32
|
* stray errors and mootant's timeout.
|
|
33
|
-
* @returns Raw facts
|
|
33
|
+
* @returns Raw facts, with the unhandled errors as the worker recorded them,
|
|
34
|
+
* which the main process reads for `classifyTry` (`readOutRecords`).
|
|
34
35
|
*/
|
|
35
|
-
export declare function readTryFacts(test: RunnerTestCase, runtime: MutantRuntime, observed: TryObservation):
|
|
36
|
+
export declare function readTryFacts(test: RunnerTestCase, runtime: MutantRuntime, observed: TryObservation): VitestTryFacts;
|
|
36
37
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { VitestOutLine } from '../types/vitest-worker.js';
|
|
2
2
|
/**
|
|
3
3
|
* Appends one record to the out file of a unit through its open descriptor. The
|
|
4
4
|
* write is synchronous, so a worker killed later loses only the test in
|
|
@@ -7,4 +7,4 @@ import { VitestOutRecord } from '../types/vitest-worker.js';
|
|
|
7
7
|
* @param descriptor - File descriptor of the out file, open for appending.
|
|
8
8
|
* @param record - Record to append as one JSON line.
|
|
9
9
|
*/
|
|
10
|
-
export declare function writeOutRecord(descriptor: number, record:
|
|
10
|
+
export declare function writeOutRecord(descriptor: number, record: VitestOutLine): void;
|
|
@@ -37,7 +37,7 @@ function r(r, a) {
|
|
|
37
37
|
...i !== void 0 && { killedBy: i },
|
|
38
38
|
...e.cause && { cause: e.cause },
|
|
39
39
|
...e.path !== null && { path: e.path },
|
|
40
|
-
...e.kind
|
|
40
|
+
...e.kind !== "expression" && { kind: e.kind },
|
|
41
41
|
...e.cached && { cached: !0 },
|
|
42
42
|
mutator: c.get(e.mutator),
|
|
43
43
|
...n(e.original, e.replacement),
|