@hughescr/stryker-bun-runner 1.8.0 → 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 CHANGED
@@ -1153,8 +1153,15 @@ More: [Mutant runs](docs/internals.md#mutant-runs), [the dry run in detail](docs
1153
1153
 
1154
1154
  ### How results are scored
1155
1155
 
1156
- - **Killed** when a test fails, or when a test file fails to load because of the mutant (bun reports
1157
- a failure count but no failing test).
1156
+ - **Killed** when a test fails, or when bun reports an error outside any test (a test file that
1157
+ fails to load, a describe body or a hook that throws) with a failure or error count but no
1158
+ failing test. `killedBy` lists the failing tests. With no failing test it lists the selected
1159
+ tests of each file that failed to load only when bun's summary shows that no test ran at all
1160
+ (passing tests are hidden in mutant runs, so nothing else shows whose tests ran), and the error
1161
+ was printed right below the header of one of the files the run handed bun; otherwise it is empty
1162
+ and the mutant re-runs on every incremental run. Stryker reuses a Killed result while at least
1163
+ one test in `killedBy` is unchanged; it does not track a test file's top-level code or its
1164
+ imports, so an edit there alone does not make it re-run the mutant. `--force` re-runs everything.
1158
1165
  - **Survived** when every selected test passes and bun finishes the run (prints its summary).
1159
1166
  - **Timeout** when the hit limit is exceeded, the time limit is reached, or `bun.maxChildRss` is
1160
1167
  exceeded.
@@ -1425,7 +1432,7 @@ also fails; see [Inspector diagnostics](docs/internals.md#inspector-diagnostics)
1425
1432
  | `Mutant <id>: inconclusive timeout, scoring as Error rather than Timeout` | A full-suite fallback did not finish within the time Stryker sized for the covering tests. | Raise Stryker's `timeoutMS` or `timeoutFactor`. |
1426
1433
  | `Mutant <id>: --test-name-pattern matched 0 tests` | The mutant changed a test's name (often an interpolated `it.each` title); the runner retries with the full suite. | Usually nothing; spot-check that the mutant changes a title. |
1427
1434
  | `no exact-name registry available` or `missing from exact-name registry` | A worker could not match test ids to bun's exact names; tests whose titles contain ` > ` may have been skipped in that run. | Check for an earlier `Failed to write dryRun registry file` warning; re-run. |
1428
- | `could not be resolved to dry-run test ids` or `no killing test identifiable — emitting empty killedBy` | A killed mutant whose killing test is unknown; it re-runs on every incremental run. | Usually a test whose output imitates bun's; harmless otherwise. |
1435
+ | `could not be resolved to dry-run test ids` or `no killing test identifiable — emitting empty killedBy` | A killed mutant whose killing test is unknown; it re-runs on every incremental run. Either a failing test's name matched no dry-run test, or bun reported an error outside any test and no failing test, and the runner could not tell for certain which file's tests it stopped: another test passed in the same run, or the error was not printed right below the header of one file the run handed bun. | Usually harmless: expected for a mutant that stops one file loading in a run where other files' tests pass, or that makes a describe body or hook throw. |
1429
1436
  | `bun test child exceeded maxChildRss` | A run went over `bun.maxChildRss`; scored Timeout. | Expected for runaway mutants; raise the limit if many hit it. |
1430
1437
  | `stryker-bun-runner: <file> was present in bun's module cache in this mutant run (mutant <id>, tests: <tests>) when the mutant first executed, and the dry run neither imported it before the tests nor saw it load.` ..., then Stryker stops with `Unexpected error occurred while running Stryker` and exit code 1 | A test loaded a mutated file that the dry run left out (a package loaded it, say), or replaced it with `mock.module()`. The runner stops the whole Stryker run, which saves no final report and no incremental file. | See [If a mutant run stops the campaign](#if-a-mutant-run-stops-the-campaign). |
1431
1438
  | `A mutant run could not use its watch list (<problem>), so it could not check for files the dry run missed; its result stands.` | The runner could not read the list of mutated files that the dry run left out, so this mutant run could not check whether a test loaded one of them. | Check the temporary directory; re-run if it recurs. |
package/dist/index.d.ts CHANGED
@@ -48,6 +48,13 @@ export declare class BunTestRunner implements TestRunner {
48
48
  * ascending order of it; undefined when neither had any, and the order is then left alone.
49
49
  */
50
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?;
51
58
  /**
52
59
  * Which test files' tests executed which mutants in the dry run, from this worker's dry
53
60
  * run or the shared registry; undefined when neither had any. Ranks a static mutant's
@@ -948,7 +955,9 @@ export declare class BunTestRunner implements TestRunner {
948
955
  * Classify a non-zero, non-signal, non-timeout mutant run in which no
949
956
  * individual test reported a failure. Returns an Error result when there is
950
957
  * no evidence the mutant was detected, or null to let the caller score it
951
- * Killed (with an empty killedBy, since no single test failed).
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).
952
961
  *
953
962
  * Killed needs evidence that the suite failed, and bun's summary is that
954
963
  * evidence: a non-zero ' N fail' (or 'Bailed out after N failures') or
@@ -1167,6 +1176,36 @@ export declare class BunTestRunner implements TestRunner {
1167
1176
  */
1168
1177
  private resolveKilledBy;
1169
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
+ /**
1170
1209
  * WARN about failed test names that could not be resolved to dry-run test
1171
1210
  * ids (and are therefore dropped from killedBy by resolveKilledBy). WARN,
1172
1211
  * not debug — the old debug-level log is why the resulting cache poisoning
package/dist/index.js CHANGED
@@ -5,12 +5,12 @@ import { PluginKind, declareClassPlugin } from "@stryker-mutator/api/plugin";
5
5
  import { randomBytes as randomBytes4 } from "node:crypto";
6
6
  import * as fsPromises3 from "node:fs/promises";
7
7
  import { tmpdir as tmpdir2 } from "node:os";
8
- import path16 from "node:path";
8
+ import path17 from "node:path";
9
9
  import { tokens, commonTokens } from "@stryker-mutator/api/plugin";
10
10
  import {
11
11
  DryRunStatus as DryRunStatus2,
12
12
  MutantRunStatus,
13
- TestStatus as TestStatus2,
13
+ TestStatus as TestStatus3,
14
14
  determineHitLimitReached,
15
15
  toMutantRunResult
16
16
  } from "@stryker-mutator/api/test-runner";
@@ -2892,6 +2892,10 @@ class InspectorClient {
2892
2892
  }
2893
2893
  }
2894
2894
  }
2895
+ // src/load-failure-killers.ts
2896
+ import path9 from "node:path";
2897
+ import { TestStatus as TestStatus2 } from "@stryker-mutator/api/test-runner";
2898
+
2895
2899
  // src/parsers/console-parser.ts
2896
2900
  import path8 from "node:path";
2897
2901
 
@@ -3206,22 +3210,41 @@ function buildBlock(printed, headerFile) {
3206
3210
  lateCall: errorLine === undefined ? undefined : LATE_CALL_RE.exec(errorLine)?.[1]
3207
3211
  };
3208
3212
  }
3209
- function parseUnhandledErrorBlocks(stderr, secrets = []) {
3213
+ function blockSpans(stderr, secrets) {
3210
3214
  const lines = cleanDiagnosticText(stderr, secrets).split(/\r?\n/).map((line) => line.trimEnd());
3211
3215
  const starts = lines.flatMap((line, i) => line === BLOCK_MARKER && lines[i + 1] === BLOCK_RULE ? [i] : []);
3212
- const blocks = [];
3213
- let headerFile;
3216
+ const spans = [];
3214
3217
  let scanned = 0;
3215
3218
  for (const [n, start] of starts.entries()) {
3216
- for (const line of lines.slice(scanned, start)) {
3217
- headerFile = FILE_HEADER_RE.exec(line)?.[1] ?? headerFile;
3218
- }
3219
3219
  const following = lines.slice(start + 2, starts[n + 1] ?? lines.length);
3220
3220
  const closingRule = following.indexOf(BLOCK_RULE);
3221
- blocks.push(buildBlock(closingRule === -1 ? following : following.slice(0, closingRule), headerFile));
3221
+ spans.push({ before: lines.slice(scanned, start), body: closingRule === -1 ? following : following.slice(0, closingRule) });
3222
3222
  scanned = closingRule === -1 ? start + 2 + following.length : start + 2 + closingRule + 1;
3223
3223
  }
3224
- return blocks;
3224
+ return spans;
3225
+ }
3226
+ function parseUnhandledErrorBlocks(stderr, secrets = []) {
3227
+ let headerFile;
3228
+ return blockSpans(stderr, secrets).map(({ before, body }) => {
3229
+ for (const line of before) {
3230
+ headerFile = FILE_HEADER_RE.exec(line)?.[1] ?? headerFile;
3231
+ }
3232
+ return buildBlock(body, headerFile);
3233
+ });
3234
+ }
3235
+ function blockHeaderFiles(stderr, runFileOf, secrets = []) {
3236
+ return blockSpans(stderr, secrets).map(({ before }) => {
3237
+ const printed = before.filter((line) => line !== "");
3238
+ const last = printed.at(-1);
3239
+ const file = last === undefined ? undefined : runFileOf(last);
3240
+ if (typeof file !== "string") {
3241
+ return;
3242
+ }
3243
+ return printed.every((line) => {
3244
+ const named = runFileOf(line);
3245
+ return named === file || named === undefined && !FILE_HEADER_RE.test(line);
3246
+ }) ? file : undefined;
3247
+ });
3225
3248
  }
3226
3249
  var isSnippetLine = (line) => SNIPPET_LINE_RE.test(line) || SNIPPET_CARET_RE.test(line);
3227
3250
  function renderBlock(block, index, total) {
@@ -3443,6 +3466,114 @@ function layOut(blocks, claims) {
3443
3466
  };
3444
3467
  }
3445
3468
 
3469
+ // src/load-failure-killers.ts
3470
+ var TEST_ID_FILE_SEPARATOR = " > ";
3471
+ var GROUP_PREFIX = "::group::";
3472
+ function indexTestIdsByFile(tests) {
3473
+ const byFile = new Map;
3474
+ const uncertain = new Set;
3475
+ for (const test of tests) {
3476
+ const file = test.fileName;
3477
+ if (file === undefined) {
3478
+ continue;
3479
+ }
3480
+ if (!test.id.startsWith(`${file}${TEST_ID_FILE_SEPARATOR}`)) {
3481
+ uncertain.add(file);
3482
+ } else if (test.status !== TestStatus2.Skipped) {
3483
+ const ids = byFile.get(file) ?? [];
3484
+ ids.push(test.id);
3485
+ byFile.set(file, ids);
3486
+ }
3487
+ }
3488
+ for (const file of uncertain) {
3489
+ byFile.delete(file);
3490
+ }
3491
+ return byFile;
3492
+ }
3493
+ function isTestIdsEntry(entry) {
3494
+ return Array.isArray(entry) && entry.length === 2 && typeof entry[0] === "string" && Array.isArray(entry[1]) && entry[1].every((id) => typeof id === "string");
3495
+ }
3496
+ function parseTestIdsByFile(value, known) {
3497
+ if (!Array.isArray(value)) {
3498
+ return;
3499
+ }
3500
+ const byFile = new Map;
3501
+ for (const entry of value) {
3502
+ if (!isTestIdsEntry(entry) || byFile.has(entry[0])) {
3503
+ return;
3504
+ }
3505
+ const [file, ids] = entry;
3506
+ if (!ids.every((id) => known.has(id) && id.startsWith(`${file}${TEST_ID_FILE_SEPARATOR}`))) {
3507
+ return;
3508
+ }
3509
+ byFile.set(file, ids);
3510
+ }
3511
+ return byFile;
3512
+ }
3513
+ function runFileResolver(testFiles, cwd) {
3514
+ const files = new Set(testFiles.map((file) => path9.resolve(cwd, file)));
3515
+ const keyCounts = new Map;
3516
+ for (const file of files) {
3517
+ const key = dryRunKey(file, cwd);
3518
+ keyCounts.set(key, (keyCounts.get(key) ?? 0) + 1);
3519
+ }
3520
+ return (line) => {
3521
+ if (!line.endsWith(":")) {
3522
+ return;
3523
+ }
3524
+ const printed = line.slice(0, -1);
3525
+ const candidates = printed.startsWith(GROUP_PREFIX) ? [printed, printed.slice(GROUP_PREFIX.length)] : [printed];
3526
+ const matches = new Set(candidates.filter((candidate) => candidate !== "").map((candidate) => path9.resolve(cwd, candidate)).filter((file) => files.has(file)));
3527
+ if (matches.size === 0) {
3528
+ return;
3529
+ }
3530
+ const [file] = matches;
3531
+ const key = dryRunKey(file, cwd);
3532
+ return matches.size === 1 && keyCounts.get(key) === 1 && path9.resolve(cwd, key) === file ? file : null;
3533
+ };
3534
+ }
3535
+ function dryRunKey(file, cwd) {
3536
+ return normalizeTestFilePath(file, cwd) ?? file;
3537
+ }
3538
+ function noTestRan(output, blockCount) {
3539
+ const summary = readBunSummary(output);
3540
+ if (summary.ran === undefined) {
3541
+ return false;
3542
+ }
3543
+ if (summary.bailed !== undefined) {
3544
+ return summary.ran === summary.bailed;
3545
+ }
3546
+ return summary.pass === 0 && summary.ran === summary.skip + summary.todo + summary.fail && summary.fail <= blockCount;
3547
+ }
3548
+ var NO_CREDIT = { killedBy: [], files: [] };
3549
+ function creditLoadFailures(run) {
3550
+ const { byFile, testFiles, cwd, covering } = run;
3551
+ if (byFile === undefined || testFiles === undefined || testFiles.length === 0) {
3552
+ return NO_CREDIT;
3553
+ }
3554
+ const headers = blockHeaderFiles(run.stderr, runFileResolver(testFiles, cwd));
3555
+ if (headers.length === 0 || !noTestRan(`${run.stdout}
3556
+ ${run.stderr}`, headers.length)) {
3557
+ return NO_CREDIT;
3558
+ }
3559
+ const killedBy = new Set;
3560
+ const files = new Set;
3561
+ for (const header of headers) {
3562
+ if (header === undefined) {
3563
+ continue;
3564
+ }
3565
+ const file = dryRunKey(header, cwd);
3566
+ const selected = (byFile.get(file) ?? []).filter((id) => covering.size === 0 || covering.has(id));
3567
+ if (selected.length > 0) {
3568
+ files.add(file);
3569
+ }
3570
+ for (const id of selected) {
3571
+ killedBy.add(id);
3572
+ }
3573
+ }
3574
+ return { killedBy: [...killedBy], files: [...files] };
3575
+ }
3576
+
3446
3577
  // src/process-runner.ts
3447
3578
  import { spawn as spawn3 } from "node:child_process";
3448
3579
 
@@ -3505,13 +3636,13 @@ async function getPsRss(pid) {
3505
3636
  }
3506
3637
 
3507
3638
  // src/utils/project-dir.ts
3508
- import path9 from "node:path";
3639
+ import path10 from "node:path";
3509
3640
  var PROJECT_DIR_ENV = "STRYKER_BUN_RUNNER_PROJECT_DIR";
3510
3641
  var STRYKER_WORKER_ENV = "STRYKER_MUTATOR_WORKER";
3511
3642
  function recordProjectDirectory() {
3512
3643
  const inherited = process.env[PROJECT_DIR_ENV];
3513
3644
  const isWorker = process.env[STRYKER_WORKER_ENV] !== undefined;
3514
- if (isWorker && inherited !== undefined && path9.isAbsolute(inherited)) {
3645
+ if (isWorker && inherited !== undefined && path10.isAbsolute(inherited)) {
3515
3646
  return inherited;
3516
3647
  }
3517
3648
  const here = process.cwd();
@@ -3520,24 +3651,24 @@ function recordProjectDirectory() {
3520
3651
  }
3521
3652
  var projectDirectory = recordProjectDirectory();
3522
3653
  function resolveAgainstProject(file) {
3523
- return path9.resolve(projectDirectory, file);
3654
+ return path10.resolve(projectDirectory, file);
3524
3655
  }
3525
3656
 
3526
3657
  // src/utils/test-file-args.ts
3527
- import path10 from "node:path";
3658
+ import path11 from "node:path";
3528
3659
  var MAX_TEST_FILE_ARGS_BYTES = 131072;
3529
3660
  var ENTRY_OVERHEAD_BYTES = 1 + 8;
3530
3661
  var bytesOf = (args) => args.reduce((sum, arg) => sum + Buffer.byteLength(arg) + ENTRY_OVERHEAD_BYTES, 0);
3531
3662
  function shortestSpelling(absolute, cwd) {
3532
- const relative = path10.relative(cwd, absolute);
3663
+ const relative = path11.relative(cwd, absolute);
3533
3664
  if (relative === "" || relative === "..") {
3534
3665
  return absolute;
3535
3666
  }
3536
- const spelled = relative.startsWith(`..${path10.sep}`) ? relative : `.${path10.sep}${relative}`;
3667
+ const spelled = relative.startsWith(`..${path11.sep}`) ? relative : `.${path11.sep}${relative}`;
3537
3668
  return spelled.length < absolute.length ? spelled : absolute;
3538
3669
  }
3539
3670
  function computeTestFileArgs(files, cwd, budget) {
3540
- const absolute = files.map((file) => path10.resolve(cwd, file));
3671
+ const absolute = files.map((file) => path11.resolve(cwd, file));
3541
3672
  const absoluteBytes = bytesOf(absolute);
3542
3673
  if (absoluteBytes <= budget) {
3543
3674
  return { args: absolute, form: "absolute", bytes: absoluteBytes, fits: true };
@@ -3551,7 +3682,7 @@ function sameEntries(a, b) {
3551
3682
  }
3552
3683
  var lastBuild;
3553
3684
  function buildTestFileArgs(files, cwd = process.cwd(), budget = MAX_TEST_FILE_ARGS_BYTES) {
3554
- if (!path10.isAbsolute(cwd)) {
3685
+ if (!path11.isAbsolute(cwd)) {
3555
3686
  return computeTestFileArgs(files, cwd, budget);
3556
3687
  }
3557
3688
  const cached = lastBuild;
@@ -3893,7 +4024,7 @@ Process error: ${error.message}`,
3893
4024
 
3894
4025
  // src/run-profile.ts
3895
4026
  import { appendFileSync as appendFileSync2 } from "node:fs";
3896
- import path11 from "node:path";
4027
+ import path12 from "node:path";
3897
4028
  import { StringDecoder } from "node:string_decoder";
3898
4029
  var PROFILE_FORMAT_VERSION = 1;
3899
4030
  var SPAWN_MARKS = ["spawnStart", "spawned", "firstStderr", "inspector", "firstFile", "decisive", "exit", "close"];
@@ -4251,7 +4382,7 @@ function createWorkerProfiler(logger, env = process.env) {
4251
4382
  if (value === undefined || value === "" || value === "0" || value === "false") {
4252
4383
  return;
4253
4384
  }
4254
- if (!path11.isAbsolute(value)) {
4385
+ if (!path12.isAbsolute(value)) {
4255
4386
  logger.warn("%s must be the absolute path of a JSONL file to append to (got %s); profiling is off", PROFILE_ENV, value);
4256
4387
  return;
4257
4388
  }
@@ -4624,7 +4755,7 @@ class SyncServer {
4624
4755
  }
4625
4756
  // src/utils/bunfig-sanitizer.ts
4626
4757
  import { readFile as readFile5, unlink as unlink3 } from "node:fs/promises";
4627
- import path12 from "node:path";
4758
+ import path13 from "node:path";
4628
4759
  import { parse, stringify } from "smol-toml";
4629
4760
  var SAFE_TEST_KEYS = new Set([
4630
4761
  "preload",
@@ -4658,7 +4789,7 @@ function absolutizePath(value, projectCwd) {
4658
4789
  if (typeof value !== "string") {
4659
4790
  return value;
4660
4791
  }
4661
- return path12.isAbsolute(value) ? value : path12.resolve(projectCwd, value);
4792
+ return path13.isAbsolute(value) ? value : path13.resolve(projectCwd, value);
4662
4793
  }
4663
4794
  function absolutizePathValue(value, projectCwd) {
4664
4795
  if (Array.isArray(value)) {
@@ -4667,7 +4798,7 @@ function absolutizePathValue(value, projectCwd) {
4667
4798
  return absolutizePath(value, projectCwd);
4668
4799
  }
4669
4800
  async function readSourceBunfig(projectCwd, sourceBunfig) {
4670
- const bunfigPath = sourceBunfig === undefined ? path12.join(projectCwd, "bunfig.toml") : path12.resolve(projectCwd, sourceBunfig);
4801
+ const bunfigPath = sourceBunfig === undefined ? path13.join(projectCwd, "bunfig.toml") : path13.resolve(projectCwd, sourceBunfig);
4671
4802
  try {
4672
4803
  const content = await readFile5(bunfigPath, "utf8");
4673
4804
  return parse(content);
@@ -4682,14 +4813,14 @@ async function readSourceBunfig(projectCwd, sourceBunfig) {
4682
4813
  async function readBunfigTestRoot(projectCwd, sourceBunfig) {
4683
4814
  const rawConfig = await readSourceBunfig(projectCwd, sourceBunfig);
4684
4815
  const root = rawConfig.test?.root;
4685
- return typeof root === "string" ? path12.resolve(projectCwd, root) : undefined;
4816
+ return typeof root === "string" ? path13.resolve(projectCwd, root) : undefined;
4686
4817
  }
4687
4818
  async function readBunfigTestPreloads(projectCwd, sourceBunfig) {
4688
4819
  return testPreloadsOf(await readSourceBunfig(projectCwd, sourceBunfig), projectCwd);
4689
4820
  }
4690
4821
  function testPreloadsOf(rawConfig, projectCwd) {
4691
4822
  const preload = rawConfig.test?.preload;
4692
- return [preload].flat().filter((entry) => typeof entry === "string").map((entry) => path12.resolve(projectCwd, entry));
4823
+ return [preload].flat().filter((entry) => typeof entry === "string").map((entry) => path13.resolve(projectCwd, entry));
4693
4824
  }
4694
4825
  var SCAN_NEUTRAL_BUNFIG_KEYS = new Set(["preload", "smol", "logLevel", "telemetry", "env", "console", "serve", "install", "run", "conditions", "test"]);
4695
4826
  var JSX_BUNFIG_KEYS = new Set(["jsx", "jsxImportSource", "jsxFactory", "jsxFragment"]);
@@ -4771,7 +4902,7 @@ async function generateSanitizedBunfig(projectCwd, tmpDir, sourceBunfig, onDropp
4771
4902
  dropped.push({ key: `test.${key}`, reason: RANDOM_ORDER_REASON, warn: false, mutantRunsOnly: true });
4772
4903
  }
4773
4904
  onDropped?.(dropped);
4774
- const outPath = path12.join(tmpDir, `stryker-bun-runner-bunfig-${process.pid}-${Date.now()}.toml`);
4905
+ const outPath = path13.join(tmpDir, `stryker-bun-runner-bunfig-${process.pid}-${Date.now()}.toml`);
4775
4906
  await writePrivateFile(outPath, stringify(sanitized));
4776
4907
  const mutantRunTest = { ...sanitizedTest, onlyFailures: true };
4777
4908
  if (randomOrderKeys.length > 0) {
@@ -4796,7 +4927,7 @@ async function cleanupSanitizedBunfig(filePath) {
4796
4927
  }
4797
4928
  // src/utils/test-file-discovery.ts
4798
4929
  import * as fsPromises2 from "node:fs/promises";
4799
- import path13 from "node:path";
4930
+ import path14 from "node:path";
4800
4931
  function isExcludedDirName(name) {
4801
4932
  return name.startsWith(".") || name.toLowerCase() === "node_modules";
4802
4933
  }
@@ -4842,7 +4973,7 @@ async function handleSymlinkFile(fullPath, entryName, ctx) {
4842
4973
  }
4843
4974
  const resolvedTarget = await tryRealpath(fullPath);
4844
4975
  if (resolvedTarget && !hasExcludedAncestor(resolvedTarget)) {
4845
- ctx.results.push(path13.relative(ctx.cwd, fullPath));
4976
+ ctx.results.push(path14.relative(ctx.cwd, fullPath));
4846
4977
  }
4847
4978
  }
4848
4979
  async function handleSymlink(fullPath, entryName, ctx) {
@@ -4858,7 +4989,7 @@ async function handleSymlink(fullPath, entryName, ctx) {
4858
4989
  }
4859
4990
  }
4860
4991
  async function processEntry(entry, dir, ctx) {
4861
- const fullPath = path13.join(dir, entry.name);
4992
+ const fullPath = path14.join(dir, entry.name);
4862
4993
  if (entry.isDirectory()) {
4863
4994
  if (!isExcludedDirName(entry.name)) {
4864
4995
  await ctx.walk(fullPath);
@@ -4866,7 +4997,7 @@ async function processEntry(entry, dir, ctx) {
4866
4997
  } else if (entry.isSymbolicLink()) {
4867
4998
  await handleSymlink(fullPath, entry.name, ctx);
4868
4999
  } else if (entry.isFile() && TEST_FILE_SUFFIX_RE.test(entry.name)) {
4869
- ctx.results.push(path13.relative(ctx.cwd, fullPath));
5000
+ ctx.results.push(path14.relative(ctx.cwd, fullPath));
4870
5001
  }
4871
5002
  }
4872
5003
  async function discoverTestFiles(cwd = process.cwd(), logger, sourceBunfig) {
@@ -4910,14 +5041,14 @@ async function walkTestFiles(walkRoot, cwd, logger) {
4910
5041
  }
4911
5042
  async function expandTestFileEntries(entries, cwd, logger) {
4912
5043
  const expanded = await Promise.all(entries.map(async (entry) => {
4913
- const absolute = path13.resolve(cwd, entry);
5044
+ const absolute = path14.resolve(cwd, entry);
4914
5045
  const stat = await tryStat(absolute);
4915
5046
  if (stat?.isFile()) {
4916
5047
  return [absolute];
4917
5048
  }
4918
5049
  if (stat?.isDirectory()) {
4919
5050
  const found = await walkTestFiles(absolute, cwd, logger);
4920
- return found.map((file) => path13.resolve(cwd, file));
5051
+ return found.map((file) => path14.resolve(cwd, file));
4921
5052
  }
4922
5053
  return entry;
4923
5054
  }));
@@ -4956,7 +5087,7 @@ class MutantWarnAggregator {
4956
5087
  }
4957
5088
  }
4958
5089
  // src/utils/likely-killer-order.ts
4959
- import path14 from "node:path";
5090
+ import path15 from "node:path";
4960
5091
  var SWITCH_DECLARATION_RE = /function stryMutAct_([\w$]+)\(/;
4961
5092
  var HELPER_CALL_RE = /(?<![\w$])(?:stryMutAct|stryCov)_([\w$]+)\(([^()]*)\)/g;
4962
5093
  var ID_ARGUMENT_RE = /"([^"\\]+)"/g;
@@ -5046,8 +5177,8 @@ function namedAfter(sourceFile) {
5046
5177
  if (sourceFile === undefined) {
5047
5178
  return () => false;
5048
5179
  }
5049
- const sourceStem = path14.parse(sourceFile).name.toLowerCase();
5050
- return (testFile) => path14.basename(testFile).replace(TEST_FILE_SUFFIX_RE, "").toLowerCase() === sourceStem;
5180
+ const sourceStem = path15.parse(sourceFile).name.toLowerCase();
5181
+ return (testFile) => path15.basename(testFile).replace(TEST_FILE_SUFFIX_RE, "").toLowerCase() === sourceStem;
5051
5182
  }
5052
5183
  function compareKillerRanks(a, b) {
5053
5184
  return a.coverage - b.coverage || b.sourceMutants - a.sourceMutants || Number(b.namedAfter) - Number(a.namedAfter);
@@ -5059,7 +5190,7 @@ function orderLikelyKillersFirst(files, rankOf) {
5059
5190
  // src/utils/dry-run-output-log.ts
5060
5191
  import { randomUUID } from "node:crypto";
5061
5192
  import { lstat as lstat2, mkdir as mkdir2, open, rename as rename2, rm as rm4 } from "node:fs/promises";
5062
- import path15 from "node:path";
5193
+ import path16 from "node:path";
5063
5194
  var MAX_LOG_STREAM_CHARS = 16 * 1024 * 1024;
5064
5195
  var MAX_LOG_COMMAND_CHARS = 4000;
5065
5196
  function capStream(text, max) {
@@ -5154,11 +5285,11 @@ function oneLine(error) {
5154
5285
  async function saveDryRunOutput(file, output, options = {}) {
5155
5286
  try {
5156
5287
  const text = formatDryRunOutputLog(output, new Date(options.now ?? Date.now()), options.maxStreamChars);
5157
- const directory = path15.dirname(file);
5288
+ const directory = path16.dirname(file);
5158
5289
  await mkdir2(directory, { recursive: true });
5159
5290
  throwIfAbandoned(options.signal);
5160
5291
  await checkTarget(file);
5161
- const temporary = path15.join(directory, `.stryker-bun-runner-output-${randomUUID()}.tmp`);
5292
+ const temporary = path16.join(directory, `.stryker-bun-runner-output-${randomUUID()}.tmp`);
5162
5293
  const handle = await open(temporary, "wx", 384);
5163
5294
  try {
5164
5295
  try {
@@ -5278,7 +5409,7 @@ async function writingTo(file, write) {
5278
5409
  var MISSING_COVERAGE_FOR_RULE_3_3 = "the run that publishes left no coverage data, so the runner cannot check that it reached every mutant the plain run of the tests reached";
5279
5410
  var RUN_ORDINALS = ["first", "second", "third"];
5280
5411
  function isGreen(result) {
5281
- return result.status === DryRunStatus2.Complete && !result.tests.some((test) => test.status === TestStatus2.Failed);
5412
+ return result.status === DryRunStatus2.Complete && !result.tests.some((test) => test.status === TestStatus3.Failed);
5282
5413
  }
5283
5414
  function buildTestNameIndex(tests, bunNames) {
5284
5415
  const testNameIndex = new Map;
@@ -5307,7 +5438,6 @@ function defaultFailureMessage(testInfo) {
5307
5438
  }
5308
5439
  var MAX_DRY_RUN_FAILURE_TESTS_LISTED = 20;
5309
5440
  var MAX_COVERAGE_BLEED_WARNINGS = 25;
5310
- var TEST_ID_FILE_SEPARATOR = " > ";
5311
5441
  function sumDurationsByFile(tests) {
5312
5442
  const durations = new Map;
5313
5443
  for (const test of tests) {
@@ -5410,6 +5540,7 @@ class BunTestRunner {
5410
5540
  loggedRandomizeOff = false;
5411
5541
  loggedFileArgNotes = new Set;
5412
5542
  testFileDurations;
5543
+ testIdsByFile;
5413
5544
  testFileCoverage;
5414
5545
  sourceCoverageCounts = new Map;
5415
5546
  sourceBunfig;
@@ -5506,7 +5637,7 @@ class BunTestRunner {
5506
5637
  maxSpawnDepth: this.maxSpawnDepth,
5507
5638
  dryRunOutputFile: this.dryRunOutputFile
5508
5639
  });
5509
- if (this.testFilesOverride?.some((p) => path16.isAbsolute(p))) {
5640
+ if (this.testFilesOverride?.some((p) => path17.isAbsolute(p))) {
5510
5641
  const isSandbox = process.cwd().includes(".stryker-tmp/sandbox-");
5511
5642
  if (isSandbox) {
5512
5643
  this.logger.warn("bun.testFiles contains absolute path(s) and the current working directory appears to be a Stryker sandbox (%s). " + "Absolute paths point at the ORIGINAL (unmutated) source files — mutations will be silently bypassed. " + "Use relative paths so that Bun resolves them against the sandbox copy.", process.cwd());
@@ -5515,7 +5646,7 @@ class BunTestRunner {
5515
5646
  }
5516
5647
  async resolveRegistryPath() {
5517
5648
  this.assertRunOwnerIsParent();
5518
- return path16.join(await resolveRunTempDir(), REGISTRY_FILE);
5649
+ return path17.join(await resolveRunTempDir(), REGISTRY_FILE);
5519
5650
  }
5520
5651
  assertRunOwnerIsParent() {
5521
5652
  if (this.runOwnerPid !== undefined && process.ppid !== this.runOwnerPid) {
@@ -5646,7 +5777,7 @@ class BunTestRunner {
5646
5777
  this.logger.debug("Stryker passed an empty testFiles array; ignoring it");
5647
5778
  }
5648
5779
  } else {
5649
- const files = [...new Set(requested.map((file) => path16.resolve(cwd, file)))].toSorted((a, b) => a.localeCompare(b));
5780
+ const files = [...new Set(requested.map((file) => path17.resolve(cwd, file)))].toSorted((a, b) => a.localeCompare(b));
5650
5781
  this.strykerTestFiles = { cwd, files };
5651
5782
  this.warnIfTestFilesOverridden(files, cwd);
5652
5783
  }
@@ -5708,7 +5839,7 @@ class BunTestRunner {
5708
5839
  if (this.warnedTestFilesConflict || this.testFilesOverride === undefined) {
5709
5840
  return;
5710
5841
  }
5711
- const configured = [...new Set(this.testFilesOverride.map((file) => path16.resolve(cwd, file)))];
5842
+ const configured = [...new Set(this.testFilesOverride.map((file) => path17.resolve(cwd, file)))];
5712
5843
  const selectedSet = new Set(selected);
5713
5844
  if (configured.length === selectedSet.size && configured.every((file) => selectedSet.has(file))) {
5714
5845
  return;
@@ -5781,7 +5912,7 @@ class BunTestRunner {
5781
5912
  this.runOwnerPid ??= process.ppid;
5782
5913
  const tempDir = await this.ensureRunTempDir();
5783
5914
  this.tempDirTouchedAt = Date.now();
5784
- this.coverageFilePath = path16.join(tempDir, `coverage-${Date.now()}.json`);
5915
+ this.coverageFilePath = path17.join(tempDir, `coverage-${Date.now()}.json`);
5785
5916
  this.logger.debug("Generating coverage preload script...");
5786
5917
  const eagerCwd = process.cwd();
5787
5918
  const testFilesPending = this.getOrDiscoverTestFiles();
@@ -5810,7 +5941,7 @@ class BunTestRunner {
5810
5941
  if (marker === undefined) {
5811
5942
  return;
5812
5943
  }
5813
- const campaign = await readRegistryCampaign(path16.join(runDir, REGISTRY_FILE));
5944
+ const campaign = await readRegistryCampaign(path17.join(runDir, REGISTRY_FILE));
5814
5945
  if (campaign?.generation !== marker.generation) {
5815
5946
  this.logger.debug("Ignoring the abort marker in %s: it belongs to an earlier campaign", runDir);
5816
5947
  return;
@@ -5885,11 +6016,12 @@ ${lines}`, ...ignored.flatMap((d) => [d.key.replace(/^test\./, "[test]."), d.rea
5885
6016
  this.strykerTestFiles = { cwd: process.cwd(), files: selectedFiles };
5886
6017
  }
5887
6018
  this.testFileDurations = parseTestFileDurations(parsed.testFileDurations);
6019
+ this.testIdsByFile = parseTestIdsByFile(parsed.testIdsByFile, this.cachedTestNames);
5888
6020
  this.setTestFileCoverage(TestFileCoverage.fromJson(parsed.mutantTestFiles));
5889
6021
  if (this.coverageAnalysis !== "off") {
5890
6022
  this.timeoutCorrectionMs = parsed.timeoutCorrectionMs;
5891
6023
  const campaign = parseCampaignState(parsed.campaign);
5892
- this.campaign = campaign === undefined ? undefined : campaignOf(campaign, path16.dirname(registryPath));
6024
+ this.campaign = campaign === undefined ? undefined : campaignOf(campaign, path17.dirname(registryPath));
5893
6025
  }
5894
6026
  this.logger.debug("Loaded dryRun registry from %s (%d entries)", registryPath, this.cachedTestNames.size);
5895
6027
  } catch (err) {
@@ -5916,7 +6048,7 @@ ${stack}` : baseFailureMessage;
5916
6048
  return {
5917
6049
  id: normalizedName,
5918
6050
  name: normalizedName,
5919
- status: TestStatus2.Failed,
6051
+ status: TestStatus3.Failed,
5920
6052
  failureMessage: t.failureMessage ?? "Test failed",
5921
6053
  timeSpentMs: Math.round(t.duration ?? 1)
5922
6054
  };
@@ -5925,14 +6057,14 @@ ${stack}` : baseFailureMessage;
5925
6057
  return {
5926
6058
  id: normalizedName,
5927
6059
  name: normalizedName,
5928
- status: TestStatus2.Skipped,
6060
+ status: TestStatus3.Skipped,
5929
6061
  timeSpentMs: Math.round(t.duration ?? 1)
5930
6062
  };
5931
6063
  }
5932
6064
  return {
5933
6065
  id: normalizedName,
5934
6066
  name: normalizedName,
5935
- status: TestStatus2.Success,
6067
+ status: TestStatus3.Success,
5936
6068
  timeSpentMs: Math.round(t.duration ?? 1)
5937
6069
  };
5938
6070
  });
@@ -5950,7 +6082,7 @@ ${stack}` : baseFailureMessage;
5950
6082
  return {
5951
6083
  id: `unknown-${inspectorId}`,
5952
6084
  name: `unknown-${inspectorId}`,
5953
- status: TestStatus2.Success,
6085
+ status: TestStatus3.Success,
5954
6086
  timeSpentMs: timePerTest
5955
6087
  };
5956
6088
  }
@@ -5966,7 +6098,7 @@ ${stack}` : baseFailureMessage;
5966
6098
  name: uniqueName,
5967
6099
  fileName,
5968
6100
  startPosition,
5969
- status: TestStatus2.Failed,
6101
+ status: TestStatus3.Failed,
5970
6102
  failureMessage: this.buildFailureMessage(testInfo, parsed),
5971
6103
  timeSpentMs: elapsed
5972
6104
  };
@@ -5977,7 +6109,7 @@ ${stack}` : baseFailureMessage;
5977
6109
  name: uniqueName,
5978
6110
  fileName,
5979
6111
  startPosition,
5980
- status: TestStatus2.Skipped,
6112
+ status: TestStatus3.Skipped,
5981
6113
  timeSpentMs: elapsed
5982
6114
  };
5983
6115
  }
@@ -5986,7 +6118,7 @@ ${stack}` : baseFailureMessage;
5986
6118
  name: uniqueName,
5987
6119
  fileName,
5988
6120
  startPosition,
5989
- status: TestStatus2.Success,
6121
+ status: TestStatus3.Success,
5990
6122
  timeSpentMs: elapsed
5991
6123
  };
5992
6124
  });
@@ -6044,7 +6176,7 @@ ${stack}` : baseFailureMessage;
6044
6176
  handed: []
6045
6177
  };
6046
6178
  if (this.inPlace && this.tempDir !== undefined) {
6047
- await removeQuietly(path16.join(this.tempDir, ABORT_MARKER_FILE));
6179
+ await removeQuietly(path17.join(this.tempDir, ABORT_MARKER_FILE));
6048
6180
  }
6049
6181
  if (coverageAnalysis === "off") {
6050
6182
  return this.runWithoutCoverage(launchContext);
@@ -6094,7 +6226,7 @@ ${stack}` : baseFailureMessage;
6094
6226
  const { expanded } = tests;
6095
6227
  let selected = [];
6096
6228
  if (expanded !== undefined) {
6097
- selected = "files" in expanded ? expanded.files : tests.entries.map((entry) => path16.resolve(ctx.cwd, entry));
6229
+ selected = "files" in expanded ? expanded.files : tests.entries.map((entry) => path17.resolve(ctx.cwd, entry));
6098
6230
  }
6099
6231
  const split = await withoutSelectedTestFiles(ctx.matched, selected);
6100
6232
  if (split.removed.length > 0) {
@@ -6215,7 +6347,7 @@ ${stack}` : baseFailureMessage;
6215
6347
  }
6216
6348
  async applicableTsconfig(cwd) {
6217
6349
  for (const name of ["tsconfig.json", "jsconfig.json"]) {
6218
- const file = path16.join(cwd, name);
6350
+ const file = path17.join(cwd, name);
6219
6351
  const stat = await fsPromises3.stat(file).catch(() => {
6220
6352
  return;
6221
6353
  });
@@ -6259,7 +6391,7 @@ ${stack}` : baseFailureMessage;
6259
6391
  }
6260
6392
  launchFiles(ctx) {
6261
6393
  return {
6262
- planFile: this.preloadScriptPath === undefined ? undefined : newLaunchFile(path16.dirname(this.preloadScriptPath), "dry-run-plan"),
6394
+ planFile: this.preloadScriptPath === undefined ? undefined : newLaunchFile(path17.dirname(this.preloadScriptPath), "dry-run-plan"),
6263
6395
  recordFile: newRecordFile(ctx.runDir)
6264
6396
  };
6265
6397
  }
@@ -6562,7 +6694,7 @@ ${outputLine}`;
6562
6694
  const abortController = new AbortController;
6563
6695
  this.currentAbortController = abortController;
6564
6696
  ctx.profile?.restartLaunch();
6565
- const coverageFile = this.coverageFilePath === undefined ? undefined : newLaunchFile(path16.dirname(this.coverageFilePath), "coverage");
6697
+ const coverageFile = this.coverageFilePath === undefined ? undefined : newLaunchFile(path17.dirname(this.coverageFilePath), "coverage");
6566
6698
  const launched = {};
6567
6699
  try {
6568
6700
  return await this.runInspectedChild(ctx, list, planFile, coverageFile, abortController, launched);
@@ -6791,7 +6923,7 @@ exit=%s timedOut=%s
6791
6923
  }
6792
6924
  checkCoverageData(coverage, tests, run, stderr) {
6793
6925
  const preloadLines = extractPreloadCoverageDiagnostics(stderr);
6794
- if (coverage !== undefined || tests.some((t) => t.status === TestStatus2.Failed)) {
6926
+ if (coverage !== undefined || tests.some((t) => t.status === TestStatus3.Failed)) {
6795
6927
  if (preloadLines.length > 0) {
6796
6928
  this.logger.warn(`The coverage preload reported problems on the dry-run child's stderr:
6797
6929
  %s`, preloadLines.join(`
@@ -6807,7 +6939,7 @@ exit=%s timedOut=%s
6807
6939
  }
6808
6940
  missingCoverageResult(coverageAnalysis, preloadLines, coverageFile) {
6809
6941
  const file = coverageFile ?? "(none configured)";
6810
- const coverageDir = coverageFile === undefined ? tmpdir2() : path16.dirname(coverageFile);
6942
+ const coverageDir = coverageFile === undefined ? tmpdir2() : path17.dirname(coverageFile);
6811
6943
  const causes = "Likely causes: the coverage preload never ran (check for a [test].preload in bunfig.toml or bun.bunArgs that replaces or bypasses it), " + `${coverageDir} is not writable, or the bun test child exited before its final afterAll hook wrote the file (e.g. a test calls process.exit).`;
6812
6944
  const diagnostics = preloadLines.length > 0 ? [`Coverage preload diagnostics from the child's stderr:
6813
6945
  ${preloadLines.join(`
@@ -6862,6 +6994,7 @@ ${preloadLines.join(`
6862
6994
  this.testNameIndex = testNameIndex;
6863
6995
  this.testFileDurations = sumDurationsByFile(tests);
6864
6996
  this.logger.debug("Recorded dry-run durations for %d test file(s) to order mutant runs cheapest-first", this.testFileDurations.size);
6997
+ this.testIdsByFile = indexTestIdsByFile(tests);
6865
6998
  this.setTestFileCoverage(testFileCoverage);
6866
6999
  this.timeoutCorrectionMs = campaignInput?.timeoutCorrectionMs;
6867
7000
  if (campaignInput !== undefined) {
@@ -6869,7 +7002,7 @@ ${preloadLines.join(`
6869
7002
  }
6870
7003
  this.campaign = undefined;
6871
7004
  try {
6872
- const indexes = { cachedTestNames: this.cachedTestNames, baseNameIndex: this.baseNameIndex, testNameIndex, testFileDurations: this.testFileDurations };
7005
+ const indexes = { cachedTestNames: this.cachedTestNames, baseNameIndex: this.baseNameIndex, testNameIndex, testFileDurations: this.testFileDurations, testIdsByFile: this.testIdsByFile };
6873
7006
  await this.writeRegistry(indexes, testFileCoverage, campaignInput);
6874
7007
  return;
6875
7008
  } catch (error) {
@@ -6882,7 +7015,7 @@ ${preloadLines.join(`
6882
7015
  return failure instanceof WriteFailure ? unpublishedCampaignMessage(failure.file, failure.message, watched) : unpublishedCampaignMessage("the run's temporary directory", errorText(failure), watched);
6883
7016
  }
6884
7017
  if (campaignInput !== undefined && failure instanceof WriteFailure) {
6885
- const registryPath = path16.join(path16.dirname(failure.file), REGISTRY_FILE);
7018
+ const registryPath = path17.join(path17.dirname(failure.file), REGISTRY_FILE);
6886
7019
  const earlier = await fsPromises3.lstat(registryPath).catch(() => {
6887
7020
  return;
6888
7021
  });
@@ -6895,7 +7028,7 @@ ${preloadLines.join(`
6895
7028
  }
6896
7029
  async writeRegistry(indexes, testFileCoverage, campaignInput) {
6897
7030
  const registryPath = await this.resolveRegistryPath();
6898
- const runDir = path16.dirname(registryPath);
7031
+ const runDir = path17.dirname(registryPath);
6899
7032
  const campaign = campaignInput === undefined ? undefined : await this.writeCampaignFiles(runDir, campaignInput);
6900
7033
  const tmpPath = `${registryPath}.tmp`;
6901
7034
  const registryData = JSON.stringify({
@@ -6906,6 +7039,7 @@ ${preloadLines.join(`
6906
7039
  testNameIndex: [...indexes.testNameIndex.entries()],
6907
7040
  testFiles: this.selectedTestFilesFor(process.cwd()),
6908
7041
  testFileDurations: [...indexes.testFileDurations.entries()],
7042
+ testIdsByFile: [...indexes.testIdsByFile.entries()],
6909
7043
  mutantTestFiles: testFileCoverage?.toJSON(),
6910
7044
  timeoutCorrectionMs: campaignInput?.timeoutCorrectionMs,
6911
7045
  campaign
@@ -6916,13 +7050,13 @@ ${preloadLines.join(`
6916
7050
  await writingTo(registryPath, async () => fsPromises3.rename(tmpPath, registryPath));
6917
7051
  } catch (error) {
6918
7052
  if (campaign?.watchListFile) {
6919
- await removeQuietly(path16.join(runDir, campaign.watchListFile));
7053
+ await removeQuietly(path17.join(runDir, campaign.watchListFile));
6920
7054
  }
6921
7055
  throw error;
6922
7056
  }
6923
7057
  this.lastRegistryTmpPath = undefined;
6924
7058
  if (campaign !== undefined) {
6925
- await removeQuietly(path16.join(runDir, ABORT_MARKER_FILE));
7059
+ await removeQuietly(path17.join(runDir, ABORT_MARKER_FILE));
6926
7060
  this.campaign = campaignOf(campaign, runDir);
6927
7061
  }
6928
7062
  this.logger.debug("Wrote dryRun registry to %s (%d entries)", registryPath, indexes.cachedTestNames.size);
@@ -6939,7 +7073,7 @@ ${preloadLines.join(`
6939
7073
  fingerprint: watchListFile === null || !this.inPlace ? null : await campaignFingerprint(campaignInput.matched)
6940
7074
  };
6941
7075
  if (watchListFile !== null) {
6942
- const file = path16.join(runDir, watchListFile);
7076
+ const file = path17.join(runDir, watchListFile);
6943
7077
  await writingTo(file, async () => writeWatchList(file, watched));
6944
7078
  }
6945
7079
  return campaign;
@@ -7018,7 +7152,7 @@ ${preloadLines.join(`
7018
7152
  if (typeof options.sandboxFileName !== "string") {
7019
7153
  return;
7020
7154
  }
7021
- const file = path16.resolve(options.sandboxFileName);
7155
+ const file = path17.resolve(options.sandboxFileName);
7022
7156
  return this.campaign?.handedFiles.has(file) === true ? file : undefined;
7023
7157
  }
7024
7158
  mutantRunGuards(options) {
@@ -7029,7 +7163,7 @@ ${preloadLines.join(`
7029
7163
  }
7030
7164
  watchListForMutantRuns() {
7031
7165
  const { campaign } = this;
7032
- return campaign?.watchListFile ? path16.join(campaign.dir, campaign.watchListFile) : undefined;
7166
+ return campaign?.watchListFile ? path17.join(campaign.dir, campaign.watchListFile) : undefined;
7033
7167
  }
7034
7168
  async enforceWitness(stderr, hitLimitToken, ctx, testNamePattern) {
7035
7169
  const { campaign } = this;
@@ -7089,7 +7223,7 @@ ${preloadLines.join(`
7089
7223
  const cwd = process.cwd();
7090
7224
  const exist = await Promise.all(entries.map(async (entry) => {
7091
7225
  try {
7092
- const stat = await fsPromises3.stat(path16.resolve(cwd, entry));
7226
+ const stat = await fsPromises3.stat(path17.resolve(cwd, entry));
7093
7227
  return stat.isFile();
7094
7228
  } catch {
7095
7229
  return false;
@@ -7161,10 +7295,10 @@ ${preloadLines.join(`
7161
7295
  this.mutantWarnings.warn(MUTANT_WARN_KIND.zeroMatchRetry, options.activeMutant.id, "Mutant %s: --test-name-pattern matched 0 tests — usually a runner pattern gap or a mutant that changed an interpolated test title (it.each); retrying once with the full suite", options.activeMutant.id);
7162
7296
  return this.executeMutantRun(ctx, undefined);
7163
7297
  }
7164
- return this.buildMutantKilledResult(result, parsed, localRegistry, localBaseIndex, options.activeMutant.id);
7298
+ return this.buildMutantKilledResult(result, parsed, localRegistry, localBaseIndex, testFiles, options.activeMutant.id);
7165
7299
  }
7166
7300
  if (!parsed.summaryPrinted) {
7167
- return this.classifyEarlyCleanExit(result, parsed, localRegistry, localBaseIndex, options.activeMutant.id);
7301
+ return this.classifyEarlyCleanExit(result, parsed, localRegistry, localBaseIndex, testFiles, options.activeMutant.id);
7168
7302
  }
7169
7303
  return {
7170
7304
  status: MutantRunStatus.Survived,
@@ -7198,7 +7332,7 @@ ${preloadLines.join(`
7198
7332
  this.mutantWarnings.warn(MUTANT_WARN_KIND.inconclusiveTimeout, mutantId, "Mutant %s: inconclusive timeout, scoring as Error rather than Timeout: %s", mutantId, errorMessage);
7199
7333
  return { status: MutantRunStatus.Error, errorMessage };
7200
7334
  }
7201
- buildMutantKilledResult(result, parsed, localRegistry, localBaseIndex, mutantId, earlyExit = false) {
7335
+ buildMutantKilledResult(result, parsed, localRegistry, localBaseIndex, testFiles, mutantId, earlyExit = false) {
7202
7336
  const rawFailedNames = parsed.tests.filter((test) => test.status === "failed").map((test) => normalizeTestName(test.name));
7203
7337
  if (result.signal && rawFailedNames.length === 0) {
7204
7338
  return this.buildSignalErrorResult(result, mutantId, `bun test terminated by ${result.signal} before any test reported a failure`);
@@ -7209,7 +7343,7 @@ ${preloadLines.join(`
7209
7343
  return noEvidenceResult;
7210
7344
  }
7211
7345
  }
7212
- const killedBy = this.resolveKilledBy(rawFailedNames, localRegistry, localBaseIndex, mutantId);
7346
+ const killedBy = this.killersOf(rawFailedNames, result, testFiles, localRegistry, localBaseIndex, mutantId);
7213
7347
  if (result.signal && killedBy.length === 0) {
7214
7348
  return this.buildSignalErrorResult(result, mutantId, `bun test terminated by ${result.signal}; the ${rawFailedNames.length} failing test(s) reported could not be attributed to a known test`);
7215
7349
  }
@@ -7261,9 +7395,9 @@ ${preloadLines.join(`
7261
7395
  errorMessage: `bun test exited with code ${result.exitCode} but reported no failing test and no fail/error count, so there is no evidence a test detected this mutant: ${output}`
7262
7396
  };
7263
7397
  }
7264
- classifyEarlyCleanExit(result, parsed, localRegistry, localBaseIndex, mutantId) {
7398
+ classifyEarlyCleanExit(result, parsed, localRegistry, localBaseIndex, testFiles, mutantId) {
7265
7399
  if (parsed.tests.some((test) => test.status === "failed")) {
7266
- return this.buildMutantKilledResult(result, parsed, localRegistry, localBaseIndex, mutantId, true);
7400
+ return this.buildMutantKilledResult(result, parsed, localRegistry, localBaseIndex, testFiles, mutantId, true);
7267
7401
  }
7268
7402
  return this.buildEarlyExitErrorResult(result, mutantId, "no test reported a failure");
7269
7403
  }
@@ -7331,7 +7465,7 @@ ${lines.join(`
7331
7465
  `)}`;
7332
7466
  }
7333
7467
  warnOnUnidentifiedDryRunFailure(result, parsed, tests) {
7334
- if (parsed.failed > 0 && !tests.some((t) => t.status === TestStatus2.Failed)) {
7468
+ if (parsed.failed > 0 && !tests.some((t) => t.status === TestStatus3.Failed)) {
7335
7469
  this.logger.warn("Bun exited with code %s and its console output reported %d failed test(s), " + "but no failing test could be identified from inspector or console data. " + "An unhandled error firing between tests (e.g. a rejected fire-and-forget " + `promise) is a likely cause. Last 500 chars of stderr:
7336
7470
  %s`, String(result.exitCode), parsed.failed, result.stderr.slice(-500));
7337
7471
  }
@@ -7376,7 +7510,7 @@ ${lines.join(`
7376
7510
  }
7377
7511
  }
7378
7512
  findCompletenessProblems(facts, summaryFailed, tests, stderr, eagerModules, secrets = []) {
7379
- if (tests.some((t) => t.status === TestStatus2.Failed)) {
7513
+ if (tests.some((t) => t.status === TestStatus3.Failed)) {
7380
7514
  return [];
7381
7515
  }
7382
7516
  const reasons = findDryRunDataLoss(facts);
@@ -7497,6 +7631,23 @@ ${outputLine}`;
7497
7631
  this.warnUnresolvedKilledBy(unresolved, mutantId);
7498
7632
  return [...killedBySet];
7499
7633
  }
7634
+ killersOf(rawFailedNames, result, testFiles, localRegistry, localBaseIndex, mutantId) {
7635
+ return rawFailedNames.length === 0 ? this.creditFilesThatFailedToLoad(result, testFiles, localRegistry, mutantId) : this.resolveKilledBy(rawFailedNames, localRegistry, localBaseIndex, mutantId);
7636
+ }
7637
+ creditFilesThatFailedToLoad(result, testFiles, localRegistry, mutantId) {
7638
+ const credit = creditLoadFailures({
7639
+ stdout: result.stdout,
7640
+ stderr: result.stderr,
7641
+ testFiles,
7642
+ cwd: process.cwd(),
7643
+ byFile: this.testIdsByFile,
7644
+ covering: localRegistry
7645
+ });
7646
+ if (credit.killedBy.length > 0) {
7647
+ this.logger.debug("Mutant %s: no test ran, and %d test file(s) failed to load (%s); killedBy holds their %d selected test(s)", mutantId, credit.files.length, credit.files.join(", "), credit.killedBy.length);
7648
+ }
7649
+ return credit.killedBy;
7650
+ }
7500
7651
  warnUnresolvedKilledBy(unresolved, mutantId) {
7501
7652
  if (unresolved.size === 0) {
7502
7653
  return;
@@ -7557,7 +7708,7 @@ ${outputLine}`;
7557
7708
  // src/checker-tsconfig.ts
7558
7709
  import { readFile as readFile7, rename as rename4, rm as rm5, writeFile as writeFile2 } from "node:fs/promises";
7559
7710
  import { createRequire as createRequire2 } from "node:module";
7560
- import path17 from "node:path";
7711
+ import path18 from "node:path";
7561
7712
  import { glob as glob2 } from "tinyglobby";
7562
7713
  var DEFAULT_MUTATE_PATTERNS = ["{src,lib}/**"];
7563
7714
  var MUTATION_RANGE_RE = /:\d+(?::\d+)?-\d+(?::\d+)?$/;
@@ -7593,7 +7744,7 @@ function checkTypeScript(exported, cwd) {
7593
7744
  }
7594
7745
  function loadTypeScript(cwd) {
7595
7746
  try {
7596
- return checkTypeScript(createRequire2(path17.join(cwd, "package.json"))("typescript"), cwd);
7747
+ return checkTypeScript(createRequire2(path18.join(cwd, "package.json"))("typescript"), cwd);
7597
7748
  } catch {
7598
7749
  return cannotLoad(cwd);
7599
7750
  }
@@ -7620,7 +7771,7 @@ async function findTestFiles(config, cwd) {
7620
7771
  for (const relativeFiles of [await discoverTestFiles(cwd, undefined, sourceBunfig), bun.testFiles]) {
7621
7772
  if (relativeFiles) {
7622
7773
  for (const file of relativeFiles) {
7623
- testFiles.add(path17.resolve(cwd, file));
7774
+ testFiles.add(path18.resolve(cwd, file));
7624
7775
  }
7625
7776
  }
7626
7777
  }
@@ -7698,12 +7849,12 @@ function derivedHeader(source) {
7698
7849
  `);
7699
7850
  }
7700
7851
  function renderDerivedTsconfig(sourcePath, derivedPath, project, entryPoints) {
7701
- const source = path17.basename(sourcePath);
7852
+ const source = path18.basename(sourcePath);
7702
7853
  const body = {
7703
7854
  extends: `./${source}`,
7704
7855
  ...project.options.declarationDir !== undefined && { compilerOptions: { declarationDir: null } },
7705
7856
  include: [],
7706
- files: entryPoints.map((file) => path17.relative(path17.dirname(derivedPath), file))
7857
+ files: entryPoints.map((file) => path18.relative(path18.dirname(derivedPath), file))
7707
7858
  };
7708
7859
  return `${derivedHeader(source)}${JSON.stringify(body, null, 2)}
7709
7860
  `;
@@ -7718,8 +7869,8 @@ async function withTestFilesExcludedFromTypeCheck(config, { cwd = process.cwd()
7718
7869
  return leaveUnchanged(config, loaded.problem);
7719
7870
  }
7720
7871
  const { ts } = loaded;
7721
- const sourcePath = path17.resolve(cwd, config.tsconfigFile ?? "tsconfig.json");
7722
- const shownSource = path17.relative(cwd, sourcePath);
7872
+ const sourcePath = path18.resolve(cwd, config.tsconfigFile ?? "tsconfig.json");
7873
+ const shownSource = path18.relative(cwd, sourcePath);
7723
7874
  const read = readProject(ts, sourcePath, shownSource);
7724
7875
  if ("problem" in read) {
7725
7876
  return leaveUnchanged(config, read.problem);
@@ -7736,10 +7887,10 @@ async function withTestFilesExcludedFromTypeCheck(config, { cwd = process.cwd()
7736
7887
  if (entryPoints.length === 0) {
7737
7888
  return leaveUnchanged(config, `${shownSource} would have no files left once test files are excluded`);
7738
7889
  }
7739
- const derivedPath = path17.join(path17.dirname(sourcePath), `${path17.basename(sourcePath, ".json")}${DERIVED_SUFFIX}`);
7740
- const shownDerived = path17.relative(cwd, derivedPath);
7890
+ const derivedPath = path18.join(path18.dirname(sourcePath), `${path18.basename(sourcePath, ".json")}${DERIVED_SUFFIX}`);
7891
+ const shownDerived = path18.relative(cwd, derivedPath);
7741
7892
  const text = renderDerivedTsconfig(sourcePath, derivedPath, project, entryPoints);
7742
- const derivedProject = ts.parseJsonSourceFileConfigFileContent(ts.parseJsonText(derivedPath, text), ts.sys, path17.dirname(derivedPath), undefined, derivedPath);
7893
+ const derivedProject = ts.parseJsonSourceFileConfigFileContent(ts.parseJsonText(derivedPath, text), ts.sys, path18.dirname(derivedPath), undefined, derivedPath);
7743
7894
  const derived = createProgram(ts, derivedProject, original);
7744
7895
  const newErrors = findNewErrors(derived, original, testFiles);
7745
7896
  if (newErrors.length > 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hughescr/stryker-bun-runner",
3
- "version": "1.8.0",
3
+ "version": "1.8.1",
4
4
  "description": "Stryker mutation testing test runner plugin for Bun (bun test), with per-test coverage",
5
5
  "keywords": [
6
6
  "stryker",