@hughescr/stryker-bun-runner 1.6.0 → 1.7.0

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/dist/index.d.ts CHANGED
@@ -61,6 +61,8 @@ export declare class BunTestRunner implements TestRunner {
61
61
  private readonly maxChildRss?;
62
62
  private readonly rssCheckIntervalMs?;
63
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?;
64
66
  /** Stryker's coverageAnalysis from the Stryker options; DryRunOptions.coverageAnalysis wins when given. */
65
67
  private readonly coverageAnalysis?;
66
68
  private preloadScriptPath?;
@@ -116,6 +118,26 @@ export declare class BunTestRunner implements TestRunner {
116
118
  private fullSuiteFallbacks;
117
119
  /** Times every run when STRYKER_BUN_PROFILE names a file; undefined otherwise (see src/run-profile.ts). */
118
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;
119
141
  /**
120
142
  * AbortController for whichever `dryRun`/`mutantRun` child process is
121
143
  * currently in flight, if any. Lets {@link dispose} kill an orphaned child
@@ -371,6 +393,26 @@ export declare class BunTestRunner implements TestRunner {
371
393
  * Initialize the test runner
372
394
  */
373
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;
374
416
  /** Create/verify the run's private temp directory (see src/utils/private-temp-dir.ts) and remember it as this worker's tempDir. */
375
417
  private ensureRunTempDir;
376
418
  /**
@@ -439,15 +481,173 @@ export declare class BunTestRunner implements TestRunner {
439
481
  */
440
482
  private buildTestsFromInspector;
441
483
  /**
442
- * Run all tests (dry run). Stryker always passes `options`; only its
443
- * `coverageAnalysis` is read (to judge missing coverage, see
444
- * checkCoverageData), falling back to the Stryker options' value. bun.timeout,
445
- * not `options.timeout` (dryRunTimeoutMinutes), bounds the child.
484
+ * Run all tests (dry run). Stryker always passes `options`; its
485
+ * `coverageAnalysis` decides what coverage the dry run collects and returns
486
+ * (see executeDryRun), 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.
446
489
  */
447
490
  dryRun(options?: DryRunOptions): Promise<DryRunResult>;
448
- /** The dry run itself; split from {@link dryRun} so its many returns all reach the profile. */
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
+ * With coverageAnalysis 'off' none of that applies: Stryker gets no coverage, so one
510
+ * plain inspected run of the tests ({@link runWithoutCoverage}). 'all' takes the
511
+ * same steps as 'perTest' and hands Stryker only which mutants were reached
512
+ * ({@link reachedOnly}).
513
+ */
449
514
  private executeDryRun;
450
515
  /**
516
+ * The dry run for coverageAnalysis 'off': Stryker then runs every test against every
517
+ * mutant and uses no coverage, so nothing the import list, the scan or the plain run
518
+ * would establish is used. One inspected run of the tests, with nothing imported first
519
+ * (bun.alwaysImport is not evaluated). The preload still records a key per test start,
520
+ * with no hit (coverageKeysOnly): that is how a test is credited to the test file that
521
+ * ran it, as with 'perTest', when bun's inspector reports the file of a shared helper
522
+ * that defined it; the completeness gate compares those keys too. Its campaign
523
+ * watches no file: with every test run for every mutant there is no coverage plan that
524
+ * a file the dry run missed could leave incomplete.
525
+ */
526
+ private runWithoutCoverage;
527
+ /** One info line naming bun.alwaysImport and bun.importDiscovery, when set: with coverageAnalysis 'off' neither has an effect. */
528
+ private noteOptionsWithoutEffect;
529
+ /** K: the files of E that bun.alwaysImport keeps, with a warning for each pattern that keeps none. */
530
+ private selectAlwaysImported;
531
+ /** `file` relative to the dry run's project directory, as the messages show it (quoted when it must be, see displayName). */
532
+ private projectPathsOf;
533
+ /** Log `message` at `level`, and at debug, for each list it shortened, the entries it left out (see listText). */
534
+ private logListed;
535
+ /**
536
+ * The import scan's verdict for this dry run (the design's step 2), and its M-scan line.
537
+ * The scan is not even started when the runner cannot name its roots or the command line
538
+ * can change what it would model; either way the answer is then `dynamic`. Its time,
539
+ * whatever the outcome, counts towards d (rule 3.6).
540
+ */
541
+ private decideShape;
542
+ /**
543
+ * The import scan's input: E, K, the tsconfig, and the roots (the test files bun will
544
+ * run, the project's `[test].preload` files and the user's `--preload` files); or why the
545
+ * runner cannot name them exactly, or why its command line, its environment or its bunfig
546
+ * (see bunfigScanProblem) can change what the tests load in a way the scan does not model.
547
+ */
548
+ private importScanInput;
549
+ /** The project's tsconfig.json (or, without one, its jsconfig.json), or null when it has neither. */
550
+ private applicableTsconfig;
551
+ /** 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). */
552
+ private dryRunFiles;
553
+ /** 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. */
554
+ private beforeLaunch;
555
+ /**
556
+ * Launch a published run with `list` (L) imported first: write its plan (the load
557
+ * sensors watch E outside L; a fresh record file), run earlier versions' inspected dry
558
+ * run, and read its record back.
559
+ */
560
+ private runPublished;
561
+ /**
562
+ * Fresh paths for one launch's plan (beside the preload, in the run's private directory)
563
+ * and record: no launch ever follows another's plan or reads another's record.
564
+ */
565
+ private launchFiles;
566
+ /** Remove a launch's plan and record, and the record's temporary file (see writePrivateFileAtomically in preload-logic.ts), however the launch ended. */
567
+ private removeLaunchFiles;
568
+ /**
569
+ * Write `plan` to `planFile`, for the next child of the dry run; without a preload
570
+ * (init() never ran, so no plan path) there is nothing to give it to. A plan that cannot
571
+ * be written is an Error.
572
+ */
573
+ private writePlan;
574
+ /** Read a launch's record and remove its file. */
575
+ private readRecord;
576
+ /** What the rules need to know about a published launch. */
577
+ private launchFacts;
578
+ /** M-eager: warn about each import of the eager loop that threw (the first ten; the rest at debug). */
579
+ private warnEagerFailures;
580
+ /**
581
+ * `full` (step 3, after `full` only 3c and 3d apply): one run with E imported first. A
582
+ * run that is not green goes to discovery when the test files name files in a literal
583
+ * `import()` or `require()` (one of those may be an entry point that breaks the run), and
584
+ * is otherwise returned as earlier versions returned it.
585
+ */
586
+ private runFullShape;
587
+ /**
588
+ * `static` (step 3): one run with the scan's list imported first and the rest watched, judged by {@link oneRunOutcome}.
589
+ *
590
+ * @param roots - The scan's roots: a test file that ran and is not among them was never read by the scan
591
+ */
592
+ private runStaticShape;
593
+ /**
594
+ * The two-run path (step 4): a plain run of the tests is observed, and the run that
595
+ * publishes imports what it was seen to load (with K); then the rules of section 3.
596
+ * After a failed first run with named files (step 3c), a plain run that is not accepted
597
+ * hands back that first run's own result instead of an Error.
598
+ */
599
+ private runTwoRuns;
600
+ /** The published run of the two-run path, judged by {@link twoRunOutcome} (rule 3.5). */
601
+ private runAfterDiscovery;
602
+ /** The messages of a two-run publication: M-G3a, M1 (when something is left out) and, after step 3c, M-named. */
603
+ private reportTwoRunPublication;
604
+ /**
605
+ * Launch the discovery run (the design's section 2.2): the published run's `bun test`
606
+ * command line, bunfig and preloads, without the inspector and the sync server, nothing
607
+ * imported first, the sensors watching E, bounded by bun.timeout; and judge it with
608
+ * {@link acceptDiscovery}.
609
+ */
610
+ private runDiscovery;
611
+ /** M-refuse: the load sensors cannot be trusted. Nothing is persisted. */
612
+ private refuseDryRun;
613
+ /**
614
+ * M-P1: the plain run of the tests was not accepted. The message carries bun's own
615
+ * output through the diagnostics the completeness error uses: the "Unhandled error
616
+ * between tests" blocks, else the tail of the output, and the line about
617
+ * bun.dryRunOutputFile.
618
+ */
619
+ private discoveryError;
620
+ /** M-G3b: candidates the plain run did not load were loaded after the published run's imports. */
621
+ private lateLoadError;
622
+ /**
623
+ * M-lost: mutant ids the plain run reached and the published run did not; their files are read from the instrumented sources.
624
+ *
625
+ * @param always - How many files of `list` only bun.alwaysImport kept
626
+ */
627
+ private lostError;
628
+ /**
629
+ * Hand Stryker a published run's result: persist the registry (for a green run with the
630
+ * timeout correction and the campaign: a new generation, the watch list W of the files E
631
+ * outside L and `seen`, none with coverageAnalysis 'off') and give the warnings of a completed run, then return it. Only
632
+ * a Complete result has anything to persist; any other is returned as it is. A run whose
633
+ * watch list cannot be published with its registry is an Error instead.
634
+ *
635
+ * @param seen - Files of E outside L the run's sensors saw (and so loaded): not watched; none by default
636
+ */
637
+ private publishDryRun;
638
+ /**
639
+ * Earlier versions' inspected dry run, once: the sync server, the `bun test` child with
640
+ * the inspector, the completeness gate and the mapper. It writes nothing that outlives
641
+ * it: the result comes back with what persisting it needs (see {@link publishDryRun}).
642
+ */
643
+ private runInspectedPass;
644
+ /**
645
+ * {@link runInspectedPass} with its coverage file: everything from the sync server to the result.
646
+ *
647
+ * @param launched - Where it puts the child's promise once the child is started
648
+ */
649
+ private runInspectedChild;
650
+ /**
451
651
  * The dry run's coverageAnalysis: Stryker's DryRunOptions value, else the
452
652
  * Stryker options' value. Extracted to keep dryRun()'s complexity under the
453
653
  * lint threshold.
@@ -461,14 +661,13 @@ export declare class BunTestRunner implements TestRunner {
461
661
  private warnOnAbnormalDrainData;
462
662
  /**
463
663
  * Post-child-exit dry-run pipeline: collect/remap coverage, build tests
464
- * from inspector data, sort them for incremental-mode determinism, run the
465
- * completeness gate, and — only if the gate passes — persist the test
466
- * registry. Returns the gate's Error result when it fires, otherwise the
467
- * Complete result.
664
+ * from inspector data, sort them for incremental-mode determinism, and run
665
+ * the completeness gate. Returns the gate's Error result when it fires,
666
+ * otherwise the Complete result with what persisting it needs: the registry
667
+ * is written only once the dry run's rules pass (see publishDryRun).
468
668
  *
469
- * Extracted from dryRun() purely to keep dryRun()'s own cyclomatic
470
- * complexity under the lint threshold; this is a pure code move — same call
471
- * order and same early-return-on-gate-failure semantics as before.
669
+ * Extracted from runInspectedPass() purely to keep its own cyclomatic
670
+ * complexity under the lint threshold.
472
671
  */
473
672
  private buildGatedDryRunResult;
474
673
  /**
@@ -482,24 +681,30 @@ export declare class BunTestRunner implements TestRunner {
482
681
  * means the preload never ran, could not write (it logs a `[Stryker Coverage]`
483
682
  * line on the child's stderr), or the child exited before that afterAll.
484
683
  *
485
- * - coverageAnalysis 'perTest': the user asked for per-test coverage, and
684
+ * - coverageAnalysis 'perTest' or 'all': the user asked for coverage, and
486
685
  * silently running the full suite per mutant can turn a run of minutes into
487
- * hours — fail the dry run (Error), naming the file and likely causes.
488
- * 'all'/'off' remain available to run without it.
489
- * - 'all' (or unknown): warn with the same explanation; the run is correct, only slower.
490
- * - 'off': Stryker wants no coverage; say nothing.
686
+ * hours (with 'all', Stryker would plan as for 'off') — fail the dry run
687
+ * (Error), naming the file and likely causes. 'off' remains available to run
688
+ * without it. A present but empty coverage is not missing.
689
+ * - unknown: warn with the same explanation; the run is correct, only slower.
690
+ * - 'off': the file holds only the test keys that say which test file ran each
691
+ * test (see runWithoutCoverage); without it a test a shared helper defines is
692
+ * credited to the helper's file, so warn, and go on.
491
693
  * A dry run with failed tests is left alone: Stryker stops on those anyway,
492
694
  * and its failed-test report is the more useful message.
493
695
  *
494
696
  * When coverage exists but covers no mutant at all, every mutant will be
495
697
  * NoCoverage (Stryker's executeNoCoverage) — warn, since that is a legitimate
496
- * outcome only when the tests really never touch the mutated files.
698
+ * outcome only when the tests really never touch the mutated files ('off' records
699
+ * no hit, so it is not judged).
497
700
  *
498
701
  * `[Stryker Coverage]` diagnostics from the preload are otherwise dropped on a
499
702
  * green run (the child's stderr is only shown on failure), so they are
500
703
  * surfaced at warn here, or folded into the missing-coverage message.
501
704
  */
502
705
  private checkCoverageData;
706
+ /** {@link checkCoverageData} for a green dry run whose coverage file was missing, unreadable or empty. */
707
+ private missingCoverageResult;
503
708
  /**
504
709
  * Warn when a completed dry run used more than {@link DRY_RUN_TIMEOUT_WARN_RATIO}
505
710
  * of bun.timeout. bun.timeout now governs only the dry run (mutant runs follow
@@ -517,8 +722,44 @@ export declare class BunTestRunner implements TestRunner {
517
722
  *
518
723
  * Writing to a .tmp path then renaming is atomic on POSIX: readers always see
519
724
  * either the previous complete file or the new one — never a partial write.
725
+ *
726
+ * With `campaignInput` (a green run) the registry also starts the campaign (see
727
+ * src/coverage/dry-run-files.ts): a new generation, which makes every abort marker of
728
+ * an earlier one stale (the stale marker is removed once the registry is in place),
729
+ * and, when the list was shortened, the watch list W the mutant runs' witness reads,
730
+ * written under the generation's own name before the registry that names it is
731
+ * renamed into place, last. And it carries the timeout correction every worker's
732
+ * mutant runs apply. Without it (a run with failing tests) the registry is the one
733
+ * earlier versions wrote.
734
+ *
735
+ * A registry that cannot be written is only warned about, as in earlier versions,
736
+ * unless the campaign has a watch list (its mutant runs would then not watch what the
737
+ * dry run left out) or an earlier run's registry stays in place (other workers would
738
+ * load it for this campaign): the failure is then returned, as the dry run's Error message.
739
+ *
740
+ * @returns Undefined, or the Error message when a campaign could not be published (see registryWriteFailed)
520
741
  */
521
742
  private buildAndPersistTestRegistry;
743
+ /**
744
+ * A registry write failed: the dry run's Error message (M-publish) when the campaign has a
745
+ * watch list, naming the file that could not be written. For any other green run (a
746
+ * campaign) it is an Error too when an earlier run's registry is still in place: other
747
+ * workers would load its test names, test-file selection and the rest for this campaign.
748
+ * Otherwise a warning, as in earlier versions (the worker that ran the dry run still has
749
+ * its in-memory copy; other workers fall back to raw names and log a warning), and undefined.
750
+ */
751
+ private registryWriteFailed;
752
+ /**
753
+ * {@link buildAndPersistTestRegistry}'s writes: the campaign's watch list (when it has one),
754
+ * then the registry, renamed into place last, then the stale marker's removal. A write that
755
+ * fails is a {@link WriteFailure} naming its file; a watch list no registry names is removed.
756
+ */
757
+ private writeRegistry;
758
+ /**
759
+ * A new campaign's state for the registry: a new generation, W, and (inPlace only) the
760
+ * fingerprint of E; W is written first, under the generation's own name.
761
+ */
762
+ private writeCampaignFiles;
522
763
  /**
523
764
  * Warn that the dry-run registry could not be written. The registry also carries
524
765
  * Stryker's testFiles selection, so when one is active the warning adds that other
@@ -540,6 +781,27 @@ export declare class BunTestRunner implements TestRunner {
540
781
  */
541
782
  mutantRun(options: MutantRunOptions): Promise<MutantRunResult>;
542
783
  /**
784
+ * Stryker's per-mutant timeout less the dry run's correction (rule 3.6), once, before the
785
+ * runner's own margin: Stryker sizes the timeout from the dry run's overhead, which the
786
+ * import scan, a discarded run and a discovery run would otherwise lengthen. A missing or
787
+ * unusable correction leaves Stryker's value as it is, and says so once at debug.
788
+ */
789
+ private correctedStrykerTimeout;
790
+ /** The watch list every mutant run's child gets: the campaign's, when it watches anything. */
791
+ private watchListForMutantRuns;
792
+ /**
793
+ * The witness's verdict on a mutant run's child, which comes before the child's own
794
+ * (Killed, Survived, Timeout): a valid line, signed with this spawn's token and naming
795
+ * only files of W, means a watched file was in bun's module cache when the mutant first
796
+ * executed. The worker then writes the abort marker for its campaign and rejects the
797
+ * mutant run with M-witness; Stryker's recovery init() then rejects too (see
798
+ * rejectIfCampaignStopped), which ends the campaign. An unusable watch list the child
799
+ * reported is warned about once, and the run's own verdict stands.
800
+ */
801
+ private enforceWitness;
802
+ /** 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). */
803
+ private witnessScope;
804
+ /**
543
805
  * Recognise a testFilter that is a list of test FILES rather than test ids.
544
806
  *
545
807
  * Stryker core's own `testFiles` option (9.6+, also 10) makes the mutant
@@ -672,6 +934,8 @@ export declare class BunTestRunner implements TestRunner {
672
934
  /**
673
935
  * Check for dry run process failures (timeout or non-zero exit).
674
936
  * Returns a DryRunResult to short-circuit if the process failed, or null to proceed.
937
+ * The child's stderr goes into the message as the diagnostics show it ({@link cleanDiagnosticText}):
938
+ * it can carry an inspector address, the run's secrets, or an import error that holds either.
675
939
  */
676
940
  private checkDryRunProcessResult;
677
941
  /**
@@ -704,6 +968,17 @@ export declare class BunTestRunner implements TestRunner {
704
968
  */
705
969
  private warnOnUnidentifiedDryRunFailure;
706
970
  /**
971
+ * The last line of a completeness error, about bun's complete output: without a bun.dryRunOutputFile
972
+ * option, which option to set; with one, the file it was written to (absolute, control characters
973
+ * escaped) or in one line why it could not be written (see src/utils/dry-run-output-log.ts). The file
974
+ * is resolved against the directory Stryker was started in (src/utils/project-dir.ts), and the child's
975
+ * working directory is the one captured at spawn: the sandbox may be gone by now.
976
+ *
977
+ * Never throws or rejects, whatever fails inside it: it is optional, and must not hide or replace the
978
+ * completeness error it accompanies.
979
+ */
980
+ private saveFailedDryRunOutput;
981
+ /**
707
982
  * Dry-run data-completeness gate.
708
983
  *
709
984
  * A dry run may only be reported Complete when every test bun ran, and every
@@ -729,17 +1004,29 @@ export declare class BunTestRunner implements TestRunner {
729
1004
  * a few ms after the drain acknowledgment on healthy runs. It is added to the
730
1005
  * message only as context once the gate has already fired.
731
1006
  *
732
- * @returns A DryRunStatus.Error result if the gate fires, otherwise null.
1007
+ * Computed once, here: the reasons the gate fails the run (empty when it does not), so that
1008
+ * the caller saves bun's output and builds the message ({@link completenessError}) only
1009
+ * for a run that fails, and a healthy one pays nothing for either.
1010
+ *
1011
+ * @returns The reasons the dry run fails, one sentence each; none when it does not.
1012
+ */
1013
+ private findCompletenessProblems;
1014
+ /**
1015
+ * The Error result for a failed completeness gate: `reasons` (from {@link findCompletenessProblems}), the
1016
+ * inspector's unexpected close as context, the advice, and last, on a line of its own, `outputLine`
1017
+ * (where bun's complete output was saved, or why it was not, or which option saves it). Logged
1018
+ * through logger.error as well.
733
1019
  */
734
- private checkCompletenessGate;
1020
+ private completenessError;
735
1021
  /**
736
1022
  * Collect coverage from the coverage file and remap counter-based IDs to
737
1023
  * full test names using the inspector's execution order.
738
1024
  *
739
1025
  * Also collects any cross-test async coverage-bleed observations recorded
740
1026
  * by the preload (see {@link emitCoverageBleedWarnings}) and warns about
741
- * them. This method's sole call site is dryRun, so bleed detection is
742
- * dry-run-only by construction — mutant runs never reach this code.
1027
+ * them, except with coverageAnalysis 'all' and 'off', which hand Stryker no per-test
1028
+ * attribution for a bleed to get wrong ('off' records no hit at all). This method's sole call site is dryRun,
1029
+ * so bleed detection is dry-run-only by construction — mutant runs never reach this code.
743
1030
  */
744
1031
  private collectAndRemapCoverage;
745
1032
  /**
@@ -997,6 +1284,58 @@ export interface BunTestRunnerOptions {
997
1284
  * @default 1
998
1285
  */
999
1286
  maxSpawnDepth?: number;
1287
+ /**
1288
+ * A file to write the dry run's complete `bun test` output (stdout and stderr) to
1289
+ * when the dry run's data-completeness check fails. Without it nothing is written,
1290
+ * and the error message ends with a line saying to set this option and run again.
1291
+ *
1292
+ * A relative path resolves against the directory Stryker was started in (your
1293
+ * project), not against Stryker's sandbox copy, which is deleted when the run ends;
1294
+ * `inPlace` makes no difference. Missing parent directories are created, and a
1295
+ * symbolic link in a parent directory is followed. Each failure replaces the file
1296
+ * atomically (a new file beside it, mode 0600, renamed over it: an old file is never
1297
+ * truncated in place, and a hard link to it keeps the old content; with several workers
1298
+ * or runs, the last rename wins). A symbolic link, a directory or any other
1299
+ * non-regular file at the path itself is refused. Saving is given a few seconds (5);
1300
+ * if it takes longer the error is reported without it, and says so.
1301
+ *
1302
+ * Removed from the file: ANSI colour codes, the paths of inspector `ws://` addresses,
1303
+ * the fragment of `debug.bun.sh` links and this run's tokens. Everything else the
1304
+ * tests or the command line print, credentials included, is saved as printed:
1305
+ * check the file before sharing it or collecting it in CI. Each stream is kept
1306
+ * whole up to 16 Mi (16 777 216) characters; a longer one is cut in the middle,
1307
+ * and the file says so.
1308
+ *
1309
+ * @example 'reports/bun-dry-run-output.log'
1310
+ */
1311
+ dryRunOutputFile?: string;
1312
+ /**
1313
+ * Files matched by `mutate` that the dry run imports before the tests even when
1314
+ * no test loads them, so that their module-level code runs before any test.
1315
+ *
1316
+ * `'all'` imports every file `mutate` matches, in one run of the tests. A list
1317
+ * holds glob patterns, matched against the project-relative paths of the files
1318
+ * `mutate` matches (dot directories and dot files included); nothing is globbed
1319
+ * again, so a pattern can only keep a file `mutate` already matched. A file is
1320
+ * kept when any pattern matches it. Negated patterns (`!…`) are not supported. A
1321
+ * pattern that matches none of those files is reported at warn.
1322
+ *
1323
+ * @example ['src/plugins/**', 'src/register.ts']
1324
+ */
1325
+ alwaysImport?: "all" | string[];
1326
+ /**
1327
+ * How the dry run establishes which mutated files the tests load.
1328
+ *
1329
+ * - `'scan'`: the runner reads the imports of the test files and the preloads.
1330
+ * When that settles the question, the tests run once; when project code could
1331
+ * load a mutated file in a way the reading cannot settle, a plain run of the
1332
+ * tests is observed first.
1333
+ * - `'run'`: a plain run of the tests is always observed first, unless the files
1334
+ * the tests import (with `alwaysImport`) already cover every mutated file.
1335
+ *
1336
+ * @default 'scan'
1337
+ */
1338
+ importDiscovery?: "scan" | "run";
1000
1339
  }
1001
1340
  /**
1002
1341
  * Extended Stryker options with Bun-specific configuration
@@ -1086,6 +1425,33 @@ export declare const strykerValidationSchema: {
1086
1425
  description: string;
1087
1426
  default: number;
1088
1427
  };
1428
+ dryRunOutputFile: {
1429
+ type: string;
1430
+ minLength: number;
1431
+ description: string;
1432
+ };
1433
+ alwaysImport: {
1434
+ description: string;
1435
+ oneOf: ({
1436
+ type: string;
1437
+ enum: string[];
1438
+ items?: undefined;
1439
+ } | {
1440
+ type: string;
1441
+ items: {
1442
+ type: string;
1443
+ minLength: number;
1444
+ pattern: string;
1445
+ };
1446
+ enum?: undefined;
1447
+ })[];
1448
+ };
1449
+ importDiscovery: {
1450
+ type: string;
1451
+ enum: string[];
1452
+ description: string;
1453
+ default: string;
1454
+ };
1089
1455
  };
1090
1456
  additionalProperties: boolean;
1091
1457
  };