supercov 4.29.7 → 4.29.9
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
|
@@ -1124,6 +1124,16 @@ one command measured on different machines and copied into one
|
|
|
1124
1124
|
`.supercov/runs` replace none of each other: each is a share of the suite, and
|
|
1125
1125
|
all are merged.
|
|
1126
1126
|
|
|
1127
|
+
A test whose records two runs hold byte for byte alike, once each run's id is
|
|
1128
|
+
the merge's, is kept once, from the first run, and so are an entry's records
|
|
1129
|
+
of no test (a server's background): a run made from another without measuring
|
|
1130
|
+
(a continuation round's shard) adds nothing to them, and the merge says how
|
|
1131
|
+
many copies it kept once (`3402 copy(ies) of records that an earlier run held
|
|
1132
|
+
byte for byte kept once, from that run`). A copy that differs in anything, a
|
|
1133
|
+
timestamp, a path the test took, an outcome, is kept beside the others, so
|
|
1134
|
+
nothing any run recorded is lost. Jobs that each measured the whole suite
|
|
1135
|
+
record each test with times of their own, and keep a copy each.
|
|
1136
|
+
|
|
1127
1137
|
The runs may differ in their tests, the helpers beside them, and the test
|
|
1128
1138
|
runners' settings, as long as nothing that changed reaches what an earlier
|
|
1129
1139
|
run's tests did. Measuring a new test alone and adding it to the runs before it
|
package/docs/mutation.md
CHANGED
|
@@ -144,6 +144,14 @@ mutants the tests let survive.
|
|
|
144
144
|
of the 450 s budget, which leaves the pass 140 s`). A measurement is never
|
|
145
145
|
cut short, since one stopped halfway records nothing: one that outlasts the
|
|
146
146
|
budget leaves the pass nothing, and the pass runs nothing.
|
|
147
|
+
- **Partial progress.** A mutant a pass left open keeps the candidate tests
|
|
148
|
+
that already passed with it, saved with the run's verdicts, and the next
|
|
149
|
+
pass runs it only against the rest (`37 mutant(s) resume where earlier
|
|
150
|
+
passes left them, with 4 of 15 candidates left (the median)`): a kill needs
|
|
151
|
+
one failing candidate, a survivor every candidate passing, and the ones
|
|
152
|
+
that passed did. The candidates are kept as verdicts are, after an edit, a
|
|
153
|
+
merge and in a later round: a candidate a change could reach runs again.
|
|
154
|
+
The Playwright driver records them.
|
|
147
155
|
- **Exit codes.** `0` with an answer; `1` when `--fail-on` or `--critical`
|
|
148
156
|
finds a mutant; `2`, after the answer, when the measured command failed (a
|
|
149
157
|
failing test kills nothing, so the verdicts cannot gate) or no mutant could
|
|
@@ -427,7 +435,12 @@ no mutants shows none of this.
|
|
|
427
435
|
stopping at its first failing test.
|
|
428
436
|
- **Playwright** carries each test's mutant with its requests, so one server
|
|
429
437
|
serves different mutants to different workers. A mutant of a server's
|
|
430
|
-
start-up runs with the server started again for it.
|
|
438
|
+
start-up runs with the server started again for it. A mutant in a
|
|
439
|
+
module-level object or array literal (a translation table, a menu) runs
|
|
440
|
+
against the tests that read its value, which a run measured with the
|
|
441
|
+
mutants' probes records, not every test whose server loaded the module;
|
|
442
|
+
the plan says how many were narrowed and by how much
|
|
443
|
+
(`docs/design/strong-mutation.md`, Module-level values). StrykerJS has no
|
|
431
444
|
Playwright runner, so Playwright's verdicts are checked by hand (see below).
|
|
432
445
|
A test run with a mutant gets StrykerJS's time limit: its baseline (the
|
|
433
446
|
longest of its measured run and its runs without a mutant in the pass)
|
|
@@ -449,6 +462,19 @@ no mutants shows none of this.
|
|
|
449
462
|
has left. A candidate in a project others start from (a login `setup`)
|
|
450
463
|
never runs with a mutant: a mutant no other test kills is an `error` that
|
|
451
464
|
says so.
|
|
465
|
+
- **A harness with slots.** A harness may run several `playwright test`
|
|
466
|
+
processes at once (slots, each with its own server and database) and keep
|
|
467
|
+
a spec file with a serial describe whole, in one slot. In a strong pass
|
|
468
|
+
such a file runs in every slot whose command names spec files, and each
|
|
469
|
+
slot takes its own mutants of it from a queue the pass's slots share, so one
|
|
470
|
+
slot no longer runs all of them. Nothing in the harness or the command
|
|
471
|
+
changes: Supercov's preload adds the file to each invocation's file filters
|
|
472
|
+
before Playwright reads them, and leaves `--list` as it is. Each slot runs
|
|
473
|
+
the file's tests once without a mutant before its first mutant there. A
|
|
474
|
+
file it cannot spread (one that sets its serial mode in a helper of its
|
|
475
|
+
own) is named in the progress lines, with what it costs (`"e2e/buy.spec.ts"
|
|
476
|
+
has a serial describe, and 1 of the 6 invocations runs it: its 37 mutant(s)
|
|
477
|
+
wait about 12m00s there, the others about 1m00s`).
|
|
452
478
|
- **Jest and Mocha** run in resident runners, as StrykerJS's do; `node:test`,
|
|
453
479
|
AVA, node-tap, `bun:test` and Vitest Browser Mode run one test file per
|
|
454
480
|
start of the command, with the mutant on from its start.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "supercov",
|
|
3
|
-
"version": "4.29.
|
|
3
|
+
"version": "4.29.9",
|
|
4
4
|
"description": "Coverage, security and code quality for coding agents",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"coverage",
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
"benchmark:check": "cargo build --release -p supercov && node scripts/rust-transform-benchmark.mjs",
|
|
98
98
|
"benchmark:python": "cargo build -p supercov && node scripts/python-benchmark.mjs",
|
|
99
99
|
"check": "npm run check:lint && npm run check:tests",
|
|
100
|
-
"check:lint": "cargo fmt --all -- --check && cargo clippy --workspace --all-targets -- -D warnings",
|
|
100
|
+
"check:lint": "node scripts/check-fault-sites.mjs && cargo fmt --all -- --check && cargo clippy --workspace --all-targets -- -D warnings",
|
|
101
101
|
"check:tests": "npm run test && npm run check:tooling",
|
|
102
102
|
"check:tooling": "npm run test:release-tooling && npm run test:runtime && npm run test:action && npm run test:rust-assets && npm run test:agent-commands && npm run test:assertions && npm run test:sweep-target && npm run test:skip-guard && npm run test:windows-tls && node scripts/package-preflight.mjs && node scripts/verify-binstall-metadata.mjs --offline",
|
|
103
103
|
"release:check": "cargo clean && node scripts/sweep-target.mjs && npm run check && npm run test:engine && npm run test:go && npm run test:jvm && npm run test:launcher && npm run test:fixture && npm run test:watchdog && npm run test:engine-contract && npm run test:agent && npm run test:child-attribution && npm run test:host-loader && npm run test:python && npm run test:ruby-coverage && npm run test:rust-public-cargo && npm run test:packed-npx && npm run test:clang-mcdc && npm run benchmark:check",
|
|
@@ -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.9",
|
|
129
|
+
"@supercov/cli-darwin-x64": "4.29.9",
|
|
130
|
+
"@supercov/cli-linux-arm64-gnu": "4.29.9",
|
|
131
|
+
"@supercov/cli-linux-arm64-musl": "4.29.9",
|
|
132
|
+
"@supercov/cli-linux-x64-gnu": "4.29.9",
|
|
133
|
+
"@supercov/cli-linux-x64-musl": "4.29.9",
|
|
134
|
+
"@supercov/cli-win32-arm64": "4.29.9",
|
|
135
|
+
"@supercov/cli-win32-x64": "4.29.9"
|
|
136
136
|
},
|
|
137
137
|
"peerDependencies": {
|
|
138
138
|
"@playwright/test": ">=1.55.0",
|
|
@@ -296,7 +296,7 @@ function buildPass(pass, root, config) {
|
|
|
296
296
|
const tests = {};
|
|
297
297
|
plan.tests.forEach((test) => {
|
|
298
298
|
if (test.runner === "playwright" && test.file)
|
|
299
|
-
tests[playwrightId(test)] = { file: test.file, title: test.title ?? null, durationMs: test.durationMs ?? null, jobs: 0 };
|
|
299
|
+
tests[playwrightId(test)] = { file: test.file, title: test.title ?? null, durationMs: test.durationMs ?? null, jobs: 0, planId: test.id };
|
|
300
300
|
});
|
|
301
301
|
// `workers` set only where the round runs one test at a time.
|
|
302
302
|
const concurrency = { workers: undefined, serialFiles: serialFilesOf(plan, tests, fullyParallelOf(config)) };
|
|
@@ -536,6 +536,108 @@ function mutantOf(pass, id) {
|
|
|
536
536
|
return mutantCache.get(id);
|
|
537
537
|
}
|
|
538
538
|
|
|
539
|
+
// `playwright test`'s options that take a value, one that may (it takes the
|
|
540
|
+
// next argument unless that is an option), and the one that takes every
|
|
541
|
+
// argument up to the next option: what tells a file filter from an option's
|
|
542
|
+
// value.
|
|
543
|
+
const VALUED_OPTIONS = new Set(["--browser", "-c", "--config", "-g", "--grep", "-G", "--grep-invert", "--global-timeout", "-j", "--workers", "--last-failed-file", "--max-failures", "--output", "--repeat-each", "--reporter", "--retries", "--run-agents", "--shard", "--test-list", "--test-list-invert", "--timeout", "--trace", "--tsconfig", "--ui-host", "--ui-port", "--update-source-method"]);
|
|
544
|
+
const OPTIONAL_VALUE_OPTIONS = new Set(["--debug", "--only-changed", "-u", "--update-snapshots"]);
|
|
545
|
+
const VARIADIC_OPTIONS = new Set(["--project"]);
|
|
546
|
+
|
|
547
|
+
/** The file filters a `playwright test` command line names (the arguments after `test`). */
|
|
548
|
+
export function fileFilters(args) {
|
|
549
|
+
const filters = [];
|
|
550
|
+
for (let at = 0; at < args.length; at++) {
|
|
551
|
+
const argument = args[at];
|
|
552
|
+
if (argument === "--")
|
|
553
|
+
break;
|
|
554
|
+
if (!argument.startsWith("-")) {
|
|
555
|
+
filters.push(argument);
|
|
556
|
+
continue;
|
|
557
|
+
}
|
|
558
|
+
if (argument.includes("="))
|
|
559
|
+
continue;
|
|
560
|
+
if (VALUED_OPTIONS.has(argument))
|
|
561
|
+
at += 1;
|
|
562
|
+
else if (OPTIONAL_VALUE_OPTIONS.has(argument) || VARIADIC_OPTIONS.has(argument)) {
|
|
563
|
+
while (at + 1 < args.length && !args[at + 1].startsWith("-")) {
|
|
564
|
+
at += 1;
|
|
565
|
+
if (!VARIADIC_OPTIONS.has(argument))
|
|
566
|
+
break;
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
return filters;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
/** A filter that matches one spec file, by its path from the project root, whatever the separator. */
|
|
574
|
+
export function specFilter(file) {
|
|
575
|
+
const parts = file.split(/[\\/]/).map((part) => part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"));
|
|
576
|
+
return `/(?:^|[\\\\/])${parts.join("[\\\\/]")}$/`;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
/** A spec file's text declares a serial describe. */
|
|
580
|
+
const SERIAL_DECLARATION = /\.describe\.serial\b|\bmode\s*:\s*["'`]serial["'`]/;
|
|
581
|
+
|
|
582
|
+
/**
|
|
583
|
+
* The spec files the pass spreads over its invocations: those with a serial
|
|
584
|
+
* describe whose tests some mutant still to run is a candidate of. Worked
|
|
585
|
+
* out once a pass, from its plan and the files' text, by the first
|
|
586
|
+
* invocation to start; the rest read it.
|
|
587
|
+
*/
|
|
588
|
+
function spreadFiles(pass, root) {
|
|
589
|
+
const saved = `${pass.shared}/spread-files.json`;
|
|
590
|
+
const known = readJsonOr(saved, undefined);
|
|
591
|
+
if (known)
|
|
592
|
+
return known;
|
|
593
|
+
const plan = readJson(pass.planPath);
|
|
594
|
+
const candidates = new Set();
|
|
595
|
+
for (const mutant of plan.mutants) {
|
|
596
|
+
if (mutant.decided || mutant.serverWide)
|
|
597
|
+
continue;
|
|
598
|
+
for (const candidate of mutant.candidates) {
|
|
599
|
+
const test = plan.tests[candidate.test];
|
|
600
|
+
if (test?.runner === "playwright" && test.file)
|
|
601
|
+
candidates.add(test.file);
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
const files = [...candidates].filter((file) => {
|
|
605
|
+
try {
|
|
606
|
+
return SERIAL_DECLARATION.test(readFileSync(resolve(root, file), "utf8"));
|
|
607
|
+
}
|
|
608
|
+
catch {
|
|
609
|
+
return false;
|
|
610
|
+
}
|
|
611
|
+
}).sort();
|
|
612
|
+
writeJson(saved, files);
|
|
613
|
+
return files;
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
/**
|
|
617
|
+
* Spreads a pass's serial spec files over every invocation that names spec
|
|
618
|
+
* files: a harness that shares tests out to several `playwright test`
|
|
619
|
+
* processes (slots, each with a server and a database of its own) keeps a
|
|
620
|
+
* file with a serial describe whole, in one of them, and that one slot ran
|
|
621
|
+
* every mutant of the file while the others ended early. The strong pass runs
|
|
622
|
+
* a serial describe as a default one and takes a mutant's claim on a test
|
|
623
|
+
* pass-wide, so the file runs in each slot, which takes its own mutants of it
|
|
624
|
+
* from the shared queue. Playwright reads its file filters from the command
|
|
625
|
+
* line before it loads any config, so the preload adds them to `argv`
|
|
626
|
+
* (`argv[2]` is `test`), before Playwright parses it. A command that names
|
|
627
|
+
* no file runs every file already; `--list` is left as it is (a harness
|
|
628
|
+
* shares its tests out from it). The files added, or none.
|
|
629
|
+
*/
|
|
630
|
+
export function spreadSerialFiles(argv, root) {
|
|
631
|
+
const pass = strongPass();
|
|
632
|
+
if (!pass || argv[2] !== "test" || argv.includes("--list"))
|
|
633
|
+
return [];
|
|
634
|
+
if (!fileFilters(argv.slice(3)).length)
|
|
635
|
+
return [];
|
|
636
|
+
const files = spreadFiles(pass, root);
|
|
637
|
+
argv.splice(3, 0, ...files.map(specFilter));
|
|
638
|
+
return files;
|
|
639
|
+
}
|
|
640
|
+
|
|
539
641
|
/**
|
|
540
642
|
* Whether this process lists the tests (`playwright test --list`) rather
|
|
541
643
|
* than run them: it reads no plan and writes nothing, and lists the
|
|
@@ -685,15 +787,37 @@ export function installCopies(baseTest) {
|
|
|
685
787
|
}
|
|
686
788
|
arrange(suite);
|
|
687
789
|
};
|
|
688
|
-
prototype._describe = function (type, ...rest) {
|
|
689
|
-
|
|
790
|
+
prototype._describe = function (type, location, ...rest) {
|
|
791
|
+
if (type === "serial" || type === "serial.only")
|
|
792
|
+
declaredSerial(location);
|
|
793
|
+
return describe.call(this, type === "serial" ? "default" : type === "serial.only" ? "only" : type, location, ...rest);
|
|
690
794
|
};
|
|
691
795
|
prototype._configure = function (location, options) {
|
|
796
|
+
if (options?.mode === "serial")
|
|
797
|
+
declaredSerial(location);
|
|
692
798
|
return configure.call(this, location, options?.mode === "serial" ? { ...options, mode: "default" } : options);
|
|
693
799
|
};
|
|
694
800
|
return true;
|
|
695
801
|
}
|
|
696
802
|
|
|
803
|
+
/**
|
|
804
|
+
* The spec files that declare a serial describe, as this process loaded
|
|
805
|
+
* them (the runner loads every file before its first test): a harness that
|
|
806
|
+
* keeps such a file's tests together gives it to one invocation, and the
|
|
807
|
+
* progress lines say what that costs.
|
|
808
|
+
*/
|
|
809
|
+
const SERIAL_FILES = Symbol.for("supercov.serialFiles");
|
|
810
|
+
function declaredSerial(location) {
|
|
811
|
+
globalThis[SERIAL_FILES] ??= new Set();
|
|
812
|
+
if (location?.file)
|
|
813
|
+
globalThis[SERIAL_FILES].add(realFile(location.file));
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
/** Whether this process loaded `file` (a real path) with a serial describe in it. */
|
|
817
|
+
export function serialFile(file) {
|
|
818
|
+
return Boolean(globalThis[SERIAL_FILES]?.has(realFile(file)));
|
|
819
|
+
}
|
|
820
|
+
|
|
697
821
|
let declaredCopies;
|
|
698
822
|
function copiesOf(file, title) {
|
|
699
823
|
if (!file)
|
|
@@ -984,11 +1108,20 @@ function workLeft(pass, test) {
|
|
|
984
1108
|
* few tests, those whose runs left take longest. `held` are the tests the
|
|
985
1109
|
* invocation runs.
|
|
986
1110
|
*/
|
|
987
|
-
export function queuedWork(pass, work, held) {
|
|
1111
|
+
export function queuedWork(pass, work, held, serial = new Set()) {
|
|
988
1112
|
const settledNow = new Set([...entries(`${pass.shared}/verdicts`), ...entries(`${pass.round}/killed`)]);
|
|
989
1113
|
const claimed = new Map();
|
|
990
1114
|
const tests = [];
|
|
1115
|
+
// Each serial file's mutants waiting for any of its tests.
|
|
1116
|
+
const serialWaiting = new Map();
|
|
991
1117
|
let ms = 0;
|
|
1118
|
+
// Every serial file this invocation runs, whether or not a mutant waits
|
|
1119
|
+
// for it here now: which invocations run a file is what says it is
|
|
1120
|
+
// confined to one.
|
|
1121
|
+
for (const id of held) {
|
|
1122
|
+
if (serial.has(id) && work.tests[id] && !serialWaiting.has(work.tests[id].file))
|
|
1123
|
+
serialWaiting.set(work.tests[id].file, new Set());
|
|
1124
|
+
}
|
|
992
1125
|
for (const id of held) {
|
|
993
1126
|
const test = work.tests[id];
|
|
994
1127
|
let waiting = 0;
|
|
@@ -998,8 +1131,11 @@ export function queuedWork(pass, work, held) {
|
|
|
998
1131
|
continue;
|
|
999
1132
|
if (!claimed.has(at))
|
|
1000
1133
|
claimed.set(at, new Set(entries(`${pass.round}/claims/${at}`)));
|
|
1001
|
-
if (
|
|
1002
|
-
|
|
1134
|
+
if (claimed.get(at).has(key(id)))
|
|
1135
|
+
continue;
|
|
1136
|
+
waiting += 1;
|
|
1137
|
+
if (serial.has(id))
|
|
1138
|
+
serialWaiting.get(test.file).add(at);
|
|
1003
1139
|
}
|
|
1004
1140
|
if (!waiting)
|
|
1005
1141
|
continue;
|
|
@@ -1008,7 +1144,8 @@ export function queuedWork(pass, work, held) {
|
|
|
1008
1144
|
tests.push({ title: test.title ?? id, waiting, baselineMs, limitMs: limitOf(baselineMs, work.timeoutFactor) });
|
|
1009
1145
|
}
|
|
1010
1146
|
tests.sort((a, b) => b.waiting * b.baselineMs - a.waiting * a.baselineMs || a.title.localeCompare(b.title));
|
|
1011
|
-
|
|
1147
|
+
const serialFiles = [...serialWaiting].map(([file, mutants]) => ({ file, mutants: mutants.size })).sort((a, b) => a.file.localeCompare(b.file));
|
|
1148
|
+
return { ms, tests: tests.slice(0, COSTLY_SHOWN), ...(serialFiles.length ? { serial: serialFiles } : {}) };
|
|
1012
1149
|
}
|
|
1013
1150
|
|
|
1014
1151
|
/**
|
|
@@ -1170,6 +1307,10 @@ export function outcomeOf(status, errors) {
|
|
|
1170
1307
|
return { outcome: "passed" };
|
|
1171
1308
|
if (status === "skipped")
|
|
1172
1309
|
return { outcome: "skipped" };
|
|
1310
|
+
// Stopped from outside (the budget, a signal): it neither passed nor
|
|
1311
|
+
// failed, and settles nothing.
|
|
1312
|
+
if (status === "interrupted")
|
|
1313
|
+
return { outcome: "interrupted" };
|
|
1173
1314
|
if (errors.length > 0 && timeout(errors[0]))
|
|
1174
1315
|
return { outcome: "timed-out", message };
|
|
1175
1316
|
return { outcome: "failed", message };
|
|
@@ -10,8 +10,9 @@
|
|
|
10
10
|
// verdict its verdict, or the round that runs it next: one verdict a mutant,
|
|
11
11
|
// from whichever invocations ran it, and what was cut short is unfinished.
|
|
12
12
|
import { appendFileSync, existsSync, readFileSync, realpathSync, statSync } from "node:fs";
|
|
13
|
+
import { dirname, join } from "node:path";
|
|
13
14
|
import { pathToFileURL } from "node:url";
|
|
14
|
-
import { attemptPath, baselineOf, entries, invocation, EVERYWHERE, firstWords, giveVerdict, key, loadPass, outcomeOf, placeOf, queuedWork, readJson, reasonOf, settleAttempt, strongPass, verdictOf, withoutCopy, writeJson } from "./playwrightStrong.mjs";
|
|
15
|
+
import { attemptPath, baselineOf, entries, invocation, EVERYWHERE, firstWords, giveVerdict, key, loadPass, outcomeOf, placeOf, queuedWork, readJson, reasonOf, serialFile, settleAttempt, strongPass, verdictOf, withoutCopy, writeJson } from "./playwrightStrong.mjs";
|
|
15
16
|
|
|
16
17
|
// How often, at most, the status file is written.
|
|
17
18
|
const STATUS_MS = 1_000;
|
|
@@ -68,6 +69,8 @@ export default class SupercovPlaywrightStrongReporter {
|
|
|
68
69
|
// The tests this invocation runs, and the baseline time of the runs
|
|
69
70
|
// it ended: its pace, for the time its work left takes.
|
|
70
71
|
this.held = [];
|
|
72
|
+
// Those of them in a file with a serial describe.
|
|
73
|
+
this.serial = new Set();
|
|
71
74
|
this.doneMs = 0;
|
|
72
75
|
this.queuedAt = 0;
|
|
73
76
|
}
|
|
@@ -91,8 +94,11 @@ export default class SupercovPlaywrightStrongReporter {
|
|
|
91
94
|
if (withoutCopy(test.titlePath()).copy)
|
|
92
95
|
continue;
|
|
93
96
|
writeJson(`${this.pass.round}/originals/${key(placeOf(test))}`, test.id);
|
|
94
|
-
if (this.work.tests[test.id]?.jobs)
|
|
97
|
+
if (this.work.tests[test.id]?.jobs) {
|
|
95
98
|
this.held.push(test.id);
|
|
99
|
+
if (serialFile(test.location.file))
|
|
100
|
+
this.serial.add(test.id);
|
|
101
|
+
}
|
|
96
102
|
}
|
|
97
103
|
this.copies = copies;
|
|
98
104
|
const mutants = Object.keys(this.work.entries).length;
|
|
@@ -227,7 +233,7 @@ export default class SupercovPlaywrightStrongReporter {
|
|
|
227
233
|
countQueued() {
|
|
228
234
|
this.queuedAt = Date.now();
|
|
229
235
|
try {
|
|
230
|
-
const queued = queuedWork(this.pass, this.work, this.held);
|
|
236
|
+
const queued = queuedWork(this.pass, this.work, this.held, this.serial);
|
|
231
237
|
const spent = (this.lastEndedAt ?? 0) - (this.firstStartedAt ?? 0);
|
|
232
238
|
if (this.doneMs > 0 && spent > 0)
|
|
233
239
|
queued.leftMs = Math.round((queued.ms * spent) / this.doneMs);
|
|
@@ -321,7 +327,13 @@ export default class SupercovPlaywrightStrongReporter {
|
|
|
321
327
|
else
|
|
322
328
|
serial.push(job);
|
|
323
329
|
};
|
|
324
|
-
|
|
330
|
+
// A round the budget or a signal stopped: from the moment it began
|
|
331
|
+
// to stop (`stopped-at`, beside the results), its servers went down
|
|
332
|
+
// under the tests still running, and a test that ended after it
|
|
333
|
+
// says nothing of its mutant. So, from an error outside any test.
|
|
334
|
+
const stopped = process.env["SUPERCOV_STRONG_STOPPED"] === "1";
|
|
335
|
+
const stoppedAt = Number(readJsonOr(join(dirname(pass.resultsPath), "stopped-at"))) || Infinity;
|
|
336
|
+
const trustedUntil = Math.min(globalError ? globalError.at : Infinity, stoppedAt);
|
|
325
337
|
// One mutant an invocation: which invocation took each, and where a
|
|
326
338
|
// server of that invocation ran it (an invocation whose server was
|
|
327
339
|
// started before it, outside it, never ran its mutant there).
|
|
@@ -365,7 +377,8 @@ export default class SupercovPlaywrightStrongReporter {
|
|
|
365
377
|
continue;
|
|
366
378
|
}
|
|
367
379
|
// A kill no control came after (the round ended first): as sure as a
|
|
368
|
-
// kill on a server no other mutant's attempt shared
|
|
380
|
+
// kill on a server no other mutant's attempt shared, where it ended
|
|
381
|
+
// before the round began to stop.
|
|
369
382
|
const killer = failed.find((attempt) => !attempt.beside && attempt.endedAt < trustedUntil);
|
|
370
383
|
if (killer) {
|
|
371
384
|
const { status, reason } = verdictOf(killer);
|
|
@@ -408,12 +421,26 @@ export default class SupercovPlaywrightStrongReporter {
|
|
|
408
421
|
}
|
|
409
422
|
for (const job of work.restarts)
|
|
410
423
|
next(job, job.reason, job.tests);
|
|
424
|
+
// What each mutant left open passed: its candidates that ran with it
|
|
425
|
+
// and passed (before any error outside a test), by the plan's ids. A
|
|
426
|
+
// later pass, or a later round, resumes there. A round of mutants a
|
|
427
|
+
// server ran from its start lends nothing to a request's own switch.
|
|
428
|
+
if (kind !== "alone") {
|
|
429
|
+
for (const id of Object.keys(work.entries)) {
|
|
430
|
+
if (existsSync(`${pass.shared}/verdicts/${key(id)}`))
|
|
431
|
+
continue;
|
|
432
|
+
const passed = (byMutant.get(id) ?? [])
|
|
433
|
+
.filter((attempt) => attempt.outcome === "passed" && attempt.endedAt < trustedUntil)
|
|
434
|
+
.map((attempt) => work.tests[attempt.original]?.planId ?? attempt.original);
|
|
435
|
+
if (passed.length)
|
|
436
|
+
write({ progress: true, id, passed: [...new Set(passed)].sort() });
|
|
437
|
+
}
|
|
438
|
+
}
|
|
411
439
|
// A round of what an earlier one left that ran to its end and decided
|
|
412
440
|
// nothing would only ask for the same again. One the budget or a
|
|
413
441
|
// signal stopped leaves its mutants without a verdict, for the next
|
|
414
442
|
// pass (a confirmation round stopped before its first test made two
|
|
415
443
|
// mutants of a 60 s pass `error`s).
|
|
416
|
-
const stopped = process.env["SUPERCOV_STRONG_STOPPED"] === "1";
|
|
417
444
|
if (kind !== "main" && !decided && !stopped) {
|
|
418
445
|
for (const job of rest)
|
|
419
446
|
write({ id: job.id, status: "error", reason: "its tests did not finish, in two rounds", tests: 0, durationMs: 0 });
|
|
@@ -1086,6 +1086,14 @@ if (generatedPlaywrightConfig &&
|
|
|
1086
1086
|
}
|
|
1087
1087
|
}
|
|
1088
1088
|
process.argv.push("--config", generatedPlaywrightConfig);
|
|
1089
|
+
// A strong pass spreads its serial spec files over every invocation of
|
|
1090
|
+
// Playwright that names spec files (playwrightStrong.mjs).
|
|
1091
|
+
if (process.env.SUPERCOV_STRONG_PLAN) {
|
|
1092
|
+
const strong = await import(__rewriteRelativeImportExtension(new URL("./playwrightStrong.mjs", import.meta.url)));
|
|
1093
|
+
const spread = strong.spreadSerialFiles(process.argv, projectRoot ?? process.cwd());
|
|
1094
|
+
if (spread.length)
|
|
1095
|
+
console.log(`[supercov] strong pass: ${spread.length} spec file(s) with a serial describe run in this invocation too, each taking its own mutants of them: ${spread.join(", ")}`);
|
|
1096
|
+
}
|
|
1089
1097
|
}
|
|
1090
1098
|
// A process the runner marked as not a test worker skips the wrapper, unless
|
|
1091
1099
|
// it was started from Playwright's own files: a worker Playwright starts some
|
|
@@ -2346,6 +2346,17 @@ function registerProbeV2(definition) {
|
|
|
2346
2346
|
none: optionalCallEmptySpread
|
|
2347
2347
|
};
|
|
2348
2348
|
rememberProbeV2File(file);
|
|
2349
|
+
// The module registering is loading until its top level ends: see trackV2.
|
|
2350
|
+
try {
|
|
2351
|
+
markModuleLoading(file);
|
|
2352
|
+
} catch {
|
|
2353
|
+
}
|
|
2354
|
+
file.loaded = () => {
|
|
2355
|
+
try {
|
|
2356
|
+
valueReadState().loading.delete(file);
|
|
2357
|
+
} catch {
|
|
2358
|
+
}
|
|
2359
|
+
};
|
|
2349
2360
|
// What a probe calls: this file's hit, by place alone. Outside a loop the
|
|
2350
2361
|
// probe is the call alone and this makes its check, so it stays small
|
|
2351
2362
|
// enough for V8 to inline where the code is hot. The epoch is NaN wherever
|
|
@@ -2725,6 +2736,174 @@ function valueV2(site, value) {
|
|
|
2725
2736
|
}
|
|
2726
2737
|
return value;
|
|
2727
2738
|
}
|
|
2739
|
+
// Module-level values (docs/design/strong-mutation.md, "Module-level
|
|
2740
|
+
// values"). An object or array literal a module's top level makes, holding a
|
|
2741
|
+
// module-level mutant, is read through a proxy: each read is a hit of a point
|
|
2742
|
+
// of the literal -- one for any read, one for each key a mutant is under --
|
|
2743
|
+
// credited as every hit is, to the test whose work read it. A read while a
|
|
2744
|
+
// module loads is a hit of the literal's other points, its escapes: what that
|
|
2745
|
+
// read took (a copy, a lookup table built from it) outlives the read, and the
|
|
2746
|
+
// plan then takes every test that loaded the module, as without the proxies.
|
|
2747
|
+
// The state is on the global object, so copies of this runtime in one realm
|
|
2748
|
+
// agree on whether a module is loading.
|
|
2749
|
+
const valueReadStateKey = Symbol.for("supercov.valueReads");
|
|
2750
|
+
const capturedQueueMicrotask = typeof queueMicrotask === "function" ? queueMicrotask : void 0;
|
|
2751
|
+
function valueReadState() {
|
|
2752
|
+
let reads = globalThis[valueReadStateKey];
|
|
2753
|
+
if (reads === void 0) {
|
|
2754
|
+
reads = { loading: /* @__PURE__ */ new Set(), resetQueued: false, targets: /* @__PURE__ */ new WeakMap(), cloneWrapped: false };
|
|
2755
|
+
try {
|
|
2756
|
+
Object.defineProperty(globalThis, valueReadStateKey, { __proto__: null, value: reads, configurable: true });
|
|
2757
|
+
} catch {
|
|
2758
|
+
return reads;
|
|
2759
|
+
}
|
|
2760
|
+
}
|
|
2761
|
+
return reads;
|
|
2762
|
+
}
|
|
2763
|
+
// A module is loading from its registration, the first thing its code does,
|
|
2764
|
+
// to the end of its top level, where it calls its file's `loaded()`. One that
|
|
2765
|
+
// throws there never gets to it: no module is loading once the code that
|
|
2766
|
+
// loaded it gives up the thread, as module graphs evaluate synchronously, and
|
|
2767
|
+
// the first microtask after runs once they are done. A module's top-level
|
|
2768
|
+
// await gives it up too, and `resumeV2` marks it loading again where it
|
|
2769
|
+
// resumes.
|
|
2770
|
+
function markModuleLoading(file) {
|
|
2771
|
+
const reads = valueReadState();
|
|
2772
|
+
reads.loading.add(file);
|
|
2773
|
+
if (reads.resetQueued)
|
|
2774
|
+
return;
|
|
2775
|
+
reads.resetQueued = true;
|
|
2776
|
+
const reset = () => {
|
|
2777
|
+
reads.loading.clear();
|
|
2778
|
+
reads.resetQueued = false;
|
|
2779
|
+
};
|
|
2780
|
+
if (capturedQueueMicrotask !== void 0)
|
|
2781
|
+
capturedQueueMicrotask(reset);
|
|
2782
|
+
else
|
|
2783
|
+
Promise.resolve().then(reset);
|
|
2784
|
+
}
|
|
2785
|
+
function resumeV2(file, value) {
|
|
2786
|
+
try {
|
|
2787
|
+
markModuleLoading(file);
|
|
2788
|
+
} catch {
|
|
2789
|
+
}
|
|
2790
|
+
return value;
|
|
2791
|
+
}
|
|
2792
|
+
// `file`'s points from `base`: any read, any read while loading, then a read
|
|
2793
|
+
// and a read while loading for each of `keys`.
|
|
2794
|
+
function trackV2(file, base, keys, value) {
|
|
2795
|
+
if (value === null || typeof value !== "object" && typeof value !== "function")
|
|
2796
|
+
return value;
|
|
2797
|
+
let reads;
|
|
2798
|
+
try {
|
|
2799
|
+
reads = valueReadState();
|
|
2800
|
+
wrapStructuredClone(reads);
|
|
2801
|
+
} catch {
|
|
2802
|
+
return value;
|
|
2803
|
+
}
|
|
2804
|
+
const places = /* @__PURE__ */ new Map();
|
|
2805
|
+
for (let place = 0; place < keys.length; place += 1)
|
|
2806
|
+
places.set(keys[place], place);
|
|
2807
|
+
const note = (key) => {
|
|
2808
|
+
try {
|
|
2809
|
+
const place = typeof key === "string" ? places.get(key) : void 0;
|
|
2810
|
+
const loading = reads.loading.size > 0 ? 1 : 0;
|
|
2811
|
+
file.hit(base + loading);
|
|
2812
|
+
if (place !== void 0)
|
|
2813
|
+
file.hit(base + 2 + 2 * place + loading);
|
|
2814
|
+
} catch {
|
|
2815
|
+
}
|
|
2816
|
+
};
|
|
2817
|
+
const proxy = new Proxy(value, {
|
|
2818
|
+
__proto__: null,
|
|
2819
|
+
get(target, key, receiver) {
|
|
2820
|
+
note(key);
|
|
2821
|
+
return Reflect.get(target, key, receiver);
|
|
2822
|
+
},
|
|
2823
|
+
has(target, key) {
|
|
2824
|
+
note(key);
|
|
2825
|
+
return Reflect.has(target, key);
|
|
2826
|
+
},
|
|
2827
|
+
getOwnPropertyDescriptor(target, key) {
|
|
2828
|
+
note(key);
|
|
2829
|
+
return Reflect.getOwnPropertyDescriptor(target, key);
|
|
2830
|
+
},
|
|
2831
|
+
ownKeys(target) {
|
|
2832
|
+
note(void 0);
|
|
2833
|
+
return Reflect.ownKeys(target);
|
|
2834
|
+
},
|
|
2835
|
+
set(target, key, assigned, receiver) {
|
|
2836
|
+
note(key);
|
|
2837
|
+
return Reflect.set(target, key, assigned, receiver === proxy ? target : receiver);
|
|
2838
|
+
},
|
|
2839
|
+
defineProperty(target, key, descriptor) {
|
|
2840
|
+
note(key);
|
|
2841
|
+
return Reflect.defineProperty(target, key, descriptor);
|
|
2842
|
+
},
|
|
2843
|
+
deleteProperty(target, key) {
|
|
2844
|
+
note(key);
|
|
2845
|
+
return Reflect.deleteProperty(target, key);
|
|
2846
|
+
}
|
|
2847
|
+
});
|
|
2848
|
+
reads.targets.set(proxy, value);
|
|
2849
|
+
return proxy;
|
|
2850
|
+
}
|
|
2851
|
+
// structuredClone refuses a proxy. A value the program clones, which holds
|
|
2852
|
+
// a tracked literal, is cloned as a copy read through it: every value the
|
|
2853
|
+
// clone holds is read, as the clone reads it without the proxies.
|
|
2854
|
+
function wrapStructuredClone(reads) {
|
|
2855
|
+
if (reads.cloneWrapped)
|
|
2856
|
+
return;
|
|
2857
|
+
reads.cloneWrapped = true;
|
|
2858
|
+
const native = globalThis.structuredClone;
|
|
2859
|
+
if (typeof native !== "function")
|
|
2860
|
+
return;
|
|
2861
|
+
const cloning = function structuredClone(value, options) {
|
|
2862
|
+
try {
|
|
2863
|
+
return arguments.length > 1 ? native(value, options) : native(value);
|
|
2864
|
+
} catch (error) {
|
|
2865
|
+
const copies = /* @__PURE__ */ new Map();
|
|
2866
|
+
let held = false;
|
|
2867
|
+
const copy = (inner) => {
|
|
2868
|
+
if (inner === null || typeof inner !== "object")
|
|
2869
|
+
return inner;
|
|
2870
|
+
if (copies.has(inner))
|
|
2871
|
+
return copies.get(inner);
|
|
2872
|
+
const tracked = reads.targets.has(inner);
|
|
2873
|
+
held || (held = tracked);
|
|
2874
|
+
if (!tracked && !Array.isArray(inner) && Object.getPrototypeOf(inner) !== Object.prototype && !(inner instanceof Map) && !(inner instanceof Set))
|
|
2875
|
+
return inner;
|
|
2876
|
+
if (inner instanceof Map) {
|
|
2877
|
+
const made2 = /* @__PURE__ */ new Map();
|
|
2878
|
+
copies.set(inner, made2);
|
|
2879
|
+
for (const [key, entry] of inner)
|
|
2880
|
+
made2.set(copy(key), copy(entry));
|
|
2881
|
+
return made2;
|
|
2882
|
+
}
|
|
2883
|
+
if (inner instanceof Set) {
|
|
2884
|
+
const made2 = /* @__PURE__ */ new Set();
|
|
2885
|
+
copies.set(inner, made2);
|
|
2886
|
+
for (const entry of inner)
|
|
2887
|
+
made2.add(copy(entry));
|
|
2888
|
+
return made2;
|
|
2889
|
+
}
|
|
2890
|
+
const made = Array.isArray(inner) ? new Array(inner.length) : {};
|
|
2891
|
+
copies.set(inner, made);
|
|
2892
|
+
for (const key of Object.keys(inner))
|
|
2893
|
+
made[key] = copy(inner[key]);
|
|
2894
|
+
return made;
|
|
2895
|
+
};
|
|
2896
|
+
const unwrapped = copy(value);
|
|
2897
|
+
if (!held)
|
|
2898
|
+
throw error;
|
|
2899
|
+
return arguments.length > 1 ? native(unwrapped, options) : native(unwrapped);
|
|
2900
|
+
}
|
|
2901
|
+
};
|
|
2902
|
+
try {
|
|
2903
|
+
Object.defineProperty(globalThis, "structuredClone", { __proto__: null, value: cloning, writable: true, configurable: true, enumerable: false });
|
|
2904
|
+
} catch {
|
|
2905
|
+
}
|
|
2906
|
+
}
|
|
2728
2907
|
// Strong mutation (mutant schemata). A file instrumented in strong mode has
|
|
2729
2908
|
// every listed mutant behind a switch and reads one record from here when
|
|
2730
2909
|
// it loads, `strongSlot(file)`, with `file` its path from the project root
|
|
@@ -3445,6 +3624,8 @@ const directRuntimeApi = {
|
|
|
3445
3624
|
assignV2,
|
|
3446
3625
|
methodV2,
|
|
3447
3626
|
valueV2,
|
|
3627
|
+
trackV2,
|
|
3628
|
+
resumeV2,
|
|
3448
3629
|
strongSlot,
|
|
3449
3630
|
setActiveMutant,
|
|
3450
3631
|
clearActiveMutant,
|
|
@@ -3527,6 +3708,8 @@ export {
|
|
|
3527
3708
|
assignV2,
|
|
3528
3709
|
methodV2,
|
|
3529
3710
|
valueV2,
|
|
3711
|
+
trackV2,
|
|
3712
|
+
resumeV2,
|
|
3530
3713
|
strongSlot,
|
|
3531
3714
|
setActiveMutant,
|
|
3532
3715
|
clearActiveMutant,
|