@hughescr/stryker-bun-runner 1.7.2 → 1.8.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 +343 -26
- package/dist/index.d.ts +111 -10
- package/dist/index.js +752 -180
- package/dist/templates/import-scan.js +1644 -21
- package/package.json +25 -19
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
// Generated by dts-bundle-generator
|
|
1
|
+
// Generated by dts-bundle-generator v10.0.0
|
|
2
2
|
|
|
3
3
|
import { PartialStrykerOptions, StrykerOptions } from '@stryker-mutator/api/core';
|
|
4
4
|
import { Logger } from '@stryker-mutator/api/logging';
|
|
5
5
|
import { PluginKind } from '@stryker-mutator/api/plugin';
|
|
6
6
|
import { DryRunOptions, DryRunResult, MutantRunOptions, MutantRunResult, TestRunner, TestRunnerCapabilities } from '@stryker-mutator/api/test-runner';
|
|
7
7
|
|
|
8
|
+
interface HandOffBudget {
|
|
9
|
+
/** Wall time in milliseconds of all the hand-off work: reading hand-offs in the files the answer reads, the walk over H's closure, and reading the mutant ids of H's files. */
|
|
10
|
+
readonly wallMs: number;
|
|
11
|
+
/** How many files the walk over H's closure may visit. */
|
|
12
|
+
readonly files: number;
|
|
13
|
+
/** How many mutant ids H's files may hold in all. */
|
|
14
|
+
readonly ids: number;
|
|
15
|
+
}
|
|
8
16
|
/**
|
|
9
17
|
* Bun test runner for Stryker mutation testing
|
|
10
18
|
*/
|
|
@@ -40,6 +48,13 @@ export declare class BunTestRunner implements TestRunner {
|
|
|
40
48
|
* ascending order of it; undefined when neither had any, and the order is then left alone.
|
|
41
49
|
*/
|
|
42
50
|
private testFileDurations?;
|
|
51
|
+
/**
|
|
52
|
+
* The ids of each test file's tests that ran in the dry run (project-relative file → ids; see
|
|
53
|
+
* indexTestIdsByFile), from this worker's dry run or the shared registry; undefined when
|
|
54
|
+
* neither had a usable one. Credits a test file that failed to load in a mutant run with its
|
|
55
|
+
* tests (see creditFilesThatFailedToLoad).
|
|
56
|
+
*/
|
|
57
|
+
private testIdsByFile?;
|
|
43
58
|
/**
|
|
44
59
|
* Which test files' tests executed which mutants in the dry run, from this worker's dry
|
|
45
60
|
* run or the shared registry; undefined when neither had any. Ranks a static mutant's
|
|
@@ -65,6 +80,8 @@ export declare class BunTestRunner implements TestRunner {
|
|
|
65
80
|
private readonly dryRunOutputFile?;
|
|
66
81
|
/** Stryker's coverageAnalysis from the Stryker options; DryRunOptions.coverageAnalysis wins when given. */
|
|
67
82
|
private readonly coverageAnalysis?;
|
|
83
|
+
/** Stryker's ignoreStatic: whether the dry run credits each test with the handed mutants credited to every test (see creditHandedCoverage). */
|
|
84
|
+
private readonly ignoreStatic;
|
|
68
85
|
private preloadScriptPath?;
|
|
69
86
|
private coverageFilePath?;
|
|
70
87
|
private sanitizedBunfigPath?;
|
|
@@ -134,7 +151,11 @@ export declare class BunTestRunner implements TestRunner {
|
|
|
134
151
|
private timeoutCorrectionMs?;
|
|
135
152
|
/** True once the "no usable timeout correction" debug line has been logged; it is shown once per runner. */
|
|
136
153
|
private loggedUnusableCorrection;
|
|
137
|
-
/**
|
|
154
|
+
/**
|
|
155
|
+
* The campaign of this worker's dry run or of the registry, the run directory its files are
|
|
156
|
+
* in, and its watch list and the files whose mutants it credited for being handed to a worker
|
|
157
|
+
* or a child process as sets (built once, for every mutant run's witness check and hit limit).
|
|
158
|
+
*/
|
|
138
159
|
private campaign?;
|
|
139
160
|
/** True once a mutant run's unusable watch list has been warned about; it is shown once per runner. */
|
|
140
161
|
private warnedWatchListProblem;
|
|
@@ -151,6 +172,12 @@ export declare class BunTestRunner implements TestRunner {
|
|
|
151
172
|
* shortens it, to make a real bun child's fallback wait short.
|
|
152
173
|
*/
|
|
153
174
|
protected readonly drainSilenceMs: number;
|
|
175
|
+
/**
|
|
176
|
+
* The import scan's hand-off budget (see HAND_OFF_BUDGET in import-scan-runner.ts). Not an
|
|
177
|
+
* option: a subclass in tests/00-integration/worker-child-integration.test.ts shrinks it,
|
|
178
|
+
* so that a real helper goes over it without hundreds of megabytes of files.
|
|
179
|
+
*/
|
|
180
|
+
protected readonly handOffBudget: HandOffBudget;
|
|
154
181
|
constructor(logger: Logger, options: StrykerOptions);
|
|
155
182
|
/**
|
|
156
183
|
* Single source of truth for the registry file name.
|
|
@@ -548,6 +575,14 @@ export declare class BunTestRunner implements TestRunner {
|
|
|
548
575
|
private selectAlwaysImported;
|
|
549
576
|
/** `file` relative to the dry run's project directory, as the messages show it (quoted when it must be, see displayName). */
|
|
550
577
|
private projectPathsOf;
|
|
578
|
+
/**
|
|
579
|
+
* How publication credits the mutants of each file of H ({@link handedCredits}), from the published run's `tests`:
|
|
580
|
+
* which test belongs to which file is read from them, except with coverageAnalysis 'all' (where Stryker runs every
|
|
581
|
+
* test for any mutant reached); then, as for a file the scan names no launcher of, every test.
|
|
582
|
+
*/
|
|
583
|
+
private handedCreditsOf;
|
|
584
|
+
/** The files of H among `notLoaded` that hold a mutant id, by how publication credits them (M1 names them), as the messages show them. */
|
|
585
|
+
private handedSummary;
|
|
551
586
|
/** Log `message` at `level`, and at debug, for each list it shortened, the entries it left out (see listText). */
|
|
552
587
|
private logListed;
|
|
553
588
|
/**
|
|
@@ -650,9 +685,23 @@ export declare class BunTestRunner implements TestRunner {
|
|
|
650
685
|
* a Complete result has anything to persist; any other is returned as it is. A run whose
|
|
651
686
|
* watch list cannot be published with its registry is an Error instead.
|
|
652
687
|
*
|
|
688
|
+
* The mutants of the files of H, whether or not the run also loaded them in the test
|
|
689
|
+
* process, are credited to the tests of the test files that start them, or to every test
|
|
690
|
+
* ({@link handedCredits}, {@link creditHandedCoverage}), in the result handed to Stryker
|
|
691
|
+
* only, after every check; the files of H that hold an id are stored with the campaign,
|
|
692
|
+
* before the registry is written, for their mutants' runs, which have neither the witness
|
|
693
|
+
* nor a hit limit (see mutantRunGuards). Nothing after the registry is written depends on
|
|
694
|
+
* how many ids there are.
|
|
695
|
+
*
|
|
653
696
|
* @param seen - Files of E outside L the run's sensors saw (and so loaded): not watched; none by default
|
|
654
697
|
*/
|
|
655
698
|
private publishDryRun;
|
|
699
|
+
/**
|
|
700
|
+
* When the coverage exists but covers no mutant at all, every mutant will be NoCoverage
|
|
701
|
+
* (Stryker's executeNoCoverage): warn, since that is a legitimate outcome only when the
|
|
702
|
+
* tests really never touch the mutated files ('off' records no hit, so it is not judged).
|
|
703
|
+
*/
|
|
704
|
+
private warnIfNoMutantCovered;
|
|
656
705
|
/**
|
|
657
706
|
* Earlier versions' inspected dry run, once: the sync server, the `bun test` child with
|
|
658
707
|
* the inspector, the completeness gate and the mapper. It writes nothing that outlives
|
|
@@ -712,9 +761,10 @@ export declare class BunTestRunner implements TestRunner {
|
|
|
712
761
|
* and its failed-test report is the more useful message.
|
|
713
762
|
*
|
|
714
763
|
* When coverage exists but covers no mutant at all, every mutant will be
|
|
715
|
-
* NoCoverage (Stryker's executeNoCoverage) — warn
|
|
716
|
-
*
|
|
717
|
-
* no
|
|
764
|
+
* NoCoverage (Stryker's executeNoCoverage) — warn ({@link warnIfNoMutantCovered}).
|
|
765
|
+
* When a file of H holds a mutant id (`handedIdsHeld`), there is no warning:
|
|
766
|
+
* a coverage that covers nothing measures no id as static, so publication
|
|
767
|
+
* credits that id, and some mutant is covered.
|
|
718
768
|
*
|
|
719
769
|
* `[Stryker Coverage]` diagnostics from the preload are otherwise dropped on a
|
|
720
770
|
* green run (the child's stderr is only shown on failure), so they are
|
|
@@ -774,9 +824,11 @@ export declare class BunTestRunner implements TestRunner {
|
|
|
774
824
|
*/
|
|
775
825
|
private writeRegistry;
|
|
776
826
|
/**
|
|
777
|
-
* A new campaign's state for the registry: a new generation, W,
|
|
778
|
-
*
|
|
779
|
-
*
|
|
827
|
+
* A new campaign's state for the registry: a new generation, W, the files of H whose
|
|
828
|
+
* mutants publication credited for being handed to a worker or a child process, and
|
|
829
|
+
* (inPlace only) the fingerprint of every file matched by mutate (test files included,
|
|
830
|
+
* as init() computes it in rejectIfCampaignStopped); W is written first, under the
|
|
831
|
+
* generation's own name. The state goes into the registry, which is renamed into place.
|
|
780
832
|
*/
|
|
781
833
|
private writeCampaignFiles;
|
|
782
834
|
/**
|
|
@@ -806,6 +858,22 @@ export declare class BunTestRunner implements TestRunner {
|
|
|
806
858
|
* unusable correction leaves Stryker's value as it is, and says so once at debug.
|
|
807
859
|
*/
|
|
808
860
|
private correctedStrykerTimeout;
|
|
861
|
+
/**
|
|
862
|
+
* The file of the active mutant (Stryker's `sandboxFileName`, the file as E names it) when
|
|
863
|
+
* the campaign credited its mutants for being handed to a worker or a child process, to the
|
|
864
|
+
* tests that start it or to every test; undefined otherwise.
|
|
865
|
+
*/
|
|
866
|
+
private handedFileOf;
|
|
867
|
+
/**
|
|
868
|
+
* The hit limit and the watch list of a mutant run's child. A mutant of a file handed to a
|
|
869
|
+
* worker or a child process, however publication credited it, may run there first: what the
|
|
870
|
+
* tests load and execute in the test process afterwards (a fallback that imports a support
|
|
871
|
+
* file and the handed file, and runs its code many times) follows from the mutant. So its run
|
|
872
|
+
* has no witness, which looks only at the mutant's first execution in the test process, and
|
|
873
|
+
* no hit limit, which Stryker derived from hits that measured nothing of the worker or the
|
|
874
|
+
* child (see creditHandedCoverage); the run's timeout still applies. Every other run gets both.
|
|
875
|
+
*/
|
|
876
|
+
private mutantRunGuards;
|
|
809
877
|
/** The watch list every mutant run's child gets: the campaign's, when it watches anything. */
|
|
810
878
|
private watchListForMutantRuns;
|
|
811
879
|
/**
|
|
@@ -887,7 +955,9 @@ export declare class BunTestRunner implements TestRunner {
|
|
|
887
955
|
* Classify a non-zero, non-signal, non-timeout mutant run in which no
|
|
888
956
|
* individual test reported a failure. Returns an Error result when there is
|
|
889
957
|
* no evidence the mutant was detected, or null to let the caller score it
|
|
890
|
-
* Killed (
|
|
958
|
+
* Killed (no single test failed, so killedBy holds the selected tests of the
|
|
959
|
+
* test files that failed to load when they can be told for certain, and is
|
|
960
|
+
* otherwise empty: see creditFilesThatFailedToLoad).
|
|
891
961
|
*
|
|
892
962
|
* Killed needs evidence that the suite failed, and bun's summary is that
|
|
893
963
|
* evidence: a non-zero ' N fail' (or 'Bailed out after N failures') or
|
|
@@ -1106,6 +1176,36 @@ export declare class BunTestRunner implements TestRunner {
|
|
|
1106
1176
|
*/
|
|
1107
1177
|
private resolveKilledBy;
|
|
1108
1178
|
/**
|
|
1179
|
+
* A Killed run's killedBy: its failing tests (see resolveKilledBy), or, when no
|
|
1180
|
+
* test failed (a non-zero exit with a fail or error count: see
|
|
1181
|
+
* classifyRunWithoutFailedTest), the tests of the test files bun reported
|
|
1182
|
+
* failing to load, when they can be told (see creditFilesThatFailedToLoad).
|
|
1183
|
+
*/
|
|
1184
|
+
private killersOf;
|
|
1185
|
+
/**
|
|
1186
|
+
* killedBy for a run in which no test failed but bun reported a failure (see
|
|
1187
|
+
* classifyRunWithoutFailedTest): the selected tests of each test file that bun
|
|
1188
|
+
* printed an "Unhandled error between tests" block right below the header of,
|
|
1189
|
+
* when bun's summary shows that no test ran at all (see creditLoadFailures for
|
|
1190
|
+
* every condition). The file is the header's, not a stack frame's: a load
|
|
1191
|
+
* failure's frames name the module that threw. The header must name exactly one
|
|
1192
|
+
* of the files this spawn handed bun (`testFiles`), so a file outside the run (a
|
|
1193
|
+
* file Stryker's testFiles option left out, say) is never credited, and a spawn
|
|
1194
|
+
* that handed bun no list credits nothing.
|
|
1195
|
+
*
|
|
1196
|
+
* Selected means the mutant's covering tests when it has any (localRegistry),
|
|
1197
|
+
* also on a full-suite fallback: that run loaded more files than Stryker planned
|
|
1198
|
+
* for, and crediting only the planned tests keeps killedBy within the covering
|
|
1199
|
+
* set. Without covering tests (a static mutant, coverageAnalysis 'off' or 'all',
|
|
1200
|
+
* a run of Stryker's testFiles) every test of the file that ran in the dry run is
|
|
1201
|
+
* selected.
|
|
1202
|
+
*
|
|
1203
|
+
* Every id comes from testIdsByFile, so each is a dry-run TestResult.id (see
|
|
1204
|
+
* resolveKilledBy for why nothing else may be). When nothing is credited the
|
|
1205
|
+
* caller warns as for any other unattributable kill.
|
|
1206
|
+
*/
|
|
1207
|
+
private creditFilesThatFailedToLoad;
|
|
1208
|
+
/**
|
|
1109
1209
|
* WARN about failed test names that could not be resolved to dry-run test
|
|
1110
1210
|
* ids (and are therefore dropped from killedBy by resolveKilledBy). WARN,
|
|
1111
1211
|
* not debug — the old debug-level log is why the resulting cache poisoning
|
|
@@ -1170,7 +1270,8 @@ export interface TestFilesExcludedFromTypeCheckOptions {
|
|
|
1170
1270
|
* Logs one line per call: `console.info` on success, `console.warn` with the
|
|
1171
1271
|
* reason on every fallback. Returns `config` itself, writing nothing, when
|
|
1172
1272
|
* `checkers` does not include `typescript`, typescript cannot be loaded from
|
|
1173
|
-
* `cwd
|
|
1273
|
+
* `cwd` or exports no compiler API to read the tsconfig with (a shim, or TypeScript
|
|
1274
|
+
* 7 or later, which gets its own reason), the tsconfig is missing, has errors or uses project references,
|
|
1174
1275
|
* includes no test files, would be left with no files at all, leaving the tests
|
|
1175
1276
|
* out adds type errors, or the derived file cannot be written or belongs to
|
|
1176
1277
|
* somebody else (it has no generated header).
|