supercov 4.30.2 → 4.30.3
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
|
@@ -1302,11 +1302,12 @@ The merged run keeps the strong verdicts the runs saved (`mutants test`,
|
|
|
1302
1302
|
from each run, and how many the merged run's plan decides without running
|
|
1303
1303
|
them (`1265 strong verdict(s) kept from runs r8, r7: 1103 from r8, 150 from
|
|
1304
1304
|
r7, 12 the merged run's plan decides`). A verdict two runs hold alike counts
|
|
1305
|
-
for the first run named. A kill in any run is a kill. A survival stands only
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1305
|
+
for the first run named. A kill in any run is a kill. A survival stands only
|
|
1306
|
+
where every test of the merged suite that could kill it ran with the mutant in
|
|
1307
|
+
a run that let it survive, or in one whose tests passed without running the
|
|
1308
|
+
mutated code; where another run's tests could, and it has no verdict, the
|
|
1309
|
+
mutant is left for a pass over the merged run to run. An error stands only
|
|
1310
|
+
where no run holds anything else. A run whose verdicts are of another mutant set than the
|
|
1310
1311
|
merged run lists lends none, and `merge` names it; a run some of whose tests
|
|
1311
1312
|
another measured again lends none either. Split a strong pass across jobs this
|
|
1312
1313
|
way: each job measures and runs `supercov mutants --shard k/n -- <command>`,
|
package/docs/mutation.md
CHANGED
|
@@ -643,6 +643,20 @@ no mutants shows none of this.
|
|
|
643
643
|
- **Jest and Mocha** run in resident runners, as StrykerJS's do; `node:test`,
|
|
644
644
|
AVA, node-tap, `bun:test` and Vitest Browser Mode run one test file per
|
|
645
645
|
start of the command, with the mutant on from its start.
|
|
646
|
+
Jobs run side by side, several of one test file at once. A test file that
|
|
647
|
+
does not run beside a copy of itself as it does alone (a server on a fixed
|
|
648
|
+
port, a fixed temporary path) would let one job's tests reach another's
|
|
649
|
+
server, with another mutant or none. Its first baseline runs as two copies
|
|
650
|
+
at once, and where they end differently its jobs run one at a time, and
|
|
651
|
+
the pass names it (`[supercov] tests/api.test.ts does not run beside a copy
|
|
652
|
+
of itself ...`). Giving such a test a free port makes it fast again. Two
|
|
653
|
+
copies without a mutant that share a server can both pass, as either
|
|
654
|
+
server answers alike; such a file is not caught, and only its own free
|
|
655
|
+
port makes its verdicts sound.
|
|
656
|
+
A job past its limit runs again beside its tests without the mutant (a
|
|
657
|
+
control), under the same load, its limit 3× the slower of the control and
|
|
658
|
+
its baseline, and 10 s; the pass no longer waits for the machine to empty
|
|
659
|
+
first, which kept it half idle where some jobs take minutes.
|
|
646
660
|
- Rust compiled to wasm and loaded by these tests is mutated too:
|
|
647
661
|
the command builds the wasm with the mutants switched in, and each wasm
|
|
648
662
|
instance, in Node or in a Playwright page, runs the test's mutant.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "supercov",
|
|
3
|
-
"version": "4.30.
|
|
3
|
+
"version": "4.30.3",
|
|
4
4
|
"description": "Coverage, security and code quality for coding agents",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"coverage",
|
|
@@ -126,14 +126,14 @@
|
|
|
126
126
|
"test:windows-tls": "node scripts/windows-tls-test.mjs"
|
|
127
127
|
},
|
|
128
128
|
"optionalDependencies": {
|
|
129
|
-
"@supercov/cli-darwin-arm64": "4.30.
|
|
130
|
-
"@supercov/cli-darwin-x64": "4.30.
|
|
131
|
-
"@supercov/cli-linux-arm64-gnu": "4.30.
|
|
132
|
-
"@supercov/cli-linux-arm64-musl": "4.30.
|
|
133
|
-
"@supercov/cli-linux-x64-gnu": "4.30.
|
|
134
|
-
"@supercov/cli-linux-x64-musl": "4.30.
|
|
135
|
-
"@supercov/cli-win32-arm64": "4.30.
|
|
136
|
-
"@supercov/cli-win32-x64": "4.30.
|
|
129
|
+
"@supercov/cli-darwin-arm64": "4.30.3",
|
|
130
|
+
"@supercov/cli-darwin-x64": "4.30.3",
|
|
131
|
+
"@supercov/cli-linux-arm64-gnu": "4.30.3",
|
|
132
|
+
"@supercov/cli-linux-arm64-musl": "4.30.3",
|
|
133
|
+
"@supercov/cli-linux-x64-gnu": "4.30.3",
|
|
134
|
+
"@supercov/cli-linux-x64-musl": "4.30.3",
|
|
135
|
+
"@supercov/cli-win32-arm64": "4.30.3",
|
|
136
|
+
"@supercov/cli-win32-x64": "4.30.3"
|
|
137
137
|
},
|
|
138
138
|
"peerDependencies": {
|
|
139
139
|
"@playwright/test": ">=1.55.0",
|
|
@@ -196,6 +196,10 @@ function wrappedRegistration(original, parentTestId, forcedStatus) {
|
|
|
196
196
|
// environment while testing integrations. Keep this attempt's transport
|
|
197
197
|
// destination fixed to the value present when the test was registered.
|
|
198
198
|
beginBufferedServerEvidence(scope);
|
|
199
|
+
// How long the test took, its t.after callbacks included: a
|
|
200
|
+
// strong pass orders a mutant's test files and sets its limits
|
|
201
|
+
// by it, and took every node:test test for 1 s without it.
|
|
202
|
+
const begun = performance.now();
|
|
199
203
|
// A todo test runs, and stays todo whether its body passes or fails.
|
|
200
204
|
let status = marked ?? "passed";
|
|
201
205
|
const job = strongJob();
|
|
@@ -234,7 +238,7 @@ function wrappedRegistration(original, parentTestId, forcedStatus) {
|
|
|
234
238
|
return;
|
|
235
239
|
emitted = true;
|
|
236
240
|
const flushedServerEvidence = flushBufferedServerEvidence(scope);
|
|
237
|
-
writeRunnerEvidence(identity, nextStatus, scope, evidenceDirectory, takeNodeAssertionPhases(scope), flushedServerEvidence);
|
|
241
|
+
writeRunnerEvidence(identity, nextStatus, scope, evidenceDirectory, takeNodeAssertionPhases(scope), flushedServerEvidence, false, performance.now() - begun);
|
|
238
242
|
};
|
|
239
243
|
const finishBody = () => {
|
|
240
244
|
// User t.after callbacks run after the body. Register last so
|
|
@@ -125,7 +125,7 @@ export function readScopedServerEvidence(scope, evidencePath = serverEvidencePat
|
|
|
125
125
|
return [];
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
|
-
export function writeRunnerEvidence(identity, status, scope, evidenceDirectoryOverride, phases = [], serverEvidenceSource, snapshot = false) {
|
|
128
|
+
export function writeRunnerEvidence(identity, status, scope, evidenceDirectoryOverride, phases = [], serverEvidenceSource, snapshot = false, durationMs = undefined) {
|
|
129
129
|
const evidenceDirectory = evidenceDirectoryOverride ?? process.env["SUPERCOV_EVIDENCE_DIR"];
|
|
130
130
|
if (!evidenceDirectory)
|
|
131
131
|
return;
|
|
@@ -138,6 +138,7 @@ export function writeRunnerEvidence(identity, status, scope, evidenceDirectoryOv
|
|
|
138
138
|
title: identity.name.split(" > ").at(-1) ?? identity.name,
|
|
139
139
|
retry: identity.retry ?? 0,
|
|
140
140
|
status,
|
|
141
|
+
...(typeof durationMs === "number" ? { durationMs: Math.round(durationMs) } : {}),
|
|
141
142
|
...(identity.role ? { role: identity.role } : {}),
|
|
142
143
|
provenance: inferTestProvenance({
|
|
143
144
|
runner: identity.runner,
|
|
@@ -28,9 +28,13 @@
|
|
|
28
28
|
// only have waited: on the jobs beside it (the CPU; Cargo's lock on a build
|
|
29
29
|
// directory, where each job builds Rust compiled to wasm), or on a machine
|
|
30
30
|
// busier than when its baseline ran (other work on it, beyond the pass's
|
|
31
|
-
// own). So
|
|
32
|
-
//
|
|
33
|
-
// baseline, and 10 s: only a job past that is a timeout.
|
|
31
|
+
// own). So its tests run again without the mutant, beside the same jobs
|
|
32
|
+
// (a control), and the mutant again after them, its limit 3x the slower of
|
|
33
|
+
// that run and its baseline, and 10 s: only a job past that is a timeout.
|
|
34
|
+
// Nothing waits for the machine to empty. A test file runs beside a copy of
|
|
35
|
+
// itself, as a pass runs many mutants against one file at once; one whose
|
|
36
|
+
// first baseline does not do there what it does alone (a fixed port, a fixed
|
|
37
|
+
// path) runs one job at a time from then on, and the pass says so.
|
|
34
38
|
import { fork, spawn } from "node:child_process";
|
|
35
39
|
import { appendFileSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
36
40
|
import { availableParallelism, constants, cpus } from "node:os";
|
|
@@ -106,49 +110,6 @@ export function slots(size) {
|
|
|
106
110
|
};
|
|
107
111
|
}
|
|
108
112
|
|
|
109
|
-
// Turns at the machine: `shared` work runs beside other shared work, and
|
|
110
|
-
// `alone` work waits until none runs, while no shared work starts. A shared
|
|
111
|
-
// turn learns whether other work ran beside it (`crowded`).
|
|
112
|
-
export function turns() {
|
|
113
|
-
const running = new Set();
|
|
114
|
-
const idle = [];
|
|
115
|
-
let alone;
|
|
116
|
-
return {
|
|
117
|
-
async shared(work) {
|
|
118
|
-
while (alone)
|
|
119
|
-
await alone;
|
|
120
|
-
const turn = { crowded: running.size > 0 };
|
|
121
|
-
for (const other of running)
|
|
122
|
-
other.crowded = true;
|
|
123
|
-
running.add(turn);
|
|
124
|
-
try {
|
|
125
|
-
return await work(turn);
|
|
126
|
-
}
|
|
127
|
-
finally {
|
|
128
|
-
running.delete(turn);
|
|
129
|
-
if (running.size === 0)
|
|
130
|
-
for (const wake of idle.splice(0))
|
|
131
|
-
wake();
|
|
132
|
-
}
|
|
133
|
-
},
|
|
134
|
-
async alone(work) {
|
|
135
|
-
while (alone)
|
|
136
|
-
await alone;
|
|
137
|
-
let end;
|
|
138
|
-
alone = new Promise((done) => { end = done; });
|
|
139
|
-
try {
|
|
140
|
-
if (running.size > 0)
|
|
141
|
-
await new Promise((wake) => idle.push(wake));
|
|
142
|
-
return await work({ crowded: false });
|
|
143
|
-
}
|
|
144
|
-
finally {
|
|
145
|
-
alone = undefined;
|
|
146
|
-
end();
|
|
147
|
-
}
|
|
148
|
-
},
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
|
|
152
113
|
// Every file under `directory`, recursively.
|
|
153
114
|
function filesUnder(directory) {
|
|
154
115
|
let entries;
|
|
@@ -732,19 +693,28 @@ export async function drive({ command, build, plan, resultsPath, root = process.
|
|
|
732
693
|
});
|
|
733
694
|
return handed ? parallel(work, priority) : result;
|
|
734
695
|
};
|
|
735
|
-
const profile = { jobs: 0, baselines: 0, confirmations: 0, overturned: 0, stopped: 0,
|
|
736
|
-
|
|
696
|
+
const profile = { jobs: 0, baselines: 0, confirmations: 0, overturned: 0, stopped: 0, controls: 0, jobMs: 0, residentJobs: 0, residentFallbacks: 0, oneAtATime: [] };
|
|
697
|
+
// Test files that do not run as they should beside a copy of
|
|
698
|
+
// themselves: one job of each at a time, in turn.
|
|
699
|
+
const oneAtATime = new Map();
|
|
737
700
|
let jobNumber = 0;
|
|
738
701
|
|
|
739
702
|
// One start of the command: `tests` of `file` (null: all of them), with
|
|
740
703
|
// `mutant` on (null: none), stopped at `limitMs`. A job of a mutant's
|
|
741
704
|
// later batch (`priority` 1, 2, ...) waits behind every first file's,
|
|
742
705
|
// so that the kills most mutants get at once come first, and a
|
|
743
|
-
// survivor's many files fill what is left.
|
|
744
|
-
//
|
|
745
|
-
function job({ mutant, file, tests: chosen, bail, limitMs, priority = 0,
|
|
746
|
-
const start = (work) =>
|
|
747
|
-
|
|
706
|
+
// survivor's many files fill what is left. A job of a file that runs one
|
|
707
|
+
// at a time waits for the file's job before it, then for a slot.
|
|
708
|
+
function job({ mutant, file, tests: chosen, bail, limitMs, priority = 0, command: asCommand = false, handle }) {
|
|
709
|
+
const start = (work) => {
|
|
710
|
+
const before = oneAtATime.get(file);
|
|
711
|
+
if (before === undefined)
|
|
712
|
+
return run(work, priority);
|
|
713
|
+
const mine = before.then(() => run(work, priority));
|
|
714
|
+
oneAtATime.set(file, mine.catch(() => undefined));
|
|
715
|
+
return mine;
|
|
716
|
+
};
|
|
717
|
+
return start(() => new Promise((resolveJob) => {
|
|
748
718
|
const number = ++jobNumber;
|
|
749
719
|
profile.jobs += 1;
|
|
750
720
|
const directory = join(work, String(number));
|
|
@@ -762,7 +732,7 @@ export async function drive({ command, build, plan, resultsPath, root = process.
|
|
|
762
732
|
const statuses = outcomes(evidence);
|
|
763
733
|
if (environment.SUPERCOV_STRONG_KEEP !== "1")
|
|
764
734
|
rmSync(directory, { recursive: true, force: true });
|
|
765
|
-
return { ...outcome, statuses
|
|
735
|
+
return { ...outcome, statuses };
|
|
766
736
|
};
|
|
767
737
|
// A runner's own command, started for this job alone.
|
|
768
738
|
const spawnJob = () => {
|
|
@@ -810,11 +780,19 @@ export async function drive({ command, build, plan, resultsPath, root = process.
|
|
|
810
780
|
child.stdout.resume();
|
|
811
781
|
child.stderr.resume();
|
|
812
782
|
let timedOut = false;
|
|
813
|
-
const
|
|
783
|
+
const expire = () => {
|
|
814
784
|
timedOut = true;
|
|
815
785
|
profile.stopped += 1;
|
|
816
786
|
stop(child);
|
|
817
|
-
}
|
|
787
|
+
};
|
|
788
|
+
let timer = setTimeout(expire, handle?.limitMs ?? limitMs);
|
|
789
|
+
// A job started beside its control is given its limit
|
|
790
|
+
// once the control ends, or starts with it.
|
|
791
|
+
if (handle)
|
|
792
|
+
handle.setLimit = (ms) => {
|
|
793
|
+
clearTimeout(timer);
|
|
794
|
+
timer = setTimeout(expire, Math.max(0, begun + ms - Date.now()));
|
|
795
|
+
};
|
|
818
796
|
const finish = (code, error) => {
|
|
819
797
|
clearTimeout(timer);
|
|
820
798
|
profile.jobMs += Date.now() - begun;
|
|
@@ -905,12 +883,32 @@ export async function drive({ command, build, plan, resultsPath, root = process.
|
|
|
905
883
|
.reduce((sum, id) => sum + (byId.get(id)?.durationMs ?? 1_000), 0);
|
|
906
884
|
const baselineLimit = (file, chosen) => 3 * cost(file, chosen) + baselineGraceMs;
|
|
907
885
|
const passedAll = (result, chosen) => !result.timedOut && [...chosen].every((id) => result.statuses.get(id) === "passed");
|
|
886
|
+
// A file's first baseline: two copies at once, where the pass runs jobs
|
|
887
|
+
// side by side. Where the copies end alike, the file runs beside itself
|
|
888
|
+
// as it does alone; where they do not, its jobs run one at a time from
|
|
889
|
+
// then on, and its baseline runs again so.
|
|
890
|
+
const probed = new Set();
|
|
891
|
+
const alike = (one, other) => one.timedOut === other.timedOut
|
|
892
|
+
&& one.statuses.size === other.statuses.size
|
|
893
|
+
&& [...one.statuses].every(([id, status]) => other.statuses.get(id) === status);
|
|
894
|
+
async function baselineJob(spec) {
|
|
895
|
+
if (workers < 2 || probed.has(spec.file) || oneAtATime.has(spec.file))
|
|
896
|
+
return job(spec);
|
|
897
|
+
probed.add(spec.file);
|
|
898
|
+
const [one, other] = await Promise.all([job(spec), job(spec)]);
|
|
899
|
+
if (alike(one, other))
|
|
900
|
+
return one;
|
|
901
|
+
oneAtATime.set(spec.file, Promise.resolve());
|
|
902
|
+
profile.oneAtATime.push(spec.file);
|
|
903
|
+
console.error(`[supercov] ${spec.file} does not run beside a copy of itself as it runs alone (a fixed port or path?): its jobs run one at a time`);
|
|
904
|
+
return job(spec);
|
|
905
|
+
}
|
|
908
906
|
async function wholeBaseline(file) {
|
|
909
907
|
const state = fileState(file);
|
|
910
908
|
state.whole ??= (async () => {
|
|
911
909
|
const once = async () => {
|
|
912
910
|
profile.baselines += 1;
|
|
913
|
-
const result = await
|
|
911
|
+
const result = await baselineJob({ mutant: null, file, tests: null, bail: false, limitMs: baselineLimit(file, null) });
|
|
914
912
|
const passing = new Set([...result.statuses].filter(([, status]) => status === "passed").map(([id]) => id));
|
|
915
913
|
return { ...result, passing, finished: !result.timedOut && passing.size > 0 };
|
|
916
914
|
};
|
|
@@ -937,7 +935,7 @@ export async function drive({ command, build, plan, resultsPath, root = process.
|
|
|
937
935
|
const once = async () => {
|
|
938
936
|
profile.baselines += 1;
|
|
939
937
|
const chosen = new Set(state.union);
|
|
940
|
-
const result = await
|
|
938
|
+
const result = await baselineJob({ mutant: null, file, tests: chosen, bail: false, limitMs: baselineLimit(file, chosen) });
|
|
941
939
|
return { ...result, chosen, finished: passedAll(result, chosen) };
|
|
942
940
|
};
|
|
943
941
|
return commandWhereResidentFails(file, once, (result) => result.finished);
|
|
@@ -981,18 +979,40 @@ export async function drive({ command, build, plan, resultsPath, root = process.
|
|
|
981
979
|
const killerIn = (outcome) => [...outcome.statuses].find(([id, status]) => status === "failed" && (chosen === null || chosen.has(id)) && !excluded(id))?.[0];
|
|
982
980
|
// Past its limit with nothing failed: it may only have waited, on
|
|
983
981
|
// the jobs beside it or on a machine busier than when its
|
|
984
|
-
// baseline ran. It runs again
|
|
985
|
-
//
|
|
986
|
-
//
|
|
982
|
+
// baseline ran. It runs again beside the same tests without the
|
|
983
|
+
// mutant (a control), under the same load, and its limit is 3x
|
|
984
|
+
// the slower of the control and its baseline, and the grace: at
|
|
985
|
+
// the machine's speed now. Neither waits for the machine to
|
|
986
|
+
// empty, which, with long jobs, kept it half idle.
|
|
987
987
|
if (result.timedOut && !result.mutantTimedOut && killerIn(result) === undefined) {
|
|
988
|
-
profile.
|
|
988
|
+
profile.controls += 1;
|
|
989
989
|
// A resident runner's limit is tighter than a command's, which
|
|
990
990
|
// starts the runner and the browser within it: the job runs
|
|
991
991
|
// again as a command, with a command's limit.
|
|
992
992
|
const asCommand = Boolean(result.resident);
|
|
993
|
-
const
|
|
994
|
-
const
|
|
995
|
-
|
|
993
|
+
const controlLimit = baselineLimit(group.file, chosen);
|
|
994
|
+
const limitAfter = (control) => 3 * Math.max(baseline.durationMs, control.durationMs) + aloneGraceMs;
|
|
995
|
+
const control = { mutant: null, file: group.file, tests: chosen, bail: false, limitMs: controlLimit, priority: -1, command: asCommand };
|
|
996
|
+
// A resident runner cannot change a job's limit once it
|
|
997
|
+
// runs: the control first, then the mutant. (A file that
|
|
998
|
+
// runs one job at a time runs them so anyway, its control
|
|
999
|
+
// queued first.)
|
|
1000
|
+
if (!asCommand && residentFor(group.file)) {
|
|
1001
|
+
const now = await job(control);
|
|
1002
|
+
result = await job({ mutant, file: group.file, tests: chosen, bail, limitMs: limitAfter(now), priority: -1, command: asCommand });
|
|
1003
|
+
}
|
|
1004
|
+
else {
|
|
1005
|
+
// Its limit is the longest the control could set, until
|
|
1006
|
+
// the control ends and sets it. The control is queued
|
|
1007
|
+
// first: with one slot, it runs first.
|
|
1008
|
+
const handle = { limitMs: limitAfter({ durationMs: controlLimit }) };
|
|
1009
|
+
const controlled = job(control);
|
|
1010
|
+
const pending = job({ mutant, file: group.file, tests: chosen, bail, limitMs: handle.limitMs, priority: -1, command: asCommand, handle });
|
|
1011
|
+
const now = await controlled;
|
|
1012
|
+
handle.limitMs = limitAfter(now);
|
|
1013
|
+
handle.setLimit?.(handle.limitMs);
|
|
1014
|
+
result = await pending;
|
|
1015
|
+
}
|
|
996
1016
|
}
|
|
997
1017
|
const ran = [...result.statuses].filter(([id, status]) => status !== "skipped" && (chosen === null || chosen.has(id)));
|
|
998
1018
|
const killer = killerIn(result);
|