supercov 4.29.4 → 4.29.5

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
@@ -559,6 +559,10 @@ phpunit`). See `docs/design/strong-mutation.md`,
559
559
  - `--budget <seconds>` stops the pass once it is spent: it ends as a finished
560
560
  pass, its verdicts saved, and says how many mutants it left for the next.
561
561
  The cheapest mutants run first, by their tests' recorded times.
562
+ - `--timeout-factor <x>`: a Playwright test that runs with a mutant is
563
+ stopped past x times its baseline + 5 s (default 1.5, StrykerJS's), and the
564
+ mutant is a `timeout`. `SUPERCOV_STRONG_TIMEOUT_FACTOR` sets it where the
565
+ option is not given.
562
566
  - After an edit, `supercov mutants` measures the checkout again and keeps an
563
567
  earlier run's verdict for each mutant whose file is as it was and whose
564
568
  candidate tests, and their test files, nothing changed could reach (as
@@ -1316,6 +1320,7 @@ terminal or offline environment after the package has been downloaded.
1316
1320
  | `SUPERCOV_KEEP_WORKSPACE` | Set to `1` to leave the instrumented copy of the project in `.supercov/workspaces/` after the run, to inspect what the command ran |
1317
1321
  | `SUPERCOV_MUTANTS` | Set to `1` to measure a run with the probes that record the values its mutants' verdicts read, and list its mutants as it runs (see [Mutants](#mutants)); a plain run lists none and places no probe |
1318
1322
  | `SUPERCOV_STRONG_WORKERS` | How many test processes a JavaScript or Python strong pass runs at once (default: about one per CPU) |
1323
+ | `SUPERCOV_STRONG_TIMEOUT_FACTOR` | A Playwright strong pass's time limit for a test run with a mutant: this many times the test's baseline, + 5 s (default `1.5`; `--timeout-factor` overrides it) |
1319
1324
  | `SUPERCOV_COMMAND_TIMEOUT_MS` | Stop the test command after this many milliseconds: what is still running is asked to stop, then made to five seconds later, what ran is recorded, and Supercov exits `124`. No deadline by default |
1320
1325
 
1321
1326
  Examples:
package/docs/mutation.md CHANGED
@@ -224,6 +224,10 @@ npx supercov runs latest mutants test --plan --json
224
224
  [A pass split across jobs](#a-pass-split-across-jobs)).
225
225
  - `--budget <seconds>` stops the pass once that time is spent, its verdicts
226
226
  saved, and leaves the rest for the next pass.
227
+ - `--timeout-factor <x>` (or `SUPERCOV_STRONG_TIMEOUT_FACTOR`) sets a
228
+ Playwright test's time limit when it runs with a mutant: x times its
229
+ baseline, + 5 s (default 1.5, StrykerJS's `timeoutFactor`). See
230
+ [Playwright](#javascript-and-typescript).
227
231
  - `--plan` prints what would run, and runs nothing.
228
232
 
229
233
  Some mutants no test can tell apart from the original. Accept them in
@@ -368,6 +372,16 @@ no mutants shows none of this.
368
372
  serves different mutants to different workers. A mutant of a server's
369
373
  start-up runs with the server started again for it. StrykerJS has no
370
374
  Playwright runner, so Playwright's verdicts are checked by hand (see below).
375
+ A test run with a mutant gets StrykerJS's time limit: its baseline (the
376
+ longest of its measured run and its runs without a mutant in the pass)
377
+ × 1.5 + 5 s, or its own timeout where that is shorter. Playwright's test
378
+ timeout is set to it, and a `test.setTimeout()` or `test.slow()` in the
379
+ test may shorten it but not lengthen it, so a click or an `expect` that
380
+ waits for an element the mutant broke ends there, not at its own 30 s. A
381
+ test that runs out of its limit makes its mutant a `timeout`, which counts
382
+ as detected; the summary says how many, and against what limit.
383
+ `--timeout-factor <x>` (or `SUPERCOV_STRONG_TIMEOUT_FACTOR`) changes the
384
+ 1.5: a suite whose tests' times vary widely between runs may want 2 or 3.
371
385
  - **Jest and Mocha** run in resident runners, as StrykerJS's do; `node:test`,
372
386
  AVA, node-tap, `bun:test` and Vitest Browser Mode run one test file per
373
387
  start of the command, with the mutant on from its start.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "supercov",
3
- "version": "4.29.4",
3
+ "version": "4.29.5",
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.4",
129
- "@supercov/cli-darwin-x64": "4.29.4",
130
- "@supercov/cli-linux-arm64-gnu": "4.29.4",
131
- "@supercov/cli-linux-arm64-musl": "4.29.4",
132
- "@supercov/cli-linux-x64-gnu": "4.29.4",
133
- "@supercov/cli-linux-x64-musl": "4.29.4",
134
- "@supercov/cli-win32-arm64": "4.29.4",
135
- "@supercov/cli-win32-x64": "4.29.4"
128
+ "@supercov/cli-darwin-arm64": "4.29.5",
129
+ "@supercov/cli-darwin-x64": "4.29.5",
130
+ "@supercov/cli-linux-arm64-gnu": "4.29.5",
131
+ "@supercov/cli-linux-arm64-musl": "4.29.5",
132
+ "@supercov/cli-linux-x64-gnu": "4.29.5",
133
+ "@supercov/cli-linux-x64-musl": "4.29.5",
134
+ "@supercov/cli-win32-arm64": "4.29.5",
135
+ "@supercov/cli-win32-x64": "4.29.5"
136
136
  },
137
137
  "peerDependencies": {
138
138
  "@playwright/test": ">=1.55.0",
@@ -22,10 +22,17 @@
22
22
  // no request named, or is a server module's top level, or ran for a request
23
23
  // that named no test) is run alone afterwards, in an invocation of its own
24
24
  // with SUPERCOV_ACTIVE_MUTANT set, which the engine starts for each `restart`
25
- // record the judge writes (javascript_run.rs). So do a test that only ran
26
- // out of time (again, with twice the time), a kill that ran beside another
27
- // mutant's attempt or whose control failed (one test at a time), and the
28
- // mutants one invocation had no room for.
25
+ // record the judge writes (javascript_run.rs). So do a kill (or a timeout)
26
+ // that ran beside another mutant's attempt or whose control failed (one test
27
+ // at a time), and the mutants one invocation had no room for.
28
+ //
29
+ // An attempt with a mutant has a time limit: its test's baseline (the
30
+ // longest of its measured run and every control of this pass that passed) ×
31
+ // the pass's timeout factor (1.5, `--timeout-factor`) + 5 s, StrykerJS's
32
+ // limit, or the test's own timeout where that is shorter. Playwright's test
33
+ // timeout is set to it, so an action or an `expect` that waits for what the
34
+ // mutant broke ends there; an attempt that ran out of it is a `timeout`,
35
+ // confirmed as a kill is.
29
36
  //
30
37
  // This module holds what the config, the fixture (playwright.mjs) and the
31
38
  // reporter (playwrightStrongReporter.mjs) share.
@@ -135,9 +142,30 @@ export function mark(path) {
135
142
  }
136
143
  }
137
144
 
138
- function budgetOf(durations, factor = 1) {
139
- const longest = Math.max(DEFAULT_DURATION_MS, ...durations.map((ms) => ms ?? DEFAULT_DURATION_MS));
140
- return Math.ceil((longest * TIMEOUT_FACTOR + TIMEOUT_CONSTANT_MS) * factor);
145
+ /**
146
+ * How long a test takes without a mutant: the longest of its measured run
147
+ * and every control of it that passed in this pass, in any worker or round
148
+ * (a test whose time varies is given its slowest), and a second at least.
149
+ */
150
+ function baselineMsOf(pass, original, test) {
151
+ let longest = Math.max(DEFAULT_DURATION_MS, test.durationMs ?? 0);
152
+ for (const name of entries(`${pass.shared}/durations/${key(original)}`))
153
+ longest = Math.max(longest, Number(name.split("-")[1]) || 0);
154
+ return longest;
155
+ }
156
+
157
+ /** A mutant attempt's time limit from its test's baseline: StrykerJS's `timeoutMS`. */
158
+ function limitOf(baselineMs, factor) {
159
+ return Math.ceil(baselineMs * factor + TIMEOUT_CONSTANT_MS);
160
+ }
161
+
162
+ /** What a verdict says of an attempt that ran out of its time limit. */
163
+ function limitReason(attempt) {
164
+ const seconds = (ms) => `${(ms / 1000).toFixed(1)} s`;
165
+ const why = attempt.limitMs < limitOf(attempt.baselineMs, attempt.timeoutFactor)
166
+ ? "the test's own timeout"
167
+ : `${attempt.timeoutFactor} × its ${seconds(attempt.baselineMs)} baseline + ${TIMEOUT_CONSTANT_MS / 1000} s`;
168
+ return `ran past its time limit of ${seconds(attempt.limitMs)} (${why})`;
141
169
  }
142
170
 
143
171
  /**
@@ -249,7 +277,7 @@ function buildPass(pass, root, config) {
249
277
  if (job && job.kind !== "main") {
250
278
  for (const entry of job.mutants) {
251
279
  const all = [...entry.tests, ...(entry.rest ?? [])].filter((id) => tests[id]);
252
- mutants.push({ id: entry.id, mutant: entry.mutant, tests: [...new Set(all)], reason: entry.reason, budgetFactor: entry.budgetFactor ?? 1 });
280
+ mutants.push({ id: entry.id, mutant: entry.mutant, tests: [...new Set(all)], reason: entry.reason });
253
281
  }
254
282
  // A serial round runs one test at a time: what it kills, nothing
255
283
  // beside it did.
@@ -306,10 +334,10 @@ function buildPass(pass, root, config) {
306
334
  const ordered = [...new Set([...own.filter((test) => test.infected), ...own.filter((test) => !test.infected)].map((test) => test.id))];
307
335
  const switched = `${mutant.file}#${found.index}`;
