supercov 4.29.11 → 4.29.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/docs/cli.md CHANGED
@@ -507,7 +507,10 @@ many more). `mutants` then shows each mutant's verdict beside its weak status,
507
507
  and the mutation score with the verdicts' counts; `mutants --status survived`
508
508
  (or `killed`, `timeout`, `no-coverage`, `error`, `unviable`) lists the mutants
509
509
  with that verdict, and `--format markdown` lists the survivors under the
510
- mutation score.
510
+ mutation score. A Playwright mutant with many candidates that lived through
511
+ its first tier, with the rest of its candidates not run yet, is
512
+ `survived-so-far`: listed by `--status survived` as such (and alone by
513
+ `--status survived-so-far`), counted apart, and not in the score.
511
514
 
512
515
  It runs far less than StrykerJS: no dry run (the measured run is one), no
513
516
  mutant no test infected (decided `survived`) or reached (`no-coverage`), and
@@ -546,7 +549,11 @@ phpunit`). See `docs/design/strong-mutation.md`,
546
549
  run of its own even on an unchanged checkout, so a job never saves into a
547
550
  run it restored, which every job of its round holds a copy of. There it
548
551
  makes that run from the newest restored run whose command passed, without
549
- measuring again, and keeps every verdict the restored runs hold.
552
+ measuring again, and keeps every verdict the restored runs hold. A run whose
553
+ command failed only because tests failed is made into one too, where none
554
+ passed: a failed test is no candidate, and the shard says which it leaves
555
+ out. A run whose command failed otherwise (no test failed, or no exit
556
+ status) is not, and the shard measures, saying what kept that run out.
550
557
  - `--critical <glob>` (repeatable): every mutant there must be killed or
551
558
  accepted, or the command fails.
552
559
  - `--fail-on survived,timeout,no-coverage,error`: fail on any asked mutant with
@@ -1019,7 +1026,9 @@ pass in the run is listed regardless.
1019
1026
  per line, for a runner's filter. A Vitest, Playwright or node:test test inside
1020
1027
  `describe` blocks is printed as the blocks and the test joined by spaces
1021
1028
  (`small charges`), which is what `vitest -t`, `--grep` and
1022
- `--test-name-pattern` match. `--kind`, `--runner`, `--tag`, `--title` and
1029
+ `--test-name-pattern` match. A Rust test is printed as its path in its crate
1030
+ (`tests::it_works`), which `cargo test -- --exact` and nextest's `test(=...)`
1031
+ match. `--kind`, `--runner`, `--tag`, `--title` and
1023
1032
  `--test-file` list only the affected tests they pick: from a run that merged two
1024
1033
  runners' suites, `tests affected --names --runner playwright` gives Playwright
1025
1034
  only its own tests. A helper beside the tests, or source outside what is
@@ -1032,6 +1041,20 @@ A source file
1032
1041
  added since the run is outside every test's record; the working-tree check
1033
1042
  says so, and the suite should run in full.
1034
1043
 
1044
+ A Rust test loads what it names by path: a fixture, a data file or a script
1045
+ named in its own function (or in its entry of a macro that declares a test
1046
+ per entry), or anywhere in its file outside another test, and what a script it
1047
+ names imports and names in turn. A path that goes on in a placeholder
1048
+ (`tests/fixtures/{name}`) names the directory before it. So a change to one
1049
+ fixture affects the tests that name it, and a file no test names, as before,
1050
+ affects every test. A file measured Rust source embeds with `include_str!` or
1051
+ `include_bytes!` is part of the declaration embedding it: a template or a
1052
+ script compiled into the binary affects the tests that ran that code. Changed
1053
+ code no probe of the run measured -- code for another platform, a feature the
1054
+ run's build left off -- is listed under `unmeasured` (`--json`) and named in
1055
+ the text: no test's record says what it reaches, so run the suite in full
1056
+ where that code is compiled.
1057
+
1035
1058
  A server the suite starts is recorded too: a mock server `webServer` starts,
1036
1059
  or the application's own. Each Node process of a Playwright run notes the
1037
1060
  project files it loads and reads, and the tests it serves, by the test a
package/docs/mutation.md CHANGED
@@ -108,8 +108,12 @@ mutants the tests let survive.
108
108
  its own, so that each job's share is saved into a run no other job writes:
109
109
  made from the newest run of the checkout whose command passed, without
110
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)).
111
+ this shard saves its verdicts into run r9, made from it`), or, where none
112
+ passed, from the newest whose command failed only because tests failed,
113
+ which are no candidates (`continuing from run r4, whose command failed: 1
114
+ test failed while measuring and is not a candidate: checkout > pays`), or
115
+ measured where there is none, saying why (see
116
+ [A pass split across jobs](#a-pass-split-across-jobs)).
113
117
  An earlier run measured on the same files, byte for byte, keeps every
114
118
  verdict a pass reached, whatever the two measurements recorded: a test
115
119
  whose path depends on the time, or that failed in one of them, moves no
@@ -152,6 +156,12 @@ mutants the tests let survive.
152
156
  that passed did. The candidates are kept as verdicts are, after an edit, a
153
157
  merge and in a later round: a candidate a change could reach runs again.
154
158
  The Playwright driver records them.
159
+ - **A first tier.** A Playwright mutant with more candidates than its first
160
+ tier holds (32, or more where the run's kills come later) runs against
161
+ that tier first, every such mutant before any runs the rest. One the tier
162
+ lets live is `survived-so-far` until the rest runs, in the same pass where
163
+ it has the time: listed with the survivors as such, never in the score
164
+ (`docs/design/strong-mutation.md`, A first tier, then the rest).
155
165
  - **Exit codes.** `0` with an answer; `1` when `--fail-on` or `--critical`
156
166
  finds a mutant; `2`, after the answer, when the measured command failed (a
157
167
  failing test kills nothing, so the verdicts cannot gate) or no mutant could
@@ -343,8 +353,9 @@ merge ([CLI reference](cli.md#combine-shards)).
343
353
  - **Another round.** On the commit the restored runs measured, each job saves
344
354
  into a run of its own: `supercov mutants --shard` never saves into a run it
345
355
  restored, of which every job of the round holds a copy. It makes that run
346
- from the newest restored run whose command passed and that recorded its
347
- mutants' values, without measuring again: the run holds that run's evidence
356
+ from the newest restored run that recorded its mutants' values and whose
357
+ command passed, or failed only in tests that failed, without measuring
358
+ again: the run holds that run's evidence
348
359
  under an id of its own. It keeps every verdict a pass reached that the
349
360
  restored runs hold (`1317 verdict(s) kept from runs r8, r7, r6, r5: the
350
361
  checkout is unchanged since them`), and the shares are of what is left.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "supercov",
3
- "version": "4.29.11",
3
+ "version": "4.29.13",
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.11",
129
- "@supercov/cli-darwin-x64": "4.29.11",
130
- "@supercov/cli-linux-arm64-gnu": "4.29.11",
131
- "@supercov/cli-linux-arm64-musl": "4.29.11",
132
- "@supercov/cli-linux-x64-gnu": "4.29.11",
133
- "@supercov/cli-linux-x64-musl": "4.29.11",
134
- "@supercov/cli-win32-arm64": "4.29.11",
135
- "@supercov/cli-win32-x64": "4.29.11"
128
+ "@supercov/cli-darwin-arm64": "4.29.13",
129
+ "@supercov/cli-darwin-x64": "4.29.13",
130
+ "@supercov/cli-linux-arm64-gnu": "4.29.13",
131
+ "@supercov/cli-linux-arm64-musl": "4.29.13",
132
+ "@supercov/cli-linux-x64-gnu": "4.29.13",
133
+ "@supercov/cli-linux-x64-musl": "4.29.13",
134
+ "@supercov/cli-win32-arm64": "4.29.13",
135
+ "@supercov/cli-win32-x64": "4.29.13"
136
136
  },
137
137
  "peerDependencies": {
138
138
  "@playwright/test": ">=1.55.0",
@@ -30,10 +30,10 @@
30
30
  // The attempt's mutant goes into its scope, which reaches the app's server
31
31
  // with every request (header, cookies, child processes) and the page through
32
32
  // an init script. A mutant the server must start with (its code ran in work
33
- // no request named, or is a server module's top level, or ran for a request
34
- // that named no test, or its switch is evaluated as a server module loads)
35
- // is run alone afterwards, in an invocation of its own
36
- // with SUPERCOV_ACTIVE_MUTANT set, which the engine starts for each `restart`
33
+ // no request named or waited for, or is a server module's top level, or ran
34
+ // for a request that named no test, or its switch is evaluated as a server
35
+ // module loads) is run alone afterwards, in an invocation of its own with
36
+ // SUPERCOV_ACTIVE_MUTANT set, which the engine starts for each `restart`
37
37
  // record the judge writes (javascript_run.rs). So do a kill (or a timeout)
38
38
  // that ran beside another mutant's attempt or whose control failed (one test
39
39
  // at a time), and the mutants one invocation had no room for.
@@ -1497,7 +1497,7 @@ function surviveIfDone(pass, id) {
1497
1497
  }
1498
1498
 
1499
1499
  export const WHY = {
1500
- "background": "its code ran in server work no request named",
1500
+ "background": "its code ran in server work no request was waiting for",
1501
1501
  "module-level": "it is a server module's top-level code",
1502
1502
  "by-time": "its code ran for a request that named no test",
1503
1503
  "unfinished": "not every candidate test ran in the shared pass",
@@ -322,6 +322,37 @@ var _a6;
322
322
  var serverPhaseStorage = (_a6 = serverPhaseStorages.get(runtimeInstance)) != null ? _a6 : createServerPhaseStorage();
323
323
  if (serverPhaseStorage)
324
324
  serverPhaseStorages.set(runtimeInstance, serverPhaseStorage);
325
+ // A request's work, until its response has finished: what an attempt's
326
+ // request set off and left running after it was answered -- a promise no one
327
+ // awaits, a poller a first request started that later requests' work runs
328
+ // in -- keeps the request's context, and ran as that test's long after the
329
+ // test, or any request of it, waited for it. Such work is no test's: it is
330
+ // recorded as work no request named, and a strong pass switches no
331
+ // request's mutant on there, so it runs with the server started with it
332
+ // (docs/design/strong-mutation.md). A context carries its request's
333
+ // lifetime under this key, which spreads copy and JSON leaves out.
334
+ var REQUEST_LIFETIME = Symbol.for("supercov.requestLifetime");
335
+ function answered(context) {
336
+ const lifetime = context[REQUEST_LIFETIME];
337
+ return lifetime !== void 0 && lifetime.answered;
338
+ }
339
+ // The request's lifetime, made by whichever copy of the runtime sees the
340
+ // request first. It ends once the response has finished (or its connection
341
+ // closed) and the listeners of that event have run: what they start goes
342
+ // on after it, and is no longer the request's.
343
+ function requestLifetime(request, response) {
344
+ let lifetime = request[REQUEST_LIFETIME];
345
+ if (lifetime !== void 0)
346
+ return lifetime;
347
+ lifetime = { answered: false };
348
+ Object.defineProperty(request, REQUEST_LIFETIME, { __proto__: null, value: lifetime, configurable: true });
349
+ const answer = () => queueMicrotask(() => {
350
+ lifetime.answered = true;
351
+ });
352
+ for (const event of ["finish", "close"])
353
+ response.once(event, answer);
354
+ return lifetime;
355
+ }
325
356
  function probeV2ContextKey(context) {
326
357
  var _a8, _b;
327
358
  const phase = (_a8 = context.phaseId) != null ? _a8 : "unscoped";
@@ -366,13 +397,18 @@ function activateProbeV2Key(key, force = false) {
366
397
  // The async hook activates the current request's context before every
367
398
  // callback the server runs, and building its key and looking it up was most of
368
399
  // a Next server's time in the hook. A request's context object is never
369
- // changed once made, and its key is made of it alone, so each keeps the epoch
370
- // it was given until the epochs are cleared.
400
+ // changed once made but for its request's lifetime, and its key is made of it
401
+ // alone, so each keeps the epoch it was given until the epochs are cleared or
402
+ // its request is answered.
371
403
  // Every copy of the runtime in a process shares one state, and the hook is the
372
404
  // first copy's, so the cache and its generation live on that state too: a
373
405
  // reset from another copy has to reach them.
374
406
  var emptyProbeV2Context = Object.freeze({});
375
407
  function activateProbeV2Context(context) {
408
+ // What a request left running after its answer is no request's: only its
409
+ // lifetime changes once the context is made, and is looked at first.
410
+ if (answered(context))
411
+ context = emptyProbeV2Context;
376
412
  // Work no request owns is keyed by the test running when it runs, which
377
413
  // changes under the same context: only a request's context keeps its epoch.
378
414
  if (!context.scope)
@@ -1449,7 +1485,7 @@ function appendServer(record) {
1449
1485
  // Work done while handling a request that named no test -- a webhook a
1450
1486
  // mock server sends -- says so, with the request's number.
1451
1487
  const stored = serverPhaseStorage == null ? void 0 : serverPhaseStorage.getStore();
1452
- const unscopedRequest = !scope && stored && stored.request ? { request: stored.request } : {};
1488
+ const unscopedRequest = !scope && stored && stored.request && !answered(stored) ? { request: stored.request } : {};
1453
1489
  const serialized = __spreadValues(__spreadValues(__spreadValues({}, record), scope ? { scope } : {}), unscopedRequest);
1454
1490
  if (scope && state.bufferedAttempts.has(attemptKey(scope))) {
1455
1491
  const key = attemptKey(scope);
@@ -1500,7 +1536,7 @@ function environmentRequestContext() {
1500
1536
  function currentRequestContext() {
1501
1537
  const stored = serverPhaseStorage == null ? void 0 : serverPhaseStorage.getStore();
1502
1538
  if (stored !== void 0) {
1503
- if (stored.scope || stored.phaseId)
1539
+ if ((stored.scope || stored.phaseId) && !answered(stored))
1504
1540
  return stored;
1505
1541
  return runtimeGlobal.__SUPERCOV_ACTIVE_SCOPE__ ? { scope: runtimeGlobal.__SUPERCOV_ACTIVE_SCOPE__ } : {};
1506
1542
  }
@@ -1519,15 +1555,15 @@ function activateCoverageScope(scope) {
1519
1555
  }
1520
1556
  function coverageCarrier() {
1521
1557
  const context = currentRequestContext();
1522
- return __spreadValues(__spreadValues({
1558
+ return __spreadValues(__spreadValues(__spreadValues({
1523
1559
  version: 1
1524
- }, context.scope ? { scope: context.scope } : {}), context.phaseId ? { phaseId: context.phaseId } : {});
1560
+ }, context.scope ? { scope: context.scope } : {}), context.phaseId ? { phaseId: context.phaseId } : {}), context[REQUEST_LIFETIME] ? { [REQUEST_LIFETIME]: context[REQUEST_LIFETIME] } : {});
1525
1561
  }
1526
1562
  function withCoverageCarrier(carrier, callback) {
1527
1563
  const decoded = typeof carrier === "string" ? decodeCoverageCarrier(carrier) : carrier;
1528
1564
  if (!serverPhaseStorage || !decoded)
1529
1565
  return callback();
1530
- const context = __spreadValues(__spreadValues({}, decoded.scope ? { scope: decoded.scope } : {}), decoded.phaseId ? { phaseId: decoded.phaseId } : {});
1566
+ const context = __spreadValues(__spreadValues(__spreadValues({}, decoded.scope ? { scope: decoded.scope } : {}), decoded.phaseId ? { phaseId: decoded.phaseId } : {}), decoded[REQUEST_LIFETIME] ? { [REQUEST_LIFETIME]: decoded[REQUEST_LIFETIME] } : {});
1531
1567
  return serverPhaseStorage.run(context, () => withProbeV2Context(context, callback));
1532
1568
  }
1533
1569
  function assertionPhaseState(scope) {
@@ -2129,6 +2165,9 @@ function installNodeRequestPropagation() {
2129
2165
  // the report credits its work to the test running when it came.
2130
2166
  if (incoming && serverPhaseStorage && !(context && (context.scope || context.phaseId)))
2131
2167
  context = { request: nextUnscopedRequest() };
2168
+ // Until its response has finished.
2169
+ if (incoming && context && request && typeof request === "object" && response && typeof response.once === "function")
2170
+ context = __spreadValues(__spreadValues({}, context), { [REQUEST_LIFETIME]: requestLifetime(request, response) });
2132
2171
  // Node emits a request's body and its response's events outside the
2133
2172
  // handler's context, so a handler that reads the body -- `req.on('end')`
2134
2173
  // -- ran as no test's. The request and response carry it with them.
@@ -2188,6 +2227,9 @@ function withRequestPhase(handler, event) {
2188
2227
  const context = __spreadValues(__spreadValues({}, ((_a8 = requestContext == null ? void 0 : requestContext.scope) != null ? _a8 : inheritedContext.scope) ? { scope: (_b = requestContext == null ? void 0 : requestContext.scope) != null ? _b : inheritedContext.scope } : {}), ((_c = requestContext == null ? void 0 : requestContext.phaseId) != null ? _c : inheritedContext.phaseId) ? { phaseId: (_d = requestContext == null ? void 0 : requestContext.phaseId) != null ? _d : inheritedContext.phaseId } : {});
2189
2228
  if (requestContext !== void 0 && !context.scope)
2190
2229
  context.request = nextUnscopedRequest();
2230
+ const lifetime = requestContext !== void 0 ? args.map((argument) => argument && typeof argument === "object" ? argument[REQUEST_LIFETIME] : void 0).find((found) => found !== void 0) : void 0;
2231
+ if (lifetime !== void 0)
2232
+ context[REQUEST_LIFETIME] = lifetime;
2191
2233
  const invoke = () => {
2192
2234
  if (event === "connection" && context.scope && args[0] &&
2193
2235
  typeof args[0] === "object" && typeof args[0].emit === "function")