supercov 4.29.5 → 4.29.7
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,7 +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)).
|
|
545
|
+
[Combine shards](#combine-shards)). `supercov mutants --shard` saves into a
|
|
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. 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.
|
|
546
550
|
- `--critical <glob>` (repeatable): every mutant there must be killed or
|
|
547
551
|
accepted, or the command fails.
|
|
548
552
|
- `--fail-on survived,timeout,no-coverage,error`: fail on any asked mutant with
|
|
@@ -556,9 +560,11 @@ phpunit`). See `docs/design/strong-mutation.md`,
|
|
|
556
560
|
that never ended, Ctrl-C, a killed job) keeps what it decided, and the next
|
|
557
561
|
pass runs the rest. Ctrl-C or SIGTERM stops every process the pass started,
|
|
558
562
|
and the pass ends within seconds: 8 s after the signal at the latest.
|
|
559
|
-
- `--budget <seconds>` stops the pass once it is spent
|
|
560
|
-
|
|
561
|
-
|
|
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.
|
|
562
568
|
- `--timeout-factor <x>`: a Playwright test that runs with a mutant is
|
|
563
569
|
stopped past x times its baseline + 5 s (default 1.5, StrykerJS's), and the
|
|
564
570
|
mutant is a `timeout`. `SUPERCOV_STRONG_TIMEOUT_FACTOR` sets it where the
|
|
@@ -1215,8 +1221,11 @@ adds none, and where its tests ran a mutant, a verdict that needs values they
|
|
|
1215
1221
|
did not record is `unknown`.
|
|
1216
1222
|
|
|
1217
1223
|
The merged run keeps the strong verdicts the runs saved (`mutants test`,
|
|
1218
|
-
`--shard` among them), by mutant, and `merge` prints how many
|
|
1219
|
-
|
|
1224
|
+
`--shard` among them), by mutant, and `merge` prints how many, how many came
|
|
1225
|
+
from each run, and how many the merged run's plan decides without running
|
|
1226
|
+
them (`1265 strong verdict(s) kept from runs r8, r7: 1103 from r8, 150 from
|
|
1227
|
+
r7, 12 the merged run's plan decides`). A verdict two runs hold alike counts
|
|
1228
|
+
for the first run named. A kill in any run is a kill. A survival stands only where the run that
|
|
1220
1229
|
let the mutant survive measured every test of the merged suite that could
|
|
1221
1230
|
kill it; where another run's tests could, and it has no verdict, the mutant is
|
|
1222
1231
|
left for a pass over the merged run to run. An error stands only where no run
|
|
@@ -1224,7 +1233,17 @@ holds anything else. A run whose verdicts are of another mutant set than the
|
|
|
1224
1233
|
merged run lists lends none, and `merge` names it; a run some of whose tests
|
|
1225
1234
|
another measured again lends none either. Split a strong pass across jobs this
|
|
1226
1235
|
way: each job measures and runs `supercov mutants --shard k/n -- <command>`,
|
|
1227
|
-
and the last merges (see `docs/mutation.md`, A pass split across jobs).
|
|
1236
|
+
and the last merges (see `docs/mutation.md`, A pass split across jobs). A
|
|
1237
|
+
second round on the same commit restores the first round's runs and does the
|
|
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.
|
|
1241
|
+
|
|
1242
|
+
A run named twice is refused (`Each merged run must be unique: r1 is named
|
|
1243
|
+
more than once`): copies of one run that several jobs saved verdicts into
|
|
1244
|
+
share its id, and `.supercov/runs` holds one of them. Up to 4.29.5,
|
|
1245
|
+
`supercov mutants --shard` on a checkout unchanged since the runs it restored
|
|
1246
|
+
saved into the latest of them; run such a round again.
|
|
1228
1247
|
|
|
1229
1248
|
`assertions assess` assesses a merged run across every suite merged into it,
|
|
1230
1249
|
reusing the answers saved when its parts were assessed. `tests affected` of a
|
package/docs/mutation.md
CHANGED
|
@@ -104,7 +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.
|
|
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.
|
|
108
117
|
- **After an edit.** It measures the checkout again and keeps an earlier
|
|
109
118
|
verdict for each mutant whose file is as it was and whose candidate tests,
|
|
110
119
|
and their test files, nothing changed could reach, as `runs latest tests
|
|
@@ -112,9 +121,13 @@ mutants the tests let survive.
|
|
|
112
121
|
edit the tests that ran the changed code. Each mutant's verdict comes from
|
|
113
122
|
the newest earlier run of the same command, dependencies and configuration
|
|
114
123
|
that holds one it can keep, so a pass split across jobs, each holding part
|
|
115
|
-
of the verdicts in its own run, is kept whole.
|
|
116
|
-
|
|
117
|
-
|
|
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.
|
|
118
131
|
- **Interrupted.** Each verdict is saved as it is made. A pass stopped by
|
|
119
132
|
Ctrl-C, a killed job or a test worker that never ended keeps what it
|
|
120
133
|
decided, and the next pass runs only the rest. Sent SIGINT or SIGTERM, the
|
|
@@ -122,10 +135,15 @@ mutants the tests let survive.
|
|
|
122
135
|
not ended 8 s after the signal is ended, what it decided saved first.
|
|
123
136
|
- **Order and budget.** The cheapest mutants run first, by the recorded times
|
|
124
137
|
of the tests each runs against, so a pass cut short has decided as many as
|
|
125
|
-
it could. `--budget <seconds>`
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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.
|
|
129
147
|
- **Exit codes.** `0` with an answer; `1` when `--fail-on` or `--critical`
|
|
130
148
|
finds a mutant; `2`, after the answer, when the measured command failed (a
|
|
131
149
|
failing test kills nothing, so the verdicts cannot gate) or no mutant could
|
|
@@ -222,8 +240,8 @@ npx supercov runs latest mutants test --plan --json
|
|
|
222
240
|
- `--shard k/n` runs one of n shares of the mutants, of about the same cost,
|
|
223
241
|
for parallel jobs (see
|
|
224
242
|
[A pass split across jobs](#a-pass-split-across-jobs)).
|
|
225
|
-
- `--budget <seconds>` stops the pass once that time is spent
|
|
226
|
-
saved, and leaves the rest for the next pass.
|
|
243
|
+
- `--budget <seconds>` stops the pass once that time is spent since the
|
|
244
|
+
command started, its verdicts saved, and leaves the rest for the next pass.
|
|
227
245
|
- `--timeout-factor <x>` (or `SUPERCOV_STRONG_TIMEOUT_FACTOR`) sets a
|
|
228
246
|
Playwright test's time limit when it runs with a mutant: x times its
|
|
229
247
|
baseline, + 5 s (default 1.5, StrykerJS's `timeoutFactor`). See
|
|
@@ -248,12 +266,20 @@ and stays the same while that code does.
|
|
|
248
266
|
|
|
249
267
|
A large application suite's strong pass can be split across machines. Each
|
|
250
268
|
job measures the whole suite and runs its share of the mutants; a last job
|
|
251
|
-
merges the runs, and the merged run holds every job's verdicts
|
|
269
|
+
merges the runs, and the merged run holds every job's verdicts. A pass whose
|
|
270
|
+
budgets leave mutants undecided goes on in another round, the same workflow run
|
|
271
|
+
again on the same commit, and later commits go on from where the last round
|
|
272
|
+
ended:
|
|
252
273
|
|
|
253
274
|
```yaml
|
|
254
275
|
# Each of four jobs (matrix.shard 1 to 4):
|
|
255
276
|
- uses: actions/cache/restore@v4
|
|
256
|
-
with:
|
|
277
|
+
with:
|
|
278
|
+
path: .supercov/runs
|
|
279
|
+
key: mutants-${{ github.sha }}-${{ github.run_id }}-${{ github.run_attempt }}
|
|
280
|
+
restore-keys: |
|
|
281
|
+
mutants-${{ github.sha }}-
|
|
282
|
+
mutants-
|
|
257
283
|
- run: npx supercov mutants --shard ${{ matrix.shard }}/4 --budget 2400 -- npm test
|
|
258
284
|
- uses: actions/upload-artifact@v4
|
|
259
285
|
with: { name: "mutants-${{ matrix.shard }}", path: .supercov/runs, include-hidden-files: true }
|
|
@@ -262,14 +288,20 @@ merges the runs, and the merged run holds every job's verdicts:
|
|
|
262
288
|
with: { pattern: "mutants-*", path: .supercov/runs, merge-multiple: true }
|
|
263
289
|
- run: npx supercov merge
|
|
264
290
|
- run: npx supercov runs latest mutants --status survived
|
|
265
|
-
- run: npx supercov runs clean --keep 5 #
|
|
291
|
+
- run: npx supercov runs clean --keep 5 # this round's four runs and their merge
|
|
266
292
|
- uses: actions/cache/save@v4
|
|
267
|
-
with:
|
|
293
|
+
with:
|
|
294
|
+
path: .supercov/runs
|
|
295
|
+
key: mutants-${{ github.sha }}-${{ github.run_id }}-${{ github.run_attempt }}
|
|
268
296
|
```
|
|
269
297
|
|
|
298
|
+
The cache key names the round, so each round saves its own; a round restores
|
|
299
|
+
the latest one saved for its commit, or else the latest one saved.
|
|
300
|
+
|
|
270
301
|
`supercov mutants --shard k/n -- <command>` is `supercov -- <command>` with
|
|
271
302
|
the mutants' probes on, then `runs latest mutants test --shard k/n`, keeping
|
|
272
|
-
earlier verdicts as after an edit.
|
|
303
|
+
earlier verdicts as after an edit. On a checkout unchanged since a run it
|
|
304
|
+
restored, it measures nothing, as below. Name the command after `--`: without it,
|
|
273
305
|
`supercov mutants` takes the latest run's, which after a merge is the merge.
|
|
274
306
|
Every job must measure the same commit with the same dependencies, as for any
|
|
275
307
|
merge ([CLI reference](cli.md#combine-shards)).
|
|
@@ -279,9 +311,10 @@ merge ([CLI reference](cli.md#combine-shards)).
|
|
|
279
311
|
every share gets its part of the costly ones. A mutant's cost there is what
|
|
280
312
|
the plan lists of it, the copies of test files it starts and the tests they
|
|
281
313
|
run, not the tests' times, which differ between jobs.
|
|
282
|
-
- **The budget.** `--budget <seconds>` ends a job
|
|
283
|
-
`timeout` around it:
|
|
284
|
-
|
|
314
|
+
- **The budget.** `--budget <seconds>` ends a job in time without a
|
|
315
|
+
`timeout` around it: it counts from the command's start, measuring
|
|
316
|
+
included, and past it the pass stops, saves what it decided, and exits as
|
|
317
|
+
a finished pass. Within a pass the cheapest mutants
|
|
285
318
|
run first, so a job cut short has decided as many as it could, and the
|
|
286
319
|
mutants it left run in the next commit's pass, where the restored runs lend
|
|
287
320
|
the rest of their verdicts.
|
|
@@ -294,11 +327,35 @@ merge ([CLI reference](cli.md#combine-shards)).
|
|
|
294
327
|
that run has no verdict for it, as a unit run merged with an end-to-end run
|
|
295
328
|
can, the mutant is left undecided, and a pass over the merged run runs it.
|
|
296
329
|
Verdicts of another mutant set are not kept, and the merge says whose.
|
|
330
|
+
- **Another round.** On the commit the restored runs measured, each job saves
|
|
331
|
+
into a run of its own: `supercov mutants --shard` never saves into a run it
|
|
332
|
+
restored, of which every job of the round holds a copy. It makes that run
|
|
333
|
+
from the newest restored run whose command passed and that recorded its
|
|
334
|
+
mutants' values, without measuring again: the run holds that run's evidence
|
|
335
|
+
under an id of its own. It keeps every verdict a pass reached that the
|
|
336
|
+
restored runs hold (`1317 verdict(s) kept from runs r8, r7, r6, r5: the
|
|
337
|
+
checkout is unchanged since them`), and the shares are of what is left.
|
|
338
|
+
Mutants the plan decides without running, such as a survivor no test
|
|
339
|
+
infected, are decided again, not kept. Each job's run replaces the
|
|
340
|
+
restored ones of its command, so the last job's `supercov merge` takes this
|
|
341
|
+
round's runs, whose verdicts hold the earlier rounds'. It says how many
|
|
342
|
+
verdicts came from each run (`1265 strong verdict(s) kept from runs r8, r7,
|
|
343
|
+
r6, r5: 802 from r8, 151 from r7, 160 from r6, 140 from r5, 12 the merged
|
|
344
|
+
run's plan decides`): a verdict two runs hold alike, as every job's copy of
|
|
345
|
+
the earlier rounds' verdicts, counts for the first run named.
|
|
297
346
|
- **The next pass.** The restored runs lend their verdicts on a later
|
|
298
347
|
commit: each job keeps every verdict nothing changed could move, from
|
|
299
348
|
whichever earlier job's run holds it, and the shares are of what is left.
|
|
300
349
|
Keep the merged run's parts with it: a merged run's `tests affected` is
|
|
301
350
|
answered from them.
|
|
351
|
+
- **Copies of one run.** Up to 4.29.5, `supercov mutants --shard` on a
|
|
352
|
+
checkout unchanged since the runs it restored saved into the latest of them,
|
|
353
|
+
so every job of a second round wrote its share into a copy of one run. The
|
|
354
|
+
copies share an id, one directory of `.supercov/runs` holds one of them, and
|
|
355
|
+
`supercov merge` refuses a run named more than once, saying so. Run that
|
|
356
|
+
round again: each job now saves into a run of its own. In 4.29.6 that run
|
|
357
|
+
was measured again, which cost each job the suite's time and could drop a
|
|
358
|
+
verdict where a test failed in one of the measurements.
|
|
302
359
|
|
|
303
360
|
### Runners without a driver
|
|
304
361
|
|
|
@@ -382,6 +439,16 @@ no mutants shows none of this.
|
|
|
382
439
|
as detected; the summary says how many, and against what limit.
|
|
383
440
|
`--timeout-factor <x>` (or `SUPERCOV_STRONG_TIMEOUT_FACTOR`) changes the
|
|
384
441
|
1.5: a suite whose tests' times vary widely between runs may want 2 or 3.
|
|
442
|
+
A mutant tries its candidates cheapest to a kill first (a test's time over
|
|
443
|
+
how likely it is to kill: one that infected the mutant counts as four
|
|
444
|
+
times likelier than one that only reached it), and a slow test runs it only
|
|
445
|
+
once its cheaper candidates let it live; a file's tests take one mutant
|
|
446
|
+
each in turn, so mutants are decided one after another rather than all at
|
|
447
|
+
the end. The progress lines name the tests with the most work left (how
|
|
448
|
+
many mutants wait for each, and its time a run) and the time the round
|
|
449
|
+
has left. A candidate in a project others start from (a login `setup`)
|
|
450
|
+
never runs with a mutant: a mutant no other test kills is an `error` that
|
|
451
|
+
says so.
|
|
385
452
|
- **Jest and Mocha** run in resident runners, as StrykerJS's do; `node:test`,
|
|
386
453
|
AVA, node-tap, `bun:test` and Vitest Browser Mode run one test file per
|
|
387
454
|
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.7",
|
|
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.7",
|
|
129
|
+
"@supercov/cli-darwin-x64": "4.29.7",
|
|
130
|
+
"@supercov/cli-linux-arm64-gnu": "4.29.7",
|
|
131
|
+
"@supercov/cli-linux-arm64-musl": "4.29.7",
|
|
132
|
+
"@supercov/cli-linux-x64-gnu": "4.29.7",
|
|
133
|
+
"@supercov/cli-linux-x64-musl": "4.29.7",
|
|
134
|
+
"@supercov/cli-win32-arm64": "4.29.7",
|
|
135
|
+
"@supercov/cli-win32-x64": "4.29.7"
|
|
136
136
|
},
|
|
137
137
|
"peerDependencies": {
|
|
138
138
|
"@playwright/test": ">=1.55.0",
|
|
@@ -9,12 +9,23 @@
|
|
|
9
9
|
// disk that every worker and every invocation of the pass share. A mutant
|
|
10
10
|
// goes from candidate to candidate as copies take it, and stops at its first
|
|
11
11
|
// kill; nothing waits for a stage to end, and no worker restarts for a
|
|
12
|
-
// mutant.
|
|
13
|
-
// mutant: the pass's baseline the first time
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
//
|
|
12
|
+
// mutant. A test's first run in each invocation is a control, with no
|
|
13
|
+
// mutant: the pass's baseline the first time; and after a kill, the test's
|
|
14
|
+
// next run is one too, the check that it still passes without the mutant on
|
|
15
|
+
// the same server, which confirms the kill. A harness may start several
|
|
16
|
+
// invocations at once, each with a share of the tests; they share the pass's
|
|
17
|
+
// files and decide the same way.
|
|
18
|
+
//
|
|
19
|
+
// The order (docs/design/strong-mutation.md, "Which candidate first"): a
|
|
20
|
+
// mutant's candidates are ordered cheapest to a kill first (each test's time
|
|
21
|
+
// over how likely it is to kill: those whose own evidence infected it are
|
|
22
|
+
// taken as likelier), so a slow test comes last; a file's copies run in
|
|
23
|
+
// sweeps, the k-th copy of each of its tests in turn, cheapest test first;
|
|
24
|
+
// and a copy takes, of the mutants waiting for its test, the one with the
|
|
25
|
+
// fewest earlier candidates still to try, the one its test infected, and the
|
|
26
|
+
// one closest to a verdict, in that order. So a slow test runs a mutant once
|
|
27
|
+
// its cheaper candidates let it live, and a file's tests finish one mutant
|
|
28
|
+
// before the next rather than one test's mutants before the next test's.
|
|
18
29
|
//
|
|
19
30
|
// The attempt's mutant goes into its scope, which reaches the app's server
|
|
20
31
|
// with every request (header, cookies, child processes) and the page through
|
|
@@ -43,6 +54,10 @@ import { basename, dirname, resolve, sep } from "node:path";
|
|
|
43
54
|
const TIMEOUT_FACTOR = 1.5;
|
|
44
55
|
const TIMEOUT_CONSTANT_MS = 5_000;
|
|
45
56
|
const DEFAULT_DURATION_MS = 1_000;
|
|
57
|
+
// How much likelier to kill a mutant a test is taken to be where its own
|
|
58
|
+
// evidence infected it than where it only reached it: what orders a mutant's
|
|
59
|
+
// candidates, with their times.
|
|
60
|
+
const INFECTED_LIKELIER = 4;
|
|
46
61
|
const POLL_MS = 50;
|
|
47
62
|
// Playwright makes every test case of every file it loads before the first
|
|
48
63
|
// test runs, in the runner: an invocation holds about this many copies, and
|
|
@@ -57,6 +72,8 @@ export const PAGE_TIMEOUT_MARKER = "SUPERCOV_MUTANT_TIMEOUT";
|
|
|
57
72
|
|
|
58
73
|
/** A copy's describe: `[supercov copy <k>]`, k from 1. */
|
|
59
74
|
const COPY_TITLE = /^\[supercov copy (\d+)\]$/;
|
|
75
|
+
// The most costly tests a status file names.
|
|
76
|
+
const COSTLY_SHOWN = 3;
|
|
60
77
|
export function copyTitle(copy) {
|
|
61
78
|
return `[supercov copy ${copy}]`;
|
|
62
79
|
}
|
|
@@ -91,8 +108,15 @@ export function strongPass() {
|
|
|
91
108
|
};
|
|
92
109
|
}
|
|
93
110
|
|
|
111
|
+
const keys = new Map();
|
|
94
112
|
export function key(text) {
|
|
95
|
-
|
|
113
|
+
const said = String(text);
|
|
114
|
+
let found = keys.get(said);
|
|
115
|
+
if (found === undefined) {
|
|
116
|
+
found = createHash("sha256").update(said).digest("hex").slice(0, 24);
|
|
117
|
+
keys.set(said, found);
|
|
118
|
+
}
|
|
119
|
+
return found;
|
|
96
120
|
}
|
|
97
121
|
|
|
98
122
|
export function writeJson(path, value) {
|
|
@@ -147,7 +171,7 @@ export function mark(path) {
|
|
|
147
171
|
* and every control of it that passed in this pass, in any worker or round
|
|
148
172
|
* (a test whose time varies is given its slowest), and a second at least.
|
|
149
173
|
*/
|
|
150
|
-
function baselineMsOf(pass, original, test) {
|
|
174
|
+
export function baselineMsOf(pass, original, test) {
|
|
151
175
|
let longest = Math.max(DEFAULT_DURATION_MS, test.durationMs ?? 0);
|
|
152
176
|
for (const name of entries(`${pass.shared}/durations/${key(original)}`))
|
|
153
177
|
longest = Math.max(longest, Number(name.split("-")[1]) || 0);
|
|
@@ -155,7 +179,7 @@ function baselineMsOf(pass, original, test) {
|
|
|
155
179
|
}
|
|
156
180
|
|
|
157
181
|
/** A mutant attempt's time limit from its test's baseline: StrykerJS's `timeoutMS`. */
|
|
158
|
-
function limitOf(baselineMs, factor) {
|
|
182
|
+
export function limitOf(baselineMs, factor) {
|
|
159
183
|
return Math.ceil(baselineMs * factor + TIMEOUT_CONSTANT_MS);
|
|
160
184
|
}
|
|
161
185
|
|
|
@@ -204,7 +228,8 @@ function serialFilesOf(plan, tests, fullyParallel) {
|
|
|
204
228
|
/**
|
|
205
229
|
* The projects others depend on (`dependencies`, `teardown`): their tests,
|
|
206
230
|
* a login that stores the session others start from, run as they are in
|
|
207
|
-
* every invocation, with no mutant, whether or not a mutant needs them.
|
|
231
|
+
* every invocation, with no mutant, whether or not a mutant needs them. A
|
|
232
|
+
* mutant's candidate among them is never run with it.
|
|
208
233
|
*/
|
|
209
234
|
function setupProjectsOf(config) {
|
|
210
235
|
const names = new Set();
|
|
@@ -223,6 +248,12 @@ function fullyParallelOf(config) {
|
|
|
223
248
|
return projects.every((project) => project.fullyParallel ?? config?.fullyParallel ?? false);
|
|
224
249
|
}
|
|
225
250
|
|
|
251
|
+
/** The project others start from that a plan test is in, by its name (`<project> > <file> > ...`). */
|
|
252
|
+
function inSetupProject(test, setupProjects) {
|
|
253
|
+
const name = test.name ?? "";
|
|
254
|
+
return setupProjects.find((project) => project && name.startsWith(`${project} > `));
|
|
255
|
+
}
|
|
256
|
+
|
|
226
257
|
// A plan test's id as Playwright knows it: a Rust wasm run names a test by
|
|
227
258
|
// its file too (`<file>::<id>`).
|
|
228
259
|
function playwrightId(test) {
|
|
@@ -253,10 +284,12 @@ function declarationKey(file, title) {
|
|
|
253
284
|
/**
|
|
254
285
|
* The pass's work, worked out in the runner from the plan (or the job the
|
|
255
286
|
* round runs): each mutant to run with its candidate tests in the order it
|
|
256
|
-
* takes them (
|
|
257
|
-
* each test's queue of mutants (those
|
|
258
|
-
* and how many copies each test needs:
|
|
259
|
-
* one
|
|
287
|
+
* takes them (cheapest to a kill first: by measured time, those whose own
|
|
288
|
+
* evidence infected it counted as likelier), each test's queue of mutants (those
|
|
289
|
+
* it is the likeliest killer of first), and how many copies each test needs:
|
|
290
|
+
* one for each mutant that may take it, one more for each control a kill may
|
|
291
|
+
* call for, and the first control. A candidate in a project others start
|
|
292
|
+
* from is never run with the mutant: the mutant's verdict says so.
|
|
260
293
|
*/
|
|
261
294
|
function buildPass(pass, root, config) {
|
|
262
295
|
const plan = readJson(pass.planPath);
|
|
@@ -273,6 +306,8 @@ function buildPass(pass, root, config) {
|
|
|
273
306
|
const restarts = [];
|
|
274
307
|
const deferred = [];
|
|
275
308
|
const otherRunners = { ...(job?.otherRunners ?? {}) };
|
|
309
|
+
const setupOnly = { ...(job?.setupOnly ?? {}) };
|
|
310
|
+
const setupProjects = setupProjectsOf(config);
|
|
276
311
|
const mutants = [];
|
|
277
312
|
if (job && job.kind !== "main") {
|
|
278
313
|
for (const entry of job.mutants) {
|
|
@@ -312,34 +347,56 @@ function buildPass(pass, root, config) {
|
|
|
312
347
|
});
|
|
313
348
|
continue;
|
|
314
349
|
}
|
|
315
|
-
// Its candidates,
|
|
316
|
-
// evidence shows it infected first of all.
|
|
350
|
+
// Its candidates, and which of them infected it.
|
|
317
351
|
const own = [];
|
|
318
352
|
const others = new Set();
|
|
353
|
+
const setup = new Set();
|
|
319
354
|
for (const candidate of mutant.candidates) {
|
|
320
355
|
const test = plan.tests[candidate.test];
|
|
321
|
-
|
|
356
|
+
const project = test && tests[playwrightId(test)] && inSetupProject(test, setupProjects);
|
|
357
|
+
if (project)
|
|
358
|
+
setup.add(project);
|
|
359
|
+
else if (test && tests[playwrightId(test)])
|
|
322
360
|
own.push({ id: playwrightId(test), infected: candidate.reason === "infected" });
|
|
323
361
|
else if (test)
|
|
324
362
|
others.add(test.runner);
|
|
325
363
|
}
|
|
326
364
|
if (others.size)
|
|
327
365
|
otherRunners[mutant.id] = [...others].sort();
|
|
366
|
+
if (setup.size)
|
|
367
|
+
setupOnly[mutant.id] = [...setup].sort();
|
|
328
368
|
if (!own.length) {
|
|
329
|
-
|
|
330
|
-
|
|
369
|
+
const unrun = unrunReason(otherRunners[mutant.id], setupOnly[mutant.id], "its candidates");
|
|
370
|
+
immediate.push(unrun
|
|
371
|
+
? { id: mutant.id, status: "error", reason: unrun, tests: 0, durationMs: 0 }
|
|
331
372
|
: { id: mutant.id, status: "survived", reason: "no-runnable-candidate", tests: 0, durationMs: 0 });
|
|
332
373
|
continue;
|
|
333
374
|
}
|
|
334
|
-
|
|
375
|
+
// Cheapest to a kill first: each test's measured time (one the
|
|
376
|
+
// run timed none of counts as a second, the least a baseline
|
|
377
|
+
// is), over how likely it is to kill, a test whose own evidence
|
|
378
|
+
// infected it `INFECTED_LIKELIER` times likelier than one that
|
|
379
|
+
// only reached it; the plan's order between equals. So a test
|
|
380
|
+
// that infected it goes first unless it is that much slower,
|
|
381
|
+
// and a slow test goes last.
|
|
382
|
+
const costOf = (test) => (tests[test.id].durationMs ?? DEFAULT_DURATION_MS) * (test.infected ? 1 : INFECTED_LIKELIER);
|
|
383
|
+
own.sort((a, b) => costOf(a) - costOf(b));
|
|
384
|
+
const infected = [...new Set(own.filter((test) => test.infected).map((test) => test.id))];
|
|
385
|
+
const ordered = [...new Set(own.map((test) => test.id))];
|
|
335
386
|
const switched = `${mutant.file}#${found.index}`;
|
|
336
387
|
if (mutant.serverWide) {
|
|
337
388
|
restarts.push({ id: mutant.id, mutant: switched, tests: ordered, reason: mutant.serverWide });
|
|
338
389
|
continue;
|
|
339
390
|
}
|
|
340
|
-
mutants.push({ id: mutant.id, mutant: switched, tests: ordered });
|
|
391
|
+
mutants.push({ id: mutant.id, mutant: switched, tests: ordered, infected });
|
|
341
392
|
}
|
|
342
393
|
}
|
|
394
|
+
// What a survivor's verdict says of the candidates it was not run with.
|
|
395
|
+
for (const entry of mutants) {
|
|
396
|
+
const unrun = unrunReason(otherRunners[entry.id], setupOnly[entry.id], "its other candidates");
|
|
397
|
+
if (unrun)
|
|
398
|
+
entry.unrun = unrun;
|
|
399
|
+
}
|
|
343
400
|
// Each test's queue, and the copies the round's mutants need, as many as
|
|
344
401
|
// an invocation holds; the mutants past them wait for the next.
|
|
345
402
|
const limit = copiesPerInvocation();
|
|
@@ -347,7 +404,10 @@ function buildPass(pass, root, config) {
|
|
|
347
404
|
let copies = 0;
|
|
348
405
|
const entries = {};
|
|
349
406
|
for (const entry of mutants) {
|
|
350
|
-
|
|
407
|
+
// Two copies a candidate (an attempt, and a control should it
|
|
408
|
+
// kill), one more where it is not the first (a sweep it may wait
|
|
409
|
+
// out), and each test's first run.
|
|
410
|
+
const added = entry.tests.reduce((sum, id, at) => sum + 2 + (at > 0 ? 1 : 0) + (queues.has(id) ? 0 : 1), 0);
|
|
351
411
|
if (copies && copies + added > limit && kind === "main") {
|
|
352
412
|
deferred.push({ id: entry.id });
|
|
353
413
|
continue;
|
|
@@ -361,14 +421,21 @@ function buildPass(pass, root, config) {
|
|
|
361
421
|
});
|
|
362
422
|
}
|
|
363
423
|
const declared = {};
|
|
424
|
+
// What orders a sweep of a file's copies: each test's measured time.
|
|
425
|
+
const costs = {};
|
|
364
426
|
for (const [id, queue] of queues) {
|
|
365
|
-
// The likeliest killers' mutants first; the plan's order between
|
|
427
|
+
// The likeliest killers' mutants first; the plan's order between
|
|
428
|
+
// equals. A copy takes from it by each mutant's standing then.
|
|
366
429
|
queue.sort((a, b) => a.at - b.at);
|
|
367
430
|
const test = tests[id];
|
|
368
431
|
test.jobs = queue.length;
|
|
369
432
|
test.queue = queue.map((job) => job.id);
|
|
370
433
|
const where = declarationKey(resolve(root, test.file), test.title);
|
|
371
|
-
|
|
434
|
+
// A copy for each sweep the test may wait out: one for each mutant
|
|
435
|
+
// with a candidate before it.
|
|
436
|
+
const later = queue.filter((job) => job.at > 0).length;
|
|
437
|
+
declared[where] = Math.max(declared[where] ?? 0, 2 * queue.length + later + 1);
|
|
438
|
+
costs[where] = Math.max(costs[where] ?? 0, test.durationMs ?? DEFAULT_DURATION_MS);
|
|
372
439
|
}
|
|
373
440
|
return {
|
|
374
441
|
pass: pass.name,
|
|
@@ -386,16 +453,32 @@ function buildPass(pass, root, config) {
|
|
|
386
453
|
timeoutFactor: Number(plan.timeoutFactor) > 0 ? Number(plan.timeoutFactor) : TIMEOUT_FACTOR,
|
|
387
454
|
tests,
|
|
388
455
|
declared,
|
|
456
|
+
costs,
|
|
389
457
|
entries,
|
|
390
|
-
setupProjects
|
|
458
|
+
setupProjects,
|
|
391
459
|
concurrency,
|
|
392
460
|
immediate,
|
|
393
461
|
restarts,
|
|
394
462
|
otherRunners,
|
|
463
|
+
setupOnly,
|
|
395
464
|
deferred,
|
|
396
465
|
};
|
|
397
466
|
}
|
|
398
467
|
|
|
468
|
+
/**
|
|
469
|
+
* Why a mutant no Playwright test killed has no verdict of `survived`: the
|
|
470
|
+
* candidates this pass does not run with it (`lead` names them), or
|
|
471
|
+
* `undefined` where it runs every one.
|
|
472
|
+
*/
|
|
473
|
+
export function unrunReason(others, setup, lead) {
|
|
474
|
+
const parts = [];
|
|
475
|
+
if (others?.length)
|
|
476
|
+
parts.push(`${lead} ran under ${others.join(", ")}, which this pass does not run`);
|
|
477
|
+
if (setup?.length)
|
|
478
|
+
parts.push(`${lead} are in the project${setup.length > 1 ? "s" : ""} ${setup.map((name) => JSON.stringify(name)).join(", ")}, which the others start from and which run${setup.length > 1 ? "" : "s"} without a mutant`);
|
|
479
|
+
return parts.length ? parts.join("; ") : undefined;
|
|
480
|
+
}
|
|
481
|
+
|
|
399
482
|
/** The round's work: built and written by the runner, read by its judge. */
|
|
400
483
|
let passCache;
|
|
401
484
|
export function loadPass(pass) {
|
|
@@ -427,6 +510,7 @@ function writeRoundFiles(pass, work) {
|
|
|
427
510
|
timeoutFactor: work.timeoutFactor,
|
|
428
511
|
tests,
|
|
429
512
|
declared: work.declared,
|
|
513
|
+
costs: work.costs,
|
|
430
514
|
setupProjects: work.setupProjects,
|
|
431
515
|
concurrency: work.concurrency,
|
|
432
516
|
});
|
|
@@ -564,6 +648,11 @@ function invocationMutant(pass) {
|
|
|
564
648
|
* describe runs as a default one: in order, in one worker, but a failed test
|
|
565
649
|
* (a kill) does not skip the rest; a test that leans on an earlier one's
|
|
566
650
|
* state is caught by its control.
|
|
651
|
+
*
|
|
652
|
+
* A worker runs a file's tests in the order they are declared, so the
|
|
653
|
+
* copies are arranged in sweeps as they are declared (`arrange`): after the
|
|
654
|
+
* tests themselves, every test's first copy, cheapest test first, then
|
|
655
|
+
* every test's second copy, and so on, beside the tests of their describe.
|
|
567
656
|
*/
|
|
568
657
|
export function installCopies(baseTest) {
|
|
569
658
|
if (!copying())
|
|
@@ -583,9 +672,18 @@ export function installCopies(baseTest) {
|
|
|
583
672
|
if (type === "skip" || type === "fixme")
|
|
584
673
|
return;
|
|
585
674
|
const suite = this._currentSuite?.(location, "test()");
|
|
586
|
-
const
|
|
587
|
-
|
|
675
|
+
const file = suite?._requireFile ?? location?.file;
|
|
676
|
+
const copies = copiesOf(file, title);
|
|
677
|
+
if (copies < 2)
|
|
678
|
+
return;
|
|
679
|
+
const cost = costOf(file, title);
|
|
680
|
+
for (let copy = 1; copy < copies; copy++) {
|
|
588
681
|
describe.call(this, "default", location, copyTitle(copy), () => declare.call(this, type, location, title, fnOrDetails, fn));
|
|
682
|
+
const made = Array.isArray(suite?._entries) ? suite._entries[suite._entries.length - 1] : undefined;
|
|
683
|
+
if (made)
|
|
684
|
+
sweeps.set(made, { copy, cost });
|
|
685
|
+
}
|
|
686
|
+
arrange(suite);
|
|
589
687
|
};
|
|
590
688
|
prototype._describe = function (type, ...rest) {
|
|
591
689
|
return describe.call(this, type === "serial" ? "default" : type === "serial.only" ? "only" : type, ...rest);
|
|
@@ -600,8 +698,36 @@ let declaredCopies;
|
|
|
600
698
|
function copiesOf(file, title) {
|
|
601
699
|
if (!file)
|
|
602
700
|
return 1;
|
|
603
|
-
declaredCopies ??= readJsonOr(`${strongPass().round}/worker.json`, { declared: {} })
|
|
604
|
-
return declaredCopies[declarationKey(file, title)] ?? 1;
|
|
701
|
+
declaredCopies ??= readJsonOr(`${strongPass().round}/worker.json`, { declared: {}, costs: {} });
|
|
702
|
+
return declaredCopies.declared[declarationKey(file, title)] ?? 1;
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
/** A test's measured time, which places its copies in each sweep. */
|
|
706
|
+
function costOf(file, title) {
|
|
707
|
+
return declaredCopies.costs?.[declarationKey(file, title)] ?? DEFAULT_DURATION_MS;
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
/** Each copy's describe: which copy it is and its test's cost. */
|
|
711
|
+
const sweeps = new WeakMap();
|
|
712
|
+
|
|
713
|
+
/**
|
|
714
|
+
* Puts a describe's entries in sweeps: what is not a copy first, as
|
|
715
|
+
* declared, then the copies by their number, the cheapest test's first,
|
|
716
|
+
* the declared order between equals. The worker runs a file's tests in this
|
|
717
|
+
* order (it loads the file itself), so a file's tests take one mutant each
|
|
718
|
+
* in turn rather than one test all its mutants before the next test starts,
|
|
719
|
+
* and a slow test runs last in each sweep. A Playwright whose suites keep
|
|
720
|
+
* their entries otherwise is left as declared.
|
|
721
|
+
*/
|
|
722
|
+
export function arrange(suite) {
|
|
723
|
+
const list = suite?._entries;
|
|
724
|
+
if (!Array.isArray(list))
|
|
725
|
+
return;
|
|
726
|
+
const placed = list.map((entry, at) => ({ entry, at, sweep: sweeps.get(entry) ?? { copy: 0, cost: 0 } }));
|
|
727
|
+
placed.sort((a, b) => a.sweep.copy - b.sweep.copy || a.sweep.cost - b.sweep.cost || a.at - b.at);
|
|
728
|
+
placed.forEach((place, at) => {
|
|
729
|
+
list[at] = place.entry;
|
|
730
|
+
});
|
|
605
731
|
}
|
|
606
732
|
|
|
607
733
|
/** How a test did with no mutant: `passed`, `failed`, or `undefined` before it ended. */
|
|
@@ -693,9 +819,23 @@ export function invocation() {
|
|
|
693
819
|
return process.env["SUPERCOV_PLAYWRIGHT_INVOCATION"] ?? "0";
|
|
694
820
|
}
|
|
695
821
|
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
822
|
+
/**
|
|
823
|
+
* Whether a test's next run in this invocation has no mutant: none of its
|
|
824
|
+
* runs without one passed here yet (or the last failed), or a kill of it
|
|
825
|
+
* here waits for one to confirm it. A test runs with a mutant only on a
|
|
826
|
+
* server where it passed without one, whichever worker runs it.
|
|
827
|
+
*/
|
|
828
|
+
function needsControl(pass, test) {
|
|
829
|
+
return !existsSync(readyPath(pass, invocation(), test)) || entries(`${pass.round}/pending/${invocation()}/${key(test)}`).length > 0;
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
function readyPath(pass, at, test) {
|
|
833
|
+
return `${pass.round}/ready/${at}/${key(test)}`;
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
function claimPath(pass, id, test) {
|
|
837
|
+
return `${pass.round}/claims/${key(id)}/${key(test)}`;
|
|
838
|
+
}
|
|
699
839
|
|
|
700
840
|
/** Whether a mutant needs no more attempts: a verdict given, killed, or held for a later round. */
|
|
701
841
|
function settled(pass, id) {
|
|
@@ -726,44 +866,104 @@ function inFlightSince(pass, id) {
|
|
|
726
866
|
}
|
|
727
867
|
|
|
728
868
|
/**
|
|
729
|
-
* The next mutant for a copy of `test`:
|
|
730
|
-
*
|
|
731
|
-
* making its mark, which only one copy
|
|
869
|
+
* The next mutant for a copy of `test`: of its queue, one not settled, not
|
|
870
|
+
* yet tried against it and run by no other attempt now, the best by its
|
|
871
|
+
* standing (`standingOf`). Taken by making its mark, which only one copy
|
|
872
|
+
* can. Where even the best has a candidate before `test` still to try (a
|
|
873
|
+
* cheaper test, or one likelier to kill it), the copy takes none while the
|
|
874
|
+
* test's copies left (`copiesLeft`, after this one) still cover every mutant
|
|
875
|
+
* waiting for it and a control for each: the test's next copy, a sweep
|
|
876
|
+
* later, looks again. So a slow test's copies go to the mutants its cheaper
|
|
877
|
+
* candidates let live, and it runs every mutant all the same before its
|
|
878
|
+
* copies are spent.
|
|
732
879
|
*/
|
|
733
|
-
function takeJob(pass, test, only, limitMs) {
|
|
880
|
+
function takeJob(pass, shape, test, only, limitMs, copiesLeft) {
|
|
734
881
|
const queue = queueOf(pass, test);
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
882
|
+
// A test that fails without any mutant is no candidate: it holds back
|
|
883
|
+
// no later one.
|
|
884
|
+
const failed = new Map();
|
|
885
|
+
const unrunnable = (other) => {
|
|
886
|
+
if (!failed.has(other))
|
|
887
|
+
failed.set(other, baselineOf(pass, other) === "failed");
|
|
888
|
+
return failed.get(other);
|
|
889
|
+
};
|
|
890
|
+
let busy;
|
|
891
|
+
for (;;) {
|
|
892
|
+
busy = [];
|
|
893
|
+
let best;
|
|
894
|
+
let waiting = 0;
|
|
895
|
+
for (let at = queue.done; at < queue.ids.length; at++) {
|
|
896
|
+
const id = queue.ids[at];
|
|
897
|
+
if (only !== undefined && id !== only)
|
|
898
|
+
continue;
|
|
899
|
+
if (existsSync(claimPath(pass, id, test)) || settled(pass, id)) {
|
|
900
|
+
// Nothing undoes either: no copy looks at it again.
|
|
901
|
+
if (at === queue.done)
|
|
902
|
+
queue.done += 1;
|
|
903
|
+
continue;
|
|
904
|
+
}
|
|
905
|
+
waiting += 1;
|
|
906
|
+
const since = inFlightSince(pass, id);
|
|
907
|
+
if (since !== undefined) {
|
|
908
|
+
// One that has run longer than this test's limit may hang:
|
|
909
|
+
// a second attempt would only wait as long.
|
|
910
|
+
if (Date.now() - since < limitMs)
|
|
911
|
+
busy.push(id);
|
|
912
|
+
continue;
|
|
913
|
+
}
|
|
914
|
+
const standing = standingOf(pass, shape, id, test, at, unrunnable);
|
|
915
|
+
if (!best || before(standing, best.standing))
|
|
916
|
+
best = { id, standing };
|
|
754
917
|
}
|
|
755
|
-
if (
|
|
756
|
-
|
|
918
|
+
if (!best)
|
|
919
|
+
break;
|
|
920
|
+
const controls = entries(`${pass.round}/pending/${invocation()}/${key(test)}`).length;
|
|
921
|
+
if (only === undefined && best.standing[0] > 0 && copiesLeft >= 2 * waiting + controls)
|
|
922
|
+
return undefined;
|
|
923
|
+
if (mark(claimPath(pass, best.id, test)))
|
|
924
|
+
return best.id;
|
|
925
|
+
// Another copy took it first: choose again.
|
|
757
926
|
}
|
|
758
927
|
// Every mutant left runs elsewhere now: one of them here too, rather
|
|
759
928
|
// than leave this test's copies unused while its attempt runs.
|
|
760
929
|
for (const id of busy) {
|
|
761
|
-
if (only === undefined && !settled(pass, id) && mark(
|
|
930
|
+
if (only === undefined && !settled(pass, id) && mark(claimPath(pass, id, test)))
|
|
762
931
|
return id;
|
|
763
932
|
}
|
|
764
933
|
return undefined;
|
|
765
934
|
}
|
|
766
935
|
|
|
936
|
+
/**
|
|
937
|
+
* Where a mutant stands for a copy of `test`, best first: how many of its
|
|
938
|
+
* candidates before `test` are still to try (none: its cheaper candidates
|
|
939
|
+
* let it live, and this test is the next that may kill it), whether `test`
|
|
940
|
+
* infected it, how long its candidates still to try take (the closest to a
|
|
941
|
+
* verdict first), and its place in the test's queue.
|
|
942
|
+
*/
|
|
943
|
+
function standingOf(pass, shape, id, test, at, unrunnable) {
|
|
944
|
+
const entry = mutantOf(pass, id);
|
|
945
|
+
const passed = passedWith(pass, id);
|
|
946
|
+
const place = entry.tests.indexOf(test);
|
|
947
|
+
let earlier = 0;
|
|
948
|
+
let leftMs = 0;
|
|
949
|
+
entry.tests.forEach((other, index) => {
|
|
950
|
+
if (passed.has(key(other)) || unrunnable(other))
|
|
951
|
+
return;
|
|
952
|
+
leftMs += shape.tests[other]?.durationMs ?? DEFAULT_DURATION_MS;
|
|
953
|
+
if (index < place)
|
|
954
|
+
earlier += 1;
|
|
955
|
+
});
|
|
956
|
+
return [earlier, entry.infected?.includes(test) ? 0 : 1, leftMs, at];
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
function before(a, b) {
|
|
960
|
+
for (let at = 0; at < a.length; at++) {
|
|
961
|
+
if (a[at] !== b[at])
|
|
962
|
+
return a[at] < b[at];
|
|
963
|
+
}
|
|
964
|
+
return false;
|
|
965
|
+
}
|
|
966
|
+
|
|
767
967
|
/** Whether a test has mutants left to take, or kills to confirm, in this invocation. */
|
|
768
968
|
function workLeft(pass, test) {
|
|
769
969
|
if (entries(`${pass.round}/pending/${invocation()}/${key(test)}`).length)
|
|
@@ -771,12 +971,46 @@ function workLeft(pass, test) {
|
|
|
771
971
|
const queue = queueOf(pass, test);
|
|
772
972
|
for (let at = queue.done; at < queue.ids.length; at++) {
|
|
773
973
|
const id = queue.ids[at];
|
|
774
|
-
if (!existsSync(
|
|
974
|
+
if (!existsSync(claimPath(pass, id, test)) && !settled(pass, id))
|
|
775
975
|
return true;
|
|
776
976
|
}
|
|
777
977
|
return false;
|
|
778
978
|
}
|
|
779
979
|
|
|
980
|
+
/**
|
|
981
|
+
* The work left in this invocation's tests, for the progress lines: how
|
|
982
|
+
* many mutants wait for each test it runs (not settled, not yet tried
|
|
983
|
+
* against it), how long that takes at the test's baseline, and the costliest
|
|
984
|
+
* few tests, those whose runs left take longest. `held` are the tests the
|
|
985
|
+
* invocation runs.
|
|
986
|
+
*/
|
|
987
|
+
export function queuedWork(pass, work, held) {
|
|
988
|
+
const settledNow = new Set([...entries(`${pass.shared}/verdicts`), ...entries(`${pass.round}/killed`)]);
|
|
989
|
+
const claimed = new Map();
|
|
990
|
+
const tests = [];
|
|
991
|
+
let ms = 0;
|
|
992
|
+
for (const id of held) {
|
|
993
|
+
const test = work.tests[id];
|
|
994
|
+
let waiting = 0;
|
|
995
|
+
for (const mutant of test?.queue ?? []) {
|
|
996
|
+
const at = key(mutant);
|
|
997
|
+
if (settledNow.has(at))
|
|
998
|
+
continue;
|
|
999
|
+
if (!claimed.has(at))
|
|
1000
|
+
claimed.set(at, new Set(entries(`${pass.round}/claims/${at}`)));
|
|
1001
|
+
if (!claimed.get(at).has(key(id)))
|
|
1002
|
+
waiting += 1;
|
|
1003
|
+
}
|
|
1004
|
+
if (!waiting)
|
|
1005
|
+
continue;
|
|
1006
|
+
const baselineMs = baselineMsOf(pass, id, test);
|
|
1007
|
+
ms += waiting * baselineMs;
|
|
1008
|
+
tests.push({ title: test.title ?? id, waiting, baselineMs, limitMs: limitOf(baselineMs, work.timeoutFactor) });
|
|
1009
|
+
}
|
|
1010
|
+
tests.sort((a, b) => b.waiting * b.baselineMs - a.waiting * a.baselineMs || a.title.localeCompare(b.title));
|
|
1011
|
+
return { ms, tests: tests.slice(0, COSTLY_SHOWN) };
|
|
1012
|
+
}
|
|
1013
|
+
|
|
780
1014
|
/**
|
|
781
1015
|
* Notes that an attempt runs, and whether another mutant's attempt runs
|
|
782
1016
|
* beside it in this invocation (its server): each attempt that starts looks
|
|
@@ -849,9 +1083,10 @@ export async function strongClaim(testInfo) {
|
|
|
849
1083
|
if (entries(unreliable).length >= CONTROL_FAILURES)
|
|
850
1084
|
return null;
|
|
851
1085
|
let attempt;
|
|
852
|
-
if (!shape.everywhere &&
|
|
853
|
-
// The test's first run in this
|
|
854
|
-
// here
|
|
1086
|
+
if (!shape.everywhere && needsControl(pass, original)) {
|
|
1087
|
+
// The test's first run in this invocation, the first since it failed
|
|
1088
|
+
// here, or the first since a kill here: without a mutant, the
|
|
1089
|
+
// round's baseline or a kill's control.
|
|
855
1090
|
if (!workLeft(pass, original))
|
|
856
1091
|
return null;
|
|
857
1092
|
attempt = shape.baselines && baselineOf(pass, original) === undefined
|
|
@@ -866,7 +1101,11 @@ export async function strongClaim(testInfo) {
|
|
|
866
1101
|
const derived = limitOf(baselineMs, shape.timeoutFactor);
|
|
867
1102
|
// The test's own timeout, where shorter, ends it first anyway.
|
|
868
1103
|
const limitMs = configured > 0 ? Math.min(derived, configured) : derived;
|
|
869
|
-
|
|
1104
|
+
// This copy's number, and the test's copies after it in this
|
|
1105
|
+
// invocation: what a copy that waits a sweep may spend.
|
|
1106
|
+
const copy = withoutCopy(testInfo.titlePath).copy;
|
|
1107
|
+
const copiesLeft = copiesOf(testInfo.file, testInfo.title) - 1 - copy;
|
|
1108
|
+
const id = takeJob(pass, shape, original, shape.batch ? invocationMutant(pass) ?? null : undefined, limitMs, copiesLeft);
|
|
870
1109
|
if (!id)
|
|
871
1110
|
return null;
|
|
872
1111
|
const entry = mutantOf(pass, id);
|
|
@@ -960,9 +1199,8 @@ function surviveIfDone(pass, id) {
|
|
|
960
1199
|
if (!entry.tests.every((test) => passed.has(key(test))))
|
|
961
1200
|
return;
|
|
962
1201
|
const ran = entry.tests.length;
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
? { id, status: "error", reason: `no Playwright test killed it, and its other candidates ran under ${others.join(", ")}, which this pass does not run`, tests: ran, durationMs: 0 }
|
|
1202
|
+
giveVerdict(pass, entry.unrun
|
|
1203
|
+
? { id, status: "error", reason: `no Playwright test killed it, and ${entry.unrun}`, tests: ran, durationMs: 0 }
|
|
966
1204
|
: { id, status: "survived", ...(entry.reason ? { reason: reasonOf(loadWorker(pass).kind, entry.reason) } : {}), tests: ran, durationMs: 0 });
|
|
967
1205
|
}
|
|
968
1206
|
|
|
@@ -1028,7 +1266,6 @@ export function settleAttempt(pass, attempt) {
|
|
|
1028
1266
|
return ended;
|
|
1029
1267
|
}
|
|
1030
1268
|
if (ended.outcome === "passed") {
|
|
1031
|
-
passedHere.add(test);
|
|
1032
1269
|
mark(`${pass.round}/passed/${key(attempt.id)}/${key(test)}`);
|
|
1033
1270
|
// One mutant an invocation: a survivor waits for the judge, who
|
|
1034
1271
|
// knows whether its server ran it.
|
|
@@ -1041,7 +1278,6 @@ export function settleAttempt(pass, attempt) {
|
|
|
1041
1278
|
// A kill, or a timeout (it ran out of its limit): no other copy takes
|
|
1042
1279
|
// the mutant now, and either is confirmed alike.
|
|
1043
1280
|
const { status, reason } = verdictOf(ended);
|
|
1044
|
-
passedHere.delete(test);
|
|
1045
1281
|
mark(`${pass.round}/killed/${key(attempt.id)}`);
|
|
1046
1282
|
if (beside)
|
|
1047
1283
|
mark(`${pass.round}/confirm/${key(attempt.id)}`);
|
|
@@ -1069,9 +1305,9 @@ function suffix(shape, entry) {
|
|
|
1069
1305
|
/**
|
|
1070
1306
|
* A run with no mutant: the test's baseline (the first in a main round), or
|
|
1071
1307
|
* a control after a kill. Passing, it lets the test take mutants in this
|
|
1072
|
-
*
|
|
1073
|
-
* them in doubt, and a test that fails so twice in an invocation is not
|
|
1074
|
-
* there again.
|
|
1308
|
+
* invocation and confirms the kills before it on this server; failing, it
|
|
1309
|
+
* puts them in doubt, and a test that fails so twice in an invocation is not
|
|
1310
|
+
* run there again.
|
|
1075
1311
|
*/
|
|
1076
1312
|
function settleControl(pass, ended, shape) {
|
|
1077
1313
|
const test = ended.original;
|
|
@@ -1099,7 +1335,7 @@ function settleControl(pass, ended, shape) {
|
|
|
1099
1335
|
mark(`${pass.round}/doubt/${key(kill.id)}`);
|
|
1100
1336
|
}
|
|
1101
1337
|
if (passed) {
|
|
1102
|
-
|
|
1338
|
+
mark(readyPath(pass, ended.invocation, test));
|
|
1103
1339
|
// Its time, for its mutants' limits.
|
|
1104
1340
|
mark(`${pass.shared}/durations/${key(test)}`);
|
|
1105
1341
|
writeFileSync(`${pass.shared}/durations/${key(test)}/${ended.worker}-${ended.endedAt - ended.startedAt}`, "");
|
|
@@ -1107,7 +1343,7 @@ function settleControl(pass, ended, shape) {
|
|
|
1107
1343
|
}
|
|
1108
1344
|
if (ended.outcome === "skipped")
|
|
1109
1345
|
return;
|
|
1110
|
-
|
|
1346
|
+
rmSync(readyPath(pass, ended.invocation, test), { recursive: true, force: true });
|
|
1111
1347
|
mark(`${pass.round}/unreliable/${ended.invocation}/${key(test)}`);
|
|
1112
1348
|
writeFileSync(`${pass.round}/unreliable/${ended.invocation}/${key(test)}/${ended.worker}-${Date.now()}`, "");
|
|
1113
1349
|
}
|
|
@@ -11,10 +11,12 @@
|
|
|
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
13
|
import { pathToFileURL } from "node:url";
|
|
14
|
-
import { attemptPath, baselineOf, entries, invocation, EVERYWHERE, firstWords, giveVerdict, key, loadPass, outcomeOf, placeOf, readJson, reasonOf, settleAttempt, strongPass, verdictOf, withoutCopy, writeJson } from "./playwrightStrong.mjs";
|
|
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
15
|
|
|
16
16
|
// How often, at most, the status file is written.
|
|
17
17
|
const STATUS_MS = 1_000;
|
|
18
|
+
// How often, at most, the work left is counted for it.
|
|
19
|
+
const QUEUED_MS = 5_000;
|
|
18
20
|
|
|
19
21
|
/** Each JSON file in a directory of the pass, or none. */
|
|
20
22
|
function readAll(directory) {
|
|
@@ -63,6 +65,11 @@ export default class SupercovPlaywrightStrongReporter {
|
|
|
63
65
|
this.running = new Map();
|
|
64
66
|
this.counts = { baselines: 0, controls: 0, failedControls: 0, attempts: 0, killed: 0, timedOut: 0, passed: 0 };
|
|
65
67
|
this.writtenAt = 0;
|
|
68
|
+
// The tests this invocation runs, and the baseline time of the runs
|
|
69
|
+
// it ended: its pace, for the time its work left takes.
|
|
70
|
+
this.held = [];
|
|
71
|
+
this.doneMs = 0;
|
|
72
|
+
this.queuedAt = 0;
|
|
66
73
|
}
|
|
67
74
|
// It prints its own lines, and says it prints: Playwright adds a reporter
|
|
68
75
|
// of its own where none does. The command's output is a log beside the
|
|
@@ -84,6 +91,8 @@ export default class SupercovPlaywrightStrongReporter {
|
|
|
84
91
|
if (withoutCopy(test.titlePath()).copy)
|
|
85
92
|
continue;
|
|
86
93
|
writeJson(`${this.pass.round}/originals/${key(placeOf(test))}`, test.id);
|
|
94
|
+
if (this.work.tests[test.id]?.jobs)
|
|
95
|
+
this.held.push(test.id);
|
|
87
96
|
}
|
|
88
97
|
this.copies = copies;
|
|
89
98
|
const mutants = Object.keys(this.work.entries).length;
|
|
@@ -137,6 +146,8 @@ export default class SupercovPlaywrightStrongReporter {
|
|
|
137
146
|
/** A line on the command's output for each attempt with a mutant, and each control that failed. */
|
|
138
147
|
say(attempt) {
|
|
139
148
|
const took = seconds((attempt.endedAt ?? Date.now()) - attempt.startedAt);
|
|
149
|
+
this.firstStartedAt ??= attempt.startedAt;
|
|
150
|
+
this.doneMs += attempt.baselineMs ?? this.work.tests[attempt.original]?.durationMs ?? 0;
|
|
140
151
|
if (attempt.kind !== "mutant") {
|
|
141
152
|
this.counts[attempt.kind === "baseline" ? "baselines" : "controls"] += 1;
|
|
142
153
|
if (attempt.outcome === "failed" || attempt.outcome === "timed-out") {
|
|
@@ -186,6 +197,8 @@ export default class SupercovPlaywrightStrongReporter {
|
|
|
186
197
|
limitMs: attempt?.limitMs,
|
|
187
198
|
};
|
|
188
199
|
});
|
|
200
|
+
if (now && this.work && Date.now() - this.queuedAt >= QUEUED_MS)
|
|
201
|
+
this.countQueued();
|
|
189
202
|
try {
|
|
190
203
|
writeJson(`${this.pass.shared}/status/${process.pid}.json`, {
|
|
191
204
|
round: this.pass.name,
|
|
@@ -198,12 +211,32 @@ export default class SupercovPlaywrightStrongReporter {
|
|
|
198
211
|
firstMutantAt: this.firstMutantAt,
|
|
199
212
|
lastEndedAt: this.lastEndedAt,
|
|
200
213
|
running,
|
|
214
|
+
...(this.queued ? { queued: this.queued } : {}),
|
|
201
215
|
});
|
|
202
216
|
}
|
|
203
217
|
catch {
|
|
204
218
|
// The status is for the progress line; the pass goes on without it.
|
|
205
219
|
}
|
|
206
220
|
}
|
|
221
|
+
/**
|
|
222
|
+
* The work left in this invocation's tests (`queuedWork`), and the time
|
|
223
|
+
* it takes at the pace so far: the baseline time of the runs it ended
|
|
224
|
+
* over the time they took, which counts what runs besides the tests (a
|
|
225
|
+
* copy with nothing to run, a new worker after a kill).
|
|
226
|
+
*/
|
|
227
|
+
countQueued() {
|
|
228
|
+
this.queuedAt = Date.now();
|
|
229
|
+
try {
|
|
230
|
+
const queued = queuedWork(this.pass, this.work, this.held);
|
|
231
|
+
const spent = (this.lastEndedAt ?? 0) - (this.firstStartedAt ?? 0);
|
|
232
|
+
if (this.doneMs > 0 && spent > 0)
|
|
233
|
+
queued.leftMs = Math.round((queued.ms * spent) / this.doneMs);
|
|
234
|
+
this.queued = queued;
|
|
235
|
+
}
|
|
236
|
+
catch {
|
|
237
|
+
// Counted again at the next status.
|
|
238
|
+
}
|
|
239
|
+
}
|
|
207
240
|
onEnd() {
|
|
208
241
|
if (!this.pass)
|
|
209
242
|
return;
|
|
@@ -369,9 +402,8 @@ export default class SupercovPlaywrightStrongReporter {
|
|
|
369
402
|
next(entry, "unfinished", left);
|
|
370
403
|
continue;
|
|
371
404
|
}
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
? { status: "error", reason: `no Playwright test killed it, and its other candidates ran under ${others.join(", ")}, which this pass does not run` }
|
|
405
|
+
verdict(entry.unrun
|
|
406
|
+
? { status: "error", reason: `no Playwright test killed it, and ${entry.unrun}` }
|
|
375
407
|
: { status: "survived", ...(after ? { reason: after } : {}) });
|
|
376
408
|
}
|
|
377
409
|
for (const job of work.restarts)
|
|
@@ -407,13 +439,13 @@ export default class SupercovPlaywrightStrongReporter {
|
|
|
407
439
|
for (const entry of aloneAgain)
|
|
408
440
|
(takenAny ? alone : aloneEach).push(entry);
|
|
409
441
|
if (alone.length)
|
|
410
|
-
write({ restart: { kind: "alone", everywhere: true, batch: true, reason: "server-wide", mutants: alone, otherRunners: work.otherRunners } });
|
|
442
|
+
write({ restart: { kind: "alone", everywhere: true, batch: true, reason: "server-wide", mutants: alone, otherRunners: work.otherRunners, setupOnly: work.setupOnly } });
|
|
411
443
|
for (const job of aloneEach)
|
|
412
|
-
write({ restart: { kind: "alone", everywhere: true, reason: job.reason, mutants: [job], otherRunners: work.otherRunners } });
|
|
444
|
+
write({ restart: { kind: "alone", everywhere: true, reason: job.reason, mutants: [job], otherRunners: work.otherRunners, setupOnly: work.setupOnly } });
|
|
413
445
|
if (rest.length)
|
|
414
|
-
write({ restart: { kind: "rest", reason: "unfinished", mutants: rest, otherRunners: work.otherRunners } });
|
|
446
|
+
write({ restart: { kind: "rest", reason: "unfinished", mutants: rest, otherRunners: work.otherRunners, setupOnly: work.setupOnly } });
|
|
415
447
|
if (serial.length)
|
|
416
|
-
write({ restart: { kind: "serial", reason: [...new Set(serial.map((job) => job.reason))].join(", "), mutants: serial, otherRunners: work.otherRunners } });
|
|
448
|
+
write({ restart: { kind: "serial", reason: [...new Set(serial.map((job) => job.reason))].join(", "), mutants: serial, otherRunners: work.otherRunners, setupOnly: work.setupOnly } });
|
|
417
449
|
const mutated = attempts.filter((attempt) => attempt.kind === "mutant");
|
|
418
450
|
write({
|
|
419
451
|
summary: true,
|