@hughescr/stryker-bun-runner 1.5.2 → 1.6.1
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 +491 -24
- package/dist/index.d.ts +486 -32
- package/dist/index.js +3490 -334
- package/dist/templates/coverage-preload.js +1128 -0
- package/dist/templates/import-scan.js +902 -0
- package/package.json +5 -2
- package/dist/coverage/preload-logic.js +0 -255
- package/dist/templates/coverage-preload.ts +0 -440
package/dist/index.d.ts
CHANGED
|
@@ -25,8 +25,9 @@ export declare class BunTestRunner implements TestRunner {
|
|
|
25
25
|
/** {@link bunArgs} for mutant runs: without `--randomize`/`--seed`, which only the dry run keeps (see stripRandomizeArgs). */
|
|
26
26
|
private readonly mutantBunArgs?;
|
|
27
27
|
/**
|
|
28
|
-
* True when the current sanitized bunfig randomizes the test order,
|
|
29
|
-
*
|
|
28
|
+
* True when the current sanitized bunfig randomizes the test order, which its mutant-run copy (see
|
|
29
|
+
* mutantRunBunfigPath) turns off; only logged (see logRandomizeOffOnce). Set whenever the sanitized bunfig is
|
|
30
|
+
* (re)generated, which every run does first.
|
|
30
31
|
*/
|
|
31
32
|
private sanitizedBunfigRandomizes?;
|
|
32
33
|
/** True once the "randomized order is off for mutant runs" debug line has been logged; it is shown once per runner. */
|
|
@@ -39,6 +40,19 @@ export declare class BunTestRunner implements TestRunner {
|
|
|
39
40
|
* ascending order of it; undefined when neither had any, and the order is then left alone.
|
|
40
41
|
*/
|
|
41
42
|
private testFileDurations?;
|
|
43
|
+
/**
|
|
44
|
+
* Which test files' tests executed which mutants in the dry run, from this worker's dry
|
|
45
|
+
* run or the shared registry; undefined when neither had any. Ranks a static mutant's
|
|
46
|
+
* files likely killers first (see orderForMutantRun).
|
|
47
|
+
*/
|
|
48
|
+
private testFileCoverage?;
|
|
49
|
+
/**
|
|
50
|
+
* Per instrumented source file (MutantRunOptions.sandboxFileName), per test file, how
|
|
51
|
+
* many of its mutants the test file's tests executed in the dry run. Derived from
|
|
52
|
+
* {@link testFileCoverage} and the file's mutant switches on a static run's first need;
|
|
53
|
+
* cleared when that changes.
|
|
54
|
+
*/
|
|
55
|
+
private readonly sourceCoverageCounts;
|
|
42
56
|
/** The user's bunfig named by `--config`/`-c` in `bun.bunArgs`, as written: the source the runner sanitizes and reads `[test].root` from. */
|
|
43
57
|
private readonly sourceBunfig?;
|
|
44
58
|
private readonly testFilesOverride?;
|
|
@@ -47,6 +61,8 @@ export declare class BunTestRunner implements TestRunner {
|
|
|
47
61
|
private readonly maxChildRss?;
|
|
48
62
|
private readonly rssCheckIntervalMs?;
|
|
49
63
|
private readonly maxSpawnDepth?;
|
|
64
|
+
/** The file a failed dry run's complete output is written to (bun.dryRunOutputFile), as the user wrote it; undefined when none is configured. */
|
|
65
|
+
private readonly dryRunOutputFile?;
|
|
50
66
|
/** Stryker's coverageAnalysis from the Stryker options; DryRunOptions.coverageAnalysis wins when given. */
|
|
51
67
|
private readonly coverageAnalysis?;
|
|
52
68
|
private preloadScriptPath?;
|
|
@@ -54,6 +70,10 @@ export declare class BunTestRunner implements TestRunner {
|
|
|
54
70
|
private sanitizedBunfigPath?;
|
|
55
71
|
private sanitizedBunfigCwd?;
|
|
56
72
|
private tempDir?;
|
|
73
|
+
/** When this worker last marked tempDir in use (see keepRunTempDirFresh). */
|
|
74
|
+
private tempDirTouchedAt;
|
|
75
|
+
/** process.ppid at the first init(): the Stryker main process that owns the run (see assertRunOwnerIsParent). */
|
|
76
|
+
private runOwnerPid?;
|
|
57
77
|
private cachedTestNames?;
|
|
58
78
|
private baseNameIndex?;
|
|
59
79
|
private testNameIndex?;
|
|
@@ -96,6 +116,28 @@ export declare class BunTestRunner implements TestRunner {
|
|
|
96
116
|
private mutantRunsByStatus;
|
|
97
117
|
/** Mutant runs that had covering tests but ran the full suite anyway (pattern too long, or zero-match retry). Reset with {@link mutantRunsByStatus}. */
|
|
98
118
|
private fullSuiteFallbacks;
|
|
119
|
+
/** Times every run when STRYKER_BUN_PROFILE names a file; undefined otherwise (see src/run-profile.ts). */
|
|
120
|
+
private readonly profiler?;
|
|
121
|
+
/** `bun.alwaysImport` as given: the files of the eager list every dry run imports first. */
|
|
122
|
+
private readonly alwaysImport?;
|
|
123
|
+
/** `bun.importDiscovery` as given (undefined is the default, 'scan'). */
|
|
124
|
+
private readonly importDiscovery?;
|
|
125
|
+
/** Stryker's `incremental` option: the messages that name a remedy then add the --force advice. */
|
|
126
|
+
private readonly incremental;
|
|
127
|
+
/** Stryker's `inPlace` option: campaigns of one process then share the run directory (see dry-run-files.ts). */
|
|
128
|
+
private readonly inPlace;
|
|
129
|
+
/**
|
|
130
|
+
* What mutant runs take off Stryker's per-mutant timeout (rule 3.6), as this worker's dry
|
|
131
|
+
* run computed it or the registry held it (unchecked: see correctStrykerTimeout); undefined
|
|
132
|
+
* without either.
|
|
133
|
+
*/
|
|
134
|
+
private timeoutCorrectionMs?;
|
|
135
|
+
/** True once the "no usable timeout correction" debug line has been logged; it is shown once per runner. */
|
|
136
|
+
private loggedUnusableCorrection;
|
|
137
|
+
/** The campaign of this worker's dry run or of the registry, the run directory its files are in, and its watch list as a set (built once, for every mutant run's witness check). */
|
|
138
|
+
private campaign?;
|
|
139
|
+
/** True once a mutant run's unusable watch list has been warned about; it is shown once per runner. */
|
|
140
|
+
private warnedWatchListProblem;
|
|
99
141
|
/**
|
|
100
142
|
* AbortController for whichever `dryRun`/`mutantRun` child process is
|
|
101
143
|
* currently in flight, if any. Lets {@link dispose} kill an orphaned child
|
|
@@ -108,16 +150,17 @@ export declare class BunTestRunner implements TestRunner {
|
|
|
108
150
|
* Single source of truth for the registry file name.
|
|
109
151
|
*
|
|
110
152
|
* Lives in the OS temp directory, not cwd: under Stryker's --inPlace mode
|
|
111
|
-
* cwd IS the user's real project root, and writing there would
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
153
|
+
* cwd IS the user's real project root, and writing there would pollute
|
|
154
|
+
* the user's project. No worker removes it (dispose() deliberately never
|
|
155
|
+
* unlinks the registry itself — see its doc comment); the run's Stryker
|
|
156
|
+
* main process removes the whole directory when it exits
|
|
157
|
+
* (removeRunTempDirsOnExit). Specifically it is the run's
|
|
115
158
|
* private directory (src/utils/private-temp-dir.ts): owned by the current
|
|
116
159
|
* user, mode 0700, re-resolved (and so re-verified) before every write and
|
|
117
160
|
* before the lazy load, so another local user can neither plant nor read a
|
|
118
161
|
* registry.
|
|
119
162
|
*
|
|
120
|
-
* Keyed by sha256(cwd + ':' + ppid) (plus the uid, in the directory name): every worker process Stryker spawns
|
|
163
|
+
* Keyed by sha256(cwd + ':' + ppid) (plus the uid, the pid space and the ppid, in the directory name): every worker process Stryker spawns
|
|
121
164
|
* for one run is a direct child of that run's single Stryker main
|
|
122
165
|
* process, so all of them share BOTH process.cwd() (the sandbox
|
|
123
166
|
* directory) AND process.ppid (the main process's pid) — and therefore
|
|
@@ -156,15 +199,34 @@ export declare class BunTestRunner implements TestRunner {
|
|
|
156
199
|
*/
|
|
157
200
|
private resolveRegistryPath;
|
|
158
201
|
/**
|
|
202
|
+
* Refuse to resolve (and so create) the run directory once this worker's parent
|
|
203
|
+
* has changed since init(): the Stryker main process that owned the run has
|
|
204
|
+
* exited, and has removed the directory or will, and this worker has been
|
|
205
|
+
* reparented. Stryker's signal path exits without disposing the workers, so one
|
|
206
|
+
* can still be finishing a run. Under its new parent it would derive, and
|
|
207
|
+
* create, a directory named for a process that never ran Stryker, which no
|
|
208
|
+
* cleanup would ever judge finished.
|
|
209
|
+
*/
|
|
210
|
+
private assertRunOwnerIsParent;
|
|
211
|
+
/**
|
|
212
|
+
* Mark the run directory in use at most every RUN_DIR_TOUCH_INTERVAL_MS, so a
|
|
213
|
+
* live run's directory never looks abandoned to another process's cleanup
|
|
214
|
+
* (see STALE_RUN_DIR_AGE_MS in src/utils/private-temp-dir.ts). One syscall
|
|
215
|
+
* every few minutes; skipped once this worker is orphaned.
|
|
216
|
+
*/
|
|
217
|
+
private keepRunTempDirFresh;
|
|
218
|
+
/**
|
|
159
219
|
* Narrow a targeted mutant run to just the test FILES its covering tests live
|
|
160
220
|
* in.
|
|
161
221
|
*
|
|
162
222
|
* `--test-name-pattern` filters at the TEST level, not the file level: bun
|
|
163
223
|
* still loads every test file it was given in order to discover which names
|
|
164
|
-
* match
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
224
|
+
* match, and a run that ends up executing two tests pays that in full, on
|
|
225
|
+
* every mutant. Measured on bun 1.4.2 (4-CPU Linux, the benchmark fixture's
|
|
226
|
+
* 160 instrumented test files), a run selecting two tests takes ~180ms when
|
|
227
|
+
* handed every file and ~18ms when handed only the covering file. Of those
|
|
228
|
+
* ~18ms, ~15ms is the child's startup through the coverage preload (bun itself
|
|
229
|
+
* ~2ms, `bun test`'s own setup ~6ms, our argv and preload ~6ms).
|
|
168
230
|
*
|
|
169
231
|
* Test ids are `<projectFile> > <fullName>` (see buildProjectFileTestName), so
|
|
170
232
|
* the file is already the id's prefix and no extra bookkeeping is needed.
|
|
@@ -194,6 +256,43 @@ export declare class BunTestRunner implements TestRunner {
|
|
|
194
256
|
* all — go last in their old order. `files` itself is not modified.
|
|
195
257
|
*/
|
|
196
258
|
private orderCheapestFirst;
|
|
259
|
+
/** Each of `files` mapped to its project-relative path, normalized once, for the orderings of one mutant run to share. */
|
|
260
|
+
private projectFilesOf;
|
|
261
|
+
/**
|
|
262
|
+
* True when a mutant run hands bun its files likely killers first (see
|
|
263
|
+
* orderForMutantRun) rather than cheapest first: a planned full-suite run (no
|
|
264
|
+
* covering test ids: a static mutant, a mutant with no coverage, or a run scoped
|
|
265
|
+
* to Stryker's testFiles) that bails.
|
|
266
|
+
*
|
|
267
|
+
* - Without bail every file runs whatever the order, so reordering saves nothing.
|
|
268
|
+
* - A targeted run's files all executed the mutant; its first file usually kills
|
|
269
|
+
* it already (measured: under 3% of killed targeted mutants on the benchmark
|
|
270
|
+
* fixture needed a second file), so it stays cheapest first.
|
|
271
|
+
* - A full-suite fallback (covering tests, but the pattern was too long or matched
|
|
272
|
+
* nothing) runs against a deadline Stryker sized for those covering tests only.
|
|
273
|
+
* Moving a slower file ahead of the killer there could turn a kill into the
|
|
274
|
+
* inconclusive-timeout Error, so it stays cheapest first.
|
|
275
|
+
*/
|
|
276
|
+
private ordersLikelyKillersFirst;
|
|
277
|
+
/**
|
|
278
|
+
* `files` in the order a mutant run hands them to bun: cheapest first (see
|
|
279
|
+
* orderCheapestFirst), then, when {@link ordersLikelyKillersFirst} says so, with
|
|
280
|
+
* the files likeliest to kill this mutant moved to the front, ranked by dry-run
|
|
281
|
+
* coverage of the mutant and of its source file, and by a name match (see
|
|
282
|
+
* likely-killer-order.ts). Files that rank the same keep their cheapest-first
|
|
283
|
+
* order, so with no signal at all the order is cheapest first.
|
|
284
|
+
*/
|
|
285
|
+
private orderForMutantRun;
|
|
286
|
+
/** Replace the dry-run per-file mutant coverage, and drop everything derived from the old one. */
|
|
287
|
+
private setTestFileCoverage;
|
|
288
|
+
/**
|
|
289
|
+
* Per test file, how many mutants of the instrumented source file `sandboxFileName`
|
|
290
|
+
* its tests executed in the dry run, or undefined without dry-run coverage. The
|
|
291
|
+
* file's mutants are read from its mutant switches (see
|
|
292
|
+
* mutantIdsInInstrumentedSource) once per worker; a file that cannot be read
|
|
293
|
+
* counts as having none, which only leaves that rank unused.
|
|
294
|
+
*/
|
|
295
|
+
private sourceCoverageFor;
|
|
197
296
|
/**
|
|
198
297
|
* Say once, at debug, that mutant runs do not randomize the test order although
|
|
199
298
|
* the project asked for it (in the bunfig, in bun.bunArgs, or both). They run
|
|
@@ -294,6 +393,26 @@ export declare class BunTestRunner implements TestRunner {
|
|
|
294
393
|
* Initialize the test runner
|
|
295
394
|
*/
|
|
296
395
|
init(): Promise<void>;
|
|
396
|
+
/**
|
|
397
|
+
* Reject init() with the witness's message (M-witness) while the run directory holds an
|
|
398
|
+
* abort marker of the current campaign.
|
|
399
|
+
*
|
|
400
|
+
* Stryker answers a rejected mutant run by disposing the worker, starting a new one and
|
|
401
|
+
* calling its init(); a rejection there ends the campaign without a report or an
|
|
402
|
+
* incremental file (measured on every supported core). So the worker whose mutant run
|
|
403
|
+
* the witness stopped leaves a marker, and every init() of the same campaign rejects.
|
|
404
|
+
*
|
|
405
|
+
* The marker counts only for the campaign that wrote it: its generation must be the
|
|
406
|
+
* registry's. Without inPlace that settles it, since every campaign has a run directory
|
|
407
|
+
* of its own. With inPlace the files matched by mutate must also be the ones that
|
|
408
|
+
* campaign's dry run saw (the fingerprint the registry then holds, see
|
|
409
|
+
* dry-run-files.ts): that is what lets a later campaign in the same run directory start,
|
|
410
|
+
* as Stryker starts its workers before its dry run replaces the generation, and it has
|
|
411
|
+
* written the instrumented files anew.
|
|
412
|
+
*
|
|
413
|
+
* Costs one failed read per init() when there is no marker.
|
|
414
|
+
*/
|
|
415
|
+
private rejectIfCampaignStopped;
|
|
297
416
|
/** Create/verify the run's private temp directory (see src/utils/private-temp-dir.ts) and remember it as this worker's tempDir. */
|
|
298
417
|
private ensureRunTempDir;
|
|
299
418
|
/**
|
|
@@ -362,13 +481,154 @@ export declare class BunTestRunner implements TestRunner {
|
|
|
362
481
|
*/
|
|
363
482
|
private buildTestsFromInspector;
|
|
364
483
|
/**
|
|
365
|
-
* Run all tests (dry run). Stryker always passes `options`;
|
|
484
|
+
* Run all tests (dry run). Stryker always passes `options`; its
|
|
366
485
|
* `coverageAnalysis` is read (to judge missing coverage, see
|
|
367
|
-
* checkCoverageData), falling back to the Stryker options' value
|
|
368
|
-
*
|
|
486
|
+
* checkCoverageData), falling back to the Stryker options' value, and its
|
|
487
|
+
* `timeout` (dryRunTimeoutMinutes) only to warn when another run of the tests
|
|
488
|
+
* might not fit (M-budget). bun.timeout bounds each child.
|
|
369
489
|
*/
|
|
370
490
|
dryRun(options?: DryRunOptions): Promise<DryRunResult>;
|
|
371
491
|
/**
|
|
492
|
+
* The dry run itself; split from {@link dryRun} so its many returns all reach the profile.
|
|
493
|
+
*
|
|
494
|
+
* Which files of the eager list (E) the run that publishes results imports before the
|
|
495
|
+
* tests, and how that is established:
|
|
496
|
+
*
|
|
497
|
+
* 1. E is empty, or bun.alwaysImport keeps all of it: earlier versions' run, no scan.
|
|
498
|
+
* 2. Otherwise the import scan reads the tests' imports (see decideShape) and answers:
|
|
499
|
+
* - `full`: what the tests import covers E; one run with E imported first
|
|
500
|
+
* ({@link runFullShape});
|
|
501
|
+
* - `static`: something is left out and nothing could load it; one run with the
|
|
502
|
+
* shortened list, watched by the load sensors ({@link runStaticShape});
|
|
503
|
+
* - `dynamic`, or bun.importDiscovery 'run': a plain run of the tests is observed
|
|
504
|
+
* first, then the run that publishes ({@link runTwoRuns}).
|
|
505
|
+
*
|
|
506
|
+
* Every published run is earlier versions' inspected run with its result held back
|
|
507
|
+
* until the rules pass; nothing is persisted before that ({@link publishDryRun}).
|
|
508
|
+
*/
|
|
509
|
+
private executeDryRun;
|
|
510
|
+
/** K: the files of E that bun.alwaysImport keeps, with a warning for each pattern that keeps none. */
|
|
511
|
+
private selectAlwaysImported;
|
|
512
|
+
/** `file` relative to the dry run's project directory, as the messages show it (quoted when it must be, see displayName). */
|
|
513
|
+
private projectPathsOf;
|
|
514
|
+
/** Log `message` at `level`, and at debug, for each list it shortened, the entries it left out (see listText). */
|
|
515
|
+
private logListed;
|
|
516
|
+
/**
|
|
517
|
+
* The import scan's verdict for this dry run (the design's step 2), and its M-scan line.
|
|
518
|
+
* The scan is not even started when the runner cannot name its roots or the command line
|
|
519
|
+
* can change what it would model; either way the answer is then `dynamic`. Its time,
|
|
520
|
+
* whatever the outcome, counts towards d (rule 3.6).
|
|
521
|
+
*/
|
|
522
|
+
private decideShape;
|
|
523
|
+
/**
|
|
524
|
+
* The import scan's input: E, K, the tsconfig, and the roots (the test files bun will
|
|
525
|
+
* run, the project's `[test].preload` files and the user's `--preload` files); or why the
|
|
526
|
+
* runner cannot name them exactly, or why its command line, its environment or its bunfig
|
|
527
|
+
* (see bunfigScanProblem) can change what the tests load in a way the scan does not model.
|
|
528
|
+
*/
|
|
529
|
+
private importScanInput;
|
|
530
|
+
/** The project's tsconfig.json (or, without one, its jsconfig.json), or null when it has neither. */
|
|
531
|
+
private applicableTsconfig;
|
|
532
|
+
/** The sanitized bunfig and the test-file arguments every run of this dry run hands bun (see the inspected run's own resolution of both). */
|
|
533
|
+
private dryRunFiles;
|
|
534
|
+
/** Before each run of the tests: count it, and warn (M-budget) before a second or third when the rest of Stryker's budget may not hold it. */
|
|
535
|
+
private beforeLaunch;
|
|
536
|
+
/**
|
|
537
|
+
* Launch a published run with `list` (L) imported first: write its plan (the load
|
|
538
|
+
* sensors watch E outside L; a fresh record file), run earlier versions' inspected dry
|
|
539
|
+
* run, and read its record back.
|
|
540
|
+
*/
|
|
541
|
+
private runPublished;
|
|
542
|
+
/**
|
|
543
|
+
* Fresh paths for one launch's plan (beside the preload, in the run's private directory)
|
|
544
|
+
* and record: no launch ever follows another's plan or reads another's record.
|
|
545
|
+
*/
|
|
546
|
+
private launchFiles;
|
|
547
|
+
/** Remove a launch's plan and record, and the record's temporary file (see writePrivateFileAtomically in preload-logic.ts), however the launch ended. */
|
|
548
|
+
private removeLaunchFiles;
|
|
549
|
+
/**
|
|
550
|
+
* Write `plan` to `planFile`, for the next child of the dry run; without a preload
|
|
551
|
+
* (init() never ran, so no plan path) there is nothing to give it to. A plan that cannot
|
|
552
|
+
* be written is an Error.
|
|
553
|
+
*/
|
|
554
|
+
private writePlan;
|
|
555
|
+
/** Read a launch's record and remove its file. */
|
|
556
|
+
private readRecord;
|
|
557
|
+
/** What the rules need to know about a published launch. */
|
|
558
|
+
private launchFacts;
|
|
559
|
+
/** M-eager: warn about each import of the eager loop that threw (the first ten; the rest at debug). */
|
|
560
|
+
private warnEagerFailures;
|
|
561
|
+
/**
|
|
562
|
+
* `full` (step 3, after `full` only 3c and 3d apply): one run with E imported first. A
|
|
563
|
+
* run that is not green goes to discovery when the test files name files in a literal
|
|
564
|
+
* `import()` or `require()` (one of those may be an entry point that breaks the run), and
|
|
565
|
+
* is otherwise returned as earlier versions returned it.
|
|
566
|
+
*/
|
|
567
|
+
private runFullShape;
|
|
568
|
+
/**
|
|
569
|
+
* `static` (step 3): one run with the scan's list imported first and the rest watched, judged by {@link oneRunOutcome}.
|
|
570
|
+
*
|
|
571
|
+
* @param roots - The scan's roots: a test file that ran and is not among them was never read by the scan
|
|
572
|
+
*/
|
|
573
|
+
private runStaticShape;
|
|
574
|
+
/**
|
|
575
|
+
* The two-run path (step 4): a plain run of the tests is observed, and the run that
|
|
576
|
+
* publishes imports what it was seen to load (with K); then the rules of section 3.
|
|
577
|
+
* After a failed first run with named files (step 3c), a plain run that is not accepted
|
|
578
|
+
* hands back that first run's own result instead of an Error.
|
|
579
|
+
*/
|
|
580
|
+
private runTwoRuns;
|
|
581
|
+
/** The published run of the two-run path, judged by {@link twoRunOutcome} (rule 3.5). */
|
|
582
|
+
private runAfterDiscovery;
|
|
583
|
+
/** The messages of a two-run publication: M-G3a, M1 (when something is left out) and, after step 3c, M-named. */
|
|
584
|
+
private reportTwoRunPublication;
|
|
585
|
+
/**
|
|
586
|
+
* Launch the discovery run (the design's section 2.2): the published run's `bun test`
|
|
587
|
+
* command line, bunfig and preloads, without the inspector and the sync server, nothing
|
|
588
|
+
* imported first, the sensors watching E, bounded by bun.timeout; and judge it with
|
|
589
|
+
* {@link acceptDiscovery}.
|
|
590
|
+
*/
|
|
591
|
+
private runDiscovery;
|
|
592
|
+
/** M-refuse: the load sensors cannot be trusted. Nothing is persisted. */
|
|
593
|
+
private refuseDryRun;
|
|
594
|
+
/**
|
|
595
|
+
* M-P1: the plain run of the tests was not accepted. The message carries bun's own
|
|
596
|
+
* output through the diagnostics the completeness error uses: the "Unhandled error
|
|
597
|
+
* between tests" blocks, else the tail of the output, and the line about
|
|
598
|
+
* bun.dryRunOutputFile.
|
|
599
|
+
*/
|
|
600
|
+
private discoveryError;
|
|
601
|
+
/** M-G3b: candidates the plain run did not load were loaded after the published run's imports. */
|
|
602
|
+
private lateLoadError;
|
|
603
|
+
/**
|
|
604
|
+
* M-lost: mutant ids the plain run reached and the published run did not; their files are read from the instrumented sources.
|
|
605
|
+
*
|
|
606
|
+
* @param always - How many files of `list` only bun.alwaysImport kept
|
|
607
|
+
*/
|
|
608
|
+
private lostError;
|
|
609
|
+
/**
|
|
610
|
+
* Hand Stryker a published run's result: persist the registry (for a green run with the
|
|
611
|
+
* timeout correction and the campaign: a new generation, the watch list W of the files E
|
|
612
|
+
* outside L and `seen`) and give the warnings of a completed run, then return it. Only
|
|
613
|
+
* a Complete result has anything to persist; any other is returned as it is. A run whose
|
|
614
|
+
* watch list cannot be published with its registry is an Error instead.
|
|
615
|
+
*
|
|
616
|
+
* @param seen - Files of E outside L the run's sensors saw (and so loaded): not watched; none by default
|
|
617
|
+
*/
|
|
618
|
+
private publishDryRun;
|
|
619
|
+
/**
|
|
620
|
+
* Earlier versions' inspected dry run, once: the sync server, the `bun test` child with
|
|
621
|
+
* the inspector, the completeness gate and the mapper. It writes nothing that outlives
|
|
622
|
+
* it: the result comes back with what persisting it needs (see {@link publishDryRun}).
|
|
623
|
+
*/
|
|
624
|
+
private runInspectedPass;
|
|
625
|
+
/**
|
|
626
|
+
* {@link runInspectedPass} with its coverage file: everything from the sync server to the result.
|
|
627
|
+
*
|
|
628
|
+
* @param launched - Where it puts the child's promise once the child is started
|
|
629
|
+
*/
|
|
630
|
+
private runInspectedChild;
|
|
631
|
+
/**
|
|
372
632
|
* The dry run's coverageAnalysis: Stryker's DryRunOptions value, else the
|
|
373
633
|
* Stryker options' value. Extracted to keep dryRun()'s complexity under the
|
|
374
634
|
* lint threshold.
|
|
@@ -382,14 +642,13 @@ export declare class BunTestRunner implements TestRunner {
|
|
|
382
642
|
private warnOnAbnormalDrainData;
|
|
383
643
|
/**
|
|
384
644
|
* Post-child-exit dry-run pipeline: collect/remap coverage, build tests
|
|
385
|
-
* from inspector data, sort them for incremental-mode determinism, run
|
|
386
|
-
* completeness gate
|
|
387
|
-
*
|
|
388
|
-
*
|
|
645
|
+
* from inspector data, sort them for incremental-mode determinism, and run
|
|
646
|
+
* the completeness gate. Returns the gate's Error result when it fires,
|
|
647
|
+
* otherwise the Complete result with what persisting it needs: the registry
|
|
648
|
+
* is written only once the dry run's rules pass (see publishDryRun).
|
|
389
649
|
*
|
|
390
|
-
* Extracted from
|
|
391
|
-
* complexity under the lint threshold
|
|
392
|
-
* order and same early-return-on-gate-failure semantics as before.
|
|
650
|
+
* Extracted from runInspectedPass() purely to keep its own cyclomatic
|
|
651
|
+
* complexity under the lint threshold.
|
|
393
652
|
*/
|
|
394
653
|
private buildGatedDryRunResult;
|
|
395
654
|
/**
|
|
@@ -438,8 +697,41 @@ export declare class BunTestRunner implements TestRunner {
|
|
|
438
697
|
*
|
|
439
698
|
* Writing to a .tmp path then renaming is atomic on POSIX: readers always see
|
|
440
699
|
* either the previous complete file or the new one — never a partial write.
|
|
700
|
+
*
|
|
701
|
+
* With `campaignInput` (a green run) the registry also starts the campaign (see
|
|
702
|
+
* src/coverage/dry-run-files.ts): a new generation, which makes every abort marker of
|
|
703
|
+
* an earlier one stale (the stale marker is removed once the registry is in place),
|
|
704
|
+
* and, when the list was shortened, the watch list W the mutant runs' witness reads,
|
|
705
|
+
* written under the generation's own name before the registry that names it is
|
|
706
|
+
* renamed into place, last. And it carries the timeout correction every worker's
|
|
707
|
+
* mutant runs apply. Without it (a run with failing tests) the registry is the one
|
|
708
|
+
* earlier versions wrote.
|
|
709
|
+
*
|
|
710
|
+
* A registry that cannot be written is only warned about, as in earlier versions,
|
|
711
|
+
* unless the campaign has a watch list: its mutant runs would then not watch what the
|
|
712
|
+
* dry run left out, so the failure is returned, as the dry run's Error message.
|
|
713
|
+
*
|
|
714
|
+
* @returns Undefined, or the Error message when a campaign with a watch list could not be published
|
|
441
715
|
*/
|
|
442
716
|
private buildAndPersistTestRegistry;
|
|
717
|
+
/**
|
|
718
|
+
* A registry write failed: the dry run's Error message (M-publish) when the campaign has a
|
|
719
|
+
* watch list, naming the file that could not be written; otherwise a warning, as in
|
|
720
|
+
* earlier versions (the worker that ran the dry run still has its in-memory copy; other
|
|
721
|
+
* workers fall back to raw names and log a warning), and undefined.
|
|
722
|
+
*/
|
|
723
|
+
private registryWriteFailed;
|
|
724
|
+
/**
|
|
725
|
+
* {@link buildAndPersistTestRegistry}'s writes: the campaign's watch list (when it has one),
|
|
726
|
+
* then the registry, renamed into place last, then the stale marker's removal. A write that
|
|
727
|
+
* fails is a {@link WriteFailure} naming its file; a watch list no registry names is removed.
|
|
728
|
+
*/
|
|
729
|
+
private writeRegistry;
|
|
730
|
+
/**
|
|
731
|
+
* A new campaign's state for the registry: a new generation, W, and (inPlace only) the
|
|
732
|
+
* fingerprint of E; W is written first, under the generation's own name.
|
|
733
|
+
*/
|
|
734
|
+
private writeCampaignFiles;
|
|
443
735
|
/**
|
|
444
736
|
* Warn that the dry-run registry could not be written. The registry also carries
|
|
445
737
|
* Stryker's testFiles selection, so when one is active the warning adds that other
|
|
@@ -461,6 +753,27 @@ export declare class BunTestRunner implements TestRunner {
|
|
|
461
753
|
*/
|
|
462
754
|
mutantRun(options: MutantRunOptions): Promise<MutantRunResult>;
|
|
463
755
|
/**
|
|
756
|
+
* Stryker's per-mutant timeout less the dry run's correction (rule 3.6), once, before the
|
|
757
|
+
* runner's own margin: Stryker sizes the timeout from the dry run's overhead, which the
|
|
758
|
+
* import scan, a discarded run and a discovery run would otherwise lengthen. A missing or
|
|
759
|
+
* unusable correction leaves Stryker's value as it is, and says so once at debug.
|
|
760
|
+
*/
|
|
761
|
+
private correctedStrykerTimeout;
|
|
762
|
+
/** The watch list every mutant run's child gets: the campaign's, when it watches anything. */
|
|
763
|
+
private watchListForMutantRuns;
|
|
764
|
+
/**
|
|
765
|
+
* The witness's verdict on a mutant run's child, which comes before the child's own
|
|
766
|
+
* (Killed, Survived, Timeout): a valid line, signed with this spawn's token and naming
|
|
767
|
+
* only files of W, means a watched file was in bun's module cache when the mutant first
|
|
768
|
+
* executed. The worker then writes the abort marker for its campaign and rejects the
|
|
769
|
+
* mutant run with M-witness; Stryker's recovery init() then rejects too (see
|
|
770
|
+
* rejectIfCampaignStopped), which ends the campaign. An unusable watch list the child
|
|
771
|
+
* reported is warned about once, and the run's own verdict stands.
|
|
772
|
+
*/
|
|
773
|
+
private enforceWitness;
|
|
774
|
+
/** The tests a mutant run selected, in M-witness's words, and the covering tests it lists when it ran those (the rest of a long list goes to debug). */
|
|
775
|
+
private witnessScope;
|
|
776
|
+
/**
|
|
464
777
|
* Recognise a testFilter that is a list of test FILES rather than test ids.
|
|
465
778
|
*
|
|
466
779
|
* Stryker core's own `testFiles` option (9.6+, also 10) makes the mutant
|
|
@@ -561,8 +874,40 @@ export declare class BunTestRunner implements TestRunner {
|
|
|
561
874
|
*/
|
|
562
875
|
private classifyRunWithoutFailedTest;
|
|
563
876
|
/**
|
|
877
|
+
* Classify a mutant run that exited 0 without bun's summary.
|
|
878
|
+
*
|
|
879
|
+
* Bun prints its summary (` N pass` … `Ran N tests across M files`) only once
|
|
880
|
+
* every file has run, on every run that gets that far: with every reporter,
|
|
881
|
+
* `onlyFailures`, `--dots`, junit, the AI-agent reporter, and a `-t` pattern
|
|
882
|
+
* (verified on bun 1.4.2). So an exit with code 0 and no summary means the
|
|
883
|
+
* process left early: a test, a hook or a module at load called
|
|
884
|
+
* `process.exit(0)` (bun 1.4.2 then prints nothing more, not even the
|
|
885
|
+
* summary of the tests that already passed), and every selected test after
|
|
886
|
+
* that point never ran. The mutant changed what the suite does, so the run
|
|
887
|
+
* is never Survived. It is scored as the other early terminations are
|
|
888
|
+
* (a non-zero exit with no failing test, a signal death): Killed when a
|
|
889
|
+
* failing test that matches a known test was reported before the exit
|
|
890
|
+
* (without bail, bun still exits 0 after one), and otherwise Error, since
|
|
891
|
+
* no test is known to have failed.
|
|
892
|
+
*
|
|
893
|
+
* The signal is the summary's absence, not its count: a `-t` pattern counts
|
|
894
|
+
* only the tests it matched (a partial miss is legitimate), and skipped,
|
|
895
|
+
* pending, retried and `.only`-filtered tests change the count on healthy
|
|
896
|
+
* runs, so a count lower than the selected tests proves nothing.
|
|
897
|
+
*/
|
|
898
|
+
private classifyEarlyCleanExit;
|
|
899
|
+
/**
|
|
900
|
+
* Error result for a run that exited 0 before bun's summary with no
|
|
901
|
+
* attributable failing test — see classifyEarlyCleanExit. It quotes the END
|
|
902
|
+
* of the output (stdout, then stderr), which shows where the exit happened;
|
|
903
|
+
* with passing tests hidden, the start is usually just a file header.
|
|
904
|
+
*/
|
|
905
|
+
private buildEarlyExitErrorResult;
|
|
906
|
+
/**
|
|
564
907
|
* Check for dry run process failures (timeout or non-zero exit).
|
|
565
908
|
* Returns a DryRunResult to short-circuit if the process failed, or null to proceed.
|
|
909
|
+
* The child's stderr goes into the message as the diagnostics show it ({@link cleanDiagnosticText}):
|
|
910
|
+
* it can carry an inspector address, the run's secrets, or an import error that holds either.
|
|
566
911
|
*/
|
|
567
912
|
private checkDryRunProcessResult;
|
|
568
913
|
/**
|
|
@@ -595,6 +940,17 @@ export declare class BunTestRunner implements TestRunner {
|
|
|
595
940
|
*/
|
|
596
941
|
private warnOnUnidentifiedDryRunFailure;
|
|
597
942
|
/**
|
|
943
|
+
* The last line of a completeness error, about bun's complete output: without a bun.dryRunOutputFile
|
|
944
|
+
* option, which option to set; with one, the file it was written to (absolute, control characters
|
|
945
|
+
* escaped) or in one line why it could not be written (see src/utils/dry-run-output-log.ts). The file
|
|
946
|
+
* is resolved against the directory Stryker was started in (src/utils/project-dir.ts), and the child's
|
|
947
|
+
* working directory is the one captured at spawn: the sandbox may be gone by now.
|
|
948
|
+
*
|
|
949
|
+
* Never throws or rejects, whatever fails inside it: it is optional, and must not hide or replace the
|
|
950
|
+
* completeness error it accompanies.
|
|
951
|
+
*/
|
|
952
|
+
private saveFailedDryRunOutput;
|
|
953
|
+
/**
|
|
598
954
|
* Dry-run data-completeness gate.
|
|
599
955
|
*
|
|
600
956
|
* A dry run may only be reported Complete when every test bun ran, and every
|
|
@@ -620,9 +976,20 @@ export declare class BunTestRunner implements TestRunner {
|
|
|
620
976
|
* a few ms after the drain acknowledgment on healthy runs. It is added to the
|
|
621
977
|
* message only as context once the gate has already fired.
|
|
622
978
|
*
|
|
623
|
-
*
|
|
979
|
+
* Computed once, here: the reasons the gate fails the run (empty when it does not), so that
|
|
980
|
+
* the caller saves bun's output and builds the message ({@link completenessError}) only
|
|
981
|
+
* for a run that fails, and a healthy one pays nothing for either.
|
|
982
|
+
*
|
|
983
|
+
* @returns The reasons the dry run fails, one sentence each; none when it does not.
|
|
624
984
|
*/
|
|
625
|
-
private
|
|
985
|
+
private findCompletenessProblems;
|
|
986
|
+
/**
|
|
987
|
+
* The Error result for a failed completeness gate: `reasons` (from {@link findCompletenessProblems}), the
|
|
988
|
+
* inspector's unexpected close as context, the advice, and last, on a line of its own, `outputLine`
|
|
989
|
+
* (where bun's complete output was saved, or why it was not, or which option saves it). Logged
|
|
990
|
+
* through logger.error as well.
|
|
991
|
+
*/
|
|
992
|
+
private completenessError;
|
|
626
993
|
/**
|
|
627
994
|
* Collect coverage from the coverage file and remap counter-based IDs to
|
|
628
995
|
* full test names using the inspector's execution order.
|
|
@@ -704,15 +1071,23 @@ export declare class BunTestRunner implements TestRunner {
|
|
|
704
1071
|
*/
|
|
705
1072
|
private logMutantRunSummary;
|
|
706
1073
|
/**
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
1074
|
+
* Append the worker's profile summary, if profiling. Profiling is diagnostic
|
|
1075
|
+
* only: a summary that throws is warned about, never allowed to stop
|
|
1076
|
+
* dispose() from stopping the child and cleaning up.
|
|
1077
|
+
*/
|
|
1078
|
+
private writeProfileSummary;
|
|
1079
|
+
/**
|
|
1080
|
+
* Cleanup resources
|
|
1081
|
+
*
|
|
1082
|
+
* Removes only this worker's own files. The registry, and so the run's private
|
|
1083
|
+
* temp directory holding it, is deliberately left in place: Stryker gives a
|
|
1084
|
+
* worker no signal that it is the last one, and maxTestRunnerReuse, timeouts
|
|
1085
|
+
* and crash recovery dispose (and kill) a worker before forking the fresh
|
|
1086
|
+
* process that replaces it, which must still find the registry (with
|
|
1087
|
+
* concurrency 1 no worker is alive in between, so a "last one out" check would
|
|
1088
|
+
* delete it from under its successor). The run's Stryker main process removes
|
|
1089
|
+
* the directory when it exits (removeRunTempDirsOnExit, src/index.ts).
|
|
1090
|
+
*/
|
|
716
1091
|
dispose(): Promise<void>;
|
|
717
1092
|
}
|
|
718
1093
|
/** Options for {@link withTestFilesExcludedFromTypeCheck}. */
|
|
@@ -880,6 +1255,58 @@ export interface BunTestRunnerOptions {
|
|
|
880
1255
|
* @default 1
|
|
881
1256
|
*/
|
|
882
1257
|
maxSpawnDepth?: number;
|
|
1258
|
+
/**
|
|
1259
|
+
* A file to write the dry run's complete `bun test` output (stdout and stderr) to
|
|
1260
|
+
* when the dry run's data-completeness check fails. Without it nothing is written,
|
|
1261
|
+
* and the error message ends with a line saying to set this option and run again.
|
|
1262
|
+
*
|
|
1263
|
+
* A relative path resolves against the directory Stryker was started in (your
|
|
1264
|
+
* project), not against Stryker's sandbox copy, which is deleted when the run ends;
|
|
1265
|
+
* `inPlace` makes no difference. Missing parent directories are created, and a
|
|
1266
|
+
* symbolic link in a parent directory is followed. Each failure replaces the file
|
|
1267
|
+
* atomically (a new file beside it, mode 0600, renamed over it: an old file is never
|
|
1268
|
+
* truncated in place, and a hard link to it keeps the old content; with several workers
|
|
1269
|
+
* or runs, the last rename wins). A symbolic link, a directory or any other
|
|
1270
|
+
* non-regular file at the path itself is refused. Saving is given a few seconds (5);
|
|
1271
|
+
* if it takes longer the error is reported without it, and says so.
|
|
1272
|
+
*
|
|
1273
|
+
* Removed from the file: ANSI colour codes, the paths of inspector `ws://` addresses,
|
|
1274
|
+
* the fragment of `debug.bun.sh` links and this run's tokens. Everything else the
|
|
1275
|
+
* tests or the command line print, credentials included, is saved as printed:
|
|
1276
|
+
* check the file before sharing it or collecting it in CI. Each stream is kept
|
|
1277
|
+
* whole up to 16 Mi (16 777 216) characters; a longer one is cut in the middle,
|
|
1278
|
+
* and the file says so.
|
|
1279
|
+
*
|
|
1280
|
+
* @example 'reports/bun-dry-run-output.log'
|
|
1281
|
+
*/
|
|
1282
|
+
dryRunOutputFile?: string;
|
|
1283
|
+
/**
|
|
1284
|
+
* Files matched by `mutate` that the dry run imports before the tests even when
|
|
1285
|
+
* no test loads them, so that their module-level code runs before any test.
|
|
1286
|
+
*
|
|
1287
|
+
* `'all'` imports every file `mutate` matches, in one run of the tests. A list
|
|
1288
|
+
* holds glob patterns, matched against the project-relative paths of the files
|
|
1289
|
+
* `mutate` matches (dot directories and dot files included); nothing is globbed
|
|
1290
|
+
* again, so a pattern can only keep a file `mutate` already matched. A file is
|
|
1291
|
+
* kept when any pattern matches it. Negated patterns (`!…`) are not supported. A
|
|
1292
|
+
* pattern that matches none of those files is reported at warn.
|
|
1293
|
+
*
|
|
1294
|
+
* @example ['src/plugins/**', 'src/register.ts']
|
|
1295
|
+
*/
|
|
1296
|
+
alwaysImport?: "all" | string[];
|
|
1297
|
+
/**
|
|
1298
|
+
* How the dry run establishes which mutated files the tests load.
|
|
1299
|
+
*
|
|
1300
|
+
* - `'scan'`: the runner reads the imports of the test files and the preloads.
|
|
1301
|
+
* When that settles the question, the tests run once; when project code could
|
|
1302
|
+
* load a mutated file in a way the reading cannot settle, a plain run of the
|
|
1303
|
+
* tests is observed first.
|
|
1304
|
+
* - `'run'`: a plain run of the tests is always observed first, unless the files
|
|
1305
|
+
* the tests import (with `alwaysImport`) already cover every mutated file.
|
|
1306
|
+
*
|
|
1307
|
+
* @default 'scan'
|
|
1308
|
+
*/
|
|
1309
|
+
importDiscovery?: "scan" | "run";
|
|
883
1310
|
}
|
|
884
1311
|
/**
|
|
885
1312
|
* Extended Stryker options with Bun-specific configuration
|
|
@@ -969,6 +1396,33 @@ export declare const strykerValidationSchema: {
|
|
|
969
1396
|
description: string;
|
|
970
1397
|
default: number;
|
|
971
1398
|
};
|
|
1399
|
+
dryRunOutputFile: {
|
|
1400
|
+
type: string;
|
|
1401
|
+
minLength: number;
|
|
1402
|
+
description: string;
|
|
1403
|
+
};
|
|
1404
|
+
alwaysImport: {
|
|
1405
|
+
description: string;
|
|
1406
|
+
oneOf: ({
|
|
1407
|
+
type: string;
|
|
1408
|
+
enum: string[];
|
|
1409
|
+
items?: undefined;
|
|
1410
|
+
} | {
|
|
1411
|
+
type: string;
|
|
1412
|
+
items: {
|
|
1413
|
+
type: string;
|
|
1414
|
+
minLength: number;
|
|
1415
|
+
pattern: string;
|
|
1416
|
+
};
|
|
1417
|
+
enum?: undefined;
|
|
1418
|
+
})[];
|
|
1419
|
+
};
|
|
1420
|
+
importDiscovery: {
|
|
1421
|
+
type: string;
|
|
1422
|
+
enum: string[];
|
|
1423
|
+
description: string;
|
|
1424
|
+
default: string;
|
|
1425
|
+
};
|
|
972
1426
|
};
|
|
973
1427
|
additionalProperties: boolean;
|
|
974
1428
|
};
|