supercov 4.29.1 → 4.29.2
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/docs/cli.md
CHANGED
|
@@ -537,7 +537,8 @@ many in a line per runner (`12 mutant(s) not run: no strong driver for
|
|
|
537
537
|
phpunit`). See `docs/design/strong-mutation.md`,
|
|
538
538
|
`docs/design/python-mutants.md` and `docs/design/mutation-drivers.md`.
|
|
539
539
|
|
|
540
|
-
- `--shard k/n` runs one of n shares of the mutants,
|
|
540
|
+
- `--shard k/n` runs one of n shares of the mutants, of about the same cost
|
|
541
|
+
(the copies and tests each mutant runs), for parallel jobs; each
|
|
541
542
|
job's run holds its share's verdicts, `merge` keeps them all in the merged
|
|
542
543
|
run, and a later `supercov mutants` keeps each verdict nothing changed could
|
|
543
544
|
move from whichever earlier run holds it (see
|
|
@@ -553,7 +554,11 @@ phpunit`). See `docs/design/strong-mutation.md`,
|
|
|
553
554
|
- A second `mutants test` over the same run runs only what has no verdict yet.
|
|
554
555
|
The pass saves each verdict as it comes: one that stops early (a test worker
|
|
555
556
|
that never ended, Ctrl-C, a killed job) keeps what it decided, and the next
|
|
556
|
-
pass runs the rest. Ctrl-C stops every process the pass started
|
|
557
|
+
pass runs the rest. Ctrl-C or SIGTERM stops every process the pass started,
|
|
558
|
+
and the pass ends within seconds: 8 s after the signal at the latest.
|
|
559
|
+
- `--budget <seconds>` stops the pass once it is spent: it ends as a finished
|
|
560
|
+
pass, its verdicts saved, and says how many mutants it left for the next.
|
|
561
|
+
The cheapest mutants run first, by their tests' recorded times.
|
|
557
562
|
- After an edit, `supercov mutants` measures the checkout again and keeps an
|
|
558
563
|
earlier run's verdict for each mutant whose file is as it was and whose
|
|
559
564
|
candidate tests, and their test files, nothing changed could reach (as
|
package/docs/mutation.md
CHANGED
|
@@ -117,8 +117,15 @@ mutants the tests let survive.
|
|
|
117
117
|
from runs r2, r1`).
|
|
118
118
|
- **Interrupted.** Each verdict is saved as it is made. A pass stopped by
|
|
119
119
|
Ctrl-C, a killed job or a test worker that never ended keeps what it
|
|
120
|
-
decided,
|
|
121
|
-
|
|
120
|
+
decided, and the next pass runs only the rest. Sent SIGINT or SIGTERM, the
|
|
121
|
+
pass stops every process it started and ends within seconds: one that has
|
|
122
|
+
not ended 8 s after the signal is ended, what it decided saved first.
|
|
123
|
+
- **Order and budget.** The cheapest mutants run first, by the recorded times
|
|
124
|
+
of the tests each runs against, so a pass cut short has decided as many as
|
|
125
|
+
it could. `--budget <seconds>` stops the pass once it is spent and ends it
|
|
126
|
+
as a finished one, its verdicts saved; the summary says how many mutants it
|
|
127
|
+
left for the next pass (`budget of 2400 s spent: 812 mutant(s) left without
|
|
128
|
+
a verdict, for the next pass`).
|
|
122
129
|
- **Exit codes.** `0` with an answer; `1` when `--fail-on` or `--critical`
|
|
123
130
|
finds a mutant; `2`, after the answer, when the measured command failed (a
|
|
124
131
|
failing test kills nothing, so the verdicts cannot gate) or no mutant could
|
|
@@ -212,8 +219,11 @@ npx supercov runs latest mutants test --plan --json
|
|
|
212
219
|
|
|
213
220
|
- `--critical <glob>` (repeatable): every mutant in those files must be killed
|
|
214
221
|
or accepted, or the command fails.
|
|
215
|
-
- `--shard k/n` runs one of n shares of the mutants,
|
|
222
|
+
- `--shard k/n` runs one of n shares of the mutants, of about the same cost,
|
|
223
|
+
for parallel jobs (see
|
|
216
224
|
[A pass split across jobs](#a-pass-split-across-jobs)).
|
|
225
|
+
- `--budget <seconds>` stops the pass once that time is spent, its verdicts
|
|
226
|
+
saved, and leaves the rest for the next pass.
|
|
217
227
|
- `--plan` prints what would run, and runs nothing.
|
|
218
228
|
|
|
219
229
|
Some mutants no test can tell apart from the original. Accept them in
|
|
@@ -240,7 +250,7 @@ merges the runs, and the merged run holds every job's verdicts:
|
|
|
240
250
|
# Each of four jobs (matrix.shard 1 to 4):
|
|
241
251
|
- uses: actions/cache/restore@v4
|
|
242
252
|
with: { path: .supercov/runs, key: "mutants-${{ github.sha }}", restore-keys: "mutants-" }
|
|
243
|
-
- run: npx supercov mutants --shard ${{ matrix.shard }}/4 -- npm test
|
|
253
|
+
- run: npx supercov mutants --shard ${{ matrix.shard }}/4 --budget 2400 -- npm test
|
|
244
254
|
- uses: actions/upload-artifact@v4
|
|
245
255
|
with: { name: "mutants-${{ matrix.shard }}", path: .supercov/runs, include-hidden-files: true }
|
|
246
256
|
# Then one job:
|
|
@@ -260,6 +270,18 @@ earlier verdicts as after an edit. Name the command after `--`: without it,
|
|
|
260
270
|
Every job must measure the same commit with the same dependencies, as for any
|
|
261
271
|
merge ([CLI reference](cli.md#combine-shards)).
|
|
262
272
|
|
|
273
|
+
- **The shares.** Each job computes the same split from its own run: the
|
|
274
|
+
mutants to run are dealt in turn, back and forth, most costly first, so
|
|
275
|
+
every share gets its part of the costly ones. A mutant's cost there is what
|
|
276
|
+
the plan lists of it, the copies of test files it starts and the tests they
|
|
277
|
+
run, not the tests' times, which differ between jobs.
|
|
278
|
+
- **The budget.** `--budget <seconds>` ends a job's pass in time without a
|
|
279
|
+
`timeout` around it: past the budget the pass stops, saves what it
|
|
280
|
+
decided, and exits as a finished pass. Within a pass the cheapest mutants
|
|
281
|
+
run first, so a job cut short has decided as many as it could, and the
|
|
282
|
+
mutants it left run in the next commit's pass, where the restored runs lend
|
|
283
|
+
the rest of their verdicts.
|
|
284
|
+
|
|
263
285
|
- **The merge.** `supercov merge` keeps the strong verdicts of the runs it
|
|
264
286
|
merges, mutant by mutant, and says how many and from which runs. A kill in
|
|
265
287
|
any run is a kill. A survival stands where the run that let the mutant
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "supercov",
|
|
3
|
-
"version": "4.29.
|
|
3
|
+
"version": "4.29.2",
|
|
4
4
|
"description": "Coverage, security and code quality for coding agents",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"coverage",
|
|
@@ -125,14 +125,14 @@
|
|
|
125
125
|
"test:windows-tls": "node scripts/windows-tls-test.mjs"
|
|
126
126
|
},
|
|
127
127
|
"optionalDependencies": {
|
|
128
|
-
"@supercov/cli-darwin-arm64": "4.29.
|
|
129
|
-
"@supercov/cli-darwin-x64": "4.29.
|
|
130
|
-
"@supercov/cli-linux-arm64-gnu": "4.29.
|
|
131
|
-
"@supercov/cli-linux-arm64-musl": "4.29.
|
|
132
|
-
"@supercov/cli-linux-x64-gnu": "4.29.
|
|
133
|
-
"@supercov/cli-linux-x64-musl": "4.29.
|
|
134
|
-
"@supercov/cli-win32-arm64": "4.29.
|
|
135
|
-
"@supercov/cli-win32-x64": "4.29.
|
|
128
|
+
"@supercov/cli-darwin-arm64": "4.29.2",
|
|
129
|
+
"@supercov/cli-darwin-x64": "4.29.2",
|
|
130
|
+
"@supercov/cli-linux-arm64-gnu": "4.29.2",
|
|
131
|
+
"@supercov/cli-linux-arm64-musl": "4.29.2",
|
|
132
|
+
"@supercov/cli-linux-x64-gnu": "4.29.2",
|
|
133
|
+
"@supercov/cli-linux-x64-musl": "4.29.2",
|
|
134
|
+
"@supercov/cli-win32-arm64": "4.29.2",
|
|
135
|
+
"@supercov/cli-win32-x64": "4.29.2"
|
|
136
136
|
},
|
|
137
137
|
"peerDependencies": {
|
|
138
138
|
"@playwright/test": ">=1.55.0",
|
|
@@ -72,6 +72,10 @@ function claim() {
|
|
|
72
72
|
};
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
// What a file before this one in the same worker reported to is not this
|
|
76
|
+
// file's copy.
|
|
77
|
+
if (globalThis.__vitest_worker__)
|
|
78
|
+
globalThis.__vitest_worker__.supercovReport = undefined;
|
|
75
79
|
const claimed = claim();
|
|
76
80
|
// A copy with nothing to run -- beyond its file's assignments, or one whose
|
|
77
81
|
// mutant another copy has decided -- ends here, before its test file loads.
|
|
@@ -117,6 +121,53 @@ function outsideTests(error) {
|
|
|
117
121
|
/SUPERCOV_MUTANT_TIMEOUT|MutantTimeout/.test(`${error?.name} ${error?.code} ${error?.message}`);
|
|
118
122
|
report({ outside: true, timeout, message: `${error?.message ?? error}`.slice(0, 300), hits: hitsNow() });
|
|
119
123
|
}
|
|
124
|
+
// A test file that does not load or set up -- a setup file after this one
|
|
125
|
+
// throws, or one of its imports does -- runs none of its tests and none of
|
|
126
|
+
// its hooks: Vitest tells its collection, and the copy reports what failed
|
|
127
|
+
// with how often its mutant had run by then. Reported once per worker: a
|
|
128
|
+
// worker that runs files one after another reports each to its own copy.
|
|
129
|
+
const workerState = globalThis.__vitest_worker__;
|
|
130
|
+
if (workerState)
|
|
131
|
+
workerState.supercovReport = assignment ? (record) => report({ ...record, hits: hitsNow() }) : undefined;
|
|
132
|
+
if (workerState?.rpc && !workerState.supercovCollected) {
|
|
133
|
+
workerState.supercovCollected = true;
|
|
134
|
+
const rpc = workerState.rpc;
|
|
135
|
+
workerState.rpc = new Proxy(rpc, {
|
|
136
|
+
get(target, name) {
|
|
137
|
+
const value = Reflect.get(target, name);
|
|
138
|
+
if (name !== "onCollected" || typeof value !== "function")
|
|
139
|
+
return value;
|
|
140
|
+
return (files, ...rest) => {
|
|
141
|
+
const error = files?.find?.((file) => file?.result?.state === "fail")?.result?.errors?.[0];
|
|
142
|
+
if (error)
|
|
143
|
+
workerState.supercovReport?.({ loadError: true, message: messageOf(error) });
|
|
144
|
+
return value.call(target, files, ...rest);
|
|
145
|
+
};
|
|
146
|
+
},
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// An error as a verdict's reason says it.
|
|
151
|
+
function messageOf(error) {
|
|
152
|
+
return `${error?.message ?? error}`.slice(0, 300);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// The first hook of `suite` or a suite in it that failed (a `beforeAll`
|
|
156
|
+
// that threw): Vitest records it on its suite and skips the suite's tests.
|
|
157
|
+
function failedHook(suite) {
|
|
158
|
+
if (!suite || suite.type === "test")
|
|
159
|
+
return undefined;
|
|
160
|
+
const own = suite.result?.errors?.[0];
|
|
161
|
+
if (own)
|
|
162
|
+
return own;
|
|
163
|
+
for (const child of suite.tasks ?? []) {
|
|
164
|
+
const error = failedHook(child);
|
|
165
|
+
if (error)
|
|
166
|
+
return error;
|
|
167
|
+
}
|
|
168
|
+
return undefined;
|
|
169
|
+
}
|
|
170
|
+
|
|
120
171
|
if (assignment) {
|
|
121
172
|
process.on("uncaughtException", outsideTests);
|
|
122
173
|
process.on("unhandledRejection", outsideTests);
|
|
@@ -206,9 +257,16 @@ const LEFT_RUNNING_PROBE_EVALUATIONS = Math.ceil(LEFT_RUNNING_EVALUATIONS * LEFT
|
|
|
206
257
|
// clock (vi.useFakeTimers) and leaves it faked must not hold the look up.
|
|
207
258
|
const realSetTimeout = globalThis.setTimeout;
|
|
208
259
|
const pause = (ms) => new Promise((resolve) => realSetTimeout(resolve, ms));
|
|
209
|
-
|
|
260
|
+
// No parameter is declared: Vitest 4 reads a suite hook's first one as the
|
|
261
|
+
// fixtures it asks for, and passes the suite second (Vitest 1-3, first).
|
|
262
|
+
afterAll(async function () {
|
|
210
263
|
if (!assignment)
|
|
211
264
|
return;
|
|
265
|
+
// A hook that failed skipped its suite's tests: what failed, and how
|
|
266
|
+
// often the mutant had run by the file's end.
|
|
267
|
+
const hook = failedHook([...arguments].find((value) => value?.type === "suite"));
|
|
268
|
+
if (hook)
|
|
269
|
+
report({ hook: true, message: messageOf(hook), hits: hitsNow() });
|
|
212
270
|
if (assignment.mutant && runtime.mutantHitCount) {
|
|
213
271
|
const before = runtime.mutantHitCount();
|
|
214
272
|
await pause(LEFT_RUNNING_PROBE_MS);
|
|
@@ -148,6 +148,12 @@ function readOutcome(out) {
|
|
|
148
148
|
outcome.doneAt = record.at;
|
|
149
149
|
outcome.channelLost = Boolean(record.channelLost);
|
|
150
150
|
}
|
|
151
|
+
// Its test file did not load or set up, or a hook failed and its
|
|
152
|
+
// suite's tests were skipped: the first such error.
|
|
153
|
+
else if (record.loadError)
|
|
154
|
+
outcome.loadError ??= record;
|
|
155
|
+
else if (record.hook)
|
|
156
|
+
outcome.hook ??= record;
|
|
151
157
|
else if (record.test)
|
|
152
158
|
outcome.tests.push(record);
|
|
153
159
|
else if (record.outside)
|
|
@@ -1138,7 +1144,7 @@ async function drive(vitest, runFiles, specs, plan, resultsPath) {
|
|
|
1138
1144
|
entry.state = "waiting";
|
|
1139
1145
|
if (outcome.cancelled && !outcome.claimed && !stalled && ++entry.tries < 3)
|
|
1140
1146
|
return;
|
|
1141
|
-
const failed = outcome.tests.some((test) => test.failed);
|
|
1147
|
+
const failed = outcome.tests.some((test) => test.failed) || Boolean(outcome.hook);
|
|
1142
1148
|
if ((failed || !outcome.done) && !entry.whole) {
|
|
1143
1149
|
entry.whole = true;
|
|
1144
1150
|
entry.tests = new Set();
|
|
@@ -1166,6 +1172,8 @@ async function drive(vitest, runFiles, specs, plan, resultsPath) {
|
|
|
1166
1172
|
wholeBaseline.add(entry.file);
|
|
1167
1173
|
if (outcome.outside.length)
|
|
1168
1174
|
baselineFailed.add(`${entry.file}#outside`);
|
|
1175
|
+
if (outcome.hook)
|
|
1176
|
+
baselineFailed.add(`${entry.file}#hook`);
|
|
1169
1177
|
if (!outcome.done)
|
|
1170
1178
|
baselineFailed.add(`${entry.file}#file`);
|
|
1171
1179
|
for (const test of outcome.tests)
|
|
@@ -1285,7 +1293,8 @@ async function drive(vitest, runFiles, specs, plan, resultsPath) {
|
|
|
1285
1293
|
job.confirming.splice(job.confirming.indexOf(waiting), 1);
|
|
1286
1294
|
const alsoWithout = evidence.test ? result.failed.has(evidence.test)
|
|
1287
1295
|
: evidence.outside ? result.outside
|
|
1288
|
-
:
|
|
1296
|
+
: evidence.hook ? result.hook
|
|
1297
|
+
: !result.done;
|
|
1289
1298
|
if (!alsoWithout) {
|
|
1290
1299
|
finish(job, verdict);
|
|
1291
1300
|
return;
|
|
@@ -1394,6 +1403,10 @@ async function drive(vitest, runFiles, specs, plan, resultsPath) {
|
|
|
1394
1403
|
// the same way without the mutant.
|
|
1395
1404
|
kill({ unfinished: true }, { status: "timeout", killedBy: group.file, reason: "its test file stopped before its end, past its limit" });
|
|
1396
1405
|
}
|
|
1406
|
+
// Its file did not load or set up before the mutant ran: not the
|
|
1407
|
+
// mutant's doing.
|
|
1408
|
+
else if (outcome.loadError?.hits === 0)
|
|
1409
|
+
finish(job, { status: "error", reason: `its copy of ${group.file} did not load before the mutant ran: ${outcome.loadError.message}` });
|
|
1397
1410
|
else if (!outcome.done) {
|
|
1398
1411
|
// The copy started and its file did not finish: the mutant
|
|
1399
1412
|
// broke it while it loaded or ran.
|
|
@@ -1402,6 +1415,9 @@ async function drive(vitest, runFiles, specs, plan, resultsPath) {
|
|
|
1402
1415
|
else
|
|
1403
1416
|
kill({ unfinished: true }, { status: "killed", killedBy: group.file, reason: "the test file did not finish" });
|
|
1404
1417
|
}
|
|
1418
|
+
// A hook failed with the mutant, as it does not without it.
|
|
1419
|
+
else if (outcome.hook?.hits > 0 && !baselineFailed.has(`${group.file}#hook`))
|
|
1420
|
+
kill({ hook: true }, { status: "killed", killedBy: group.file, reason: `a hook failed: ${outcome.hook.message}` });
|
|
1405
1421
|
else {
|
|
1406
1422
|
const short = ranNone(claim, outcome, { order: baselineOrder.get(group.file) }, group.file);
|
|
1407
1423
|
if (short)
|
|
@@ -1420,6 +1436,7 @@ async function drive(vitest, runFiles, specs, plan, resultsPath) {
|
|
|
1420
1436
|
check.result = {
|
|
1421
1437
|
failed: new Set(outcome.tests.filter((test) => test.failed).map((test) => test.test)),
|
|
1422
1438
|
outside: outcome.outside.length > 0,
|
|
1439
|
+
hook: Boolean(outcome.hook),
|
|
1423
1440
|
// A copy no worker took cannot say the tests fail without the
|
|
1424
1441
|
// mutant: the kill stands.
|
|
1425
1442
|
done: outcome.done || !outcome.claimed,
|
|
@@ -1463,9 +1480,13 @@ async function drive(vitest, runFiles, specs, plan, resultsPath) {
|
|
|
1463
1480
|
const missing = expected.filter((id) => !ran.has(id));
|
|
1464
1481
|
if (!missing.length && (ran.size || !claim.wholeFile))
|
|
1465
1482
|
return undefined;
|
|
1483
|
+
// What kept them from running, where the copy said: a hook that
|
|
1484
|
+
// failed, or its file not loading.
|
|
1485
|
+
const why = outcome.hook ?? outcome.loadError;
|
|
1486
|
+
const said = why ? `: ${why.message}` : "";
|
|
1466
1487
|
if (!ran.size)
|
|
1467
|
-
return `its copy of ${file} ran none of the tests it was to run`;
|
|
1468
|
-
return `its copy of ${file} ran ${expected.length - missing.length} of the ${expected.length} tests it was to run`;
|
|
1488
|
+
return `its copy of ${file} ran none of the tests it was to run${said}`;
|
|
1489
|
+
return `its copy of ${file} ran ${expected.length - missing.length} of the ${expected.length} tests it was to run${said}`;
|
|
1469
1490
|
}
|
|
1470
1491
|
async function runContinuous() {
|
|
1471
1492
|
// Each file's baselines: `union` (its mutants' candidates together)
|
|
@@ -1510,7 +1531,7 @@ async function drive(vitest, runFiles, specs, plan, resultsPath) {
|
|
|
1510
1531
|
entry.state = "waiting";
|
|
1511
1532
|
return;
|
|
1512
1533
|
}
|
|
1513
|
-
if (shape === "union" && (!outcome.done || outcome.tests.some((test) => test.failed))) {
|
|
1534
|
+
if (shape === "union" && (!outcome.done || outcome.hook || outcome.tests.some((test) => test.failed))) {
|
|
1514
1535
|
// Recorded, and the file's copies run whole from now on.
|
|
1515
1536
|
entry.state = "known";
|
|
1516
1537
|
entry.done = false;
|
|
@@ -1523,6 +1544,9 @@ async function drive(vitest, runFiles, specs, plan, resultsPath) {
|
|
|
1523
1544
|
entry.order = outcome.tests.map((test) => test.test);
|
|
1524
1545
|
entry.failed = new Set(outcome.tests.filter((test) => test.failed).map((test) => test.test));
|
|
1525
1546
|
entry.outside = outcome.outside.length > 0;
|
|
1547
|
+
// A hook of the file fails without a mutant too: one that fails
|
|
1548
|
+
// with a mutant says nothing of it.
|
|
1549
|
+
entry.hook = Boolean(outcome.hook);
|
|
1526
1550
|
if (outcome.done) {
|
|
1527
1551
|
entry.copyMs = outcome.doneAt - outcome.claimedAt;
|
|
1528
1552
|
let testsMs = 0;
|
|
@@ -1568,8 +1592,7 @@ async function drive(vitest, runFiles, specs, plan, resultsPath) {
|
|
|
1568
1592
|
provide(vitest, { root, stage: directory });
|
|
1569
1593
|
const fileKeyOf = new Map();
|
|
1570
1594
|
const nextIndex = new Map();
|
|
1571
|
-
// Every mutant's files, in the order it would take them
|
|
1572
|
-
// work left first (long chains do not end the pass).
|
|
1595
|
+
// Every mutant's files, in the order it would take them.
|
|
1573
1596
|
// A copy of the whole file costs what its tests took in the measured
|
|
1574
1597
|
// run (its whole baseline may never run).
|
|
1575
1598
|
const estimateC = (group) => shapeOf(group) === "whole"
|
|
@@ -1584,7 +1607,14 @@ async function drive(vitest, runFiles, specs, plan, resultsPath) {
|
|
|
1584
1607
|
job.confirmingKills = 0;
|
|
1585
1608
|
}
|
|
1586
1609
|
const idle = (job) => !job.done && !job.open && !job.confirmingKills;
|
|
1587
|
-
|
|
1610
|
+
// The cheapest mutants first, the plan's order (its estimate)
|
|
1611
|
+
// between equals: a pass cut short -- a budget, a job's time limit --
|
|
1612
|
+
// has decided as many as it could, where the costliest first spent a
|
|
1613
|
+
// large suite's whole budget on a few dozen of them. A worker with
|
|
1614
|
+
// no mutant waiting takes the next file of the one with the most
|
|
1615
|
+
// work left (`besides`), so that long chains do not end the pass.
|
|
1616
|
+
const order = [...pending].sort((a, b) => remainingOf(a) - remainingOf(b));
|
|
1617
|
+
const besides = [...order].reverse();
|
|
1588
1618
|
const rankOf = new Map(order.map((job, rank) => [job, rank]));
|
|
1589
1619
|
const checks = [];
|
|
1590
1620
|
const waiters = [];
|
|
@@ -1685,7 +1715,7 @@ async function drive(vitest, runFiles, specs, plan, resultsPath) {
|
|
|
1685
1715
|
// next file beside it (the most work left first). Its verdict
|
|
1686
1716
|
// is the same either way; a copy its mutant's kill makes moot is
|
|
1687
1717
|
// stopped.
|
|
1688
|
-
for (const job of
|
|
1718
|
+
for (const job of besides) {
|
|
1689
1719
|
if (job.done || job.confirmingKills || !job.open)
|
|
1690
1720
|
continue;
|
|
1691
1721
|
const group = nextOf(job);
|
|
@@ -1820,7 +1850,10 @@ async function drive(vitest, runFiles, specs, plan, resultsPath) {
|
|
|
1820
1850
|
// once; a failure that repeats counts (the mutant may have run in
|
|
1821
1851
|
// a process the copy started).
|
|
1822
1852
|
const unevaluated = (evidence) => evidence?.hits === 0;
|
|
1823
|
-
|
|
1853
|
+
// A hook that failed (its suite's tests skipped), or a file that
|
|
1854
|
+
// did not load or set up, where the file's baseline had neither.
|
|
1855
|
+
const broke = failed || outside ? undefined : outcome.loadError ?? (entry.hook ? undefined : outcome.hook);
|
|
1856
|
+
if (!group.rerunUnevaluated && (unevaluated(failed) || (!failed && unevaluated(outside)) || unevaluated(broke))) {
|
|
1824
1857
|
group.rerunUnevaluated = true;
|
|
1825
1858
|
profile.unevaluatedReruns += 1;
|
|
1826
1859
|
job.ran -= outcome.tests.length;
|
|
@@ -1836,8 +1869,16 @@ async function drive(vitest, runFiles, specs, plan, resultsPath) {
|
|
|
1836
1869
|
: { status: "killed", killedBy: group.file, reason: `an error outside any test: ${outside.message}` });
|
|
1837
1870
|
else if (outcome.hung)
|
|
1838
1871
|
kill(job, group, claim, outcome, { unfinished: true }, { status: "timeout", killedBy: group.file, reason: "its test file stopped before its end, past its limit" });
|
|
1872
|
+
// It broke again before the mutant ran, as it did the first
|
|
1873
|
+
// time: not the mutant's doing, and its tests did not run.
|
|
1874
|
+
else if (unevaluated(broke))
|
|
1875
|
+
finishC(job, { status: "error", reason: `its copy of ${group.file} ${broke.loadError ? "did not load" : "ran no test: a hook failed"} before the mutant ran, twice: ${broke.message}` });
|
|
1839
1876
|
else if (!outcome.done)
|
|
1840
1877
|
kill(job, group, claim, outcome, { unfinished: true }, { status: "killed", killedBy: group.file, reason: "the test file did not finish" });
|
|
1878
|
+
// A hook failed with the mutant, as it does not without it: the
|
|
1879
|
+
// run fails, as Vitest's own does where a hook fails.
|
|
1880
|
+
else if (broke)
|
|
1881
|
+
kill(job, group, claim, outcome, { hook: true }, { status: "killed", killedBy: group.file, reason: `a hook failed: ${broke.message}` });
|
|
1841
1882
|
else if (ranNone(claim, outcome, entry, group.file))
|
|
1842
1883
|
finishC(job, { status: "error", reason: ranNone(claim, outcome, entry, group.file) });
|
|
1843
1884
|
else
|
|
@@ -1858,7 +1899,8 @@ async function drive(vitest, runFiles, specs, plan, resultsPath) {
|
|
|
1858
1899
|
}
|
|
1859
1900
|
const alsoWithout = evidence.test ? result.failed.has(evidence.test)
|
|
1860
1901
|
: evidence.outside ? result.outside
|
|
1861
|
-
:
|
|
1902
|
+
: evidence.hook ? result.hook
|
|
1903
|
+
: !result.done;
|
|
1862
1904
|
if (!alsoWithout) {
|
|
1863
1905
|
finishC(job, verdict);
|
|
1864
1906
|
return;
|
|
@@ -1879,6 +1921,7 @@ async function drive(vitest, runFiles, specs, plan, resultsPath) {
|
|
|
1879
1921
|
check.result = {
|
|
1880
1922
|
failed: new Set(outcome.tests.filter((test) => test.failed).map((test) => test.test)),
|
|
1881
1923
|
outside: outcome.outside.length > 0,
|
|
1924
|
+
hook: Boolean(outcome.hook),
|
|
1882
1925
|
done: outcome.done || !outcome.claimed,
|
|
1883
1926
|
};
|
|
1884
1927
|
// A run of the whole file with no mutant is its whole baseline.
|