supercov 4.29.16 → 4.29.18
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/README.md +6 -5
- package/docs/cli.md +6 -6
- package/docs/mutation.md +81 -27
- package/docs/performance.md +59 -0
- package/docs/supported-suites.md +6 -6
- package/package.json +10 -9
- package/runtime/javascript/playwright.mjs +66 -10
- package/runtime/javascript/playwrightStrong.mjs +54 -4
- package/runtime/javascript/playwrightStrongReporter.mjs +13 -2
- package/runtime/javascript/register.mjs +18 -2
- package/runtime/javascript/runtime.mjs +202 -11
- package/runtime/javascript/snapshots.mjs +52 -0
- package/runtime/javascript/strongJobs.mjs +26 -11
- package/runtime/javascript/vitestStrongReporter.mjs +13 -2
package/README.md
CHANGED
|
@@ -172,8 +172,9 @@ npx supercov runs latest mutants --diff origin/main --fail-on not-infected,not-r
|
|
|
172
172
|
Each language uses its established tool's mutants, and its verdicts were
|
|
173
173
|
compared with that tool's on public projects: StrykerJS for JavaScript and
|
|
174
174
|
TypeScript, under Vitest, Playwright, Jest, `node:test`, Mocha, AVA,
|
|
175
|
-
node-tap, `bun:test` and Vitest Browser Mode;
|
|
176
|
-
|
|
175
|
+
node-tap, `bun:test` and Vitest Browser Mode; cargo-mutants for Rust, under
|
|
176
|
+
`cargo test` and cargo-nextest; and in preview, mutmut for Python, Gremlins
|
|
177
|
+
for Go and mutant for Ruby. The run already knows which tests reach
|
|
177
178
|
each mutant and which never change its value, so a mutant no test reaches or
|
|
178
179
|
infects is decided without running anything, and the rest run only against
|
|
179
180
|
the tests that can kill them. A plain run costs nothing more. See
|
|
@@ -332,9 +333,9 @@ Supercov uses exact per-test attribution where an adapter is available. For othe
|
|
|
332
333
|
| Mocha | Exact per test and retry, `--parallel` included | StrykerJS's mutants |
|
|
333
334
|
| AVA | Exact per test, concurrent tests included | StrykerJS's mutants |
|
|
334
335
|
| node-tap 15 and newer | Exact per subtest | StrykerJS's mutants |
|
|
335
|
-
| Cargo's standard libtest runner | Exact test, attempt, and passing-assertion identity |
|
|
336
|
-
| rustdoc doctests | Exact per doctest |
|
|
337
|
-
| cargo-nextest | Exact test, attempt, retry, and binary identity |
|
|
336
|
+
| Cargo's standard libtest runner | Exact test, attempt, and passing-assertion identity | cargo-mutants' mutants |
|
|
337
|
+
| rustdoc doctests | Exact per doctest | cargo-mutants' mutants |
|
|
338
|
+
| cargo-nextest | Exact test, attempt, retry, and binary identity | cargo-mutants' mutants |
|
|
338
339
|
| pytest and `python -m unittest` | Exact test and setup/call/teardown phase identity | Preview: mutmut's mutants |
|
|
339
340
|
| `go test` | Exact per test | Preview: Gremlins' mutants |
|
|
340
341
|
| JUnit 5, JUnit 4, Kotest, Spock and TestNG | Exact per test | Not yet |
|
package/docs/cli.md
CHANGED
|
@@ -178,7 +178,7 @@ npx supercov runs <run-id> [query] [options]
|
|
|
178
178
|
| `runners` | Group coverage by test runner |
|
|
179
179
|
| `scope` | See what is source and what is not, by directory and reason; `--files` lists every file |
|
|
180
180
|
| `assertions` | Read the share of executed statements the tests assert, and the ones they do not; `assertions assess` works it out |
|
|
181
|
-
| `mutants [path[:line]]` | See, for each mutant the language's established tool would make (StrykerJS; in preview mutmut,
|
|
181
|
+
| `mutants [path[:line]]` | See, for each mutant the language's established tool would make (StrykerJS, cargo-mutants; in preview mutmut, Gremlins and mutant), whether a test reached it and changed its value |
|
|
182
182
|
| `source <path>` | Read matching current project source with line numbers |
|
|
183
183
|
| `minimize` | Find a small test subset that preserves a coverage target |
|
|
184
184
|
|
|
@@ -308,9 +308,9 @@ npx supercov runs <run-id> mutants --diff origin/main --fail-on not-infected,not
|
|
|
308
308
|
```
|
|
309
309
|
|
|
310
310
|
`mutants` reads weak mutation from the run: for each mutant StrykerJS 10.1.1
|
|
311
|
-
(JavaScript, TypeScript)
|
|
312
|
-
|
|
313
|
-
make (see [Mutation testing](mutation.md)), whether a test
|
|
311
|
+
(JavaScript, TypeScript) or cargo-mutants 27.1.0 (Rust) would make, or in
|
|
312
|
+
preview mutmut 3.8.1 (Python), Gremlins 0.6.0 (Go) or mutant 0.17.1 (Ruby)
|
|
313
|
+
would make (see [Mutation testing](mutation.md)), whether a test
|
|
314
314
|
ran the mutated code and whether the mutant's value would have differed there.
|
|
315
315
|
Nothing runs again. A plain run does nothing for mutants and costs nothing
|
|
316
316
|
more for them: a run lists its mutants from its sources the first time they are asked for (by `mutants`,
|
|
@@ -532,8 +532,8 @@ start-up run with the server restarted for them. Jest, node:test, Mocha, AVA,
|
|
|
532
532
|
node-tap, bun:test and Vitest's Browser Mode run one test file per start of the
|
|
533
533
|
command, with the mutant switched on in every process from its start (in the
|
|
534
534
|
page, under Browser Mode) and only that file's candidate tests, stopping at
|
|
535
|
-
the first failure; Jest and Mocha keep resident runners for it. Python,
|
|
536
|
-
|
|
535
|
+
the first failure; Jest and Mocha keep resident runners for it. Python, Go
|
|
536
|
+
and Ruby are in preview. Rust mutants
|
|
537
537
|
run through cargo's tests, or through the JavaScript tests that load the
|
|
538
538
|
crate compiled to wasm. Go mutants run each package's test binary, built once.
|
|
539
539
|
Ruby mutants run in a fork of the loaded suite under RSpec, Minitest, test-unit
|
package/docs/mutation.md
CHANGED
|
@@ -14,7 +14,7 @@ counts and verdicts can be compared with that tool's:
|
|
|
14
14
|
| --- | --- | --- |
|
|
15
15
|
| JavaScript, TypeScript | StrykerJS 10.1.1 | Full, under nine runners |
|
|
16
16
|
| Python | mutmut 3.8.1 | Preview |
|
|
17
|
-
| Rust | cargo-mutants 27.1.0 |
|
|
17
|
+
| Rust | cargo-mutants 27.1.0 | Full, under `cargo test` (libtest and doctests) and cargo-nextest |
|
|
18
18
|
| Go | Gremlins 0.6.0, every mutator | Preview |
|
|
19
19
|
| Ruby | mutant 0.17.1, light operators | Preview |
|
|
20
20
|
|
|
@@ -210,8 +210,10 @@ mutants the tests let survive.
|
|
|
210
210
|
the mutant switched on, which may be code it never ran without (a function
|
|
211
211
|
no test calls that a mutant sends a test into counts): for a JavaScript or
|
|
212
212
|
TypeScript test run in its runner's process (Jest, Vitest, Mocha, ...),
|
|
213
|
-
nothing its imports load and its code can name; for a
|
|
214
|
-
|
|
213
|
+
nothing its imports load and its code can name; for a Rust test, nothing
|
|
214
|
+
its own function can name in any Rust file (a trait implementation's
|
|
215
|
+
method counts where its type is named, as the language calls it
|
|
216
|
+
unnamed); for a Python or Ruby test, no code its imports load; for any other (a Playwright test, a mutant a
|
|
215
217
|
server starts with), `runs latest tests affected` finds it unaffected and
|
|
216
218
|
no code but tests' changed. The summary says how many verdicts were kept,
|
|
217
219
|
from which runs and commits (`26 verdict(s) kept from run r5 (commit
|
|
@@ -233,7 +235,9 @@ mutants the tests let survive.
|
|
|
233
235
|
of the tests each runs against, so a pass cut short has decided as many as
|
|
234
236
|
it could. `--budget <seconds>` is the whole command's, measuring and
|
|
235
237
|
planning included: once it is spent the pass stops and ends as a finished
|
|
236
|
-
one, its verdicts saved, so a job ends when its budget says.
|
|
238
|
+
one, its verdicts saved, so a job ends when its budget says. Nothing is
|
|
239
|
+
judged once the pass begins to stop: a test the stop cut short says nothing
|
|
240
|
+
of its mutant, which is left for the next pass. The summary
|
|
237
241
|
says how many mutants it left for the next pass (`budget of 2400 s spent:
|
|
238
242
|
812 mutant(s) left without a verdict, for the next pass`), and, where
|
|
239
243
|
measuring took half the budget or more, what it took (`measuring took 310 s
|
|
@@ -537,7 +541,7 @@ no mutants shows none of this.
|
|
|
537
541
|
| --- | --- |
|
|
538
542
|
| JavaScript, TypeScript | Vitest, Vitest Browser Mode, Playwright, Jest, `node:test`, Mocha, AVA, node-tap, `bun:test` |
|
|
539
543
|
| Python (preview) | pytest, `python -m unittest` |
|
|
540
|
-
| Rust
|
|
544
|
+
| Rust | `cargo test` (libtest and doctests), cargo-nextest; wasm in Node, under WASI and in Chrome |
|
|
541
545
|
| Go (preview) | `go test` |
|
|
542
546
|
| Ruby (preview) | RSpec, Minitest, test-unit, Cucumber |
|
|
543
547
|
|
|
@@ -617,7 +621,7 @@ no mutants shows none of this.
|
|
|
617
621
|
- **Jest and Mocha** run in resident runners, as StrykerJS's do; `node:test`,
|
|
618
622
|
AVA, node-tap, `bun:test` and Vitest Browser Mode run one test file per
|
|
619
623
|
start of the command, with the mutant on from its start.
|
|
620
|
-
- Rust compiled to wasm and loaded by these tests is mutated too
|
|
624
|
+
- Rust compiled to wasm and loaded by these tests is mutated too:
|
|
621
625
|
the command builds the wasm with the mutants switched in, and each wasm
|
|
622
626
|
instance, in Node or in a Playwright page, runs the test's mutant.
|
|
623
627
|
- Limits: wasm loaded in Vitest Browser Mode's pages is not measured, so its
|
|
@@ -637,14 +641,28 @@ own script (`TextTestRunner().run`) rather than `unittest.main` has its
|
|
|
637
641
|
mutants recorded `error`. mutmut's `do_not_mutate_patterns` and
|
|
638
642
|
`mutate_only_covered_lines` are not read.
|
|
639
643
|
|
|
640
|
-
### Rust
|
|
644
|
+
### Rust
|
|
641
645
|
|
|
642
646
|
Every mutant of a pass is built in one switched copy, and each test runs by
|
|
643
647
|
its exact name in a process of its own; doctests run through `cargo test
|
|
644
648
|
--doc`. Under cargo-nextest each test runs through nextest with the project's
|
|
645
|
-
configuration.
|
|
646
|
-
|
|
647
|
-
|
|
649
|
+
configuration. Each mutant is the program cargo-mutants' replacement text
|
|
650
|
+
makes, regrouping included (`a - b * c` with `*` made `+` is `(a - b) + c`).
|
|
651
|
+
A mutant the compiler refuses is `unviable`, as cargo-mutants reports it,
|
|
652
|
+
those no test reaches included; a mutant in code the compiler evaluates
|
|
653
|
+
(`const`, `static`, `const fn`) is built on its own.
|
|
654
|
+
|
|
655
|
+
- **Time limits** are cargo-mutants': a test's baseline × 5, at least 20 s.
|
|
656
|
+
A test past its limit beside other tests runs again alone, after a run of
|
|
657
|
+
it without the mutant sets its limit, so a busier machine makes no
|
|
658
|
+
timeout.
|
|
659
|
+
- **Stopping**: `--budget` and a signal stop the pass at once, its test
|
|
660
|
+
processes with it; nothing a stop cut short is judged, and each candidate a
|
|
661
|
+
mutant already passed is kept for the next pass.
|
|
662
|
+
- **After an edit**, a Rust test keeps a verdict where nothing its own
|
|
663
|
+
function can name changed, a trait implementation's methods counting
|
|
664
|
+
where its type or trait is named; a doctest keeps one only where no code
|
|
665
|
+
changed (`docs/design/rust-mutation.md`, After an edit).
|
|
648
666
|
|
|
649
667
|
Limits: tests built for wasm run against mutants in Node, under WASI and in
|
|
650
668
|
Chrome; tests run in Firefox, Safari or Edge have their mutants recorded
|
|
@@ -759,23 +777,59 @@ each tool on a machine of its own, 4-CPU Linux machines (AWS m8a.xlarge),
|
|
|
759
777
|
| parse 1.22.4 | 1,306 | 56.5 s | 1.4 + 12.6 s |
|
|
760
778
|
| humanize 4.17.0 | 1,348 | 152.3 s | 4.6 + 19.8 s |
|
|
761
779
|
|
|
762
|
-
### Rust
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
780
|
+
### Rust, against cargo-mutants 27.1.0
|
|
781
|
+
|
|
782
|
+
Eleven public crates pinned to a tag (`benchmarks/mutation/rust/`), every
|
|
783
|
+
mutant of each joined by id: cargo-mutants runs the package's whole suite
|
|
784
|
+
for each mutant; Supercov measures the suite and runs its strong pass. Both
|
|
785
|
+
on GitHub's `ubuntu-latest` (4 vCPUs), two mutants at a time, 2026-11-27:
|
|
786
|
+
cargo-mutants in shards of a crate's mutants, Supercov's `supercov mutants
|
|
787
|
+
--shard k/n` (measuring included) with its shards merged. Times are summed
|
|
788
|
+
over each tool's jobs (wall / CPU seconds), each job repeating its own build
|
|
789
|
+
and baseline, or its own measured run.
|
|
790
|
+
|
|
791
|
+
| Crate | Shape | Mutants joined | Agree | Soundness violations | Other disagreements | cargo-mutants | Supercov |
|
|
792
|
+
| --- | --- | ---: | ---: | ---: | ---: | ---: | ---: |
|
|
793
|
+
| strsim 0.11.1 | small library, doctests | 363 | 363 | 0 | 0 | 195 / 529 s | 97 / 201 s |
|
|
794
|
+
| hex 0.4.3 | deny-by-default lints | 104 | 102 | 0 | 2 lint | 131 / 434 s | 88 / 216 s |
|
|
795
|
+
| semver 1.0.27 | `const` code, integration tests | 365 | 363 | 0 | 2 lint | 163 / 405 s | 136 / 185 s |
|
|
796
|
+
| itoa 1.0.15 | generic over integer types | 46 | 46 | 0 | 0 | 8 / 17 s | 2 / 2 s |
|
|
797
|
+
| smallvec 1.15.1 | unsafe collection | 458 | 458 | 0 | 0 | 301 / 876 s | 181 / 368 s |
|
|
798
|
+
| unicode-width 0.2.1 | generated tables | 383 | 383 | 0 | 0 | 576 / 1,598 s | 218 / 410 s |
|
|
799
|
+
| bitflags 2.9.1 | macro-generated code | 107 | 107 | 0 | 0 | 267 / 577 s | 134 / 309 s |
|
|
800
|
+
| anyhow 1.0.98 | build script, `deny(dead_code)` | 201 | 192 | 0 | 9 lint | 218 / 796 s | 74 / 238 s |
|
|
801
|
+
| fastrand 2.3.0 | under cargo-nextest | 205 | 195 | 0 | 10 (8 lint) | 508 / 1,537 s | 719 / 340 s |
|
|
802
|
+
| regex-syntax 0.8.5 | workspace member, parser | 1,301 | 1,301 | 0 | 0 | 13,679 / 50,595 s (39 jobs) | 3,611 / 8,964 s |
|
|
803
|
+
| base64 0.22.1 | randomized round trips | 311 | 311 | 0 | 0 | 9,561 / 30,615 s (23 jobs) | 3,247 / 9,470 s |
|
|
804
|
+
|
|
805
|
+
No mutant one tool detects is one the other lets live. The other
|
|
806
|
+
disagreements, each applied by hand:
|
|
807
|
+
|
|
808
|
+
- **Lints** (hex, semver, anyhow, fastrand): cargo-mutants' build fails on a lint the
|
|
809
|
+
crate denies (`arithmetic_overflow` after `+` made `*`, anyhow's
|
|
810
|
+
`#![deny(dead_code, unused_imports)]` once a body is replaced); Supercov
|
|
811
|
+
caps lints as a measured run does, builds the mutant, and its tests kill
|
|
812
|
+
it, or none reaches it.
|
|
813
|
+
- **`vec!` in a `no_std` crate** (fastrand, 2): a body replaced by `vec![]`
|
|
814
|
+
where no `vec!` is in scope does not compile, an error rustc gives no code.
|
|
815
|
+
The run measured here called those mutants `no-coverage`; this release reads
|
|
816
|
+
that error as the mutant's own, and calls them `unviable`.
|
|
817
|
+
- **Time limits**: a test's limit is cargo-mutants' rule applied to that test,
|
|
818
|
+
5 × its baseline and at least 20 s, where cargo-mutants applies it to the
|
|
819
|
+
whole suite. A mutant of fastrand that makes rejection sampling loop far
|
|
820
|
+
longer ended its one test past 20 s in one run, within 5 × the suite: a
|
|
821
|
+
`timeout` here, missed there; in another run it ended in time, as there.
|
|
822
|
+
|
|
823
|
+
Mutants the table does not join were left by a job's time: base64's tests
|
|
824
|
+
are slow under mutation (cargo-mutants' 24 jobs reached 375 of its 619
|
|
825
|
+
mutants), fastrand runs each test through nextest (27 of Supercov's left for
|
|
826
|
+
a next pass), and regex-syntax's mutants of a `const fn`'s arms are each
|
|
827
|
+
built on their own (19). Supercov's wall time is the larger on fastrand:
|
|
828
|
+
nextest starts a process per test, against cargo-mutants' one per mutant;
|
|
829
|
+
its CPU time is a fifth. Each earlier gap the benchmark found is fixed and held by a test (`CHANGELOG.md`,
|
|
830
|
+
4.29.18): a probe that failed `u128` tests, `const fn` mutants read as never
|
|
831
|
+
run, operator mutants that regroup their expression, unviable mutants no
|
|
832
|
+
test reaches.
|
|
779
833
|
|
|
780
834
|
### Go (preview), against Gremlins 0.6.0
|
|
781
835
|
|
package/docs/performance.md
CHANGED
|
@@ -72,6 +72,65 @@ compare a cold package, browser, build, or VM cache with a warm one. Supercov
|
|
|
72
72
|
never runs the test command a second time automatically because suites may write
|
|
73
73
|
data, call paid services, or be intentionally non-repeatable.
|
|
74
74
|
|
|
75
|
+
### Where a browser suite's time goes
|
|
76
|
+
|
|
77
|
+
A Next.js app's Playwright suite (170 tests on one worker, against a
|
|
78
|
+
production build the suite builds itself, on a 4-CPU runner) takes 12 to 13%
|
|
79
|
+
longer measured than plain when run whole. Each part was timed plain and
|
|
80
|
+
measured on the same machine, an eighth of the suite at a time, which adds up
|
|
81
|
+
to 8%; the rest is the open contexts below:
|
|
82
|
+
|
|
83
|
+
| Part | Plain | Measured | Why |
|
|
84
|
+
| --- | --- | --- | --- |
|
|
85
|
+
| Supercov's start, before the build | 0.7 s | 1.5 s | Copying the project and instrumenting its sources |
|
|
86
|
+
| `next build` | 52 s | 57 s (+9.5%) | The build compiles the instrumented sources: probes, and source maps that keep stack traces on the author's lines |
|
|
87
|
+
| Server start to the first test | 3.6 s | 5.0 s | The runtime's preload in each process, and a larger server bundle |
|
|
88
|
+
| Tests | 255 s | 272 s (+6.4%) | See below |
|
|
89
|
+
| After the tests | 0.3 s | 1.6 s | Reading the evidence (0.25 s) and publishing the run (0.35 s), and closing the collector |
|
|
90
|
+
|
|
91
|
+
Most of what the tests add is waiting, not Supercov's own code:
|
|
92
|
+
|
|
93
|
+
- **Each action tells the browser its phase first.** A click, a fill or a
|
|
94
|
+
navigation waits for one round trip to every page of the test, about 6 ms
|
|
95
|
+
on such a runner (822 actions: about 5 s). The page has to know the phase
|
|
96
|
+
before the action's effects reach it, or the work it does would be credited
|
|
97
|
+
to the step before. An assertion sends the same message without waiting.
|
|
98
|
+
- **Pages run instrumented code.** The browser does more work for each page
|
|
99
|
+
the app renders.
|
|
100
|
+
- **A context the suite leaves open is the next tests' as well.** Its pages
|
|
101
|
+
are told each phase and read at the end of each test, in case they still
|
|
102
|
+
run code: a suite that opens contexts and never closes them pays a little
|
|
103
|
+
more with each one. On the suite above, the same test cost about 120 ms more
|
|
104
|
+
late in a whole run than at the start of a run of an eighth of it.
|
|
105
|
+
|
|
106
|
+
The server records every test's first hits in each phase as lines of JSON. It
|
|
107
|
+
writes them through a file kept open, and builds each line directly, which
|
|
108
|
+
takes about a third of the time it did before. The collector reads each page's
|
|
109
|
+
evidence in the columns it stores, which takes about a quarter of the time.
|
|
110
|
+
|
|
111
|
+
### Prove a speed-up changes nothing
|
|
112
|
+
|
|
113
|
+
A change meant to make measurement faster must leave every answer as it was.
|
|
114
|
+
`scripts/speed/answers.mjs` writes down every answer a run gives: its summary
|
|
115
|
+
and every view of it, every file, line (with its tests and phases) and
|
|
116
|
+
decision (with MC/DC vectors and witness pairs), every test, the mutants and
|
|
117
|
+
their candidates, and every record of the evidence. It replaces what differs
|
|
118
|
+
from run to run by its nature (run, attempt and worker ids, times, process
|
|
119
|
+
ids, paths) with stable names. Two runs of a suite that runs the same way each
|
|
120
|
+
time give files equal byte for byte:
|
|
121
|
+
|
|
122
|
+
```sh
|
|
123
|
+
node scripts/speed/answers.mjs ./old/supercov . "$OLD_RUN" old.json
|
|
124
|
+
node scripts/speed/answers.mjs ./new/supercov . "$NEW_RUN" new.json
|
|
125
|
+
diff old.json new.json
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
A suite whose timing decides what each phase runs (a page that renders after
|
|
129
|
+
a fetch, a server that answers while the next step starts) differs even
|
|
130
|
+
between two runs of one binary. The `speed` label's benchmark therefore
|
|
131
|
+
compares each binary's two rounds as well as the binaries
|
|
132
|
+
(`--quick` for its large apps), and the counts are read against each other.
|
|
133
|
+
|
|
75
134
|
### Python subprocesses
|
|
76
135
|
|
|
77
136
|
Interpreter count matters as well as test count. Each child initializes the
|
package/docs/supported-suites.md
CHANGED
|
@@ -20,7 +20,7 @@ npx supercov -- mvn test
|
|
|
20
20
|
| --- | --- | --- | --- |
|
|
21
21
|
| JavaScript | Available | `npx supercov -- npm test` | StrykerJS 10.1.1's mutants |
|
|
22
22
|
| TypeScript | Available | `npx supercov -- npm test` | StrykerJS 10.1.1's mutants |
|
|
23
|
-
| Rust | Available | `npx supercov -- cargo test` |
|
|
23
|
+
| Rust | Available | `npx supercov -- cargo test` | cargo-mutants 27.1.0's mutants |
|
|
24
24
|
| Python | Available | `npx supercov -- pytest` | Preview: mutmut 3.8.1's mutants |
|
|
25
25
|
| Ruby | Available | `npx supercov -- rspec` | Preview: mutant 0.17.1's mutants |
|
|
26
26
|
| Go | Available | `npx supercov -- go test ./...` | Preview: Gremlins 0.6.0's mutants |
|
|
@@ -37,7 +37,7 @@ The npm-distributed CLI requires Node.js 22 or newer for every language.
|
|
|
37
37
|
`npx supercov mutants -- <test command>` lists the mutants the language's
|
|
38
38
|
established tool would make of every source the run measured, says from the
|
|
39
39
|
run which ones no test reaches or infects, and runs the rest against the tests
|
|
40
|
-
that reach them. JavaScript and
|
|
40
|
+
that reach them. JavaScript, TypeScript and Rust are fully supported; Python,
|
|
41
41
|
Go and Ruby are in preview, each validated against its tool on public
|
|
42
42
|
projects; Java and Kotlin have no mutants yet. The Mutation testing column of
|
|
43
43
|
each runner table below says whether that runner's tests run against mutants.
|
|
@@ -200,9 +200,9 @@ loses nothing there either.
|
|
|
200
200
|
|
|
201
201
|
| Runner | Attribution | Current requirement | Mutation testing |
|
|
202
202
|
| --- | --- | --- | --- |
|
|
203
|
-
| Cargo's standard libtest runner | Exact test, attempt, and passing-assertion identity | Rust 1.95; run with `npx supercov -- cargo test` |
|
|
204
|
-
| rustdoc doctests | Exact doctest identity; every doctest runs in a process of its own | Rust 1.95; part of `npx supercov -- cargo test` |
|
|
205
|
-
| cargo-nextest | Exact test, attempt, retry, and binary identity | cargo-nextest 0.9.138 or newer (tested with 0.9.140 and 0.9.148) |
|
|
203
|
+
| Cargo's standard libtest runner | Exact test, attempt, and passing-assertion identity | Rust 1.95; run with `npx supercov -- cargo test` | Yes |
|
|
204
|
+
| rustdoc doctests | Exact doctest identity; every doctest runs in a process of its own | Rust 1.95; part of `npx supercov -- cargo test` | Yes |
|
|
205
|
+
| cargo-nextest | Exact test, attempt, retry, and binary identity | cargo-nextest 0.9.138 or newer (tested with 0.9.140 and 0.9.148) | Yes, with the project's nextest configuration |
|
|
206
206
|
|
|
207
207
|
Supercov preserves Cargo's test selection, scheduling, fail-fast behavior,
|
|
208
208
|
environment and exit status. Doctests run with their own identities; nextest
|
|
@@ -241,7 +241,7 @@ npx supercov -- cargo nextest run --workspace
|
|
|
241
241
|
explanation instead of silently falling back to plausible but inaccurate
|
|
242
242
|
attribution.
|
|
243
243
|
|
|
244
|
-
### Mutation testing
|
|
244
|
+
### Mutation testing
|
|
245
245
|
|
|
246
246
|
`supercov runs latest mutants` lists cargo-mutants' mutants (27.1.0) of the
|
|
247
247
|
files a Rust run measured, with what the run's tests tell of each, and
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "supercov",
|
|
3
|
-
"version": "4.29.
|
|
3
|
+
"version": "4.29.18",
|
|
4
4
|
"description": "Coverage, security and code quality for coding agents",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"coverage",
|
|
@@ -100,6 +100,7 @@
|
|
|
100
100
|
"check:lint": "node scripts/check-fault-sites.mjs && cargo fmt --all -- --check && cargo clippy --workspace --all-targets -- -D warnings",
|
|
101
101
|
"check:tests": "npm run test && npm run check:tooling",
|
|
102
102
|
"check:tooling": "npm run test:release-tooling && npm run test:runtime && npm run test:action && npm run test:rust-assets && npm run test:agent-commands && npm run test:assertions && npm run test:sweep-target && npm run test:skip-guard && npm run test:windows-tls && node scripts/package-preflight.mjs && node scripts/verify-binstall-metadata.mjs --offline",
|
|
103
|
+
"pre-push": "bash scripts/pre-push.sh",
|
|
103
104
|
"release:check": "cargo clean && node scripts/sweep-target.mjs && npm run check && npm run test:engine && npm run test:go && npm run test:jvm && npm run test:launcher && npm run test:fixture && npm run test:watchdog && npm run test:engine-contract && npm run test:agent && npm run test:child-attribution && npm run test:host-loader && npm run test:python && npm run test:ruby-coverage && npm run test:rust-public-cargo && npm run test:packed-npx && npm run test:clang-mcdc && npm run benchmark:check",
|
|
104
105
|
"release:bump": "node scripts/bump-version.mjs",
|
|
105
106
|
"release:verify": "node scripts/verify-release.mjs",
|
|
@@ -125,14 +126,14 @@
|
|
|
125
126
|
"test:windows-tls": "node scripts/windows-tls-test.mjs"
|
|
126
127
|
},
|
|
127
128
|
"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.
|
|
129
|
+
"@supercov/cli-darwin-arm64": "4.29.18",
|
|
130
|
+
"@supercov/cli-darwin-x64": "4.29.18",
|
|
131
|
+
"@supercov/cli-linux-arm64-gnu": "4.29.18",
|
|
132
|
+
"@supercov/cli-linux-arm64-musl": "4.29.18",
|
|
133
|
+
"@supercov/cli-linux-x64-gnu": "4.29.18",
|
|
134
|
+
"@supercov/cli-linux-x64-musl": "4.29.18",
|
|
135
|
+
"@supercov/cli-win32-arm64": "4.29.18",
|
|
136
|
+
"@supercov/cli-win32-x64": "4.29.18"
|
|
136
137
|
},
|
|
137
138
|
"peerDependencies": {
|
|
138
139
|
"@playwright/test": ">=1.55.0",
|
|
@@ -18,9 +18,9 @@ import * as standardPlaywright from "@playwright/test";
|
|
|
18
18
|
import * as coverageRuntime from "./runtime.mjs";
|
|
19
19
|
import { inferTestProvenance, testTags } from "./provenance.mjs";
|
|
20
20
|
import { appendJsonLineDurableSync, appendJsonLineSync } from "./atomic.mjs";
|
|
21
|
-
import { expandSnapshot, mergeSnapshots, columnarEvents } from "./snapshots.mjs";
|
|
21
|
+
import { expandSnapshot, mergeSnapshots, columnarEvents, eventsOfColumns, keepSnapshotText, recordLine } from "./snapshots.mjs";
|
|
22
22
|
import { COVERAGE_DOCUMENT_PHASE_COOKIE, COVERAGE_DOCUMENT_PHASE_SITE_COOKIE, COVERAGE_PHASE_HEADER, COVERAGE_PHASE_COOKIE, COVERAGE_PHASE_SITE_COOKIE, COVERAGE_SCOPE_COOKIE, COVERAGE_SCOPE_HEADER, COVERAGE_SCOPE_SITE_COOKIE, COVERAGE_CARRIER_ENV, encodeCoverageCarrier, encodeCoverageScope, serverEvidenceDirectory, serverEvidencePath, startDocumentInPhase, } from "./transport.mjs";
|
|
23
|
-
import { PAGE_ANSWER_MS, PAGE_BUSY, PAGE_GONE, PAGE_TIMEOUT_MARKER, activatePageMutant, describeCall, installCopies, keepsWorker, ownDeadline, pendingBefore, ranInWorker, stallDetails, stalledOn, strongClaim, strongFinish, watchPageWork, watchStall } from "./playwrightStrong.mjs";
|
|
23
|
+
import { PAGE_ANSWER_MS, PAGE_BUSY, PAGE_GONE, PAGE_TIMEOUT_MARKER, activatePageMutant, describeCall, installCopies, keepsWorker, ownDeadline, ownEndPast, pendingBefore, ranInWorker, stallDetails, stalledOn, strongClaim, strongFinish, watchPageWork, watchStall } from "./playwrightStrong.mjs";
|
|
24
24
|
export * from "@playwright/test";
|
|
25
25
|
const generatedTargetModule = "__SUPERCOV_PLAYWRIGHT_MODULE__";
|
|
26
26
|
const targetModule = process.env["SUPERCOV_PLAYWRIGHT_MODULE"] ??
|
|
@@ -80,6 +80,21 @@ function internally(owner, work) {
|
|
|
80
80
|
Error.prepareStackTrace = prepareStackTrace;
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* The Playwright object behind one of the collector's proxies (`wrap`). The
|
|
85
|
+
* suite's `page` fixture is the proxy of a page the collector registered
|
|
86
|
+
* already, when its context opened it: registered again by its proxy, every
|
|
87
|
+
* page and its context were known twice, and every action told the page and
|
|
88
|
+
* its cookies its phase twice, the context ran the runtime and the test's
|
|
89
|
+
* scripts twice, and a test's evidence was read twice and written twice.
|
|
90
|
+
*/
|
|
91
|
+
const proxiedTargets = new WeakMap();
|
|
92
|
+
function unwrapped(value) {
|
|
93
|
+
// A proxy an earlier test's controller made, wrapped again by this one.
|
|
94
|
+
while (proxiedTargets.has(value))
|
|
95
|
+
value = proxiedTargets.get(value);
|
|
96
|
+
return value;
|
|
97
|
+
}
|
|
83
98
|
function bounded(promise, milliseconds) {
|
|
84
99
|
let timer;
|
|
85
100
|
return Promise.race([
|
|
@@ -373,8 +388,10 @@ class CoveragePhaseController {
|
|
|
373
388
|
if (snapshot)
|
|
374
389
|
snapshots.push(snapshot);
|
|
375
390
|
}
|
|
391
|
+
// A snapshot read as columns is stored as it is; merged with what
|
|
392
|
+
// documents handed over as they left, its events are objects again.
|
|
376
393
|
this.runtimeSnapshots = this.leftSnapshots.length > 0
|
|
377
|
-
? [mergeSnapshots([...this.leftSnapshots, ...snapshots])]
|
|
394
|
+
? [mergeSnapshots([...this.leftSnapshots, ...snapshots.map(eventsOfColumns)])]
|
|
378
395
|
: snapshots;
|
|
379
396
|
return this.runtimeSnapshots;
|
|
380
397
|
}
|
|
@@ -459,6 +476,7 @@ class CoveragePhaseController {
|
|
|
459
476
|
}
|
|
460
477
|
/** Read a registered page's evidence while it can still be evaluated. */
|
|
461
478
|
async snapshotBeforeClose(page) {
|
|
479
|
+
page = unwrapped(page);
|
|
462
480
|
if (!this.pages.has(page) || this.snapshottedPages.has(page) || this.runtimeSnapshots)
|
|
463
481
|
return;
|
|
464
482
|
return internally(page, () => this.snapshotBeforeCloseNow(page));
|
|
@@ -550,6 +568,7 @@ class CoveragePhaseController {
|
|
|
550
568
|
* know its phase, and its hits were left to be placed by their time.
|
|
551
569
|
*/
|
|
552
570
|
registerPage(page) {
|
|
571
|
+
page = unwrapped(page);
|
|
553
572
|
if (this.disposed)
|
|
554
573
|
return Promise.resolve();
|
|
555
574
|
let registration = this.pageRegistrations.get(page);
|
|
@@ -607,6 +626,7 @@ class CoveragePhaseController {
|
|
|
607
626
|
void this.registerWorker(worker);
|
|
608
627
|
}
|
|
609
628
|
async registerContext(context, { adopted = false } = {}) {
|
|
629
|
+
context = unwrapped(context);
|
|
610
630
|
if (this.contexts.has(context) || this.disposed)
|
|
611
631
|
return;
|
|
612
632
|
this.contexts.add(context);
|
|
@@ -711,6 +731,7 @@ class CoveragePhaseController {
|
|
|
711
731
|
register(page);
|
|
712
732
|
}
|
|
713
733
|
async registerWorker(worker) {
|
|
734
|
+
worker = unwrapped(worker);
|
|
714
735
|
if (this.workers.has(worker))
|
|
715
736
|
return;
|
|
716
737
|
this.workers.add(worker);
|
|
@@ -842,7 +863,7 @@ class CoveragePhaseController {
|
|
|
842
863
|
// a page, as Playwright's fixtures do); the first such call is where
|
|
843
864
|
// the test's own time starts.
|
|
844
865
|
// Where in the test it was called (`at`), for a timeout's reason.
|
|
845
|
-
const wait = { operation: at ? `${operation} at ${at}` : operation, deadline, fromTest: !LIFECYCLE.has(operation.split(" ")[0]) };
|
|
866
|
+
const wait = { operation: at ? `${operation} at ${at}` : operation, deadline, fromTest: !LIFECYCLE.has(operation.split(" ")[0]), startedAt: Date.now(), pending };
|
|
846
867
|
if (wait.fromTest)
|
|
847
868
|
this.testCalledAt ??= Date.now();
|
|
848
869
|
this.waits.add(wait);
|
|
@@ -876,11 +897,32 @@ class CoveragePhaseController {
|
|
|
876
897
|
const workers = pages.reduce((sum, page) => sum + page.workers().length, 0);
|
|
877
898
|
return pendingBefore({ frames, requests: this.unanswered.size, workers, limitAt, now: Date.now() });
|
|
878
899
|
}
|
|
879
|
-
/**
|
|
880
|
-
|
|
900
|
+
/**
|
|
901
|
+
* What a strong attempt is stalled on before `limitAt`, if it is, what it
|
|
902
|
+
* waits on now, and when the calls it waits on end by their own timeouts
|
|
903
|
+
* past the limit, where they all do (`ownEndPast`).
|
|
904
|
+
*/
|
|
905
|
+
stall(limitAt, testTimeoutAt) {
|
|
881
906
|
const newest = this.newestWait;
|
|
882
907
|
const stalled = stalledOn({ waits: this.waits, newest, limitAt, quietSince: this.quietSince, now: Date.now() });
|
|
883
|
-
return {
|
|
908
|
+
return {
|
|
909
|
+
stalled: stalled?.operation,
|
|
910
|
+
waiting: this.waits.has(newest) ? newest.operation : undefined,
|
|
911
|
+
since: this.testCalledAt,
|
|
912
|
+
ownEnd: ownEndPast({ waits: this.waits, limitAt, testTimeoutAt }),
|
|
913
|
+
};
|
|
914
|
+
}
|
|
915
|
+
/**
|
|
916
|
+
* The calls the test waits on now run past `limitAt` to their own
|
|
917
|
+
* timeouts (`watchStall`), and the test's own outcome decides. Where
|
|
918
|
+
* they have all ended before the limit, it holds again (`restore`).
|
|
919
|
+
*/
|
|
920
|
+
extendPast(limitAt, restore) {
|
|
921
|
+
const waits = [...this.waits];
|
|
922
|
+
Promise.allSettled(waits.map((wait) => wait.pending)).then(() => {
|
|
923
|
+
if (Date.now() < limitAt)
|
|
924
|
+
restore();
|
|
925
|
+
});
|
|
884
926
|
}
|
|
885
927
|
async dispose() {
|
|
886
928
|
this.disposed = true;
|
|
@@ -971,6 +1013,7 @@ class CoveragePhaseController {
|
|
|
971
1013
|
});
|
|
972
1014
|
this.proxyCache.set(target, proxy);
|
|
973
1015
|
this.proxyTargets.set(proxy, target);
|
|
1016
|
+
proxiedTargets.set(proxy, target);
|
|
974
1017
|
// Playwright's built-in `page` fixture is created through the wrapped
|
|
975
1018
|
// worker-scoped browser. The test-scoped fixture sees that proxy again;
|
|
976
1019
|
// treating our own proxy as a fresh target would nest wrappers, emit two
|
|
@@ -1362,9 +1405,15 @@ function readSnapshot(target) {
|
|
|
1362
1405
|
return target
|
|
1363
1406
|
.evaluate(() => {
|
|
1364
1407
|
const getSnapshot = globalThis.__SUPERCOV_COVERAGE_SNAPSHOT__;
|
|
1408
|
+
const columns = globalThis.__SUPERCOV_COLUMNS_SNAPSHOT__;
|
|
1365
1409
|
const compact = globalThis.__SUPERCOV_COMPACT_SNAPSHOT__;
|
|
1366
1410
|
if (!getSnapshot)
|
|
1367
1411
|
return undefined;
|
|
1412
|
+
// A runtime that keeps its events as columns gives them as such: the
|
|
1413
|
+
// snapshot the evidence stores (columnarEvents). An older copy in
|
|
1414
|
+
// the page gives its events compactly.
|
|
1415
|
+
if (typeof columns === "function")
|
|
1416
|
+
return columns();
|
|
1368
1417
|
return typeof compact === "function" ? compact(getSnapshot()) : JSON.stringify(getSnapshot());
|
|
1369
1418
|
})
|
|
1370
1419
|
.then((text) => {
|
|
@@ -1372,7 +1421,13 @@ function readSnapshot(target) {
|
|
|
1372
1421
|
return undefined;
|
|
1373
1422
|
// Phase timing counts the bytes each read carried, as its "ms".
|
|
1374
1423
|
timingCount("transfer.snapshotBytes", text.length);
|
|
1375
|
-
|
|
1424
|
+
const parsed = JSON.parse(text);
|
|
1425
|
+
const snapshot = expandSnapshot(parsed);
|
|
1426
|
+
// The page wrote it with JSON.stringify, as the record will: kept,
|
|
1427
|
+
// the record takes the text as it came instead of writing it again.
|
|
1428
|
+
if (snapshot === parsed && snapshot && typeof snapshot === "object")
|
|
1429
|
+
keepSnapshotText(snapshot, text);
|
|
1430
|
+
return snapshot;
|
|
1376
1431
|
});
|
|
1377
1432
|
}
|
|
1378
1433
|
let activeController;
|
|
@@ -1428,6 +1483,7 @@ function liveTrackedContexts() {
|
|
|
1428
1483
|
}
|
|
1429
1484
|
/** The controller that registered `page`, whichever test it belongs to. */
|
|
1430
1485
|
function controllerOwning(page) {
|
|
1486
|
+
page = unwrapped(page);
|
|
1431
1487
|
if (activeController?.pages.has(page))
|
|
1432
1488
|
return activeController;
|
|
1433
1489
|
for (const controller of controllers.values())
|
|
@@ -2060,7 +2116,7 @@ const instrumentedFixtures = {
|
|
|
2060
2116
|
// state in it: the next test gets a new worker.
|
|
2061
2117
|
let restartWorker = false;
|
|
2062
2118
|
// A mutant attempt that stalls ends there, a timeout.
|
|
2063
|
-
const stall = watchStall(testInfo, strong, (limitAt) => controller.stall(limitAt), (limitAt) => controller.pageWork(limitAt));
|
|
2119
|
+
const stall = watchStall(testInfo, strong, (limitAt, testTimeoutAt) => controller.stall(limitAt, testTimeoutAt), (limitAt) => controller.pageWork(limitAt), (limitAt, restore) => controller.extendPast(limitAt, restore));
|
|
2064
2120
|
try {
|
|
2065
2121
|
await use();
|
|
2066
2122
|
}
|
|
@@ -2097,7 +2153,7 @@ const instrumentedFixtures = {
|
|
|
2097
2153
|
browser: browser.map(columnarEvents),
|
|
2098
2154
|
span: [startedAtMs, endedAtMs],
|
|
2099
2155
|
};
|
|
2100
|
-
appendEvidenceLine(`${
|
|
2156
|
+
appendEvidenceLine(`${recordLine(payload)}\n`);
|
|
2101
2157
|
}
|
|
2102
2158
|
finally {
|
|
2103
2159
|
strongFinish(testInfo, strong, { attemptId: scope.attemptId, pageTimeout: controller.mutantRanAway === true, ...stallDetails(stall) });
|
|
@@ -76,6 +76,8 @@ const STALL_CONSTANT_MS = 1_000;
|
|
|
76
76
|
const QUIET_MS = 1_000;
|
|
77
77
|
// How often a stalled attempt is looked for.
|
|
78
78
|
const STALL_POLL_MS = 100;
|
|
79
|
+
// How long after a wait's own timeout its failure takes to end the test.
|
|
80
|
+
const OWN_END_GRACE_MS = 1_000;
|
|
79
81
|
// How long a page has to say what it has yet to do; one that cannot answer is
|
|
80
82
|
// busy.
|
|
81
83
|
export const PAGE_ANSWER_MS = 1_000;
|
|
@@ -293,6 +295,32 @@ export function stalledOn({ waits, newest, limitAt, quietSince, now }) {
|
|
|
293
295
|
return newest;
|
|
294
296
|
}
|
|
295
297
|
|
|
298
|
+
/**
|
|
299
|
+
* When a mutant attempt may run to, past its limit, for the test's own waits
|
|
300
|
+
* to end by their own timeouts: the latest of them, where every call the
|
|
301
|
+
* test is waiting on started before `limitAt` and ends by a timeout of its
|
|
302
|
+
* own after it, before `testTimeoutAt` (the test's own timeout, where it has
|
|
303
|
+
* one) with time to fail. `undefined` where any of them could wait for ever,
|
|
304
|
+
* or all end before the limit anyway. An `expect` that started late on a
|
|
305
|
+
* loaded machine then fails by itself, as it does on an idle one, rather
|
|
306
|
+
* than being stopped at the limit as a timeout.
|
|
307
|
+
*/
|
|
308
|
+
export function ownEndPast({ waits, limitAt, testTimeoutAt }) {
|
|
309
|
+
if (waits.size === 0)
|
|
310
|
+
return undefined;
|
|
311
|
+
let end = -Infinity;
|
|
312
|
+
for (const wait of waits) {
|
|
313
|
+
if (!Number.isFinite(wait.deadline) || !(wait.startedAt < limitAt))
|
|
314
|
+
return undefined;
|
|
315
|
+
end = Math.max(end, wait.deadline);
|
|
316
|
+
}
|
|
317
|
+
if (end <= limitAt)
|
|
318
|
+
return undefined;
|
|
319
|
+
if (testTimeoutAt !== undefined && end + OWN_END_GRACE_MS > testTimeoutAt)
|
|
320
|
+
return undefined;
|
|
321
|
+
return end;
|
|
322
|
+
}
|
|
323
|
+
|
|
296
324
|
/**
|
|
297
325
|
* What a page could still do that may end a wait before `limitAt`, as one
|
|
298
326
|
* phrase, and when to ask again (`retryAt`); `undefined` where nothing can.
|
|
@@ -464,14 +492,15 @@ export function stallWindowOf(baselineMs, factor) {
|
|
|
464
492
|
* wait and why (`doubted`), and, where it went on to its limit, what it last
|
|
465
493
|
* waited on (`waiting`). `stop()` ends the watch.
|
|
466
494
|
*/
|
|
467
|
-
export function watchStall(testInfo, claimed, look, doubt) {
|
|
495
|
+
export function watchStall(testInfo, claimed, look, doubt, extend) {
|
|
468
496
|
if (claimed?.kind !== "mutant")
|
|
469
497
|
return undefined;
|
|
470
498
|
const from = claimed.startedAt + stallWindowOf(claimed.baselineMs, claimed.timeoutFactor);
|
|
471
499
|
if (from >= claimed.limitAt)
|
|
472
500
|
return undefined;
|
|
473
501
|
const windowMs = stallWindowOf(claimed.baselineMs, claimed.timeoutFactor);
|
|
474
|
-
const watch = { stalled: undefined, doubted: undefined, waiting: undefined, timer: undefined, stopped: false };
|
|
502
|
+
const watch = { stalled: undefined, doubted: undefined, waiting: undefined, extended: undefined, timer: undefined, stopped: false };
|
|
503
|
+
const testTimeoutAt = claimed.testTimeoutMs > 0 ? claimed.claimedAt + claimed.testTimeoutMs : undefined;
|
|
475
504
|
// A test whose body has ended (it failed, ran out of time, or its
|
|
476
505
|
// fixtures are being torn down: Playwright sets its duration then) waits
|
|
477
506
|
// on nothing of its own: what its teardown closes is not what it waited
|
|
@@ -483,8 +512,25 @@ export function watchStall(testInfo, claimed, look, doubt) {
|
|
|
483
512
|
const check = () => {
|
|
484
513
|
if (ended())
|
|
485
514
|
return;
|
|
486
|
-
const { stalled, waiting, since } = look(claimed.limitAt);
|
|
515
|
+
const { stalled, waiting, since, ownEnd } = look(claimed.limitAt, testTimeoutAt);
|
|
487
516
|
watch.waiting = waiting;
|
|
517
|
+
// Every call the test waits on ends by its own timeout past the
|
|
518
|
+
// limit: the attempt runs until then, and the test's own outcome
|
|
519
|
+
// decides (`ownEndPast`). Once they end, the limit holds again.
|
|
520
|
+
// Past the hold on its timeout, where the attempt has one.
|
|
521
|
+
const raise = rawTimeouts.get(testInfo) ?? testInfo.setTimeout?.bind(testInfo);
|
|
522
|
+
if (!watch.extended && ownEnd !== undefined && raise && extend && Date.now() < claimed.limitAt) {
|
|
523
|
+
watch.extended = { untilAt: ownEnd + OWN_END_GRACE_MS };
|
|
524
|
+
raise(watch.extended.untilAt - claimed.claimedAt);
|
|
525
|
+
extend(claimed.limitAt, () => {
|
|
526
|
+
watch.extended = undefined;
|
|
527
|
+
raise(claimed.limitAt - claimed.claimedAt);
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
if (watch.extended) {
|
|
531
|
+
later(STALL_POLL_MS);
|
|
532
|
+
return;
|
|
533
|
+
}
|
|
488
534
|
// The window counts from the test's first call of its own, not from
|
|
489
535
|
// its claim: setting up its page in a new worker on a loaded machine
|
|
490
536
|
// took seconds, which no baseline holds.
|
|
@@ -1632,6 +1678,8 @@ function startRunning(pass, testId, mutant) {
|
|
|
1632
1678
|
return { running: `${running}/${mine}`, beside };
|
|
1633
1679
|
}
|
|
1634
1680
|
|
|
1681
|
+
/** Each held attempt's own setter of its timeout, past the hold (`watchStall`). */
|
|
1682
|
+
const rawTimeouts = new WeakMap();
|
|
1635
1683
|
/**
|
|
1636
1684
|
* Holds a mutant attempt to its time limit (`timeout`, from the test's
|
|
1637
1685
|
* start): the test's own `test.setTimeout()` and `test.slow()` may shorten
|
|
@@ -1640,6 +1688,7 @@ function startRunning(pass, testId, mutant) {
|
|
|
1640
1688
|
*/
|
|
1641
1689
|
function holdTimeout(testInfo, timeout) {
|
|
1642
1690
|
const setTimeout = testInfo.setTimeout.bind(testInfo);
|
|
1691
|
+
rawTimeouts.set(testInfo, setTimeout);
|
|
1643
1692
|
setTimeout(timeout);
|
|
1644
1693
|
testInfo.setTimeout = (asked) => setTimeout(asked > 0 ? Math.min(asked, timeout) : timeout);
|
|
1645
1694
|
// `test.slow()` in a test's body (Playwright's own modifier): it
|
|
@@ -1755,7 +1804,7 @@ export async function strongClaim(testInfo) {
|
|
|
1755
1804
|
mutant: attempt.mutant,
|
|
1756
1805
|
// A mutant's: when its limit ends it, and when its claim began,
|
|
1757
1806
|
// which the test's timeout counts from (`watchStall`).
|
|
1758
|
-
...(attempt.kind === "mutant" ? { baselineMs: attempt.baselineMs, limitMs: attempt.limitMs, timeoutFactor: attempt.timeoutFactor, limitAt: startedAt + attempt.limitMs, claimedAt: started, ...(attempt.cold ? { cold: true } : {}) } : {}),
|
|
1807
|
+
...(attempt.kind === "mutant" ? { baselineMs: attempt.baselineMs, limitMs: attempt.limitMs, timeoutFactor: attempt.timeoutFactor, limitAt: startedAt + attempt.limitMs, claimedAt: started, testTimeoutMs: configured, ...(attempt.cold ? { cold: true } : {}) } : {}),
|
|
1759
1808
|
startedAt,
|
|
1760
1809
|
lock,
|
|
1761
1810
|
running,
|
|
@@ -1868,6 +1917,7 @@ export const WHY = {
|
|
|
1868
1917
|
"module-level": "it is a server module's top-level code",
|
|
1869
1918
|
"by-time": "its code ran for a request that named no test",
|
|
1870
1919
|
"unfinished": "not every candidate test ran in the shared pass",
|
|
1920
|
+
"unfinished-twice": "not every candidate test ran in two rounds of tests side by side",
|
|
1871
1921
|
"confirm": "a test killed it beside other mutants' attempts",
|
|
1872
1922
|
"doubt": "the test that killed it failed without it too, on the same server",
|
|
1873
1923
|
"unreached": "its candidates passed on the shared server, yet no attempt of theirs ran it there: the requests that reached its code did not carry their test's mutant",
|
|
@@ -498,9 +498,20 @@ export default class SupercovPlaywrightStrongReporter {
|
|
|
498
498
|
// signal stopped leaves its mutants without a verdict, for the next
|
|
499
499
|
// pass (a confirmation round stopped before its first test made two
|
|
500
500
|
// mutants of a 60 s pass `error`s).
|
|
501
|
+
// A `rest` round's mutant runs one test at a time first: beside one
|
|
502
|
+
// another, a worker with nothing it could take yet ran through a
|
|
503
|
+
// test's copies while another worker's attempt ran, and the round
|
|
504
|
+
// ended with mutants still waiting for that test. One whose every
|
|
505
|
+
// candidate kills it (a test that fails without it is left out)
|
|
506
|
+
// was an `error` on a loaded runner. One at a time, no copy is spent
|
|
507
|
+
// so; what a serial round leaves is the `error`.
|
|
501
508
|
if (kind !== "main" && !decided && !stopped) {
|
|
502
|
-
for (const job of rest)
|
|
503
|
-
|
|
509
|
+
for (const job of rest) {
|
|
510
|
+
if (kind === "rest")
|
|
511
|
+
serial.push({ ...job, reason: "unfinished-twice" });
|
|
512
|
+
else
|
|
513
|
+
write({ id: job.id, status: "error", reason: "its tests did not finish, in two rounds", tests: 0, durationMs: 0 });
|
|
514
|
+
}
|
|
504
515
|
rest.splice(0, rest.length);
|
|
505
516
|
}
|
|
506
517
|
// A mutant run alone with the whole command started with it, whose
|
|
@@ -25,8 +25,24 @@ if ((process.env.NODE_OPTIONS ?? "").split(/\s+/).filter((option) => option ===
|
|
|
25
25
|
typeof Module.setSourceMapsSupport === "function")
|
|
26
26
|
Module.setSourceMapsSupport(true, { nodeModules: false, generatedCode: true });
|
|
27
27
|
// Before anything else loads: every module after this compiles from the
|
|
28
|
-
// code the run's earlier processes left (atomic.mjs says why).
|
|
29
|
-
|
|
28
|
+
// code the run's earlier processes left (atomic.mjs says why). Not in npm's
|
|
29
|
+
// own process (`npm run`, `npx`, `npm exec`), which runs none of the
|
|
30
|
+
// project's code: writing the compiled code of the hundreds of modules npm
|
|
31
|
+
// loads cost each launcher more than the launchers after it saved, about
|
|
32
|
+
// 3 ms per test on each of a measured Next.js suite's three. The commands it
|
|
33
|
+
// launches have this preload, and the cache, of their own.
|
|
34
|
+
// It is started through a link (`bin/npx`), so its script is looked at
|
|
35
|
+
// where the link leads.
|
|
36
|
+
const isNpmItself = (() => {
|
|
37
|
+
try {
|
|
38
|
+
return /[\\/]npm[\\/]bin[\\/]np[mx]-cli\.js$/.test(realpathSync(process.argv[1] ?? ""));
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
})();
|
|
44
|
+
if (!isNpmItself)
|
|
45
|
+
enableNodeCompileCache(process.env.SUPERCOV_COMPILE_CACHE);
|
|
30
46
|
installLaunchSupervisor();
|
|
31
47
|
// Playwright's compile cache, written whole (atomic.mjs says why).
|
|
32
48
|
writePlaywrightCacheWhole();
|
|
@@ -35,10 +35,21 @@ var COVERAGE_SCOPE_SITE_COOKIE = "__supercov_scope_site";
|
|
|
35
35
|
var COVERAGE_PHASE_SITE_COOKIE = "__supercov_phase_site";
|
|
36
36
|
var COVERAGE_CARRIER_ENV = "SUPERCOV_CONTEXT";
|
|
37
37
|
var DEFAULT_SERVER_EVIDENCE_ROOT = "/tmp/supercov-server-evidence";
|
|
38
|
+
// Supercov gives a process its evidence root when it starts it, so the root
|
|
39
|
+
// is read once per environment object, as SUPERCOV_CONTEXT is: a read of
|
|
40
|
+
// process.env is an interceptor's call, and a server made one for every
|
|
41
|
+
// record it wrote. A suite that swaps process.env for another object is read
|
|
42
|
+
// again.
|
|
43
|
+
var configuredRoot = { env: void 0, root: DEFAULT_SERVER_EVIDENCE_ROOT };
|
|
38
44
|
function configuredServerEvidenceRoot() {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
45
|
+
const env = typeof process !== "undefined" ? process.env : void 0;
|
|
46
|
+
if (env === void 0 || env === null)
|
|
47
|
+
return DEFAULT_SERVER_EVIDENCE_ROOT;
|
|
48
|
+
if (env === configuredRoot.env)
|
|
49
|
+
return configuredRoot.root;
|
|
50
|
+
const configured = env["SUPERCOV_SERVER_EVIDENCE_ROOT"];
|
|
51
|
+
configuredRoot = { env, root: configured ? configured : DEFAULT_SERVER_EVIDENCE_ROOT };
|
|
52
|
+
return configuredRoot.root;
|
|
42
53
|
}
|
|
43
54
|
function nonEmpty(value) {
|
|
44
55
|
return typeof value === "string" && value.length > 0;
|
|
@@ -169,6 +180,7 @@ for (const name of [
|
|
|
169
180
|
"__SUPERCOV_BUFFER_EXIT_INSTALLED__",
|
|
170
181
|
"__SUPERCOV_BUFFER_FLUSHERS__",
|
|
171
182
|
"__SUPERCOV_CHILD_PATCHED__",
|
|
183
|
+
"__SUPERCOV_COLUMNS_SNAPSHOT__",
|
|
172
184
|
"__SUPERCOV_COMPACT_SNAPSHOT__",
|
|
173
185
|
"__SUPERCOV_COVERAGE_SNAPSHOT__",
|
|
174
186
|
"__SUPERCOV_DIRECT_RUNTIME__",
|
|
@@ -254,7 +266,10 @@ function createState() {
|
|
|
254
266
|
eventKeys: /* @__PURE__ */ new Map(),
|
|
255
267
|
bufferedAttempts: /* @__PURE__ */ new Set(),
|
|
256
268
|
serverBuffers: /* @__PURE__ */ new Map(),
|
|
257
|
-
|
|
269
|
+
// The records written for each attempt, by attempt (attemptKey): a hit's
|
|
270
|
+
// by its phase and then its id, any other by its serverRecordKey. One key
|
|
271
|
+
// joining them all was built and hashed for every record.
|
|
272
|
+
persistedServerRecords: /* @__PURE__ */ new Map(),
|
|
258
273
|
backgroundBuffers: /* @__PURE__ */ new Map(),
|
|
259
274
|
backgroundWriters: /* @__PURE__ */ new Map(),
|
|
260
275
|
backgroundShardSizes: /* @__PURE__ */ new Map(),
|
|
@@ -680,6 +695,13 @@ function compactSnapshotText(snapshot) {
|
|
|
680
695
|
return JSON.stringify({ supercovCompactSnapshot: 1, order: keys, rest, strings, shapes, rows, hits });
|
|
681
696
|
}
|
|
682
697
|
runtimeGlobal.__SUPERCOV_COMPACT_SNAPSHOT__ = compactSnapshotText;
|
|
698
|
+
// The text of a snapshot as the Playwright collector stores it: what
|
|
699
|
+
// JSON.stringify(columnarEvents(coverageSnapshot())) writes, made from the
|
|
700
|
+
// columns the events are kept in. Read through compactSnapshotText, every
|
|
701
|
+
// event became an object, then a row, and the collector made each an object
|
|
702
|
+
// again and then a column: on a page of 30,000 events, 26 ms at the end of
|
|
703
|
+
// each test against 7.
|
|
704
|
+
runtimeGlobal.__SUPERCOV_COLUMNS_SNAPSHOT__ = () => JSON.stringify(coverageSnapshotColumns());
|
|
683
705
|
runtimeGlobal.__SUPERCOV_RESET__ = resetCoverage;
|
|
684
706
|
// A dedicated worker blocked in `Atomics.wait` runs no evaluation, so the
|
|
685
707
|
// test runner could not read its evidence and reported the test as a lower
|
|
@@ -1415,7 +1437,7 @@ function flushServerAppends() {
|
|
|
1415
1437
|
makeEvidenceDirectory(fs, entry.directory);
|
|
1416
1438
|
state.createdEvidenceDirectories.add(entry.directory);
|
|
1417
1439
|
}
|
|
1418
|
-
fs
|
|
1440
|
+
appendAttemptLines(fs, path, entry.lines.join(""));
|
|
1419
1441
|
} catch (cause) {
|
|
1420
1442
|
const failure = serverTransportError(entry.runId, cause);
|
|
1421
1443
|
state.serverTransportFailure = failure;
|
|
@@ -1423,6 +1445,62 @@ function flushServerAppends() {
|
|
|
1423
1445
|
}
|
|
1424
1446
|
}
|
|
1425
1447
|
}
|
|
1448
|
+
// An attempt's file, appended to through a descriptor kept open: opening
|
|
1449
|
+
// and closing it for every turn's lines was most of what a server's first
|
|
1450
|
+
// hits cost (a Next server renders a page over hundreds of turns). The bytes
|
|
1451
|
+
// and their order are the same. A file removed since it was opened -- a
|
|
1452
|
+
// test's fixture clears its attempt's file before the test starts -- is
|
|
1453
|
+
// opened again, so nothing is written where no one reads it; a descriptor
|
|
1454
|
+
// that fails is opened again once. Windows cannot remove a file a process
|
|
1455
|
+
// holds open, so there each turn's lines are appended as before.
|
|
1456
|
+
var ATTEMPT_DESCRIPTORS_KEPT = 32;
|
|
1457
|
+
function appendAttemptLines(fs, path, text) {
|
|
1458
|
+
if (process.platform === "win32" || typeof fs.openSync !== "function") {
|
|
1459
|
+
fs.appendFileSync(path, text);
|
|
1460
|
+
return;
|
|
1461
|
+
}
|
|
1462
|
+
const descriptors = state.attemptDescriptors || (state.attemptDescriptors = /* @__PURE__ */ new Map());
|
|
1463
|
+
let descriptor = descriptors.get(path);
|
|
1464
|
+
if (descriptor !== void 0 && !descriptorLinked(fs, descriptor)) {
|
|
1465
|
+
closeAttemptDescriptor(fs, path);
|
|
1466
|
+
descriptor = void 0;
|
|
1467
|
+
}
|
|
1468
|
+
const bytes = capturedBuffer.from(text);
|
|
1469
|
+
if (descriptor !== void 0) {
|
|
1470
|
+
try {
|
|
1471
|
+
writeAllSync(fs, descriptor, bytes);
|
|
1472
|
+
return;
|
|
1473
|
+
} catch (e) {
|
|
1474
|
+
closeAttemptDescriptor(fs, path);
|
|
1475
|
+
}
|
|
1476
|
+
}
|
|
1477
|
+
descriptor = fs.openSync(path, "a");
|
|
1478
|
+
// The oldest attempt's file is closed once a server holds more than a few:
|
|
1479
|
+
// its test has ended, and what comes later for it opens it again.
|
|
1480
|
+
if (descriptors.size >= ATTEMPT_DESCRIPTORS_KEPT)
|
|
1481
|
+
closeAttemptDescriptor(fs, descriptors.keys().next().value);
|
|
1482
|
+
descriptors.set(path, descriptor);
|
|
1483
|
+
writeAllSync(fs, descriptor, bytes);
|
|
1484
|
+
}
|
|
1485
|
+
function descriptorLinked(fs, descriptor) {
|
|
1486
|
+
try {
|
|
1487
|
+
return fs.fstatSync(descriptor).nlink > 0;
|
|
1488
|
+
} catch (e) {
|
|
1489
|
+
return false;
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1492
|
+
function closeAttemptDescriptor(fs, path) {
|
|
1493
|
+
const descriptor = state.attemptDescriptors.get(path);
|
|
1494
|
+
state.attemptDescriptors.delete(path);
|
|
1495
|
+
try {
|
|
1496
|
+
fs.closeSync(descriptor);
|
|
1497
|
+
} catch (e) {
|
|
1498
|
+
}
|
|
1499
|
+
}
|
|
1500
|
+
function writeAllSync(fs, descriptor, bytes) {
|
|
1501
|
+
for (let written = 0; written < bytes.length; )
|
|
1502
|
+
written += fs.writeSync(descriptor, bytes, written, bytes.length - written);
|
|
1503
|
+
}
|
|
1426
1504
|
function enqueueServerAppend(directory, path, line, runId) {
|
|
1427
1505
|
// Fail closed with the original context: after one transport failure the
|
|
1428
1506
|
// very next probe re-raises it synchronously.
|
|
@@ -1457,6 +1535,103 @@ function scheduleServerFlush() {
|
|
|
1457
1535
|
});
|
|
1458
1536
|
}
|
|
1459
1537
|
}
|
|
1538
|
+
// An attempt's key, made once per scope object: a request's scope is one
|
|
1539
|
+
// object for all of the request's records.
|
|
1540
|
+
var attemptKeys = /* @__PURE__ */ new WeakMap();
|
|
1541
|
+
function cachedAttemptKey(scope) {
|
|
1542
|
+
let key = attemptKeys.get(scope);
|
|
1543
|
+
if (key === void 0) {
|
|
1544
|
+
key = attemptKey(scope);
|
|
1545
|
+
attemptKeys.set(scope, key);
|
|
1546
|
+
}
|
|
1547
|
+
return key;
|
|
1548
|
+
}
|
|
1549
|
+
// What an attempt's records are kept apart by (state.persistedServerRecords).
|
|
1550
|
+
function persistedOf(scope) {
|
|
1551
|
+
const key = cachedAttemptKey(scope);
|
|
1552
|
+
let persisted = builtinMapGet.call(state.persistedServerRecords, key);
|
|
1553
|
+
if (persisted === void 0) {
|
|
1554
|
+
persisted = { hits: /* @__PURE__ */ new Map(), other: /* @__PURE__ */ new Set() };
|
|
1555
|
+
builtinMapSet.call(state.persistedServerRecords, key, persisted);
|
|
1556
|
+
}
|
|
1557
|
+
return persisted;
|
|
1558
|
+
}
|
|
1559
|
+
function persistedHitsOf(persisted, phaseId) {
|
|
1560
|
+
let ids = builtinMapGet.call(persisted.hits, phaseId);
|
|
1561
|
+
if (ids === void 0) {
|
|
1562
|
+
ids = /* @__PURE__ */ new Set();
|
|
1563
|
+
builtinMapSet.call(persisted.hits, phaseId, ids);
|
|
1564
|
+
}
|
|
1565
|
+
return ids;
|
|
1566
|
+
}
|
|
1567
|
+
// The set a record of a scope with a phase is kept in, and its key there
|
|
1568
|
+
// (persistedKey): what serverRecordKey tells apart, told apart.
|
|
1569
|
+
function persistedRecordsOf(scope, record) {
|
|
1570
|
+
const persisted = persistedOf(scope);
|
|
1571
|
+
return plainHit(record) ? persistedHitsOf(persisted, record.phaseId) : persisted.other;
|
|
1572
|
+
}
|
|
1573
|
+
function plainHit(record) {
|
|
1574
|
+
return record.type === "hit" && record.outcome === void 0 && !record.request;
|
|
1575
|
+
}
|
|
1576
|
+
function persistedKey(record) {
|
|
1577
|
+
return plainHit(record) ? record.id : serverRecordKey(record);
|
|
1578
|
+
}
|
|
1579
|
+
// Where a record of the current request goes, when it names its test and
|
|
1580
|
+
// phase and its attempt's file already has its first line: what appendServer
|
|
1581
|
+
// works out with an object or two per record, a server's first hits and
|
|
1582
|
+
// decision vectors in every phase of every test, a Next server's page
|
|
1583
|
+
// thousands. Anything else -- no test, no phase, a buffered attempt, a
|
|
1584
|
+
// snapshot-kept run, an attempt file's first line -- goes through
|
|
1585
|
+
// appendServer.
|
|
1586
|
+
function scopedRecordTarget(phaseId) {
|
|
1587
|
+
if (!phaseId || state.runtimeSnapshots)
|
|
1588
|
+
return void 0;
|
|
1589
|
+
const scope = currentRequestContext().scope;
|
|
1590
|
+
if (scope === void 0 || !scope.runId || !getFs())
|
|
1591
|
+
return void 0;
|
|
1592
|
+
if (state.bufferedAttempts.size !== 0 && state.bufferedAttempts.has(cachedAttemptKey(scope)))
|
|
1593
|
+
return void 0;
|
|
1594
|
+
const location = scopedEvidenceLocation(scope);
|
|
1595
|
+
return scopedPathsWritten.has(location.path) ? { scope, location } : void 0;
|
|
1596
|
+
}
|
|
1597
|
+
function enqueueScopedLine(target, line) {
|
|
1598
|
+
try {
|
|
1599
|
+
enqueueServerAppend(target.location.directory, target.location.path, line, target.scope.runId);
|
|
1600
|
+
} catch (cause) {
|
|
1601
|
+
if (cause instanceof Error && cause.code === "SUPERCOV_EVIDENCE_TRANSPORT_FAILED")
|
|
1602
|
+
throw cause;
|
|
1603
|
+
throw serverTransportError(target.scope.runId, cause);
|
|
1604
|
+
}
|
|
1605
|
+
}
|
|
1606
|
+
// A first hit, written as appendServer writes `{ type: "hit", id, timestampMs,
|
|
1607
|
+
// phaseId }`: the same line, byte for byte.
|
|
1608
|
+
function appendServerHit(id, timestampMs, phaseId) {
|
|
1609
|
+
const target = scopedRecordTarget(phaseId);
|
|
1610
|
+
if (target === void 0) {
|
|
1611
|
+
appendServer(phaseId ? { type: "hit", id, timestampMs, phaseId } : { type: "hit", id, timestampMs });
|
|
1612
|
+
return;
|
|
1613
|
+
}
|
|
1614
|
+
const ids = persistedHitsOf(persistedOf(target.scope), phaseId);
|
|
1615
|
+
if (builtinSetHas.call(ids, id))
|
|
1616
|
+
return;
|
|
1617
|
+
enqueueScopedLine(target, `{"type":"hit","id":${JSON.stringify(id)},"timestampMs":${JSON.stringify(timestampMs)},"phaseId":${JSON.stringify(phaseId)}}\n`);
|
|
1618
|
+
builtinSetAdd.call(ids, id);
|
|
1619
|
+
}
|
|
1620
|
+
// A decision's vector, as appendServer writes it: the record's own keys, in
|
|
1621
|
+
// their order.
|
|
1622
|
+
function appendServerDecision(record) {
|
|
1623
|
+
const target = scopedRecordTarget(record.phaseId);
|
|
1624
|
+
if (target === void 0) {
|
|
1625
|
+
appendServer(record);
|
|
1626
|
+
return;
|
|
1627
|
+
}
|
|
1628
|
+
const other = persistedOf(target.scope).other;
|
|
1629
|
+
const key = serverRecordKey(record);
|
|
1630
|
+
if (builtinSetHas.call(other, key))
|
|
1631
|
+
return;
|
|
1632
|
+
enqueueScopedLine(target, `${JSON.stringify(record)}\n`);
|
|
1633
|
+
builtinSetAdd.call(other, key);
|
|
1634
|
+
}
|
|
1460
1635
|
function appendServer(record) {
|
|
1461
1636
|
var _a8, _b, _c, _d;
|
|
1462
1637
|
if (state.runtimeSnapshots) {
|
|
@@ -1499,16 +1674,17 @@ function appendServer(record) {
|
|
|
1499
1674
|
state.serverBuffers.set(key, buffered);
|
|
1500
1675
|
return;
|
|
1501
1676
|
}
|
|
1502
|
-
const
|
|
1503
|
-
|
|
1677
|
+
const persisted = scope && serialized.phaseId ? persistedRecordsOf(scope, serialized) : void 0;
|
|
1678
|
+
const recordKey = persisted !== void 0 ? persistedKey(serialized) : void 0;
|
|
1679
|
+
if (persisted !== void 0 && builtinSetHas.call(persisted, recordKey))
|
|
1504
1680
|
return;
|
|
1505
1681
|
if (!path) {
|
|
1506
1682
|
appendDurableBackgroundRecord(fs, runId, serialized);
|
|
1507
1683
|
return;
|
|
1508
1684
|
}
|
|
1509
1685
|
enqueueServerAppend(directory, path, serverLine(serialized, path) + "\n", runId);
|
|
1510
|
-
if (
|
|
1511
|
-
|
|
1686
|
+
if (persisted !== void 0)
|
|
1687
|
+
builtinSetAdd.call(persisted, recordKey);
|
|
1512
1688
|
} catch (cause) {
|
|
1513
1689
|
if (cause instanceof Error && cause.code === "SUPERCOV_EVIDENCE_TRANSPORT_FAILED")
|
|
1514
1690
|
throw cause;
|
|
@@ -2337,7 +2513,7 @@ function recordCoverageHit(id) {
|
|
|
2337
2513
|
// record: an object built per first hit only to be read once.
|
|
2338
2514
|
recordBrowserEvent("hit", id, void 0, timestampMs, phaseId, "server");
|
|
2339
2515
|
} else {
|
|
2340
|
-
|
|
2516
|
+
appendServerHit(id, timestampMs, phaseId);
|
|
2341
2517
|
}
|
|
2342
2518
|
}
|
|
2343
2519
|
// A first hit's event, built as one literal in the order the spread helpers
|
|
@@ -2427,6 +2603,21 @@ function registerProbeV2(definition) {
|
|
|
2427
2603
|
if (hitEpochs[index] !== clock.e)
|
|
2428
2604
|
recordCoverageHitV2(file, index);
|
|
2429
2605
|
};
|
|
2606
|
+
// What a decision's outcome calls: this file's end, by decision alone, with
|
|
2607
|
+
// its vector and the outcome, which a false one leaves out (`end(3, 1)`,
|
|
2608
|
+
// `end(3, 2, 1)`). It records what mcdcEndV2(file, ...) does, and makes the
|
|
2609
|
+
// same check first, so the call stays as small as the probe.
|
|
2610
|
+
const decisionEpochs = file.decisionEpochs;
|
|
2611
|
+
file.end = (decisionIndex, encoded, outcome) => {
|
|
2612
|
+
if (encoded === 0)
|
|
2613
|
+
return;
|
|
2614
|
+
if (clock.fast) {
|
|
2615
|
+
const seen = decisionEpochs[decisionIndex];
|
|
2616
|
+
if (seen !== void 0 && seen.size === void 0 && seen[encoded * 2 + (outcome ? 1 : 0)] === clock.e)
|
|
2617
|
+
return;
|
|
2618
|
+
}
|
|
2619
|
+
recordMcdcEndV2(file, decisionIndex, encoded, outcome);
|
|
2620
|
+
};
|
|
2430
2621
|
if (isBrowser) {
|
|
2431
2622
|
state.probeV2Clock.fast = true;
|
|
2432
2623
|
activateProbeV2Key(`browser\0${(_a8 = runtimeGlobal.__SUPERCOV_MCDC_TEST_ID__) != null ? _a8 : testId}\0${(_b = runtimeGlobal.__SUPERCOV_PHASE_ID__) != null ? _b : "unscoped"}`);
|
|
@@ -3647,7 +3838,7 @@ function mcdcEnd(frame, value) {
|
|
|
3647
3838
|
} else if (state.runtimeSnapshots) {
|
|
3648
3839
|
recordBrowserEvent("decision", decision.id, vector, timestampMs, phaseId, "server");
|
|
3649
3840
|
} else {
|
|
3650
|
-
|
|
3841
|
+
appendServerDecision(phaseId ? { type: "decision", id: decision.id, vector, timestampMs, phaseId } : { type: "decision", id: decision.id, vector, timestampMs });
|
|
3651
3842
|
}
|
|
3652
3843
|
return value;
|
|
3653
3844
|
}
|
|
@@ -121,6 +121,35 @@ export function expandSnapshot(value) {
|
|
|
121
121
|
snapshot[key] = key === "events" ? events : key === "hits" ? hits.map((index) => strings[index]) : rest[key];
|
|
122
122
|
return snapshot;
|
|
123
123
|
}
|
|
124
|
+
/**
|
|
125
|
+
* A snapshot read as columns (runtime.mjs, coverageSnapshotColumns) with its
|
|
126
|
+
* events as objects again, each as the runtime built it (hitEvent,
|
|
127
|
+
* decisionEvent): what mergeSnapshots reads. columnarEvents gives the columns
|
|
128
|
+
* back. Anything else is returned as it is.
|
|
129
|
+
*/
|
|
130
|
+
export function eventsOfColumns(snapshot) {
|
|
131
|
+
const columns = snapshot?.eventColumns;
|
|
132
|
+
if (!columns || typeof columns !== "object")
|
|
133
|
+
return snapshot;
|
|
134
|
+
const { eventColumns: _columns, ...rest } = snapshot;
|
|
135
|
+
const events = [];
|
|
136
|
+
let timestampMs = 0;
|
|
137
|
+
for (let position = 0; position < columns.id.length; position += 1) {
|
|
138
|
+
const raw = columns.id[position];
|
|
139
|
+
const id = typeof raw === "number" ? rest.hits[raw] : raw;
|
|
140
|
+
const type = columns.types[columns.type[position]];
|
|
141
|
+
const phase = columns.phase[position];
|
|
142
|
+
const environment = columns.environments[columns.environment[position]];
|
|
143
|
+
timestampMs += columns.t[position];
|
|
144
|
+
const event = type === "hit" ? { type, id } : { type, id, vector: columns.vector[position] };
|
|
145
|
+
event.timestampMs = timestampMs;
|
|
146
|
+
if (phase !== -1)
|
|
147
|
+
event.phaseId = columns.phases[phase];
|
|
148
|
+
event.environment = environment;
|
|
149
|
+
events.push(event);
|
|
150
|
+
}
|
|
151
|
+
return { ...rest, events };
|
|
152
|
+
}
|
|
124
153
|
/**
|
|
125
154
|
* A snapshot's events as columns: each event's type, phase and environment
|
|
126
155
|
* as an index into a table of the distinct ones, its time as the difference
|
|
@@ -168,3 +197,26 @@ export function columnarEvents(snapshot) {
|
|
|
168
197
|
},
|
|
169
198
|
};
|
|
170
199
|
}
|
|
200
|
+
/**
|
|
201
|
+
* The text each snapshot was read as, where it is the snapshot's own
|
|
202
|
+
* JSON.stringify: a page's runtime writes it so (runtime.mjs,
|
|
203
|
+
* `__SUPERCOV_COLUMNS_SNAPSHOT__`), and parsing JSON that JSON.stringify
|
|
204
|
+
* wrote and writing it again gives the same text. A test's record holds its
|
|
205
|
+
* pages' snapshots, hundreds of kilobytes on a large frontend, and writing
|
|
206
|
+
* them again was most of what writing the record cost.
|
|
207
|
+
*/
|
|
208
|
+
const snapshotTexts = new WeakMap();
|
|
209
|
+
/** Keep `text`, the JSON.stringify of `snapshot` its page wrote, for `recordLine`. */
|
|
210
|
+
export function keepSnapshotText(snapshot, text) {
|
|
211
|
+
snapshotTexts.set(snapshot, text);
|
|
212
|
+
}
|
|
213
|
+
const RECORD_SNAPSHOTS = "\u0000supercov-snapshots\u0000";
|
|
214
|
+
/** `JSON.stringify(record)`, with its `browser` snapshots' kept texts. */
|
|
215
|
+
export function recordLine(record) {
|
|
216
|
+
const snapshots = record.browser;
|
|
217
|
+
const text = JSON.stringify({ ...record, browser: RECORD_SNAPSHOTS });
|
|
218
|
+
const placeholder = `"browser":${JSON.stringify(RECORD_SNAPSHOTS)}`;
|
|
219
|
+
const at = text.indexOf(placeholder);
|
|
220
|
+
const written = `[${snapshots.map((snapshot) => snapshotTexts.get(snapshot) ?? JSON.stringify(snapshot) ?? "null").join(",")}]`;
|
|
221
|
+
return `${text.slice(0, at)}"browser":${written}${text.slice(at + placeholder.length)}`;
|
|
222
|
+
}
|
|
@@ -20,15 +20,17 @@
|
|
|
20
20
|
// whose parent was not chosen) runs whole from then on. A kill by a job that
|
|
21
21
|
// ran other tests than its baseline did is confirmed by running the job's
|
|
22
22
|
// tests again without the mutant. A job past 3x its baseline and 10 s is
|
|
23
|
-
// stopped: a timeout, unless a test had already failed. A
|
|
24
|
-
//
|
|
25
|
-
//
|
|
26
|
-
//
|
|
27
|
-
//
|
|
23
|
+
// stopped: a timeout, unless a test had already failed. A stopped job may
|
|
24
|
+
// only have waited: on the jobs beside it (the CPU; Cargo's lock on a build
|
|
25
|
+
// directory, where each job builds Rust compiled to wasm), or on a machine
|
|
26
|
+
// busier than when its baseline ran (other work on it, beyond the pass's
|
|
27
|
+
// own). So it runs again alone, after its tests ran alone without the
|
|
28
|
+
// mutant, and its limit there is 3x the slower of that run and its
|
|
29
|
+
// baseline, and 10 s: only a job past that is a timeout.
|
|
28
30
|
import { fork, spawn } from "node:child_process";
|
|
29
31
|
import { appendFileSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
|
|
30
32
|
import { availableParallelism, constants, cpus } from "node:os";
|
|
31
|
-
import { basename, delimiter, join, resolve } from "node:path";
|
|
33
|
+
import { basename, delimiter, dirname, join, resolve } from "node:path";
|
|
32
34
|
import { fileURLToPath } from "node:url";
|
|
33
35
|
|
|
34
36
|
// A file whose baseline job took at most this long, the start of the command
|
|
@@ -386,7 +388,15 @@ function stop(child) {
|
|
|
386
388
|
|
|
387
389
|
export async function drive({ command, plan, resultsPath, root = process.cwd(), workers = parallelism(), environment = process.env, graceMs = 10_000, baselineGraceMs = 60_000 }) {
|
|
388
390
|
const started = Date.now();
|
|
389
|
-
|
|
391
|
+
// Once the pass is told to stop (`stopped-at` beside the results), its
|
|
392
|
+
// jobs are stopped under their tests: one that ends then says nothing of
|
|
393
|
+
// its mutant, and no verdict is written (vitestStrongReporter.mjs).
|
|
394
|
+
const stopping = join(dirname(resultsPath), "stopped-at");
|
|
395
|
+
const write = (record) => {
|
|
396
|
+
if (record.status !== undefined && existsSync(stopping))
|
|
397
|
+
return;
|
|
398
|
+
appendFileSync(resultsPath, `${JSON.stringify(record)}\n`);
|
|
399
|
+
};
|
|
390
400
|
const work = `${resultsPath}.jobs`;
|
|
391
401
|
mkdirSync(work, { recursive: true });
|
|
392
402
|
const tests = plan.tests;
|
|
@@ -685,11 +695,16 @@ export async function drive({ command, plan, resultsPath, root = process.cwd(),
|
|
|
685
695
|
const bail = !whole || [...baseline.statuses.values()].every((status) => status === "passed");
|
|
686
696
|
let result = await job({ mutant, file: group.file, tests: chosen, bail, limitMs, priority });
|
|
687
697
|
const killerIn = (outcome) => [...outcome.statuses].find(([id, status]) => status === "failed" && (chosen === null || chosen.has(id)) && !excluded(id))?.[0];
|
|
688
|
-
// Past its limit
|
|
689
|
-
//
|
|
690
|
-
|
|
698
|
+
// Past its limit with nothing failed: it may only have waited, on
|
|
699
|
+
// the jobs beside it or on a machine busier than when its
|
|
700
|
+
// baseline ran. It runs again alone, its limit from the same
|
|
701
|
+
// tests without the mutant run alone just before it, at the
|
|
702
|
+
// machine's speed now.
|
|
703
|
+
if (result.timedOut && !result.mutantTimedOut && killerIn(result) === undefined) {
|
|
691
704
|
profile.alone += 1;
|
|
692
|
-
|
|
705
|
+
const now = await job({ mutant: null, file: group.file, tests: chosen, bail: false, limitMs: baselineLimit(group.file, chosen), alone: true });
|
|
706
|
+
const slowest = Math.max(baseline.durationMs, now.durationMs);
|
|
707
|
+
result = await job({ mutant, file: group.file, tests: chosen, bail, limitMs: 3 * slowest + graceMs, alone: true });
|
|
693
708
|
}
|
|
694
709
|
const ran = [...result.statuses].filter(([id, status]) => status !== "skipped" && (chosen === null || chosen.has(id)));
|
|
695
710
|
const killer = killerIn(result);
|
|
@@ -21,7 +21,7 @@ import { syncBuiltinESMExports } from "node:module";
|
|
|
21
21
|
import { PassThrough } from "node:stream";
|
|
22
22
|
import { fileURLToPath } from "node:url";
|
|
23
23
|
import { availableParallelism } from "node:os";
|
|
24
|
-
import { relative, sep } from "node:path";
|
|
24
|
+
import { dirname, join, relative, sep } from "node:path";
|
|
25
25
|
|
|
26
26
|
// A mutant's test, and its copy, get twice StrykerJS's limit: 1.5× the
|
|
27
27
|
// measured time and 5 s, doubled.
|
|
@@ -719,7 +719,18 @@ async function drive(vitest, runFiles, specs, plan, resultsPath) {
|
|
|
719
719
|
// Vitest 2 and later pass specifications; Vitest 1, [project, file].
|
|
720
720
|
const fileOf = (spec) => spec.moduleId ?? (Array.isArray(spec) ? spec[1] : spec);
|
|
721
721
|
const specOf = new Map(specs.map((spec) => [toRelative(root, fileOf(spec)), spec]));
|
|
722
|
-
|
|
722
|
+
// Once the pass is told to stop (Supercov notes when, `stopped-at`
|
|
723
|
+
// beside the results, before it signals the command), its copies are
|
|
724
|
+
// stopped under their tests: a copy that ends then says nothing of its
|
|
725
|
+
// mutant, and no verdict is written. The mutant is left for the next
|
|
726
|
+
// pass. One judged from a copy the budget stopped on a macOS runner was a
|
|
727
|
+
// `killed` for a mutant whose test waits five minutes.
|
|
728
|
+
const stopping = join(dirname(resultsPath), "stopped-at");
|
|
729
|
+
const write = (record) => {
|
|
730
|
+
if (record.status !== undefined && existsSync(stopping))
|
|
731
|
+
return;
|
|
732
|
+
appendFileSync(resultsPath, `${JSON.stringify(record)}\n`);
|
|
733
|
+
};
|
|
723
734
|
const tests = plan.tests;
|
|
724
735
|
const started = Date.now();
|
|
725
736
|
const passCpu = machineCpu();
|