supercov 4.29.6 → 4.29.8
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
|
@@ -542,9 +542,11 @@ phpunit`). See `docs/design/strong-mutation.md`,
|
|
|
542
542
|
job's run holds its share's verdicts, `merge` keeps them all in the merged
|
|
543
543
|
run, and a later `supercov mutants` keeps each verdict nothing changed could
|
|
544
544
|
move from whichever earlier run holds it (see
|
|
545
|
-
[Combine shards](#combine-shards)). `supercov mutants --shard`
|
|
545
|
+
[Combine shards](#combine-shards)). `supercov mutants --shard` saves into a
|
|
546
546
|
run of its own even on an unchanged checkout, so a job never saves into a
|
|
547
|
-
run it restored, which every job of its round holds a copy of.
|
|
547
|
+
run it restored, which every job of its round holds a copy of. There it
|
|
548
|
+
makes that run from the newest restored run whose command passed, without
|
|
549
|
+
measuring again, and keeps every verdict the restored runs hold.
|
|
548
550
|
- `--critical <glob>` (repeatable): every mutant there must be killed or
|
|
549
551
|
accepted, or the command fails.
|
|
550
552
|
- `--fail-on survived,timeout,no-coverage,error`: fail on any asked mutant with
|
|
@@ -558,9 +560,11 @@ phpunit`). See `docs/design/strong-mutation.md`,
|
|
|
558
560
|
that never ended, Ctrl-C, a killed job) keeps what it decided, and the next
|
|
559
561
|
pass runs the rest. Ctrl-C or SIGTERM stops every process the pass started,
|
|
560
562
|
and the pass ends within seconds: 8 s after the signal at the latest.
|
|
561
|
-
- `--budget <seconds>` stops the pass once it is spent
|
|
562
|
-
|
|
563
|
-
|
|
563
|
+
- `--budget <seconds>` stops the pass once it is spent, counted from the
|
|
564
|
+
command's start (with `supercov mutants`, measuring included): it ends as a
|
|
565
|
+
finished pass, its verdicts saved, and says how many mutants it left for the
|
|
566
|
+
next, and what measuring took where that was half the budget or more. The
|
|
567
|
+
cheapest mutants run first, by their tests' recorded times.
|
|
564
568
|
- `--timeout-factor <x>`: a Playwright test that runs with a mutant is
|
|
565
569
|
stopped past x times its baseline + 5 s (default 1.5, StrykerJS's), and the
|
|
566
570
|
mutant is a `timeout`. `SUPERCOV_STRONG_TIMEOUT_FACTOR` sets it where the
|
|
@@ -1231,8 +1235,9 @@ another measured again lends none either. Split a strong pass across jobs this
|
|
|
1231
1235
|
way: each job measures and runs `supercov mutants --shard k/n -- <command>`,
|
|
1232
1236
|
and the last merges (see `docs/mutation.md`, A pass split across jobs). A
|
|
1233
1237
|
second round on the same commit restores the first round's runs and does the
|
|
1234
|
-
same: each job
|
|
1235
|
-
|
|
1238
|
+
same: each job saves into a run of its own, made from a restored one without
|
|
1239
|
+
measuring again, which keeps the restored runs' verdicts and replaces them,
|
|
1240
|
+
and the last job's `merge` takes the new runs.
|
|
1236
1241
|
|
|
1237
1242
|
A run named twice is refused (`Each merged run must be unique: r1 is named
|
|
1238
1243
|
more than once`): copies of one run that several jobs saved verdicts into
|
package/docs/mutation.md
CHANGED
|
@@ -104,10 +104,16 @@ summary gives the mutation score, every verdict counted, and ends with the
|
|
|
104
104
|
mutants the tests let survive.
|
|
105
105
|
|
|
106
106
|
- **Unchanged checkout.** The next `supercov mutants` reads the same run again
|
|
107
|
-
and runs nothing it already decided. With `--shard` it
|
|
108
|
-
own
|
|
109
|
-
run
|
|
110
|
-
|
|
107
|
+
and runs nothing it already decided. With `--shard` it saves into a run of
|
|
108
|
+
its own, so that each job's share is saved into a run no other job writes:
|
|
109
|
+
made from the newest run of the checkout whose command passed, without
|
|
110
|
+
measuring again (`not measuring: the checkout is unchanged since run r4, so
|
|
111
|
+
this shard saves its verdicts into run r9, made from it`), or measured where
|
|
112
|
+
there is none (see [A pass split across jobs](#a-pass-split-across-jobs)).
|
|
113
|
+
An earlier run measured on the same files, byte for byte, keeps every
|
|
114
|
+
verdict a pass reached, whatever the two measurements recorded: a test
|
|
115
|
+
whose path depends on the time, or that failed in one of them, moves no
|
|
116
|
+
verdict.
|
|
111
117
|
- **After an edit.** It measures the checkout again and keeps an earlier
|
|
112
118
|
verdict for each mutant whose file is as it was and whose candidate tests,
|
|
113
119
|
and their test files, nothing changed could reach, as `runs latest tests
|
|
@@ -115,9 +121,13 @@ mutants the tests let survive.
|
|
|
115
121
|
edit the tests that ran the changed code. Each mutant's verdict comes from
|
|
116
122
|
the newest earlier run of the same command, dependencies and configuration
|
|
117
123
|
that holds one it can keep, so a pass split across jobs, each holding part
|
|
118
|
-
of the verdicts in its own run, is kept whole.
|
|
119
|
-
|
|
120
|
-
|
|
124
|
+
of the verdicts in its own run, is kept whole. A test that failed in the
|
|
125
|
+
earlier run counts as reached only where the change reaches code that run
|
|
126
|
+
covered. The rest run, and the summary says how many verdicts were kept and
|
|
127
|
+
from which runs (`193 verdict(s) kept from runs r2, r1: nothing they depend
|
|
128
|
+
on changed`), and how many were not, by why (`6 earlier verdict(s) not kept,
|
|
129
|
+
so run again: 4 their file changed, 2 a test that could kill them could
|
|
130
|
+
reach a change`). An error is never kept: it runs again.
|
|
121
131
|
- **Interrupted.** Each verdict is saved as it is made. A pass stopped by
|
|
122
132
|
Ctrl-C, a killed job or a test worker that never ended keeps what it
|
|
123
133
|
decided, and the next pass runs only the rest. Sent SIGINT or SIGTERM, the
|
|
@@ -125,10 +135,23 @@ mutants the tests let survive.
|
|
|
125
135
|
not ended 8 s after the signal is ended, what it decided saved first.
|
|
126
136
|
- **Order and budget.** The cheapest mutants run first, by the recorded times
|
|
127
137
|
of the tests each runs against, so a pass cut short has decided as many as
|
|
128
|
-
it could. `--budget <seconds>`
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
138
|
+
it could. `--budget <seconds>` is the whole command's, measuring and
|
|
139
|
+
planning included: once it is spent the pass stops and ends as a finished
|
|
140
|
+
one, its verdicts saved, so a job ends when its budget says. The summary
|
|
141
|
+
says how many mutants it left for the next pass (`budget of 2400 s spent:
|
|
142
|
+
812 mutant(s) left without a verdict, for the next pass`), and, where
|
|
143
|
+
measuring took half the budget or more, what it took (`measuring took 310 s
|
|
144
|
+
of the 450 s budget, which leaves the pass 140 s`). A measurement is never
|
|
145
|
+
cut short, since one stopped halfway records nothing: one that outlasts the
|
|
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.
|
|
132
155
|
- **Exit codes.** `0` with an answer; `1` when `--fail-on` or `--critical`
|
|
133
156
|
finds a mutant; `2`, after the answer, when the measured command failed (a
|
|
134
157
|
failing test kills nothing, so the verdicts cannot gate) or no mutant could
|
|
@@ -225,8 +248,8 @@ npx supercov runs latest mutants test --plan --json
|
|
|
225
248
|
- `--shard k/n` runs one of n shares of the mutants, of about the same cost,
|
|
226
249
|
for parallel jobs (see
|
|
227
250
|
[A pass split across jobs](#a-pass-split-across-jobs)).
|
|
228
|
-
- `--budget <seconds>` stops the pass once that time is spent
|
|
229
|
-
saved, and leaves the rest for the next pass.
|
|
251
|
+
- `--budget <seconds>` stops the pass once that time is spent since the
|
|
252
|
+
command started, its verdicts saved, and leaves the rest for the next pass.
|
|
230
253
|
- `--timeout-factor <x>` (or `SUPERCOV_STRONG_TIMEOUT_FACTOR`) sets a
|
|
231
254
|
Playwright test's time limit when it runs with a mutant: x times its
|
|
232
255
|
baseline, + 5 s (default 1.5, StrykerJS's `timeoutFactor`). See
|
|
@@ -285,7 +308,8 @@ the latest one saved for its commit, or else the latest one saved.
|
|
|
285
308
|
|
|
286
309
|
`supercov mutants --shard k/n -- <command>` is `supercov -- <command>` with
|
|
287
310
|
the mutants' probes on, then `runs latest mutants test --shard k/n`, keeping
|
|
288
|
-
earlier verdicts as after an edit.
|
|
311
|
+
earlier verdicts as after an edit. On a checkout unchanged since a run it
|
|
312
|
+
restored, it measures nothing, as below. Name the command after `--`: without it,
|
|
289
313
|
`supercov mutants` takes the latest run's, which after a merge is the merge.
|
|
290
314
|
Every job must measure the same commit with the same dependencies, as for any
|
|
291
315
|
merge ([CLI reference](cli.md#combine-shards)).
|
|
@@ -295,9 +319,10 @@ merge ([CLI reference](cli.md#combine-shards)).
|
|
|
295
319
|
every share gets its part of the costly ones. A mutant's cost there is what
|
|
296
320
|
the plan lists of it, the copies of test files it starts and the tests they
|
|
297
321
|
run, not the tests' times, which differ between jobs.
|
|
298
|
-
- **The budget.** `--budget <seconds>` ends a job
|
|
299
|
-
`timeout` around it:
|
|
300
|
-
|
|
322
|
+
- **The budget.** `--budget <seconds>` ends a job in time without a
|
|
323
|
+
`timeout` around it: it counts from the command's start, measuring
|
|
324
|
+
included, and past it the pass stops, saves what it decided, and exits as
|
|
325
|
+
a finished pass. Within a pass the cheapest mutants
|
|
301
326
|
run first, so a job cut short has decided as many as it could, and the
|
|
302
327
|
mutants it left run in the next commit's pass, where the restored runs lend
|
|
303
328
|
the rest of their verdicts.
|
|
@@ -310,11 +335,16 @@ merge ([CLI reference](cli.md#combine-shards)).
|
|
|
310
335
|
that run has no verdict for it, as a unit run merged with an end-to-end run
|
|
311
336
|
can, the mutant is left undecided, and a pass over the merged run runs it.
|
|
312
337
|
Verdicts of another mutant set are not kept, and the merge says whose.
|
|
313
|
-
- **Another round.** On the commit the restored runs measured, each job
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
338
|
+
- **Another round.** On the commit the restored runs measured, each job saves
|
|
339
|
+
into a run of its own: `supercov mutants --shard` never saves into a run it
|
|
340
|
+
restored, of which every job of the round holds a copy. It makes that run
|
|
341
|
+
from the newest restored run whose command passed and that recorded its
|
|
342
|
+
mutants' values, without measuring again: the run holds that run's evidence
|
|
343
|
+
under an id of its own. It keeps every verdict a pass reached that the
|
|
344
|
+
restored runs hold (`1317 verdict(s) kept from runs r8, r7, r6, r5: the
|
|
345
|
+
checkout is unchanged since them`), and the shares are of what is left.
|
|
346
|
+
Mutants the plan decides without running, such as a survivor no test
|
|
347
|
+
infected, are decided again, not kept. Each job's run replaces the
|
|
318
348
|
restored ones of its command, so the last job's `supercov merge` takes this
|
|
319
349
|
round's runs, whose verdicts hold the earlier rounds'. It says how many
|
|
320
350
|
verdicts came from each run (`1265 strong verdict(s) kept from runs r8, r7,
|
|
@@ -331,7 +361,9 @@ merge ([CLI reference](cli.md#combine-shards)).
|
|
|
331
361
|
so every job of a second round wrote its share into a copy of one run. The
|
|
332
362
|
copies share an id, one directory of `.supercov/runs` holds one of them, and
|
|
333
363
|
`supercov merge` refuses a run named more than once, saying so. Run that
|
|
334
|
-
round again: each job now
|
|
364
|
+
round again: each job now saves into a run of its own. In 4.29.6 that run
|
|
365
|
+
was measured again, which cost each job the suite's time and could drop a
|
|
366
|
+
verdict where a test failed in one of the measurements.
|
|
335
367
|
|
|
336
368
|
### Runners without a driver
|
|
337
369
|
|
|
@@ -425,6 +457,19 @@ no mutants shows none of this.
|
|
|
425
457
|
has left. A candidate in a project others start from (a login `setup`)
|
|
426
458
|
never runs with a mutant: a mutant no other test kills is an `error` that
|
|
427
459
|
says so.
|
|
460
|
+
- **A harness with slots.** A harness may run several `playwright test`
|
|
461
|
+
processes at once (slots, each with its own server and database) and keep
|
|
462
|
+
a spec file with a serial describe whole, in one slot. In a strong pass
|
|
463
|
+
such a file runs in every slot whose command names spec files, and each
|
|
464
|
+
slot takes its own mutants of it from a queue the pass's slots share, so one
|
|
465
|
+
slot no longer runs all of them. Nothing in the harness or the command
|
|
466
|
+
changes: Supercov's preload adds the file to each invocation's file filters
|
|
467
|
+
before Playwright reads them, and leaves `--list` as it is. Each slot runs
|
|
468
|
+
the file's tests once without a mutant before its first mutant there. A
|
|
469
|
+
file it cannot spread (one that sets its serial mode in a helper of its
|
|
470
|
+
own) is named in the progress lines, with what it costs (`"e2e/buy.spec.ts"
|
|
471
|
+
has a serial describe, and 1 of the 6 invocations runs it: its 37 mutant(s)
|
|
472
|
+
wait about 12m00s there, the others about 1m00s`).
|
|
428
473
|
- **Jest and Mocha** run in resident runners, as StrykerJS's do; `node:test`,
|
|
429
474
|
AVA, node-tap, `bun:test` and Vitest Browser Mode run one test file per
|
|
430
475
|
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.8",
|
|
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.8",
|
|
129
|
+
"@supercov/cli-darwin-x64": "4.29.8",
|
|
130
|
+
"@supercov/cli-linux-arm64-gnu": "4.29.8",
|
|
131
|
+
"@supercov/cli-linux-arm64-musl": "4.29.8",
|
|
132
|
+
"@supercov/cli-linux-x64-gnu": "4.29.8",
|
|
133
|
+
"@supercov/cli-linux-x64-musl": "4.29.8",
|
|
134
|
+
"@supercov/cli-win32-arm64": "4.29.8",
|
|
135
|
+
"@supercov/cli-win32-x64": "4.29.8"
|
|
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
|