supercov 4.29.10 → 4.29.12
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
|
@@ -507,7 +507,10 @@ many more). `mutants` then shows each mutant's verdict beside its weak status,
|
|
|
507
507
|
and the mutation score with the verdicts' counts; `mutants --status survived`
|
|
508
508
|
(or `killed`, `timeout`, `no-coverage`, `error`, `unviable`) lists the mutants
|
|
509
509
|
with that verdict, and `--format markdown` lists the survivors under the
|
|
510
|
-
mutation score.
|
|
510
|
+
mutation score. A Playwright mutant with many candidates that lived through
|
|
511
|
+
its first tier, with the rest of its candidates not run yet, is
|
|
512
|
+
`survived-so-far`: listed by `--status survived` as such (and alone by
|
|
513
|
+
`--status survived-so-far`), counted apart, and not in the score.
|
|
511
514
|
|
|
512
515
|
It runs far less than StrykerJS: no dry run (the measured run is one), no
|
|
513
516
|
mutant no test infected (decided `survived`) or reached (`no-coverage`), and
|
|
@@ -1019,7 +1022,9 @@ pass in the run is listed regardless.
|
|
|
1019
1022
|
per line, for a runner's filter. A Vitest, Playwright or node:test test inside
|
|
1020
1023
|
`describe` blocks is printed as the blocks and the test joined by spaces
|
|
1021
1024
|
(`small charges`), which is what `vitest -t`, `--grep` and
|
|
1022
|
-
`--test-name-pattern` match.
|
|
1025
|
+
`--test-name-pattern` match. A Rust test is printed as its path in its crate
|
|
1026
|
+
(`tests::it_works`), which `cargo test -- --exact` and nextest's `test(=...)`
|
|
1027
|
+
match. `--kind`, `--runner`, `--tag`, `--title` and
|
|
1023
1028
|
`--test-file` list only the affected tests they pick: from a run that merged two
|
|
1024
1029
|
runners' suites, `tests affected --names --runner playwright` gives Playwright
|
|
1025
1030
|
only its own tests. A helper beside the tests, or source outside what is
|
|
@@ -1032,6 +1037,20 @@ A source file
|
|
|
1032
1037
|
added since the run is outside every test's record; the working-tree check
|
|
1033
1038
|
says so, and the suite should run in full.
|
|
1034
1039
|
|
|
1040
|
+
A Rust test loads what it names by path: a fixture, a data file or a script
|
|
1041
|
+
named in its own function (or in its entry of a macro that declares a test
|
|
1042
|
+
per entry), or anywhere in its file outside another test, and what a script it
|
|
1043
|
+
names imports and names in turn. A path that goes on in a placeholder
|
|
1044
|
+
(`tests/fixtures/{name}`) names the directory before it. So a change to one
|
|
1045
|
+
fixture affects the tests that name it, and a file no test names, as before,
|
|
1046
|
+
affects every test. A file measured Rust source embeds with `include_str!` or
|
|
1047
|
+
`include_bytes!` is part of the declaration embedding it: a template or a
|
|
1048
|
+
script compiled into the binary affects the tests that ran that code. Changed
|
|
1049
|
+
code no probe of the run measured -- code for another platform, a feature the
|
|
1050
|
+
run's build left off -- is listed under `unmeasured` (`--json`) and named in
|
|
1051
|
+
the text: no test's record says what it reaches, so run the suite in full
|
|
1052
|
+
where that code is compiled.
|
|
1053
|
+
|
|
1035
1054
|
A server the suite starts is recorded too: a mock server `webServer` starts,
|
|
1036
1055
|
or the application's own. Each Node process of a Playwright run notes the
|
|
1037
1056
|
project files it loads and reads, and the tests it serves, by the test a
|
package/docs/mutation.md
CHANGED
|
@@ -152,6 +152,12 @@ mutants the tests let survive.
|
|
|
152
152
|
that passed did. The candidates are kept as verdicts are, after an edit, a
|
|
153
153
|
merge and in a later round: a candidate a change could reach runs again.
|
|
154
154
|
The Playwright driver records them.
|
|
155
|
+
- **A first tier.** A Playwright mutant with more candidates than its first
|
|
156
|
+
tier holds (32, or more where the run's kills come later) runs against
|
|
157
|
+
that tier first, every such mutant before any runs the rest. One the tier
|
|
158
|
+
lets live is `survived-so-far` until the rest runs, in the same pass where
|
|
159
|
+
it has the time: listed with the survivors as such, never in the score
|
|
160
|
+
(`docs/design/strong-mutation.md`, A first tier, then the rest).
|
|
155
161
|
- **Exit codes.** `0` with an answer; `1` when `--fail-on` or `--critical`
|
|
156
162
|
finds a mutant; `2`, after the answer, when the measured command failed (a
|
|
157
163
|
failing test kills nothing, so the verdicts cannot gate) or no mutant could
|
|
@@ -445,7 +451,12 @@ no mutants shows none of this.
|
|
|
445
451
|
against the tests that read its value, which a run measured with the
|
|
446
452
|
mutants' probes records, not every test whose server loaded the module;
|
|
447
453
|
the plan says how many were narrowed and by how much
|
|
448
|
-
(`docs/design/strong-mutation.md`, Module-level values).
|
|
454
|
+
(`docs/design/strong-mutation.md`, Module-level values). A mutant whose
|
|
455
|
+
code ran only for requests that named no test (a webhook a mock server
|
|
456
|
+
sends while tests run) runs against the tests that were running then, not
|
|
457
|
+
every test. A test runs without a mutant only after a failure, to confirm
|
|
458
|
+
it; a failure before any such run passed on its server (a cold server)
|
|
459
|
+
runs the mutant again once one has. StrykerJS has no
|
|
449
460
|
Playwright runner, so Playwright's verdicts are checked by hand (see below).
|
|
450
461
|
A test run with a mutant gets StrykerJS's time limit: its baseline (the
|
|
451
462
|
longest of its measured run and its runs without a mutant in the pass)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "supercov",
|
|
3
|
-
"version": "4.29.
|
|
3
|
+
"version": "4.29.12",
|
|
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.12",
|
|
129
|
+
"@supercov/cli-darwin-x64": "4.29.12",
|
|
130
|
+
"@supercov/cli-linux-arm64-gnu": "4.29.12",
|
|
131
|
+
"@supercov/cli-linux-arm64-musl": "4.29.12",
|
|
132
|
+
"@supercov/cli-linux-x64-gnu": "4.29.12",
|
|
133
|
+
"@supercov/cli-linux-x64-musl": "4.29.12",
|
|
134
|
+
"@supercov/cli-win32-arm64": "4.29.12",
|
|
135
|
+
"@supercov/cli-win32-x64": "4.29.12"
|
|
136
136
|
},
|
|
137
137
|
"peerDependencies": {
|
|
138
138
|
"@playwright/test": ">=1.55.0",
|
|
@@ -30,10 +30,10 @@
|
|
|
30
30
|
// The attempt's mutant goes into its scope, which reaches the app's server
|
|
31
31
|
// with every request (header, cookies, child processes) and the page through
|
|
32
32
|
// an init script. A mutant the server must start with (its code ran in work
|
|
33
|
-
// no request named, or is a server module's top level, or ran
|
|
34
|
-
// that named no test, or its switch is evaluated as a server
|
|
35
|
-
// is run alone afterwards, in an invocation of its own
|
|
36
|
-
//
|
|
33
|
+
// no request named or waited for, or is a server module's top level, or ran
|
|
34
|
+
// for a request that named no test, or its switch is evaluated as a server
|
|
35
|
+
// module loads) is run alone afterwards, in an invocation of its own with
|
|
36
|
+
// SUPERCOV_ACTIVE_MUTANT set, which the engine starts for each `restart`
|
|
37
37
|
// record the judge writes (javascript_run.rs). So do a kill (or a timeout)
|
|
38
38
|
// that ran beside another mutant's attempt or whose control failed (one test
|
|
39
39
|
// at a time), and the mutants one invocation had no room for.
|
|
@@ -67,6 +67,9 @@ const COPIES_PER_INVOCATION = 20_000;
|
|
|
67
67
|
// A test whose control fails this often in one invocation is not run again
|
|
68
68
|
// there: its mutants wait for a later invocation.
|
|
69
69
|
const CONTROL_FAILURES = 2;
|
|
70
|
+
// The copies a test gets for a cold failure's retry: the control after it
|
|
71
|
+
// and the attempt again.
|
|
72
|
+
const COLD_RETRY_COPIES = 2;
|
|
70
73
|
|
|
71
74
|
/** What a page writes to its console when its mutant passed the hit limit. */
|
|
72
75
|
export const PAGE_TIMEOUT_MARKER = "SUPERCOV_MUTANT_TIMEOUT";
|
|
@@ -394,7 +397,7 @@ function buildPass(pass, root, config) {
|
|
|
394
397
|
restarts.push({ id: mutant.id, mutant: switched, tests: ordered, reason: serverWide });
|
|
395
398
|
continue;
|
|
396
399
|
}
|
|
397
|
-
mutants.push({ id: mutant.id, mutant: switched, tests: ordered, infected });
|
|
400
|
+
mutants.push({ id: mutant.id, mutant: switched, tests: ordered, infected, ...(mutant.passedBefore ? { passedBefore: mutant.passedBefore } : {}) });
|
|
398
401
|
}
|
|
399
402
|
}
|
|
400
403
|
// What a survivor's verdict says of the candidates it was not run with.
|
|
@@ -412,8 +415,9 @@ function buildPass(pass, root, config) {
|
|
|
412
415
|
for (const entry of mutants) {
|
|
413
416
|
// Two copies a candidate (an attempt, and a control should it
|
|
414
417
|
// kill), one more where it is not the first (a sweep it may wait
|
|
415
|
-
// out), and each test's first run
|
|
416
|
-
|
|
418
|
+
// out), and each test's first run and a cold failure's retry (its
|
|
419
|
+
// control and the attempt again).
|
|
420
|
+
const added = entry.tests.reduce((sum, id, at) => sum + 2 + (at > 0 ? 1 : 0) + (queues.has(id) ? 0 : COLD_RETRY_COPIES + 1), 0);
|
|
417
421
|
if (copies && copies + added > limit && kind === "main") {
|
|
418
422
|
deferred.push({ id: entry.id });
|
|
419
423
|
continue;
|
|
@@ -438,9 +442,9 @@ function buildPass(pass, root, config) {
|
|
|
438
442
|
test.queue = queue.map((job) => job.id);
|
|
439
443
|
const where = declarationKey(resolve(root, test.file), test.title);
|
|
440
444
|
// A copy for each sweep the test may wait out: one for each mutant
|
|
441
|
-
// with a candidate before it.
|
|
445
|
+
// with a candidate before it; and a cold failure's retry.
|
|
442
446
|
const later = queue.filter((job) => job.at > 0).length;
|
|
443
|
-
declared[where] = Math.max(declared[where] ?? 0, 2 * queue.length + later + 1);
|
|
447
|
+
declared[where] = Math.max(declared[where] ?? 0, 2 * queue.length + later + 1 + COLD_RETRY_COPIES);
|
|
444
448
|
costs[where] = Math.max(costs[where] ?? 0, test.durationMs ?? DEFAULT_DURATION_MS);
|
|
445
449
|
}
|
|
446
450
|
return {
|
|
@@ -640,10 +644,56 @@ export function spreadSerialFiles(argv, root) {
|
|
|
640
644
|
if (!fileFilters(argv.slice(3)).length)
|
|
641
645
|
return [];
|
|
642
646
|
const files = spreadFiles(pass, root);
|
|
647
|
+
// The files the command did not name itself: this invocation runs them
|
|
648
|
+
// for the pass, after the harness gave them to another.
|
|
649
|
+
const named = fileFilters(argv.slice(3)).map((filter) => resolve(filter.replace(/(:\d+)+$/, "")));
|
|
650
|
+
const own = (file) => {
|
|
651
|
+
const path = resolve(root, file);
|
|
652
|
+
return named.some((filter) => path === filter || path.startsWith(`${filter}${sep}`));
|
|
653
|
+
};
|
|
654
|
+
globalThis[SPREAD_ONLY] = { files: files.filter((file) => !own(file)), named };
|
|
643
655
|
argv.splice(3, 0, ...files.map(specFilter));
|
|
644
656
|
return files;
|
|
645
657
|
}
|
|
646
658
|
|
|
659
|
+
const SPREAD_ONLY = Symbol.for("supercov.spreadOnly");
|
|
660
|
+
|
|
661
|
+
/**
|
|
662
|
+
* Which spread files this invocation runs for the pass only (its command
|
|
663
|
+
* did not name them), written for its workers once the round's work is
|
|
664
|
+
* known: none where no mutant no candidate let live yet waits for a test of
|
|
665
|
+
* the invocation's own files (a later round's survivors-to-be), where
|
|
666
|
+
* running them in every invocation is what spreading is for.
|
|
667
|
+
*/
|
|
668
|
+
function writeSpreadOnly(pass, work, root) {
|
|
669
|
+
const said = globalThis[SPREAD_ONLY];
|
|
670
|
+
let files = said?.files ?? [];
|
|
671
|
+
if (files.length) {
|
|
672
|
+
const spread = new Set(files);
|
|
673
|
+
const ownTest = (id) => {
|
|
674
|
+
const file = work.tests[id]?.file;
|
|
675
|
+
if (!file || spread.has(file))
|
|
676
|
+
return false;
|
|
677
|
+
const path = resolve(root, file);
|
|
678
|
+
return said.named.some((filter) => path === filter || path.startsWith(`${filter}${sep}`));
|
|
679
|
+
};
|
|
680
|
+
const freshOwnWork = Object.values(work.entries).some((entry) => !entry.passedBefore && entry.tests.some(ownTest));
|
|
681
|
+
if (!freshOwnWork)
|
|
682
|
+
files = [];
|
|
683
|
+
}
|
|
684
|
+
writeJson(`${pass.round}/spread-only/${process.pid}.json`, files);
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
/**
|
|
688
|
+
* The spread files this invocation runs though its command did not name
|
|
689
|
+
* them (`spreadSerialFiles`), by their path from the project root.
|
|
690
|
+
*/
|
|
691
|
+
let spreadOnlyFiles;
|
|
692
|
+
function spreadOnly(pass, file) {
|
|
693
|
+
spreadOnlyFiles ??= new Set(readJsonOr(`${pass.round}/spread-only/${invocation()}.json`, []));
|
|
694
|
+
return spreadOnlyFiles.has(file);
|
|
695
|
+
}
|
|
696
|
+
|
|
647
697
|
/**
|
|
648
698
|
* Whether this process lists the tests (`playwright test --list`) rather
|
|
649
699
|
* than run them: it reads no plan and writes nothing, and lists the
|
|
@@ -679,6 +729,8 @@ export function strongConfig(normalized, root, reporterPath) {
|
|
|
679
729
|
process.env["SUPERCOV_PLAYWRIGHT_INVOCATION"] = String(process.pid);
|
|
680
730
|
writeJson(`${pass.round}/pass.json`, work);
|
|
681
731
|
writeRoundFiles(pass, work);
|
|
732
|
+
if (work.kind === "main")
|
|
733
|
+
writeSpreadOnly(pass, work, root);
|
|
682
734
|
passCache = work;
|
|
683
735
|
if (work.batch)
|
|
684
736
|
takeAloneMutant(pass, work, root);
|
|
@@ -950,13 +1002,67 @@ export function invocation() {
|
|
|
950
1002
|
}
|
|
951
1003
|
|
|
952
1004
|
/**
|
|
953
|
-
* Whether a test's next run in this invocation has no mutant:
|
|
954
|
-
*
|
|
955
|
-
*
|
|
956
|
-
*
|
|
1005
|
+
* Whether a test's next run in this invocation has no mutant: a kill of it
|
|
1006
|
+
* here waits for one to confirm it, or a run of it without one failed here
|
|
1007
|
+
* and none passed since. A test's first run here takes a mutant: an attempt
|
|
1008
|
+
* that passes needs no run without it, and one that fails is judged by the
|
|
1009
|
+
* control after it (`settleAttempt`), so a test whose mutants all live costs
|
|
1010
|
+
* no control at all (docs/design/strong-mutation.md, "Controls").
|
|
957
1011
|
*/
|
|
958
1012
|
function needsControl(pass, test) {
|
|
959
|
-
|
|
1013
|
+
if (entries(`${pass.round}/pending/${invocation()}/${key(test)}`).length > 0)
|
|
1014
|
+
return true;
|
|
1015
|
+
return !ready(pass, test) && entries(`${pass.round}/unreliable/${invocation()}/${key(test)}`).length > 0;
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
/** Whether a run of `test` without a mutant passed on this invocation's server. */
|
|
1019
|
+
function ready(pass, test) {
|
|
1020
|
+
return existsSync(readyPath(pass, invocation(), test));
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
/** Whether a run of `test` passed on this invocation's server, with a mutant or without. */
|
|
1024
|
+
function warm(pass, test) {
|
|
1025
|
+
return ready(pass, test) || existsSync(`${pass.round}/warm/${invocation()}/${key(test)}`);
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
/** Whether no copy of any test took a mutant yet in this round, and no earlier pass ran it. */
|
|
1029
|
+
function untried(pass, id, entry) {
|
|
1030
|
+
return !entry.passedBefore && entries(`${pass.round}/claims/${key(id)}`).length === 0;
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
/** Whether no candidate let a mutant live yet, in this pass or an earlier one. */
|
|
1034
|
+
function fresh(pass, id, entry) {
|
|
1035
|
+
return !entry.passedBefore && passedWith(pass, id).size === 0;
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
/**
|
|
1039
|
+
* Where a mutant is held while a cold attempt's failure waits for its
|
|
1040
|
+
* control (`settleAttempt`): no other copy takes it meanwhile.
|
|
1041
|
+
*/
|
|
1042
|
+
function heldPath(pass, id, test) {
|
|
1043
|
+
return `${pass.round}/held/${key(id)}/${key(test)}`;
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
/** A mutant a test runs again in this invocation, its cold attempt's failure released by the control after it. */
|
|
1047
|
+
function retryPath(pass, at, test, id) {
|
|
1048
|
+
return `${pass.round}/retry/${at}/${key(test)}/${key(id)}`;
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
/**
|
|
1052
|
+
* The mutant a copy of `test` runs again, once, where its cold attempt
|
|
1053
|
+
* failed and the control after it ran: its claim on the test stays, and its
|
|
1054
|
+
* mark (`.again`) is what takes it.
|
|
1055
|
+
*/
|
|
1056
|
+
function takeRetry(pass, test) {
|
|
1057
|
+
const retries = `${pass.round}/retry/${invocation()}/${key(test)}`;
|
|
1058
|
+
for (const name of entries(retries)) {
|
|
1059
|
+
const id = readJsonOr(`${retries}/${name}/id`, undefined);
|
|
1060
|
+
if (id === undefined || settled(pass, id))
|
|
1061
|
+
continue;
|
|
1062
|
+
if (mark(`${retries}/${name}/again`))
|
|
1063
|
+
return id;
|
|
1064
|
+
}
|
|
1065
|
+
return undefined;
|
|
960
1066
|
}
|
|
961
1067
|
|
|
962
1068
|
function readyPath(pass, at, test) {
|
|
@@ -967,10 +1073,14 @@ function claimPath(pass, id, test) {
|
|
|
967
1073
|
return `${pass.round}/claims/${key(id)}/${key(test)}`;
|
|
968
1074
|
}
|
|
969
1075
|
|
|
970
|
-
/**
|
|
1076
|
+
/**
|
|
1077
|
+
* Whether a mutant needs no more attempts: a verdict given, killed, or held
|
|
1078
|
+
* for a later round, or for now while a cold attempt's failure waits for its
|
|
1079
|
+
* control.
|
|
1080
|
+
*/
|
|
971
1081
|
function settled(pass, id) {
|
|
972
1082
|
const at = key(id);
|
|
973
|
-
return existsSync(`${pass.shared}/verdicts/${at}`) || existsSync(`${pass.round}/killed/${at}`);
|
|
1083
|
+
return existsSync(`${pass.shared}/verdicts/${at}`) || existsSync(`${pass.round}/killed/${at}`) || entries(`${pass.round}/held/${at}`).length > 0;
|
|
974
1084
|
}
|
|
975
1085
|
|
|
976
1086
|
/**
|
|
@@ -1007,7 +1117,7 @@ function inFlightSince(pass, id) {
|
|
|
1007
1117
|
* candidates let live, and it runs every mutant all the same before its
|
|
1008
1118
|
* copies are spent.
|
|
1009
1119
|
*/
|
|
1010
|
-
function takeJob(pass, shape, test, only, limitMs, copiesLeft) {
|
|
1120
|
+
function takeJob(pass, shape, test, only, limitMs, copiesLeft, freshOnly = false) {
|
|
1011
1121
|
const queue = queueOf(pass, test);
|
|
1012
1122
|
// A test that fails without any mutant is no candidate: it holds back
|
|
1013
1123
|
// no later one.
|
|
@@ -1032,6 +1142,15 @@ function takeJob(pass, shape, test, only, limitMs, copiesLeft) {
|
|
|
1032
1142
|
queue.done += 1;
|
|
1033
1143
|
continue;
|
|
1034
1144
|
}
|
|
1145
|
+
// A spread file in an invocation the harness did not give it to
|
|
1146
|
+
// takes only mutants no copy took yet, anywhere, with no
|
|
1147
|
+
// progress from an earlier pass (likely to fail it, soon
|
|
1148
|
+
// decided); the rest wait for the invocation that runs it as its
|
|
1149
|
+
// own, so that this one reaches its own files. Its first claim is
|
|
1150
|
+
// what it looks at, not a candidate passing, which a run without
|
|
1151
|
+
// the mutant first (a cold test) would leave unseen for a while.
|
|
1152
|
+
if (freshOnly && !untried(pass, id, mutantOf(pass, id)))
|
|
1153
|
+
continue;
|
|
1035
1154
|
waiting += 1;
|
|
1036
1155
|
const since = inFlightSince(pass, id);
|
|
1037
1156
|
if (since !== undefined) {
|
|
@@ -1048,7 +1167,9 @@ function takeJob(pass, shape, test, only, limitMs, copiesLeft) {
|
|
|
1048
1167
|
if (!best)
|
|
1049
1168
|
break;
|
|
1050
1169
|
const controls = entries(`${pass.round}/pending/${invocation()}/${key(test)}`).length;
|
|
1051
|
-
|
|
1170
|
+
// The copies kept back cover each mutant waiting and a control for
|
|
1171
|
+
// each, and a cold failure's retry.
|
|
1172
|
+
if (only === undefined && best.standing[0] > 0 && copiesLeft >= 2 * waiting + controls + COLD_RETRY_COPIES)
|
|
1052
1173
|
return undefined;
|
|
1053
1174
|
if (mark(claimPath(pass, best.id, test)))
|
|
1054
1175
|
return best.id;
|
|
@@ -1057,7 +1178,7 @@ function takeJob(pass, shape, test, only, limitMs, copiesLeft) {
|
|
|
1057
1178
|
// Every mutant left runs elsewhere now: one of them here too, rather
|
|
1058
1179
|
// than leave this test's copies unused while its attempt runs.
|
|
1059
1180
|
for (const id of busy) {
|
|
1060
|
-
if (only === undefined && !settled(pass, id) && mark(claimPath(pass, id, test)))
|
|
1181
|
+
if (only === undefined && !settled(pass, id) && (!freshOnly || untried(pass, id, mutantOf(pass, id))) && mark(claimPath(pass, id, test)))
|
|
1061
1182
|
return id;
|
|
1062
1183
|
}
|
|
1063
1184
|
return undefined;
|
|
@@ -1098,6 +1219,9 @@ function before(a, b) {
|
|
|
1098
1219
|
function workLeft(pass, test) {
|
|
1099
1220
|
if (entries(`${pass.round}/pending/${invocation()}/${key(test)}`).length)
|
|
1100
1221
|
return true;
|
|
1222
|
+
const retries = `${pass.round}/retry/${invocation()}/${key(test)}`;
|
|
1223
|
+
if (entries(retries).some((name) => !existsSync(`${retries}/${name}/again`)))
|
|
1224
|
+
return true;
|
|
1101
1225
|
const queue = queueOf(pass, test);
|
|
1102
1226
|
for (let at = queue.done; at < queue.ids.length; at++) {
|
|
1103
1227
|
const id = queue.ids[at];
|
|
@@ -1248,13 +1372,34 @@ export async function strongClaim(testInfo) {
|
|
|
1248
1372
|
// invocation: what a copy that waits a sweep may spend.
|
|
1249
1373
|
const copy = withoutCopy(testInfo.titlePath).copy;
|
|
1250
1374
|
const copiesLeft = copiesOf(testInfo.file, testInfo.title) - 1 - copy;
|
|
1251
|
-
const
|
|
1375
|
+
const only = shape.batch ? invocationMutant(pass) ?? null : undefined;
|
|
1376
|
+
const again = only === undefined ? takeRetry(pass, original) : undefined;
|
|
1377
|
+
const freshOnly = !shape.everywhere && only === undefined && spreadOnly(pass, test.file);
|
|
1378
|
+
const id = again ?? takeJob(pass, shape, original, only, limitMs, copiesLeft, freshOnly);
|
|
1252
1379
|
if (!id)
|
|
1253
1380
|
return null;
|
|
1254
1381
|
const entry = mutantOf(pass, id);
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1382
|
+
// Cold: no run of the test passed on this server yet, with or
|
|
1383
|
+
// without a mutant. Its failure may be the server's first request
|
|
1384
|
+
// to a page, not the mutant's: it is tried again once a control has
|
|
1385
|
+
// passed.
|
|
1386
|
+
const cold = !shape.everywhere && !warm(pass, original);
|
|
1387
|
+
if (cold && again === undefined && copiesLeft >= 1 && fresh(pass, id, entry)) {
|
|
1388
|
+
// A mutant no candidate let live yet is as likely as not to fail
|
|
1389
|
+
// its first (its cheapest likely killer): a failure there, cold,
|
|
1390
|
+
// would run it twice. The test runs without it first, and takes
|
|
1391
|
+
// it next (`takeRetry`), where a copy is left for that.
|
|
1392
|
+
mark(retryPath(pass, invocation(), original, id));
|
|
1393
|
+
writeJson(`${retryPath(pass, invocation(), original, id)}/id`, id);
|
|
1394
|
+
attempt = shape.baselines && baselineOf(pass, original) === undefined
|
|
1395
|
+
? { kind: "baseline", id: null, mutant: "-" }
|
|
1396
|
+
: { kind: "control", id: null, mutant: "-" };
|
|
1397
|
+
}
|
|
1398
|
+
else {
|
|
1399
|
+
attempt = { kind: "mutant", id, mutant: entry.mutant, baselineMs, limitMs, timeoutFactor: shape.timeoutFactor, ...(cold ? { cold } : {}) };
|
|
1400
|
+
mark(`${pass.round}/inflight/${key(id)}`);
|
|
1401
|
+
writeFileSync(`${pass.round}/inflight/${key(id)}/${process.pid}-${key(testInfo.testId)}`, String(Date.now()));
|
|
1402
|
+
}
|
|
1258
1403
|
}
|
|
1259
1404
|
const lock = shape.concurrency.workers !== 1 && shape.concurrency.serialFiles.includes(test.file)
|
|
1260
1405
|
? await lockFile(pass, test.file)
|
|
@@ -1276,7 +1421,7 @@ export async function strongClaim(testInfo) {
|
|
|
1276
1421
|
kind: attempt.kind,
|
|
1277
1422
|
id: attempt.id,
|
|
1278
1423
|
mutant: attempt.mutant,
|
|
1279
|
-
...(attempt.kind === "mutant" ? { baselineMs: attempt.baselineMs, limitMs: attempt.limitMs, timeoutFactor: attempt.timeoutFactor } : {}),
|
|
1424
|
+
...(attempt.kind === "mutant" ? { baselineMs: attempt.baselineMs, limitMs: attempt.limitMs, timeoutFactor: attempt.timeoutFactor, ...(attempt.cold ? { cold: true } : {}) } : {}),
|
|
1280
1425
|
startedAt: Date.now(),
|
|
1281
1426
|
lock,
|
|
1282
1427
|
running,
|
|
@@ -1352,7 +1497,7 @@ function surviveIfDone(pass, id) {
|
|
|
1352
1497
|
}
|
|
1353
1498
|
|
|
1354
1499
|
export const WHY = {
|
|
1355
|
-
"background": "its code ran in server work no request
|
|
1500
|
+
"background": "its code ran in server work no request was waiting for",
|
|
1356
1501
|
"module-level": "it is a server module's top-level code",
|
|
1357
1502
|
"by-time": "its code ran for a request that named no test",
|
|
1358
1503
|
"unfinished": "not every candidate test ran in the shared pass",
|
|
@@ -1414,6 +1559,7 @@ export function settleAttempt(pass, attempt) {
|
|
|
1414
1559
|
}
|
|
1415
1560
|
if (ended.outcome === "passed") {
|
|
1416
1561
|
mark(`${pass.round}/passed/${key(attempt.id)}/${key(test)}`);
|
|
1562
|
+
mark(`${pass.round}/warm/${attempt.invocation}/${key(test)}`);
|
|
1417
1563
|
// One mutant an invocation: a survivor waits for the judge, who
|
|
1418
1564
|
// knows whether its server ran it.
|
|
1419
1565
|
if (!shape.batch)
|
|
@@ -1422,6 +1568,15 @@ export function settleAttempt(pass, attempt) {
|
|
|
1422
1568
|
}
|
|
1423
1569
|
if (ended.outcome !== "failed" && ended.outcome !== "timed-out")
|
|
1424
1570
|
return ended;
|
|
1571
|
+
// A cold attempt's failure (no run of the test without a mutant had
|
|
1572
|
+
// passed on this server before it): the next control says whether the
|
|
1573
|
+
// test passes here at all, and the mutant runs it again after, warm. It
|
|
1574
|
+
// decides nothing itself; meanwhile no other copy takes the mutant.
|
|
1575
|
+
if (attempt.cold && !shape.everywhere) {
|
|
1576
|
+
mark(heldPath(pass, attempt.id, test));
|
|
1577
|
+
writeJson(`${pass.round}/pending/${attempt.invocation}/${key(test)}/${key(attempt.id)}`, { id: attempt.id, test, cold: true, endedAt: ended.endedAt });
|
|
1578
|
+
return ended;
|
|
1579
|
+
}
|
|
1425
1580
|
// A kill, or a timeout (it ran out of its limit): no other copy takes
|
|
1426
1581
|
// the mutant now, and either is confirmed alike.
|
|
1427
1582
|
const { status, reason } = verdictOf(ended);
|
|
@@ -1474,6 +1629,14 @@ function settleControl(pass, ended, shape) {
|
|
|
1474
1629
|
if (!kill || kill.endedAt > ended.startedAt)
|
|
1475
1630
|
continue;
|
|
1476
1631
|
rmSync(`${pending}/${name}`, { force: true });
|
|
1632
|
+
if (kill.cold) {
|
|
1633
|
+
// Its test runs it again (`takeJob`), after this control: warm,
|
|
1634
|
+
// or where the test fails here without any mutant.
|
|
1635
|
+
mark(retryPath(pass, ended.invocation, test, kill.id));
|
|
1636
|
+
writeJson(`${retryPath(pass, ended.invocation, test, kill.id)}/id`, kill.id);
|
|
1637
|
+
rmSync(heldPath(pass, kill.id, test), { recursive: true, force: true });
|
|
1638
|
+
continue;
|
|
1639
|
+
}
|
|
1477
1640
|
if (passed && !ended.beside) {
|
|
1478
1641
|
const entry = mutantOf(pass, kill.id);
|
|
1479
1642
|
giveVerdict(pass, { id: kill.id, status: kill.status, killedBy: kill.test, reason: `${kill.message}${suffix(shape, entry)}`, tests: 1, durationMs: kill.durationMs });
|
|
@@ -175,7 +175,10 @@ export default class SupercovPlaywrightStrongReporter {
|
|
|
175
175
|
"failed": "fails",
|
|
176
176
|
"timed-out": `ran out of its ${seconds(attempt.limitMs)} limit (its baseline ${seconds(attempt.baselineMs)})`,
|
|
177
177
|
}[attempt.outcome] ?? attempt.outcome;
|
|
178
|
-
|
|
178
|
+
// A cold attempt's failure decides nothing: it runs again once a
|
|
179
|
+
// control has passed on its server.
|
|
180
|
+
const cold = attempt.cold && (attempt.outcome === "failed" || attempt.outcome === "timed-out") ? ", before any control here: runs again after one" : "";
|
|
181
|
+
console.log(`[supercov] ${attempt.id}: ${JSON.stringify(attempt.title)} ${said} (${took}${cold})`);
|
|
179
182
|
}
|
|
180
183
|
/**
|
|
181
184
|
* What this invocation is doing, for the engine's progress line: the
|
|
@@ -379,7 +382,9 @@ export default class SupercovPlaywrightStrongReporter {
|
|
|
379
382
|
// A kill no control came after (the round ended first): as sure as a
|
|
380
383
|
// kill on a server no other mutant's attempt shared, where it ended
|
|
381
384
|
// before the round began to stop.
|
|
382
|
-
|
|
385
|
+
// A cold attempt's failure (no control had passed before it on
|
|
386
|
+
// its server) is no kill: the round ended before it ran again.
|
|
387
|
+
const killer = failed.find((attempt) => !attempt.beside && !attempt.cold && attempt.endedAt < trustedUntil);
|
|
383
388
|
if (killer) {
|
|
384
389
|
const { status, reason } = verdictOf(killer);
|
|
385
390
|
verdict({ status, killedBy: killer.original, reason: `${reason}${suffix}` });
|
|
@@ -628,6 +628,22 @@ else {
|
|
|
628
628
|
return print.apply(this, [kept.join("\\n"), ...message.slice(1)]);
|
|
629
629
|
})(warnOnce)); } catch {}
|
|
630
630
|
`.replace(/\n\s*/g, " ");
|
|
631
|
+
// A strong pass's `next build` does not check types. The check emits
|
|
632
|
+
// nothing the server runs, and says nothing of a mutant: its worker reads
|
|
633
|
+
// the sources as their authors wrote them (`installAuthoredSourceView`
|
|
634
|
+
// above), switches and all left out, so it checks the checkout the
|
|
635
|
+
// measured run built already. It took 12 s of a 30 s build, in every job
|
|
636
|
+
// of a pass split across jobs. A measured run still checks: whether its
|
|
637
|
+
// command passes is the project's.
|
|
638
|
+
const unchecked = process.env.SUPERCOV_STRONG === "1" ? `
|
|
639
|
+
;try { loadConfig = ((load) => async function loadConfig(...args) {
|
|
640
|
+
const config = await load.apply(this, args);
|
|
641
|
+
try {
|
|
642
|
+
if (config && typeof config === "object") config.typescript = { ...(config.typescript || {}), ignoreBuildErrors: true };
|
|
643
|
+
} catch {}
|
|
644
|
+
return config;
|
|
645
|
+
})(loadConfig); } catch {}
|
|
646
|
+
`.replace(/\n\s*/g, " ") : "";
|
|
631
647
|
// A project's `turbopack.root`, set to its own directory, names the copy
|
|
632
648
|
// here, while the copy's dependencies are links into the project's
|
|
633
649
|
// node_modules. Turbopack resolves no package outside its root and
|
|
@@ -677,7 +693,7 @@ else {
|
|
|
677
693
|
}
|
|
678
694
|
else if (filename.endsWith("config.js") &&
|
|
679
695
|
/[\\/]next[\\/]dist[\\/]server[\\/]config\.js$/.test(filename)) {
|
|
680
|
-
content = append(content, widened);
|
|
696
|
+
content = append(content, `${widened}${unchecked}`);
|
|
681
697
|
}
|
|
682
698
|
}
|
|
683
699
|
return Reflect.apply(compile, this, [content, filename, ...rest]);
|
|
@@ -322,6 +322,37 @@ var _a6;
|
|
|
322
322
|
var serverPhaseStorage = (_a6 = serverPhaseStorages.get(runtimeInstance)) != null ? _a6 : createServerPhaseStorage();
|
|
323
323
|
if (serverPhaseStorage)
|
|
324
324
|
serverPhaseStorages.set(runtimeInstance, serverPhaseStorage);
|
|
325
|
+
// A request's work, until its response has finished: what an attempt's
|
|
326
|
+
// request set off and left running after it was answered -- a promise no one
|
|
327
|
+
// awaits, a poller a first request started that later requests' work runs
|
|
328
|
+
// in -- keeps the request's context, and ran as that test's long after the
|
|
329
|
+
// test, or any request of it, waited for it. Such work is no test's: it is
|
|
330
|
+
// recorded as work no request named, and a strong pass switches no
|
|
331
|
+
// request's mutant on there, so it runs with the server started with it
|
|
332
|
+
// (docs/design/strong-mutation.md). A context carries its request's
|
|
333
|
+
// lifetime under this key, which spreads copy and JSON leaves out.
|
|
334
|
+
var REQUEST_LIFETIME = Symbol.for("supercov.requestLifetime");
|
|
335
|
+
function answered(context) {
|
|
336
|
+
const lifetime = context[REQUEST_LIFETIME];
|
|
337
|
+
return lifetime !== void 0 && lifetime.answered;
|
|
338
|
+
}
|
|
339
|
+
// The request's lifetime, made by whichever copy of the runtime sees the
|
|
340
|
+
// request first. It ends once the response has finished (or its connection
|
|
341
|
+
// closed) and the listeners of that event have run: what they start goes
|
|
342
|
+
// on after it, and is no longer the request's.
|
|
343
|
+
function requestLifetime(request, response) {
|
|
344
|
+
let lifetime = request[REQUEST_LIFETIME];
|
|
345
|
+
if (lifetime !== void 0)
|
|
346
|
+
return lifetime;
|
|
347
|
+
lifetime = { answered: false };
|
|
348
|
+
Object.defineProperty(request, REQUEST_LIFETIME, { __proto__: null, value: lifetime, configurable: true });
|
|
349
|
+
const answer = () => queueMicrotask(() => {
|
|
350
|
+
lifetime.answered = true;
|
|
351
|
+
});
|
|
352
|
+
for (const event of ["finish", "close"])
|
|
353
|
+
response.once(event, answer);
|
|
354
|
+
return lifetime;
|
|
355
|
+
}
|
|
325
356
|
function probeV2ContextKey(context) {
|
|
326
357
|
var _a8, _b;
|
|
327
358
|
const phase = (_a8 = context.phaseId) != null ? _a8 : "unscoped";
|
|
@@ -366,13 +397,18 @@ function activateProbeV2Key(key, force = false) {
|
|
|
366
397
|
// The async hook activates the current request's context before every
|
|
367
398
|
// callback the server runs, and building its key and looking it up was most of
|
|
368
399
|
// a Next server's time in the hook. A request's context object is never
|
|
369
|
-
// changed once made, and its key is made of it
|
|
370
|
-
// it was given until the epochs are cleared
|
|
400
|
+
// changed once made but for its request's lifetime, and its key is made of it
|
|
401
|
+
// alone, so each keeps the epoch it was given until the epochs are cleared or
|
|
402
|
+
// its request is answered.
|
|
371
403
|
// Every copy of the runtime in a process shares one state, and the hook is the
|
|
372
404
|
// first copy's, so the cache and its generation live on that state too: a
|
|
373
405
|
// reset from another copy has to reach them.
|
|
374
406
|
var emptyProbeV2Context = Object.freeze({});
|
|
375
407
|
function activateProbeV2Context(context) {
|
|
408
|
+
// What a request left running after its answer is no request's: only its
|
|
409
|
+
// lifetime changes once the context is made, and is looked at first.
|
|
410
|
+
if (answered(context))
|
|
411
|
+
context = emptyProbeV2Context;
|
|
376
412
|
// Work no request owns is keyed by the test running when it runs, which
|
|
377
413
|
// changes under the same context: only a request's context keeps its epoch.
|
|
378
414
|
if (!context.scope)
|
|
@@ -1449,7 +1485,7 @@ function appendServer(record) {
|
|
|
1449
1485
|
// Work done while handling a request that named no test -- a webhook a
|
|
1450
1486
|
// mock server sends -- says so, with the request's number.
|
|
1451
1487
|
const stored = serverPhaseStorage == null ? void 0 : serverPhaseStorage.getStore();
|
|
1452
|
-
const unscopedRequest = !scope && stored && stored.request ? { request: stored.request } : {};
|
|
1488
|
+
const unscopedRequest = !scope && stored && stored.request && !answered(stored) ? { request: stored.request } : {};
|
|
1453
1489
|
const serialized = __spreadValues(__spreadValues(__spreadValues({}, record), scope ? { scope } : {}), unscopedRequest);
|
|
1454
1490
|
if (scope && state.bufferedAttempts.has(attemptKey(scope))) {
|
|
1455
1491
|
const key = attemptKey(scope);
|
|
@@ -1500,7 +1536,7 @@ function environmentRequestContext() {
|
|
|
1500
1536
|
function currentRequestContext() {
|
|
1501
1537
|
const stored = serverPhaseStorage == null ? void 0 : serverPhaseStorage.getStore();
|
|
1502
1538
|
if (stored !== void 0) {
|
|
1503
|
-
if (stored.scope || stored.phaseId)
|
|
1539
|
+
if ((stored.scope || stored.phaseId) && !answered(stored))
|
|
1504
1540
|
return stored;
|
|
1505
1541
|
return runtimeGlobal.__SUPERCOV_ACTIVE_SCOPE__ ? { scope: runtimeGlobal.__SUPERCOV_ACTIVE_SCOPE__ } : {};
|
|
1506
1542
|
}
|
|
@@ -1519,15 +1555,15 @@ function activateCoverageScope(scope) {
|
|
|
1519
1555
|
}
|
|
1520
1556
|
function coverageCarrier() {
|
|
1521
1557
|
const context = currentRequestContext();
|
|
1522
|
-
return __spreadValues(__spreadValues({
|
|
1558
|
+
return __spreadValues(__spreadValues(__spreadValues({
|
|
1523
1559
|
version: 1
|
|
1524
|
-
}, context.scope ? { scope: context.scope } : {}), context.phaseId ? { phaseId: context.phaseId } : {});
|
|
1560
|
+
}, context.scope ? { scope: context.scope } : {}), context.phaseId ? { phaseId: context.phaseId } : {}), context[REQUEST_LIFETIME] ? { [REQUEST_LIFETIME]: context[REQUEST_LIFETIME] } : {});
|
|
1525
1561
|
}
|
|
1526
1562
|
function withCoverageCarrier(carrier, callback) {
|
|
1527
1563
|
const decoded = typeof carrier === "string" ? decodeCoverageCarrier(carrier) : carrier;
|
|
1528
1564
|
if (!serverPhaseStorage || !decoded)
|
|
1529
1565
|
return callback();
|
|
1530
|
-
const context = __spreadValues(__spreadValues({}, decoded.scope ? { scope: decoded.scope } : {}), decoded.phaseId ? { phaseId: decoded.phaseId } : {});
|
|
1566
|
+
const context = __spreadValues(__spreadValues(__spreadValues({}, decoded.scope ? { scope: decoded.scope } : {}), decoded.phaseId ? { phaseId: decoded.phaseId } : {}), decoded[REQUEST_LIFETIME] ? { [REQUEST_LIFETIME]: decoded[REQUEST_LIFETIME] } : {});
|
|
1531
1567
|
return serverPhaseStorage.run(context, () => withProbeV2Context(context, callback));
|
|
1532
1568
|
}
|
|
1533
1569
|
function assertionPhaseState(scope) {
|
|
@@ -2129,6 +2165,9 @@ function installNodeRequestPropagation() {
|
|
|
2129
2165
|
// the report credits its work to the test running when it came.
|
|
2130
2166
|
if (incoming && serverPhaseStorage && !(context && (context.scope || context.phaseId)))
|
|
2131
2167
|
context = { request: nextUnscopedRequest() };
|
|
2168
|
+
// Until its response has finished.
|
|
2169
|
+
if (incoming && context && request && typeof request === "object" && response && typeof response.once === "function")
|
|
2170
|
+
context = __spreadValues(__spreadValues({}, context), { [REQUEST_LIFETIME]: requestLifetime(request, response) });
|
|
2132
2171
|
// Node emits a request's body and its response's events outside the
|
|
2133
2172
|
// handler's context, so a handler that reads the body -- `req.on('end')`
|
|
2134
2173
|
// -- ran as no test's. The request and response carry it with them.
|
|
@@ -2188,6 +2227,9 @@ function withRequestPhase(handler, event) {
|
|
|
2188
2227
|
const context = __spreadValues(__spreadValues({}, ((_a8 = requestContext == null ? void 0 : requestContext.scope) != null ? _a8 : inheritedContext.scope) ? { scope: (_b = requestContext == null ? void 0 : requestContext.scope) != null ? _b : inheritedContext.scope } : {}), ((_c = requestContext == null ? void 0 : requestContext.phaseId) != null ? _c : inheritedContext.phaseId) ? { phaseId: (_d = requestContext == null ? void 0 : requestContext.phaseId) != null ? _d : inheritedContext.phaseId } : {});
|
|
2189
2228
|
if (requestContext !== void 0 && !context.scope)
|
|
2190
2229
|
context.request = nextUnscopedRequest();
|
|
2230
|
+
const lifetime = requestContext !== void 0 ? args.map((argument) => argument && typeof argument === "object" ? argument[REQUEST_LIFETIME] : void 0).find((found) => found !== void 0) : void 0;
|
|
2231
|
+
if (lifetime !== void 0)
|
|
2232
|
+
context[REQUEST_LIFETIME] = lifetime;
|
|
2191
2233
|
const invoke = () => {
|
|
2192
2234
|
if (event === "connection" && context.scope && args[0] &&
|
|
2193
2235
|
typeof args[0] === "object" && typeof args[0].emit === "function")
|