308
336
  if (mutant.serverWide) {
309
- restarts.push({ id: mutant.id, mutant: switched, tests: ordered, reason: mutant.serverWide, budgetFactor: 1 });
337
+ restarts.push({ id: mutant.id, mutant: switched, tests: ordered, reason: mutant.serverWide });
310
338
  continue;
311
339
  }
312
- mutants.push({ id: mutant.id, mutant: switched, tests: ordered, budgetFactor: 1 });
340
+ mutants.push({ id: mutant.id, mutant: switched, tests: ordered });
313
341
  }
314
342
  }
315
343
  // Each test's queue, and the copies the round's mutants need, as many as
@@ -354,6 +382,8 @@ function buildPass(pass, root, config) {
354
382
  batch: kind === "alone" && Boolean(job?.batch),
355
383
  // A main round's first control of a test is its baseline.
356
384
  baselines: kind === "main",
385
+ // A mutant attempt's time limit: its test's baseline × this + 5 s.
386
+ timeoutFactor: Number(plan.timeoutFactor) > 0 ? Number(plan.timeoutFactor) : TIMEOUT_FACTOR,
357
387
  tests,
358
388
  declared,
359
389
  entries,
@@ -394,6 +424,7 @@ function writeRoundFiles(pass, work) {
394
424
  everywhere: work.everywhere,
395
425
  batch: work.batch,
396
426
  baselines: work.baselines,
427
+ timeoutFactor: work.timeoutFactor,
397
428
  tests,
398
429
  declared: work.declared,
399
430
  setupProjects: work.setupProjects,
@@ -669,7 +700,7 @@ const passedHere = new Set();
669
700
  /** Whether a mutant needs no more attempts: a verdict given, killed, or held for a later round. */
670
701
  function settled(pass, id) {
671
702
  const at = key(id);
672
- return existsSync(`${pass.shared}/verdicts/${at}`) || existsSync(`${pass.round}/killed/${at}`) || existsSync(`${pass.round}/held/${at}`);
703
+ return existsSync(`${pass.shared}/verdicts/${at}`) || existsSync(`${pass.round}/killed/${at}`);
673
704
  }
674
705
 
675
706
  /**
@@ -699,7 +730,7 @@ function inFlightSince(pass, id) {
699
730
  * and not yet tried against it, one no other attempt runs first. Taken by
700
731
  * making its mark, which only one copy can.
701
732
  */
702
- function takeJob(pass, test, only, budgetMs) {
733
+ function takeJob(pass, test, only, limitMs) {
703
734
  const queue = queueOf(pass, test);
704
735
  const busy = [];
705
736
  for (let at = queue.done; at < queue.ids.length; at++) {
@@ -715,9 +746,9 @@ function takeJob(pass, test, only, budgetMs) {
715
746
  }
716
747
  const since = inFlightSince(pass, id);
717
748
  if (since !== undefined) {
718
- // One that has run longer than this test would take may hang:
749
+ // One that has run longer than this test's limit may hang:
719
750
  // a second attempt would only wait as long.
720
- if (Date.now() - since < budgetMs)
751
+ if (Date.now() - since < limitMs)
721
752
  busy.push(id);
722
753
  continue;
723
754
  }
@@ -769,10 +800,33 @@ function startRunning(pass, testId, mutant) {
769
800
  return { running: `${running}/${mine}`, beside };
770
801
  }
771
802
 
803
+ /**
804
+ * Holds a mutant attempt to its time limit (`timeout`, from the test's
805
+ * start): the test's own `test.setTimeout()` and `test.slow()` may shorten
806
+ * it, never lengthen it. Its baseline ran with them, so its time already
807
+ * says how long they let it take.
808
+ */
809
+ function holdTimeout(testInfo, timeout) {
810
+ const setTimeout = testInfo.setTimeout.bind(testInfo);
811
+ setTimeout(timeout);
812
+ testInfo.setTimeout = (asked) => setTimeout(asked > 0 ? Math.min(asked, timeout) : timeout);
813
+ // `test.slow()` in a test's body (Playwright's own modifier): it
814
+ // triples the time, which is held to the limit again.
815
+ const modifier = testInfo._modifier;
816
+ if (typeof modifier !== "function")
817
+ return;
818
+ testInfo._modifier = function (type, ...rest) {
819
+ const result = modifier.call(this, type, ...rest);
820
+ if (type === "slow")
821
+ setTimeout(Math.min(this.timeout, timeout));
822
+ return result;
823
+ };
824
+ }
825
+
772
826
  /**
773
827
  * What this copy of a test does: `undefined` outside strong mode, `null` to
774
828
  * skip, else its attempt: a control (no mutant, `-`) or the mutant it took
775
- * (`file#index`), and its time budget. A file whose tests the measured run
829
+ * (`file#index`), and its time limit. A file whose tests the measured run
776
830
  * never ran side by side runs one at a time here too.
777
831
  */
778
832
  export async function strongClaim(testInfo) {
@@ -808,31 +862,26 @@ export async function strongClaim(testInfo) {
808
862
  // A later round's test that failed without any mutant in the main one.
809
863
  if (baselineOf(pass, original) === "failed")
810
864
  return null;
811
- const id = takeJob(pass, original, shape.batch ? invocationMutant(pass) ?? null : undefined, budgetOf([test.durationMs]));
865
+ const baselineMs = baselineMsOf(pass, original, test);
866
+ const derived = limitOf(baselineMs, shape.timeoutFactor);
867
+ // The test's own timeout, where shorter, ends it first anyway.
868
+ const limitMs = configured > 0 ? Math.min(derived, configured) : derived;
869
+ const id = takeJob(pass, original, shape.batch ? invocationMutant(pass) ?? null : undefined, limitMs);
812
870
  if (!id)
813
871
  return null;
814
872
  const entry = mutantOf(pass, id);
815
- attempt = { kind: "mutant", id, mutant: entry.mutant, budgetMs: budgetOf([test.durationMs], entry.budgetFactor ?? 1) };
873
+ attempt = { kind: "mutant", id, mutant: entry.mutant, baselineMs, limitMs, timeoutFactor: shape.timeoutFactor };
816
874
  mark(`${pass.round}/inflight/${key(id)}`);
817
875
  writeFileSync(`${pass.round}/inflight/${key(id)}/${process.pid}-${key(testInfo.testId)}`, String(Date.now()));
818
876
  }
819
877
  const lock = shape.concurrency.workers !== 1 && shape.concurrency.serialFiles.includes(test.file)
820
878
  ? await lockFile(pass, test.file)
821
879
  : undefined;
822
- // The test's time from here: a mutant's from the test's measured
823
- // duration and the time Playwright gives an assertion and an action to
824
- // fail in (a failing `expect` waits for its own timeout), a control's as
825
- // configured.
826
- if (attempt.kind === "mutant") {
827
- const expectTimeout = testInfo.project?.expect?.timeout ?? 5_000;
828
- const actionTimeout = testInfo.project?.use?.actionTimeout ?? 0;
829
- // Playwright itself ends the test at its configured timeout (the
830
- // project's, or its own `test.slow()` / `describe.configure`), and an
831
- // assertion may wait up to there with a timeout of its own: that is
832
- // the floor.
833
- const budget = Math.max(attempt.budgetMs + expectTimeout + actionTimeout, configured > 0 ? configured : 0);
834
- testInfo.setTimeout(Date.now() - started + budget);
835
- }
880
+ // The test's time from here: a mutant's its limit, which ends whatever
881
+ // the test waits on there (an action, an `expect` with a timeout of its
882
+ // own); a control's, the baseline's above all, as configured.
883
+ if (attempt.kind === "mutant")
884
+ holdTimeout(testInfo, Date.now() - started + attempt.limitMs);
836
885
  else if (configured > 0)
837
886
  testInfo.setTimeout(Date.now() - started + configured);
838
887
  const { running, beside } = startRunning(pass, testInfo.testId, attempt.mutant);
@@ -845,6 +894,7 @@ export async function strongClaim(testInfo) {
845
894
  kind: attempt.kind,
846
895
  id: attempt.id,
847
896
  mutant: attempt.mutant,
897
+ ...(attempt.kind === "mutant" ? { baselineMs: attempt.baselineMs, limitMs: attempt.limitMs, timeoutFactor: attempt.timeoutFactor } : {}),
848
898
  startedAt: Date.now(),
849
899
  lock,
850
900
  running,
@@ -868,18 +918,20 @@ export function firstWords(message) {
868
918
 
869
919
  /**
870
920
  * How an attempt ended, from its errors: `passed`, `failed` (an assertion or
871
- * an action failed, or the test threw), `timed-out` (only its time ran out),
872
- * or `skipped`; and why it failed.
921
+ * an action failed, or the test threw), `timed-out` (its time ran out first:
922
+ * Playwright's timeout, or an `expect` it cut short, which says so, came
923
+ * before any other error; what failed after it failed for it), or
924
+ * `skipped`; and why it failed.
873
925
  */
874
926
  export function outcomeOf(status, errors) {
875
- const timeoutOnly = errors.length > 0 && errors.every((error) => TEST_TIMEOUT.test(stripAnsi(error?.message ?? "")));
876
- const reported = errors.find((error) => !TEST_TIMEOUT.test(stripAnsi(error?.message ?? ""))) ?? errors[0];
927
+ const timeout = (error) => TEST_TIMEOUT.test(stripAnsi(error?.message ?? ""));
928
+ const reported = errors.find((error) => !timeout(error)) ?? errors[0];
877
929
  const message = reported ? firstWords(reported.message ?? reported.value) : undefined;
878
930
  if (status === "passed")
879
931
  return { outcome: "passed" };
880
932
  if (status === "skipped")
881
933
  return { outcome: "skipped" };
882
- if (status === "timedOut" && timeoutOnly)
934
+ if (errors.length > 0 && timeout(errors[0]))
883
935
  return { outcome: "timed-out", message };
884
936
  return { outcome: "failed", message };
885
937
  }
@@ -918,7 +970,6 @@ export const WHY = {
918
970
  "background": "its code ran in server work no request named",
919
971
  "module-level": "it is a server module's top-level code",
920
972
  "by-time": "its code ran for a request that named no test",
921
- "timeout-retry": "a test ran out of time with it switched on, and ran again alone with twice the time",
922
973
  "unfinished": "not every candidate test ran in the shared pass",
923
974
  "confirm": "a test killed it beside other mutants' attempts",
924
975
  "doubt": "the test that killed it failed without it too, on the same server",
@@ -985,30 +1036,31 @@ export function settleAttempt(pass, attempt) {
985
1036
  surviveIfDone(pass, attempt.id);
986
1037
  return ended;
987
1038
  }
988
- if (ended.outcome === "timed-out") {
989
- // Only its time ran out: run again, alone, with twice the time.
990
- if (shared(shape.kind))
991
- mark(`${pass.round}/held/${key(attempt.id)}`);
992
- else if (giveVerdict(pass, verdict("timeout", "ran out of time")))
993
- mark(`${pass.round}/killed/${key(attempt.id)}`);
994
- return ended;
995
- }
996
- if (ended.outcome !== "failed")
1039
+ if (ended.outcome !== "failed" && ended.outcome !== "timed-out")
997
1040
  return ended;
998
- // A kill: no other copy takes the mutant now.
1041
+ // A kill, or a timeout (it ran out of its limit): no other copy takes
1042
+ // the mutant now, and either is confirmed alike.
1043
+ const { status, reason } = verdictOf(ended);
999
1044
  passedHere.delete(test);
1000
1045
  mark(`${pass.round}/killed/${key(attempt.id)}`);
1001
1046
  if (beside)
1002
1047
  mark(`${pass.round}/confirm/${key(attempt.id)}`);
1003
1048
  else if (shape.everywhere)
1004
- giveVerdict(pass, verdict("killed", ended.message ?? "the test failed"));
1049
+ giveVerdict(pass, verdict(status, reason));
1005
1050
  else {
1006
1051
  // Confirmed by the test's next control on this server.
1007
- writeJson(`${pass.round}/pending/${attempt.invocation}/${key(test)}/${key(attempt.id)}`, { id: attempt.id, test, message: ended.message, endedAt: ended.endedAt, durationMs: ended.endedAt - ended.startedAt });
1052
+ writeJson(`${pass.round}/pending/${attempt.invocation}/${key(test)}/${key(attempt.id)}`, { id: attempt.id, test, status, message: reason, endedAt: ended.endedAt, durationMs: ended.endedAt - ended.startedAt });
1008
1053
  }
1009
1054
  return ended;
1010
1055
  }
1011
1056
 
1057
+ /** A mutant attempt that failed or ran out of its limit: its verdict's status and reason. */
1058
+ export function verdictOf(attempt) {
1059
+ if (attempt.outcome === "timed-out")
1060
+ return { status: "timeout", reason: limitReason(attempt) };
1061
+ return { status: "killed", reason: attempt.message ?? "the test failed" };
1062
+ }
1063
+
1012
1064
  function suffix(shape, entry) {
1013
1065
  const said = reasonOf(shape.kind, entry.reason);
1014
1066
  return said ? `; ${said}` : "";
@@ -1041,13 +1093,16 @@ function settleControl(pass, ended, shape) {
1041
1093
  rmSync(`${pending}/${name}`, { force: true });
1042
1094
  if (passed && !ended.beside) {
1043
1095
  const entry = mutantOf(pass, kill.id);
1044
- giveVerdict(pass, { id: kill.id, status: "killed", killedBy: kill.test, reason: `${kill.message ?? "the test failed"}${suffix(shape, entry)}`, tests: 1, durationMs: kill.durationMs });
1096
+ giveVerdict(pass, { id: kill.id, status: kill.status, killedBy: kill.test, reason: `${kill.message}${suffix(shape, entry)}`, tests: 1, durationMs: kill.durationMs });
1045
1097
  }
1046
1098
  else
1047
1099
  mark(`${pass.round}/doubt/${key(kill.id)}`);
1048
1100
  }
1049
1101
  if (passed) {
1050
1102
  passedHere.add(test);
1103
+ // Its time, for its mutants' limits.
1104
+ mark(`${pass.shared}/durations/${key(test)}`);
1105
+ writeFileSync(`${pass.shared}/durations/${key(test)}/${ended.worker}-${ended.endedAt - ended.startedAt}`, "");
1051
1106
  return;
1052
1107
  }
1053
1108
  if (ended.outcome === "skipped")
@@ -1057,11 +1112,6 @@ function settleControl(pass, ended, shape) {
1057
1112
  writeFileSync(`${pass.round}/unreliable/${ended.invocation}/${key(test)}/${ended.worker}-${Date.now()}`, "");
1058
1113
  }
1059
1114
 
1060
- /** Whether a round runs mutants side by side on a shared server: the main round, and the rest of what it left. */
1061
- export function shared(kind) {
1062
- return kind === "main" || kind === "rest";
1063
- }
1064
-
1065
1115
  /**
1066
1116
  * Whether the attempt's mutant ran in this worker's own process: code the
1067
1117
  * test itself runs, in a process the strong pass otherwise keeps. Such a
@@ -11,7 +11,7 @@
11
11
  // from whichever invocations ran it, and what was cut short is unfinished.
12
12
  import { appendFileSync, existsSync, readFileSync, realpathSync, statSync } from "node:fs";
13
13
  import { pathToFileURL } from "node:url";
14
- import { attemptPath, baselineOf, entries, invocation, EVERYWHERE, firstWords, giveVerdict, key, loadPass, outcomeOf, placeOf, readJson, reasonOf, settleAttempt, strongPass, withoutCopy, writeJson } from "./playwrightStrong.mjs";
14
+ import { attemptPath, baselineOf, entries, invocation, EVERYWHERE, firstWords, giveVerdict, key, loadPass, outcomeOf, placeOf, readJson, reasonOf, settleAttempt, strongPass, verdictOf, withoutCopy, writeJson } from "./playwrightStrong.mjs";
15
15
 
16
16
  // How often, at most, the status file is written.
17
17
  const STATUS_MS = 1_000;
@@ -61,7 +61,7 @@ export default class SupercovPlaywrightStrongReporter {
61
61
  constructor() {
62
62
  this.pass = strongPass();
63
63
  this.running = new Map();
64
- this.counts = { baselines: 0, controls: 0, failedControls: 0, attempts: 0, killed: 0, passed: 0 };
64
+ this.counts = { baselines: 0, controls: 0, failedControls: 0, attempts: 0, killed: 0, timedOut: 0, passed: 0 };
65
65
  this.writtenAt = 0;
66
66
  }
67
67
  // It prints its own lines, and says it prints: Playwright adds a reporter
@@ -151,7 +151,13 @@ export default class SupercovPlaywrightStrongReporter {
151
151
  this.counts.passed += 1;
152
152
  else if (attempt.outcome === "failed")
153
153
  this.counts.killed += 1;
154
- const said = attempt.outcome === "passed" ? "lives" : attempt.outcome === "failed" ? "fails" : attempt.outcome;
154
+ else if (attempt.outcome === "timed-out")
155
+ this.counts.timedOut += 1;
156
+ const said = {
157
+ "passed": "lives",
158
+ "failed": "fails",
159
+ "timed-out": `ran out of its ${seconds(attempt.limitMs)} limit (its baseline ${seconds(attempt.baselineMs)})`,
160
+ }[attempt.outcome] ?? attempt.outcome;
155
161
  console.log(`[supercov] ${attempt.id}: ${JSON.stringify(attempt.title)} ${said} (${took})`);
156
162
  }
157
163
  /**
@@ -177,6 +183,7 @@ export default class SupercovPlaywrightStrongReporter {
177
183
  kind: attempt?.kind,
178
184
  mutant: attempt?.id ?? undefined,
179
185
  startedAt: attempt?.startedAt,
186
+ limitMs: attempt?.limitMs,
180
187
  };
181
188
  });
182
189
  try {
@@ -264,13 +271,13 @@ export default class SupercovPlaywrightStrongReporter {
264
271
  const rest = [];
265
272
  const aloneAgain = [];
266
273
  const aloneEach = [];
267
- const next = (entry, reason, tests, budgetFactor = 1) => {
274
+ const next = (entry, reason, tests) => {
268
275
  const runnable = tests.filter((test) => baselineOf(pass, test) !== "failed");
269
276
  if (!runnable.length) {
270
277
  write({ id: entry.id, status: "error", reason: "its candidate tests fail without any mutant", tests: 0, durationMs: 0 });
271
278
  return;
272
279
  }
273
- const job = { id: entry.id, mutant: entry.mutant, tests: runnable, reason, budgetFactor };
280
+ const job = { id: entry.id, mutant: entry.mutant, tests: runnable, reason };
274
281
  // What an alone round left runs alone again, as it was.
275
282
  if (kind === "alone")
276
283
  aloneEach.push({ ...job, reason: entry.reason });
@@ -305,7 +312,8 @@ export default class SupercovPlaywrightStrongReporter {
305
312
  const own = byMutant.get(id) ?? [];
306
313
  const ended = own.filter((attempt) => attempt.endedAt !== undefined);
307
314
  const ranAway = own.find((attempt) => timedOut.has(attempt.attemptId) || timedOutAnywhere.has(entry.mutant));
308
- const failed = ended.filter((attempt) => attempt.outcome === "failed");
315
+ // Kills, and attempts that ran out of their time limit.
316
+ const failed = ended.filter((attempt) => attempt.outcome === "failed" || attempt.outcome === "timed-out");
309
317
  const after = reasonOf(kind, entry.reason);
310
318
  const suffix = after ? `; ${after}` : "";
311
319
  const durationMs = ended.length
@@ -327,17 +335,14 @@ export default class SupercovPlaywrightStrongReporter {
327
335
  // kill on a server no other mutant's attempt shared.
328
336
  const killer = failed.find((attempt) => !attempt.beside && attempt.endedAt < trustedUntil);
329
337
  if (killer) {
330
- verdict({ status: "killed", killedBy: killer.original, reason: `${killer.message ?? "the test failed"}${suffix}` });
338
+ const { status, reason } = verdictOf(killer);
339
+ verdict({ status, killedBy: killer.original, reason: `${reason}${suffix}` });
331
340
  continue;
332
341
  }
333
342
  if (ranAway) {
334
343
  verdict({ status: "timeout", killedBy: ranAway.original, reason: `evaluated past its hit limit${suffix}` });
335
344
  continue;
336
345
  }
337
- if (existsSync(`${round}/held/${key(id)}`)) {
338
- next(entry, "timeout-retry", entry.tests, 2 * (entry.budgetFactor ?? 1));
339
- continue;
340
- }
341
346
  // Alone, the command failed outside any test: the mutant broke the
342
347
  // app (a server that would not start with it).
343
348
  // (Where one invocation of several failed so, it runs alone with
@@ -400,7 +405,7 @@ export default class SupercovPlaywrightStrongReporter {
400
405
  // command started with it.
401
406
  const takenAny = claimedBy.size > 0;
402
407
  for (const entry of aloneAgain)
403
- (takenAny ? alone : aloneEach).push({ ...entry, budgetFactor: entry.budgetFactor ?? 1 });
408
+ (takenAny ? alone : aloneEach).push(entry);
404
409
  if (alone.length)
405
410
  write({ restart: { kind: "alone", everywhere: true, batch: true, reason: "server-wide", mutants: alone, otherRunners: work.otherRunners } });
406
411
  for (const job of aloneEach)
@@ -422,6 +427,8 @@ export default class SupercovPlaywrightStrongReporter {
422
427
  workerProcesses: new Set(attempts.map((attempt) => attempt.worker)).size,
423
428
  durationMs: Date.now() - started,
424
429
  attempts: mutated.length,
430
+ timedOut: mutated.filter((attempt) => attempt.outcome === "timed-out").length,
431
+ timeoutFactor: work.timeoutFactor,
425
432
  baselines: attempts.filter((attempt) => attempt.kind === "baseline").length,
426
433
  decided,
427
434
  next: { alone: alone.length, rest: rest.length, serial: serial.length },