@hughescr/stryker-bun-runner 1.7.2 → 1.8.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/README.md +333 -23
- package/dist/index.d.ts +71 -9
- package/dist/index.js +585 -164
- package/dist/templates/import-scan.js +1644 -21
- package/package.json +25 -19
package/README.md
CHANGED
|
@@ -208,9 +208,19 @@ What can change after you upgrade:
|
|
|
208
208
|
imported, to see which files they load ([details](#if-the-dry-run-runs-your-tests-twice)).
|
|
209
209
|
- **A test that passed only because a file was imported first** can now fail, and the dry run
|
|
210
210
|
stops ([what to do](#if-the-first-plain-run-of-the-tests-fails)).
|
|
211
|
-
- **A file that only a package
|
|
212
|
-
|
|
213
|
-
|
|
211
|
+
- **A file that only a package loads** is not seen by the runner. List it in `bun.alwaysImport`.
|
|
212
|
+
If a mutant run later finds that a package loaded such a file, it stops the Stryker run and names
|
|
213
|
+
the file ([what to do](#if-a-mutant-run-stops-the-campaign)).
|
|
214
|
+
- **A file that the tests run in a worker or a child process** now has its mutants tested.
|
|
215
|
+
Before, a mutant there that no test reached in the test process was NoCoverage. When the path is
|
|
216
|
+
written out in the call that starts the worker or the child (for a child, as the script that bun
|
|
217
|
+
or node runs), the runner reports every mutant of that file as covered by the tests in the test
|
|
218
|
+
files that start it, so Stryker runs those tests against each of them; when a preload may start
|
|
219
|
+
it, or the runner cannot tell all the test files that do, by every test too (a
|
|
220
|
+
[static mutant](#terms)), beside the tests of the test files it knows to start it. This
|
|
221
|
+
holds also for a file that a test imports as well. The runner does not import a file in the test
|
|
222
|
+
process because the tests hand it to a worker or a child
|
|
223
|
+
([details](#if-a-test-runs-a-mutated-file-in-a-worker-or-a-child-process)).
|
|
214
224
|
- **`coverageAnalysis: 'all'` and `'off'` now do what Stryker says they do**
|
|
215
225
|
([coverageAnalysis](#coverageanalysis)). Before, the runner gave Stryker per-test coverage
|
|
216
226
|
whatever the value, so they behaved like `'perTest'`. Now, with `'all'`, each mutant that some
|
|
@@ -473,6 +483,13 @@ differ with `'off'` as well:
|
|
|
473
483
|
Stryker cannot see that a new or changed test now reaches a mutant, so it keeps the earlier result
|
|
474
484
|
of a mutant that was Survived or NoCoverage. With these values, run with `--force` (or set
|
|
475
485
|
`incremental: false`) each time you need results that reflect your current tests, not only once.
|
|
486
|
+
The same holds, with any value, for the mutants of the files that your tests
|
|
487
|
+
[hand to a worker or a child process](#if-a-test-runs-a-mutated-file-in-a-worker-or-a-child-process):
|
|
488
|
+
the tests recorded as covering them (the tests known to start their file and those that reach them
|
|
489
|
+
in the test process; every test for those covered by every test only with `ignoreStatic`, since
|
|
490
|
+
without it that coverage is static, which names no test; none with `'all'`) do not show what the
|
|
491
|
+
worker or the child does, so run with `--force` after upgrading the runner and whenever the tests
|
|
492
|
+
that drive the worker or the child change.
|
|
476
493
|
|
|
477
494
|
With `'all'`, Stryker may warn that static mutants take most of the time and suggest
|
|
478
495
|
`ignoreStatic`. With `'all'` every mutant that some test reaches is a [static mutant](#terms) to
|
|
@@ -522,10 +539,25 @@ that runs none of your code. Then:
|
|
|
522
539
|
files load, and then makes the dry run proper with those files imported first
|
|
523
540
|
([details](#if-the-dry-run-runs-your-tests-twice)).
|
|
524
541
|
|
|
542
|
+
A mutated file that your tests, or the code they import, start in a `Worker` or a child process
|
|
543
|
+
is not imported for that. When its path is written out in that call, the runner reports its
|
|
544
|
+
mutants as covered by the tests in the test files that start it, and, when a preload may start it,
|
|
545
|
+
by every test too ([details](#if-a-test-runs-a-mutated-file-in-a-worker-or-a-child-process)).
|
|
546
|
+
|
|
525
547
|
When some files are left out, an info line after the dry run says which ones, for example:
|
|
526
548
|
|
|
527
549
|
> `Dry run: of the <N> files matched by mutate, the runner imports <M> before the tests: <M> that the test files or preloads import statically. It does not import the other <K> itself: <files>. If the tests do load one of those in a way the runner cannot see (through a package, a worker or a child process), add it to bun.alwaysImport.`
|
|
528
550
|
|
|
551
|
+
When some of those files are ones that the tests start in a worker or a child process, a sentence
|
|
552
|
+
after the list names them and says how their mutants are covered:
|
|
553
|
+
`The tests hand <n> of them to a worker or a child process (<files>), so their mutants are reported as covered by the tests in <m> test files that start them.`
|
|
554
|
+
For files that every test may start (a preload starts them, say) it ends `as covered by every test.`
|
|
555
|
+
instead, and when there are files of both kinds it names each kind:
|
|
556
|
+
`The tests hand <n> of them to a worker or a child process: the mutants of <a> (<files>) are reported as covered by the tests in <m> test files that start them, and those of <b> (<files>) as covered by every test.`
|
|
557
|
+
The advice that follows is then for the other files, and for loads in the test process only:
|
|
558
|
+
`If the tests do load one of the others in a way the runner cannot see (through a package), add it to bun.alwaysImport. A file that only a worker or a child process runs is not covered by that: it needs the call that starts it written in a form the runner reads (the file's path written out in the call), or coverageAnalysis: 'off'.`
|
|
559
|
+
When the tests hand all of them to a worker or a child process, there is no advice.
|
|
560
|
+
|
|
529
561
|
The two options that change what is imported are `bun.alwaysImport` and `bun.importDiscovery`
|
|
530
562
|
([options table](#configuration)). With Stryker's `incremental` set, every message below that
|
|
531
563
|
names `bun.alwaysImport` ends with:
|
|
@@ -560,6 +592,11 @@ run":
|
|
|
560
592
|
|
|
561
593
|
> `Dry run: of the <N> files matched by mutate, the runner imports <M> before the tests of the second run: the <M> that a first run of the tests was seen to load. It does not import the other <K> itself: <files>. If the tests do load one of those in a way the runner cannot see (through a package, a worker or a child process), add it to bun.alwaysImport.`
|
|
562
594
|
|
|
595
|
+
When a setting stopped the runner from reading the imports at all (below), or that reading gave
|
|
596
|
+
no usable answer, the last sentence reads instead:
|
|
597
|
+
`If the tests do load one of those in a way the runner cannot see (through a package), add it to bun.alwaysImport. A file that only a worker or a child process runs is not covered by that: it needs the call that starts it written in a form the runner reads (the file's path written out in the call), or coverageAnalysis: 'off'.`
|
|
598
|
+
(see [If a test runs a mutated file in a worker or a child process](#if-a-test-runs-a-mutated-file-in-a-worker-or-a-child-process)).
|
|
599
|
+
|
|
563
600
|
If what is left of Stryker's time budget for the dry run looks too short for the next run, a
|
|
564
601
|
warning says so:
|
|
565
602
|
|
|
@@ -778,20 +815,285 @@ results as incomplete.
|
|
|
778
815
|
|
|
779
816
|
### If a test runs a mutated file in a worker or a child process
|
|
780
817
|
|
|
781
|
-
**The situation.** A test runs a mutated file
|
|
782
|
-
sees only what loads in the test process, so it does not import that file before the tests.
|
|
818
|
+
**The situation.** A test runs a mutated file inside a `Worker` or a child process, for example:
|
|
783
819
|
|
|
784
|
-
|
|
820
|
+
```javascript
|
|
821
|
+
// src/pool.ts, which a test imports
|
|
822
|
+
const worker = new Worker(new URL('./resize-worker.ts', import.meta.url));
|
|
785
823
|
|
|
786
|
-
|
|
787
|
-
|
|
824
|
+
// a test file
|
|
825
|
+
Bun.spawnSync([process.execPath, 'src/cli.ts', '--help']);
|
|
826
|
+
```
|
|
788
827
|
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
828
|
+
**What the runner does.** When the file's path is written out in the call that starts the worker
|
|
829
|
+
or the child, the runner reports every mutant in that file, and in the mutated files that it
|
|
830
|
+
loads, as covered by the tests that can start it: every test in each test file whose own code, or
|
|
831
|
+
code that it loads, makes that call. Stryker then runs those tests against each of these mutants.
|
|
832
|
+
When a preload, or another file that runs for every test file, can make the call, or the runner
|
|
833
|
+
cannot tell which test files can, it reports the mutants as covered by every test too, as
|
|
834
|
+
[static mutants](#terms), so that Stryker runs your whole suite against each of them. With
|
|
835
|
+
`ignoreStatic: true` it also reports them as covered by each test that ran in the dry run, so that
|
|
836
|
+
Stryker still runs your whole suite against them (see below for the limit). The files it loads
|
|
837
|
+
are those of its `import` statements, and those of a `require('…')` or an `import('…')` whose path is a string, wherever it is in the file
|
|
838
|
+
(in a function that may never run, too), and so on from each of those, whether or not `mutate`
|
|
839
|
+
matches them (an `entry.cjs` that only does `require('./cli.js')`, say), also in a file that has
|
|
840
|
+
something else the runner cannot follow, such as a CommonJS main guard (`if (require.main ===
|
|
841
|
+
module)`); a `require()` or an `import()` whose path is computed is not followed. When a file that
|
|
842
|
+
the worker or the child loads has something the runner cannot follow (a main guard, a
|
|
843
|
+
`require(process.argv[2])`, a computed `import()`), the tests that start it are taken for tests
|
|
844
|
+
that can start every such file, so a weaker test that starts the same file another way is never
|
|
845
|
+
its only test. In the test process, a file with a main guard (a test file, or a file a test loads)
|
|
846
|
+
is one the runner cannot read in full: it does not take that file's `require('…')` calls for
|
|
847
|
+
files to import before the tests (see
|
|
848
|
+
[If the dry run runs your tests twice](#if-the-dry-run-runs-your-tests-twice)). It still reads the
|
|
849
|
+
calls in that file that start a worker or a child
|
|
850
|
+
(`const { execFileSync } = require('node:child_process')` beside `if (require.main === module)`):
|
|
851
|
+
reading `require.main` does not stop it from trusting the file's `require`.
|
|
852
|
+
|
|
853
|
+
This holds whether or not a test also imports the file. A file that a unit test imports and a CLI
|
|
854
|
+
test runs in a child process is covered by the unit test, for what it runs in the test process,
|
|
855
|
+
and by every test in the CLI test's file, for what the child runs, so a weak unit test no longer
|
|
856
|
+
hides the CLI test that would kill the mutant.
|
|
857
|
+
|
|
858
|
+
The runner does not import a file in the test process because the tests hand it to a worker or a
|
|
859
|
+
child process, so a file that no test imports runs only where your tests start it. The mutant is
|
|
860
|
+
active there: the runner names the mutant to run in an environment variable when it starts the
|
|
861
|
+
tests, and the worker or the child receives it with the rest of the environment. So the test that
|
|
862
|
+
checks what the worker or the child does can kill the mutant, wherever it is in the file: in code
|
|
863
|
+
that runs when the file loads, or in a message handler that runs later. That holds for the calls in
|
|
864
|
+
a test file, in a preload and in the code that they load (by `import` statements, or by a
|
|
865
|
+
`require('…')` or an `import('…')` whose path is a string, as above), and for a file that the
|
|
866
|
+
worker or the child starts in turn (its tests are those that start the first one). When the file
|
|
867
|
+
that the worker or the child starts with is not one that `mutate` matches (a small launcher
|
|
868
|
+
script, say), the mutated files that it loads are reported the same way. The info line after the
|
|
869
|
+
dry run names those of these files that the runner does not import before the tests, and says how
|
|
870
|
+
their mutants are covered; a file that the tests also import is counted only in a debug line.
|
|
871
|
+
|
|
872
|
+
To find the test files that can start a file, the runner follows what each test file loads: its
|
|
873
|
+
`import` statements, and the files it, or the files it loads, name in a `require('…')` or an
|
|
874
|
+
`import('…')` whose path is a string. A test file that loads something the runner cannot follow (a
|
|
875
|
+
computed `import()`, say) is taken for one that can start every such file, and so is a test file
|
|
876
|
+
whose call the runner recognises but whose path it cannot read (see below): a path held in a `let`
|
|
877
|
+
or computed, a worker with a `preload` option (the files it preloads run in the worker too, and
|
|
878
|
+
the runner does not read them; the worker's own file is read as usual), a `fork` with an
|
|
879
|
+
`execArgv` option (`fork('./main.cjs', [], { execArgv: ['-r', './src/setup.js'] })`: node's flags
|
|
880
|
+
load files before the script, which the runner does not read; the script is read as usual), a
|
|
881
|
+
command line run through a shell (`exec` and `execSync` of `node:child_process`, bun's `` $`…` ``
|
|
882
|
+
from `bun` or `Bun.$`), a function that starts a worker or a child used other than by calling it
|
|
883
|
+
where it is named (`const execFileAsync = promisify(execFile)`, `const run = Bun.spawnSync`,
|
|
884
|
+
`{ execFile }` stored or exported, `class Pool extends Worker {}`: what it starts is called
|
|
885
|
+
somewhere the runner does not look; an `import`, `typeof` or `instanceof` of it does not count),
|
|
886
|
+
bun or node started with
|
|
887
|
+
something other than a script (`['bun', 'test']`, `-e`, a
|
|
888
|
+
script of your `package.json` such as `['bun', 'run', 'verify']`), a path that names no file that
|
|
889
|
+
exists, a command it cannot read, or one that may run through a shell, say. So does a test file
|
|
890
|
+
that starts a file whose own call the runner cannot read in that sense (a driver script that starts
|
|
891
|
+
what its arguments name), or that loads something the runner cannot follow (above). So a test
|
|
892
|
+
file that starts the CLI with a computed path, beside another that
|
|
893
|
+
writes the path out, has its tests run against the CLI's mutants too. A call whose command is a
|
|
894
|
+
plain program name (`Bun.spawnSync(['git', 'status'])`) starts none of your files and changes
|
|
895
|
+
nothing. A test that starts the worker or the child through code that its own file does not load
|
|
896
|
+
(a function that another file put on `globalThis`, say) is not counted. When the runner cannot
|
|
897
|
+
tell which test bun ran in which file, bun ran a test file the runner did not read, or a test file
|
|
898
|
+
it names as a starter ran no test, it reports these mutants as covered by every test too, beside
|
|
899
|
+
the tests of the starters it can tell.
|
|
900
|
+
|
|
901
|
+
This works only when the runner can read your tests' imports before the dry run. A setting that
|
|
902
|
+
stops it from reading them (a `[loader]` section or `jsx` settings in your bunfig, or flags such as
|
|
903
|
+
`--conditions`, `--loader` or `--define` in `bun.bunArgs`: see
|
|
904
|
+
[If the dry run runs your tests twice](#if-the-dry-run-runs-your-tests-twice)) also stops it from
|
|
905
|
+
reading these calls, and so does a reading that fails. The debug line `The import scan was not
|
|
906
|
+
started: …` or the info line `The import scan gave no usable answer: …` then ends with
|
|
907
|
+
`Files handed to a worker or a child process are not read.` The mutants that run only in the
|
|
908
|
+
worker or the child are then NoCoverage. Listing their files in `bun.alwaysImport` does not help:
|
|
909
|
+
it imports them in the test process, not where they run. If you cannot drop the setting, use
|
|
910
|
+
Stryker's `coverageAnalysis: 'off'`: Stryker then runs every test against every mutant, those
|
|
911
|
+
mutants included, at the cost of a run of your suite per mutant.
|
|
912
|
+
|
|
913
|
+
What to know about it:
|
|
914
|
+
|
|
915
|
+
- Each of these mutants costs a run of the tests in the test files that start its file, or of your
|
|
916
|
+
whole suite when it is covered by every test.
|
|
917
|
+
- Stryker's `ignoreStatic: true` runs a static mutant only against the tests that the coverage
|
|
918
|
+
names for it, and skips one that has none. With it, the mutants covered by every test are
|
|
919
|
+
covered by each test too, so it runs every test against them. That costs one entry per test and
|
|
920
|
+
mutant in the coverage handed to Stryker; past 5,000,000 entries (1,000 tests and 6,000 such
|
|
921
|
+
mutants, say) the runner reports them as static only and warns: Stryker then skips them, or runs
|
|
922
|
+
only the tests known to start their file. To test them, run without `ignoreStatic`, or write the
|
|
923
|
+
path of the worker's or the child's file out in the test file that starts it, so that the runner
|
|
924
|
+
can tell which tests start it.
|
|
925
|
+
A mutant that runs when a test imports its file stays static, and the tests that start the file
|
|
926
|
+
are among its tests, so with `ignoreStatic` those tests run for it. The mutants covered only by
|
|
927
|
+
the tests that start their file are not static, and run as usual.
|
|
928
|
+
- A file that a test also imports, or that `bun.alwaysImport` keeps, is imported in the test
|
|
929
|
+
process like any other file the tests load: its mutants keep the coverage that the tests reach
|
|
930
|
+
there, and are covered by the tests that start the worker or the child too. A mutant that runs
|
|
931
|
+
when the file loads in the test process is static, and stays so. There is no need to list a file
|
|
932
|
+
in `bun.alwaysImport` because a worker or a child process runs it.
|
|
933
|
+
- In a mutant run of one of these mutants, the runner does not check for mutated files that the dry
|
|
934
|
+
run missed (see [Mutant runs](docs/internals.md#the-witness-in-mutant-runs)), and does not apply
|
|
935
|
+
Stryker's hit limit (the run's timeout still applies): the mutant may run in the worker or the
|
|
936
|
+
child first, and what a test then loads and runs in the test process (a fallback that imports a
|
|
937
|
+
support file and the mutated file and calls it many times, say) follows from the mutant. Stryker
|
|
938
|
+
sets the hit limit from the hits the dry run counted, and for these mutants that count says
|
|
939
|
+
nothing of what the worker or the child runs: it is one hit for each test the runner reports,
|
|
940
|
+
beside what the tests reached in the test process. The runs of every other mutant keep both.
|
|
941
|
+
- With Stryker's `incremental`, Stryker reuses the result that an earlier run saved for one of these
|
|
942
|
+
mutants unless it sees a change in the mutant or in a test that it records as covering it. By
|
|
943
|
+
default those are the tests known to start its file and the tests that reach it in the test
|
|
944
|
+
process: a mutant covered by every test is static, which names no test, so a change in any other
|
|
945
|
+
test goes unseen. Only with `ignoreStatic` are such mutants recorded as covered by every test that
|
|
946
|
+
ran; with `coverageAnalysis: 'all'`, by none. Run with `--force` after upgrading the runner, and
|
|
947
|
+
whenever the tests that drive the worker or the child change.
|
|
948
|
+
- When the runner takes a file for one that a worker or a child process runs and it is not, its
|
|
949
|
+
mutants run against the tests that seem to start it (or your whole suite) and show as Survived
|
|
950
|
+
instead of NoCoverage, and their runs have neither the check nor the hit limit above. Nothing
|
|
951
|
+
else changes: which files are imported, and how many times the dry run runs your tests, do not
|
|
952
|
+
depend on what the runner reads here.
|
|
953
|
+
|
|
954
|
+
The runner reads these calls, and in each only the argument that names the code to run:
|
|
955
|
+
|
|
956
|
+
- `new Worker(…)` (the global one, `globalThis.Worker`, or `Worker` from `node:worker_threads`) and
|
|
957
|
+
`fork(…)` from `node:child_process`: the first argument. A worker whose options may hold `eval`
|
|
958
|
+
(anything but `eval: false`, or options that are not written out as an object) runs that argument
|
|
959
|
+
as code, so the runner reads nothing. A worker whose options hold `preload` runs those files
|
|
960
|
+
first, which the runner does not read: it reads the worker's own file, and takes the call for one
|
|
961
|
+
whose path it cannot read as well (above). So it does for a `fork` whose options may hold
|
|
962
|
+
`execArgv` (one other than `execArgv: false`, or options that are not written out as an object).
|
|
963
|
+
- `Bun.spawn(…)` and `Bun.spawnSync(…)`, and `spawn`, `spawnSync`, `execFile` and `execFileSync`
|
|
964
|
+
from `node:child_process`: the script, when the command is bun or node (`process.execPath`,
|
|
965
|
+
`process.argv0`, `process.argv[0]`, `'bun'` or `'node'`; `process` may be the global or a
|
|
966
|
+
default or namespace import of `node:process`, and `execPath` may be imported from it). The
|
|
967
|
+
script is the first argument after the command, or after `run` for bun. For node, any word there
|
|
968
|
+
is the path of the script (`['node', 'cli']` runs `./cli.js`). For bun, a word with a `.` or a `/`
|
|
969
|
+
is a path (after `run`, only one that starts with `./` or `../`, or is absolute); any other word
|
|
970
|
+
(`['bun', 'cli']`, `['bun', 'run', 'cli']`) names a script of your `package.json` first, so the
|
|
971
|
+
runner reads it as a file only when the nearest `package.json` from where the child runs has no
|
|
972
|
+
script of that name, and takes the call for one whose path it cannot read when it has one. A few
|
|
973
|
+
flags that take no value may come before it (`--smol`, `--bun`, `--hot`, `--watch`,
|
|
974
|
+
`--no-install`, `--no-warnings`); after any other flag (`-e`, `--preload`, `--cwd`, …) or a
|
|
975
|
+
subcommand of bun (`bun test`, `bun x`), the runner reads nothing. Each of
|
|
976
|
+
these words may be held in a `const` (below): `const mode = 'run'` reads as `'run'` written in the
|
|
977
|
+
call. With any other command, such as `echo` or `git`, it reads only the command itself, when that
|
|
978
|
+
is the path of a script. For the functions of `node:child_process`, it reads nothing when the
|
|
979
|
+
options may run the command through a shell: a `shell` option other than `shell: false`, or
|
|
980
|
+
options that are not written out as an object. `exec` and `execSync`, and bun's shell (`$` from
|
|
981
|
+
`bun`, `Bun.$`), always run a command line through a shell, so the runner reads nothing in them,
|
|
982
|
+
and takes the call for one whose path it cannot read.
|
|
983
|
+
|
|
984
|
+
That argument can be a path written as a string, `new URL('…', import.meta.url)` (with or without
|
|
985
|
+
`.href` or `.pathname`), `import.meta.resolve('…')`, `require.resolve('…')`, or
|
|
986
|
+
`path.join(import.meta.dir, '…')` (also `path.resolve`, `join` or `resolve` imported from
|
|
987
|
+
`node:path`, `import.meta.dirname` and `__dirname`). It can also be a name that a `const` in the
|
|
988
|
+
same file sets to one of these, at the top level or in a block around the call, when nothing else
|
|
989
|
+
in the file declares that name:
|
|
990
|
+
|
|
991
|
+
```js
|
|
992
|
+
const CLI = path.join(import.meta.dir, '../src/cli.ts');
|
|
993
|
+
test('help', () => { Bun.spawnSync([process.execPath, CLI, '--help']); });
|
|
793
994
|
```
|
|
794
995
|
|
|
996
|
+
A plain string is read as bun reads it:
|
|
997
|
+
relative to the directory the worker or the child runs in, which is your project directory, or the
|
|
998
|
+
`cwd` written as a string in the call's options. It is not relative to the file that makes the
|
|
999
|
+
call. When the `cwd` is not written out as a string, or something else in the options could supply
|
|
1000
|
+
it (a second `cwd`, a spread, a getter), the runner does not read a relative path. Anything else in
|
|
1001
|
+
the call (other arguments, the rest of the options, the environment) is ignored. An array with a
|
|
1002
|
+
hole before the script (`[process.execPath, , './a.js']`) gives nothing. In a file that calls
|
|
1003
|
+
`process.chdir` anywhere (also `chdir` imported from `node:process`), the runner does not read a
|
|
1004
|
+
path relative to the working directory (`'./cli.js'`, also with a relative `cwd`): write it
|
|
1005
|
+
relative to the file (`new URL('./cli.js', import.meta.url)`, `path.join(import.meta.dir,
|
|
1006
|
+
'cli.js')`) or absolute. Only a `process.chdir` in the file that makes the call counts: a helper
|
|
1007
|
+
of another file that changes directory around a callback that starts the child (`inFixture(() =>
|
|
1008
|
+
Bun.spawnSync([process.execPath, './cli.js']))`) is not seen, and the path is read against the
|
|
1009
|
+
project directory.
|
|
1010
|
+
|
|
1011
|
+
When bun runs the script (a `Worker`, `fork`, or a command that is bun), the runner finds the file
|
|
1012
|
+
the way bun does: `./src/cli.js` names `src/cli.ts` when there is no `src/cli.js`, `.jsx` names
|
|
1013
|
+
`.tsx`, `.mjs` names `.mts`, `.cjs` names `.cts`, a path without an extension (`./src/cli`)
|
|
1014
|
+
takes the extension of the file that exists, and a directory its `index` file. For `node`, it finds
|
|
1015
|
+
the file the way node finds its main script: the path as written, else with `.js` (`./cli` names
|
|
1016
|
+
`cli.js`; node adds no `.mjs`, `.cjs` or `.ts`), else a directory's `index.js`. A directory with a
|
|
1017
|
+
`package.json` is not read (bun runs the file of its `module` field before that of `main`): name
|
|
1018
|
+
the file. For a command that is itself a script, the path is taken as written. A path that names no
|
|
1019
|
+
file that exists makes the call one whose path the runner cannot read (see above). What the script
|
|
1020
|
+
loads in turn is resolved as bun resolves it, also for a child started with `node`: node resolves a
|
|
1021
|
+
`require('./x')` its own way, so where an `x.js` and an `x.ts` stand side by side, the child may
|
|
1022
|
+
load another file than the one the runner follows.
|
|
1023
|
+
|
|
1024
|
+
To keep it simple, the runner does not follow scopes: when a file declares or assigns the name of
|
|
1025
|
+
the function it would read (`spawn`, `path`, `URL`, say) anywhere else, as a parameter, a variable
|
|
1026
|
+
or the target of an assignment, it reads no call of that name in the file, and the mutants of the
|
|
1027
|
+
file it starts keep the coverage that the tests reach in the test process. The same holds when the
|
|
1028
|
+
file assigns the function as a property (`globalThis.Worker = FakeWorker`, `Bun.spawn = fake`,
|
|
1029
|
+
`childProcess.fork = fake`) or assigns the global itself (`Worker = FakeWorker`), under any
|
|
1030
|
+
spelling: a write through `globalThis`, `global`, `self` or `window`
|
|
1031
|
+
(`globalThis.Bun.spawnSync = fake`) stops the runner from reading the other spellings too
|
|
1032
|
+
(`Bun.spawnSync(…)`, `new globalThis.Worker(…)`). A local that only shadows the global (`const Worker = FakeWorker`)
|
|
1033
|
+
leaves `new globalThis.Worker(…)` read. A default value declares nothing: in
|
|
1034
|
+
`function start(worker = new Worker('./src/w.ts'))`, the call is read. `import process from
|
|
1035
|
+
'node:process'` (or `* as process`, or `const process = require('node:process')`) is the real
|
|
1036
|
+
`process`, not a shadow; any other declaration of `process` is.
|
|
1037
|
+
|
|
1038
|
+
**What is still not covered.** When the runner does not recognise the call, the file's mutants that
|
|
1039
|
+
no test reaches in the test process are NoCoverage:
|
|
1040
|
+
|
|
1041
|
+
- **Any call, when the runner cannot read your tests' imports**: see the start of this section;
|
|
1042
|
+
`coverageAnalysis: 'off'` is the workaround.
|
|
1043
|
+
- **Any call, when `bun.alwaysImport` keeps every file that `mutate` matches** (`'all'`, or
|
|
1044
|
+
patterns that match them all): the runner then imports them all with no import scan, so it reads
|
|
1045
|
+
no call that starts a worker or a child, and what runs only there is NoCoverage. Keep a handed
|
|
1046
|
+
file out of `bun.alwaysImport`, or use `coverageAnalysis: 'off'`.
|
|
1047
|
+
- **A path the runner cannot read, when no other call names the file**: one held in a `let` or a
|
|
1048
|
+
`var`, built from a template with `${…}`, passed in from somewhere else, or held in a `const` that
|
|
1049
|
+
the runner does not read (one in another function, or set to another name). When another call
|
|
1050
|
+
names the file in a form the runner reads, the tests of a call it cannot read are run against the
|
|
1051
|
+
file's mutants too (see above); when none does, write the path out in the call, or hold it in a
|
|
1052
|
+
`const` as shown above.
|
|
1053
|
+
- **A call only in a file that the tests reach solely through an `import('…')` or a `require('…')`
|
|
1054
|
+
in a helper (not in the test file itself), when no other call hands a file off**: the runner reads
|
|
1055
|
+
the files reached only that way for these calls only once it has found another call that hands a
|
|
1056
|
+
file off, so that a project without workers or child processes pays nothing for them. A call whose
|
|
1057
|
+
path or command it cannot read (an `exec`, a `` $`…` `` of bun's shell) does not count: when the
|
|
1058
|
+
tests have no call the runner reads except behind such an `import('…')` or `require('…')`, the
|
|
1059
|
+
files that call starts are NoCoverage. Import that file with an `import` statement, or name the
|
|
1060
|
+
path in the test file.
|
|
1061
|
+
- **An executable script without a file extension**, started on its own (`Bun.spawn(['./bin/tool'])`
|
|
1062
|
+
for a script that begins with `#!/usr/bin/env bun`): the runner reads only paths of code files.
|
|
1063
|
+
- **An entry point named through a package's `exports` or `imports` map that gives `import` and
|
|
1064
|
+
`require` different files**: the runner follows the file that its own reading resolves to, and
|
|
1065
|
+
the worker or the child may load the other one.
|
|
1066
|
+
- **A worker or a child whose code is too large to read in the time the runner gives it** (about a
|
|
1067
|
+
quarter of a second, apart from the rest of the dry run): the runner then reads none of the files
|
|
1068
|
+
handed to a worker or a child process, says so at debug (`hand-offs not read: …`), and the dry
|
|
1069
|
+
run goes on as it would without them. When only finding the test files that start them takes
|
|
1070
|
+
too long, their mutants are covered by every test, which the debug line also says
|
|
1071
|
+
(`hand-offs credited to every test: …`).
|
|
1072
|
+
- **A launch function taken out of `Bun`, or from `await import('node:child_process')`**: a function
|
|
1073
|
+
taken out of the global `Bun` object by destructuring or assignment (`const { spawnSync } = Bun`,
|
|
1074
|
+
`const start = globalThis.Bun.spawnSync`), or taken from that import
|
|
1075
|
+
(`const { execFileSync } = await import('node:child_process')`), is not recognised. A launch written
|
|
1076
|
+
through it is not read, and it does not count as a launch the runner cannot read either. So when
|
|
1077
|
+
another test starts the same file with a spelling the runner reads, only that other test is credited,
|
|
1078
|
+
and a mutant that only the first test would kill is reported as Survived. A plain
|
|
1079
|
+
`const start = Bun.spawnSync`, without `globalThis`, is not this case: the runner takes it for a call
|
|
1080
|
+
it cannot read, as for `const run = Bun.spawnSync` above. Call `Bun.spawnSync(…)` directly, or import
|
|
1081
|
+
the function statically (`import { spawnSync } from 'bun'`,
|
|
1082
|
+
`import { execFileSync } from 'node:child_process'`).
|
|
1083
|
+
|
|
1084
|
+
When the runner does recognise the call, but **the child is started with an environment of its
|
|
1085
|
+
own** (an `env` option without `process.env` in it), the child does not receive the variable that
|
|
1086
|
+
names the mutant, so it runs the original code and the mutants in its file are Survived rather than
|
|
1087
|
+
NoCoverage. A bun `Worker`, and a child that `Bun.spawn` starts without `env`, receive the
|
|
1088
|
+
environment that the test process started with; `Worker` from `node:worker_threads` and the
|
|
1089
|
+
functions of `node:child_process` receive `process.env` as it is when they start. Both hold the
|
|
1090
|
+
variable.
|
|
1091
|
+
|
|
1092
|
+
With Stryker's `incremental`, a result that an earlier run saved for one of these mutants
|
|
1093
|
+
(NoCoverage from a version of the runner that did not recognise the call, or Survived) is reused
|
|
1094
|
+
until you run with `--force`, even when the tests change, unless Stryker sees a change in a test
|
|
1095
|
+
that it records as covering the mutant.
|
|
1096
|
+
|
|
795
1097
|
### If one of your preloads loads a mutated file at the very end
|
|
796
1098
|
|
|
797
1099
|
**The situation.** One of your own preloads has an `afterAll` hook that loads a mutated file for
|
|
@@ -939,7 +1241,9 @@ negation for it appended so Stryker copies it into the sandbox. Add `*.stryker-c
|
|
|
939
1241
|
|
|
940
1242
|
It logs one line per call: an info naming the file and how many files it excluded and kept, or a
|
|
941
1243
|
warning with the reason it fell back. It falls back, returning your config unchanged, when
|
|
942
|
-
TypeScript cannot be loaded from the project
|
|
1244
|
+
TypeScript cannot be loaded from the project or what it exports lacks the compiler API the helper
|
|
1245
|
+
reads the tsconfig with (a `null` or other shim export, or TypeScript 7 or later, whose package
|
|
1246
|
+
exports only its version and gets a warning of its own), the tsconfig is missing, has errors or uses project
|
|
943
1247
|
references, includes no test files or would be left with none, leaving the tests out adds errors, or
|
|
944
1248
|
the file cannot be written or was not generated by the helper. With no `'typescript'` in `checkers`
|
|
945
1249
|
it does nothing (logged at info), so list the checker in the config you wrap.
|
|
@@ -980,7 +1284,7 @@ export default await withTestFilesExcludedFromTypeCheck({
|
|
|
980
1284
|
- The checker imports `@typescript/native/unstable/sync`. Its error message suggests a `typescript7`
|
|
981
1285
|
alias, but it never looks for one, so use the `@typescript/native` name above.
|
|
982
1286
|
- Pin TypeScript 7.0.2 exactly. TypeScript 7.1 renames the `unstable/sync` entry point to `sync`,
|
|
983
|
-
which
|
|
1287
|
+
which checkers 10.0.0 to 10.1.1 cannot load.
|
|
984
1288
|
- Keep `typescript` 6 or earlier: Stryker and the checker still need it, and so does
|
|
985
1289
|
`withTestFilesExcludedFromTypeCheck`. The alias installs a second `tsc` that takes over
|
|
986
1290
|
`node_modules/.bin/tsc`, so call TypeScript 6 by its path (`node node_modules/typescript/bin/tsc`)
|
|
@@ -990,8 +1294,8 @@ export default await withTestFilesExcludedFromTypeCheck({
|
|
|
990
1294
|
|
|
991
1295
|
Only if your tsconfig turns on `noUnusedLocals` or `noUnusedParameters`, or sets
|
|
992
1296
|
`allowUnreachableCode: false`. The checker's default mode switches those checks off for mutants,
|
|
993
|
-
since a mutant that leaves a variable unused is not broken.
|
|
994
|
-
whenever `tsconfigFile` is a relative path (the default, and what
|
|
1297
|
+
since a mutant that leaves a variable unused is not broken. The native mode of checkers 10.0.0 to
|
|
1298
|
+
10.1.1 fails to, whenever `tsconfigFile` is a relative path (the default, and what
|
|
995
1299
|
`withTestFilesExcludedFromTypeCheck` sets). **Symptom:** the native checker reports more
|
|
996
1300
|
CompileErrors than the default mode, with reasons such as
|
|
997
1301
|
`error TS6133: 'message' is declared but its value is never read`, and those mutants are never
|
|
@@ -999,9 +1303,10 @@ tested.
|
|
|
999
1303
|
|
|
1000
1304
|
The fix is a one-line patch. With Bun:
|
|
1001
1305
|
|
|
1002
|
-
1. Pin the checker, since
|
|
1003
|
-
|
|
1004
|
-
|
|
1306
|
+
1. Pin the checker, since a patch is for one exact version. The same patch fits 10.0.0 and 10.1.1;
|
|
1307
|
+
use your `@stryker-mutator/core` version (10.1.1 here):
|
|
1308
|
+
`bun add -D --exact @stryker-mutator/typescript-checker@10.1.1`.
|
|
1309
|
+
2. Save this as `patches/@stryker-mutator%2Ftypescript-checker@10.1.1.patch` (the `%2F` is part of
|
|
1005
1310
|
the file name):
|
|
1006
1311
|
|
|
1007
1312
|
```diff
|
|
@@ -1023,7 +1328,7 @@ The fix is a one-line patch. With Bun:
|
|
|
1023
1328
|
|
|
1024
1329
|
```json
|
|
1025
1330
|
"patchedDependencies": {
|
|
1026
|
-
"@stryker-mutator/typescript-checker@10.
|
|
1331
|
+
"@stryker-mutator/typescript-checker@10.1.1": "patches/@stryker-mutator%2Ftypescript-checker@10.1.1.patch"
|
|
1027
1332
|
}
|
|
1028
1333
|
```
|
|
1029
1334
|
|
|
@@ -1094,7 +1399,7 @@ Every log message: [Log output](docs/internals.md#log-output).
|
|
|
1094
1399
|
| `Bun exited with code <N> and its console output reported <N> failed test(s), but no failing test could be identified` | Usually an unhandled error between tests (a rejected promise nobody awaited). | Look for unawaited async work, especially in the file that ran last. |
|
|
1095
1400
|
| `mutant coverage was recorded between tests, after '<test>' completed` | Async work from that test kept running after it ended, or a `beforeAll` ran between tests. | `await` the work in the test. Harmless if it is a `beforeAll`. |
|
|
1096
1401
|
| `Failed to write dryRun registry file` | Other workers cannot read the dry run's test names. | Check the temporary directory; mutants still run, with less precise test selection. |
|
|
1097
|
-
| `Dry run: of the <N> files matched by mutate, the runner imports <M> before the tests` ... `It does not import the other <K> itself: <files>.` (info) | Which mutated files the dry run imported before the tests, and why. Shown only when some files were left out. | Nothing, unless a test loads one of the files that it does not import in a way that the runner cannot see (through a package
|
|
1402
|
+
| `Dry run: of the <N> files matched by mutate, the runner imports <M> before the tests` ... `It does not import the other <K> itself: <files>.` (info) | Which mutated files the dry run imported before the tests, and why. Shown only when some files were left out. When it says `The tests hand <n> of them to a worker or a child process`, the mutants of those files are tested against the tests in the test files that start them, or against every test, as it says. | Nothing, unless a test loads one of the files that it does not import in a way that the runner cannot see (through a package): add that file to `bun.alwaysImport`. For a file that a worker or a child process runs, see [If a test runs a mutated file in a worker or a child process](#if-a-test-runs-a-mutated-file-in-a-worker-or-a-child-process). See [Which mutated files the dry run imports](#which-mutated-files-the-dry-run-imports). |
|
|
1098
1403
|
| `<file> was loaded during the dry run, but the scan of the test files' imports found no route to it. The run is discarded, and the dry run starts again` ... | The file loaded during the dry run although the test files' import statements do not lead to it (a package loaded it, say). The runner starts again with a plain run first: three runs in all. A variant names a test file that ran but that the runner did not read. | See [If a test loads a mutated file late](#if-a-test-loads-a-mutated-file-late). |
|
|
1099
1404
|
| `The first run of the dry run failed while the runner imported first, among others, <n> files that test files or preloads reach only through a literal import() or require().` ... | A test file names a file in an `import()` or `require()` that never runs (a dead branch, a skipped test), and importing that file first may have broken the run. The runner recovered, in three runs. | Remove the `import()` or `require()` that never runs, or set `bun.importDiscovery: 'run'`. See [the related case](#if-a-mutated-file-fails-when-it-is-imported-before-the-tests). |
|
|
1100
1405
|
| `The second run of the dry run (a plain run of the tests, with no mutated file imported first, made because the first run failed) did not complete cleanly either: <reasons>. The first run's result is returned.` | As above, but the plain run failed too, so Stryker sees the first run's failing tests. | Fix the failing tests that Stryker lists. |
|
|
@@ -1104,7 +1409,7 @@ Every log message: [Log output](docs/internals.md#log-output).
|
|
|
1104
1409
|
| `bun test child exceeded maxChildRss (<N> bytes observed) during the dry run's plain run of the tests — killing it` | The plain run of the tests went over `bun.maxChildRss`; the dry run then fails. | Raise `bun.maxChildRss` above what one run of your suite needs. |
|
|
1105
1410
|
| `The dry run has used <x> s and <y> s remain of dryRunTimeoutMinutes (<n>); it now runs the tests again.` | The dry run needs another run of the tests, which may not fit in Stryker's time budget for the dry run. | If the dry run then times out, raise `dryRunTimeoutMinutes` to the value that the message suggests. See [If the dry run runs your tests twice](#if-the-dry-run-runs-your-tests-twice). |
|
|
1106
1411
|
| `bun.alwaysImport pattern "<pattern>" matches none of the <N> files matched by mutate` | A glob in `bun.alwaysImport` keeps no file. It is matched against the project-relative paths of the files that `mutate` matches, and cannot add other files. | Fix the glob, or remove it. |
|
|
1107
|
-
| `The import scan gave no usable answer: <reason>.` (info) | The short `bun` process that reads the tests' imports failed or timed out, so the runner makes a plain run of the tests first. | Nothing; report it if it recurs. |
|
|
1412
|
+
| `The import scan gave no usable answer: <reason>.` (info) | The short `bun` process that reads the tests' imports failed or timed out, so the runner makes a plain run of the tests first, and reads no file handed to a worker or a child process. | Nothing; report it if it recurs. |
|
|
1108
1413
|
|
|
1109
1414
|
Inspector diagnostics such as `Inspector data looks abnormal` need no action unless the dry run
|
|
1110
1415
|
also fails; see [Inspector diagnostics](docs/internals.md#inspector-diagnostics).
|
|
@@ -1136,10 +1441,15 @@ also fails; see [Inspector diagnostics](docs/internals.md#inspector-diagnostics)
|
|
|
1136
1441
|
- **`mock.module()` of a mutated file** that the tests load has no effect in the dry run, because
|
|
1137
1442
|
the dry run imports that file before the tests run. Use dependency injection or spy on methods
|
|
1138
1443
|
instead ([details](#if-a-test-replaces-a-mutated-file-with-mockmodule)).
|
|
1444
|
+
- **Workers and child processes.** The runner records no coverage inside a worker or a child
|
|
1445
|
+
process. When it can read the call that starts one, every mutant of the file that runs there is
|
|
1446
|
+
tested against the tests that can start it, or your whole suite when it cannot tell which those
|
|
1447
|
+
are; when no call that starts the file is one it can read (a path held in a `let`, an executable
|
|
1448
|
+
script without an extension), the mutants that no test reaches in the test process are
|
|
1449
|
+
NoCoverage ([details](#if-a-test-runs-a-mutated-file-in-a-worker-or-a-child-process)).
|
|
1139
1450
|
- **Files that load where the runner cannot see them** are not imported before the tests, and a
|
|
1140
1451
|
mutant there that no test reaches is NoCoverage. In each case, list the file in
|
|
1141
1452
|
`bun.alwaysImport`:
|
|
1142
|
-
- a file that runs only in a worker or a child process;
|
|
1143
1453
|
- a file that only a package loads, and only when the other files are not imported first
|
|
1144
1454
|
(importing them first can change what the tests do). `bun.importDiscovery: 'run'` also helps
|
|
1145
1455
|
here. If a mutant run later sees such a file loaded, it stops the Stryker run and names the file
|
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
|
*/
|
|
@@ -65,6 +73,8 @@ export declare class BunTestRunner implements TestRunner {
|
|
|
65
73
|
private readonly dryRunOutputFile?;
|
|
66
74
|
/** Stryker's coverageAnalysis from the Stryker options; DryRunOptions.coverageAnalysis wins when given. */
|
|
67
75
|
private readonly coverageAnalysis?;
|
|
76
|
+
/** Stryker's ignoreStatic: whether the dry run credits each test with the handed mutants credited to every test (see creditHandedCoverage). */
|
|
77
|
+
private readonly ignoreStatic;
|
|
68
78
|
private preloadScriptPath?;
|
|
69
79
|
private coverageFilePath?;
|
|
70
80
|
private sanitizedBunfigPath?;
|
|
@@ -134,7 +144,11 @@ export declare class BunTestRunner implements TestRunner {
|
|
|
134
144
|
private timeoutCorrectionMs?;
|
|
135
145
|
/** True once the "no usable timeout correction" debug line has been logged; it is shown once per runner. */
|
|
136
146
|
private loggedUnusableCorrection;
|
|
137
|
-
/**
|
|
147
|
+
/**
|
|
148
|
+
* The campaign of this worker's dry run or of the registry, the run directory its files are
|
|
149
|
+
* in, and its watch list and the files whose mutants it credited for being handed to a worker
|
|
150
|
+
* or a child process as sets (built once, for every mutant run's witness check and hit limit).
|
|
151
|
+
*/
|
|
138
152
|
private campaign?;
|
|
139
153
|
/** True once a mutant run's unusable watch list has been warned about; it is shown once per runner. */
|
|
140
154
|
private warnedWatchListProblem;
|
|
@@ -151,6 +165,12 @@ export declare class BunTestRunner implements TestRunner {
|
|
|
151
165
|
* shortens it, to make a real bun child's fallback wait short.
|
|
152
166
|
*/
|
|
153
167
|
protected readonly drainSilenceMs: number;
|
|
168
|
+
/**
|
|
169
|
+
* The import scan's hand-off budget (see HAND_OFF_BUDGET in import-scan-runner.ts). Not an
|
|
170
|
+
* option: a subclass in tests/00-integration/worker-child-integration.test.ts shrinks it,
|
|
171
|
+
* so that a real helper goes over it without hundreds of megabytes of files.
|
|
172
|
+
*/
|
|
173
|
+
protected readonly handOffBudget: HandOffBudget;
|
|
154
174
|
constructor(logger: Logger, options: StrykerOptions);
|
|
155
175
|
/**
|
|
156
176
|
* Single source of truth for the registry file name.
|
|
@@ -548,6 +568,14 @@ export declare class BunTestRunner implements TestRunner {
|
|
|
548
568
|
private selectAlwaysImported;
|
|
549
569
|
/** `file` relative to the dry run's project directory, as the messages show it (quoted when it must be, see displayName). */
|
|
550
570
|
private projectPathsOf;
|
|
571
|
+
/**
|
|
572
|
+
* How publication credits the mutants of each file of H ({@link handedCredits}), from the published run's `tests`:
|
|
573
|
+
* which test belongs to which file is read from them, except with coverageAnalysis 'all' (where Stryker runs every
|
|
574
|
+
* test for any mutant reached); then, as for a file the scan names no launcher of, every test.
|
|
575
|
+
*/
|
|
576
|
+
private handedCreditsOf;
|
|
577
|
+
/** The files of H among `notLoaded` that hold a mutant id, by how publication credits them (M1 names them), as the messages show them. */
|
|
578
|
+
private handedSummary;
|
|
551
579
|
/** Log `message` at `level`, and at debug, for each list it shortened, the entries it left out (see listText). */
|
|
552
580
|
private logListed;
|
|
553
581
|
/**
|
|
@@ -650,9 +678,23 @@ export declare class BunTestRunner implements TestRunner {
|
|
|
650
678
|
* a Complete result has anything to persist; any other is returned as it is. A run whose
|
|
651
679
|
* watch list cannot be published with its registry is an Error instead.
|
|
652
680
|
*
|
|
681
|
+
* The mutants of the files of H, whether or not the run also loaded them in the test
|
|
682
|
+
* process, are credited to the tests of the test files that start them, or to every test
|
|
683
|
+
* ({@link handedCredits}, {@link creditHandedCoverage}), in the result handed to Stryker
|
|
684
|
+
* only, after every check; the files of H that hold an id are stored with the campaign,
|
|
685
|
+
* before the registry is written, for their mutants' runs, which have neither the witness
|
|
686
|
+
* nor a hit limit (see mutantRunGuards). Nothing after the registry is written depends on
|
|
687
|
+
* how many ids there are.
|
|
688
|
+
*
|
|
653
689
|
* @param seen - Files of E outside L the run's sensors saw (and so loaded): not watched; none by default
|
|
654
690
|
*/
|
|
655
691
|
private publishDryRun;
|
|
692
|
+
/**
|
|
693
|
+
* When the coverage exists but covers no mutant at all, every mutant will be NoCoverage
|
|
694
|
+
* (Stryker's executeNoCoverage): warn, since that is a legitimate outcome only when the
|
|
695
|
+
* tests really never touch the mutated files ('off' records no hit, so it is not judged).
|
|
696
|
+
*/
|
|
697
|
+
private warnIfNoMutantCovered;
|
|
656
698
|
/**
|
|
657
699
|
* Earlier versions' inspected dry run, once: the sync server, the `bun test` child with
|
|
658
700
|
* the inspector, the completeness gate and the mapper. It writes nothing that outlives
|
|
@@ -712,9 +754,10 @@ export declare class BunTestRunner implements TestRunner {
|
|
|
712
754
|
* and its failed-test report is the more useful message.
|
|
713
755
|
*
|
|
714
756
|
* When coverage exists but covers no mutant at all, every mutant will be
|
|
715
|
-
* NoCoverage (Stryker's executeNoCoverage) — warn
|
|
716
|
-
*
|
|
717
|
-
* no
|
|
757
|
+
* NoCoverage (Stryker's executeNoCoverage) — warn ({@link warnIfNoMutantCovered}).
|
|
758
|
+
* When a file of H holds a mutant id (`handedIdsHeld`), there is no warning:
|
|
759
|
+
* a coverage that covers nothing measures no id as static, so publication
|
|
760
|
+
* credits that id, and some mutant is covered.
|
|
718
761
|
*
|
|
719
762
|
* `[Stryker Coverage]` diagnostics from the preload are otherwise dropped on a
|
|
720
763
|
* green run (the child's stderr is only shown on failure), so they are
|
|
@@ -774,9 +817,11 @@ export declare class BunTestRunner implements TestRunner {
|
|
|
774
817
|
*/
|
|
775
818
|
private writeRegistry;
|
|
776
819
|
/**
|
|
777
|
-
* A new campaign's state for the registry: a new generation, W,
|
|
778
|
-
*
|
|
779
|
-
*
|
|
820
|
+
* A new campaign's state for the registry: a new generation, W, the files of H whose
|
|
821
|
+
* mutants publication credited for being handed to a worker or a child process, and
|
|
822
|
+
* (inPlace only) the fingerprint of every file matched by mutate (test files included,
|
|
823
|
+
* as init() computes it in rejectIfCampaignStopped); W is written first, under the
|
|
824
|
+
* generation's own name. The state goes into the registry, which is renamed into place.
|
|
780
825
|
*/
|
|
781
826
|
private writeCampaignFiles;
|
|
782
827
|
/**
|
|
@@ -806,6 +851,22 @@ export declare class BunTestRunner implements TestRunner {
|
|
|
806
851
|
* unusable correction leaves Stryker's value as it is, and says so once at debug.
|
|
807
852
|
*/
|
|
808
853
|
private correctedStrykerTimeout;
|
|
854
|
+
/**
|
|
855
|
+
* The file of the active mutant (Stryker's `sandboxFileName`, the file as E names it) when
|
|
856
|
+
* the campaign credited its mutants for being handed to a worker or a child process, to the
|
|
857
|
+
* tests that start it or to every test; undefined otherwise.
|
|
858
|
+
*/
|
|
859
|
+
private handedFileOf;
|
|
860
|
+
/**
|
|
861
|
+
* The hit limit and the watch list of a mutant run's child. A mutant of a file handed to a
|
|
862
|
+
* worker or a child process, however publication credited it, may run there first: what the
|
|
863
|
+
* tests load and execute in the test process afterwards (a fallback that imports a support
|
|
864
|
+
* file and the handed file, and runs its code many times) follows from the mutant. So its run
|
|
865
|
+
* has no witness, which looks only at the mutant's first execution in the test process, and
|
|
866
|
+
* no hit limit, which Stryker derived from hits that measured nothing of the worker or the
|
|
867
|
+
* child (see creditHandedCoverage); the run's timeout still applies. Every other run gets both.
|
|
868
|
+
*/
|
|
869
|
+
private mutantRunGuards;
|
|
809
870
|
/** The watch list every mutant run's child gets: the campaign's, when it watches anything. */
|
|
810
871
|
private watchListForMutantRuns;
|
|
811
872
|
/**
|
|
@@ -1170,7 +1231,8 @@ export interface TestFilesExcludedFromTypeCheckOptions {
|
|
|
1170
1231
|
* Logs one line per call: `console.info` on success, `console.warn` with the
|
|
1171
1232
|
* reason on every fallback. Returns `config` itself, writing nothing, when
|
|
1172
1233
|
* `checkers` does not include `typescript`, typescript cannot be loaded from
|
|
1173
|
-
* `cwd
|
|
1234
|
+
* `cwd` or exports no compiler API to read the tsconfig with (a shim, or TypeScript
|
|
1235
|
+
* 7 or later, which gets its own reason), the tsconfig is missing, has errors or uses project references,
|
|
1174
1236
|
* includes no test files, would be left with no files at all, leaving the tests
|
|
1175
1237
|
* out adds type errors, or the derived file cannot be written or belongs to
|
|
1176
1238
|
* somebody else (it has no generated header).
|