@hughescr/stryker-bun-runner 1.8.0 → 1.8.2

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 = []) {
3210
- const lines = cleanDiagnosticText(stderr, secrets).split(/\r?\n/).map((line) => line.trimEnd());
3213
+ function blockSpans(text) {
3214
+ const lines = text.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(cleanDiagnosticText(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) {
3236
+ return blockSpans(stripAnsiForDiagnostics(stderr)).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,111 @@ 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.bailed !== undefined) {
3541
+ return summary.ran === summary.bailed;
3542
+ }
3543
+ return summary.pass === 0 && summary.ran === summary.skip + summary.todo + summary.fail && summary.fail <= blockCount;
3544
+ }
3545
+ var NO_CREDIT = { killedBy: [], files: [] };
3546
+ function creditLoadFailures(run) {
3547
+ const { byFile, testFiles, cwd, covering } = run;
3548
+ if (byFile === undefined || testFiles === undefined) {
3549
+ return NO_CREDIT;
3550
+ }
3551
+ const headers = blockHeaderFiles(run.stderr, runFileResolver(testFiles, cwd));
3552
+ if (!noTestRan(`${run.stdout}
3553
+ ${run.stderr}`, headers.length)) {
3554
+ return NO_CREDIT;
3555
+ }
3556
+ const killedBy = new Set;
3557
+ const files = new Set;
3558
+ for (const header of headers) {
3559
+ if (header === undefined) {
3560
+ continue;
3561
+ }
3562
+ const file = dryRunKey(header, cwd);
3563
+ const selected = (byFile.get(file) ?? []).filter((id) => covering.size === 0 || covering.has(id));
3564
+ if (selected.length > 0) {
3565
+ files.add(file);
3566
+ }
3567
+ for (const id of selected) {
3568
+ killedBy.add(id);
3569
+ }
3570
+ }
3571
+ return { killedBy: [...killedBy], files: [...files] };
3572
+ }
3573
+
3446
3574
  // src/process-runner.ts
3447
3575
  import { spawn as spawn3 } from "node:child_process";
3448
3576
 
@@ -3505,13 +3633,13 @@ async function getPsRss(pid) {
3505
3633
  }
3506
3634
 
3507
3635
  // src/utils/project-dir.ts
3508
- import path9 from "node:path";
3636
+ import path10 from "node:path";
3509
3637
  var PROJECT_DIR_ENV = "STRYKER_BUN_RUNNER_PROJECT_DIR";
3510
3638
  var STRYKER_WORKER_ENV = "STRYKER_MUTATOR_WORKER";
3511
3639
  function recordProjectDirectory() {
3512
3640
  const inherited = process.env[PROJECT_DIR_ENV];
3513
3641
  const isWorker = process.env[STRYKER_WORKER_ENV] !== undefined;
3514
- if (isWorker && inherited !== undefined && path9.isAbsolute(inherited)) {
3642
+ if (isWorker && inherited !== undefined && path10.isAbsolute(inherited)) {
3515
3643
  return inherited;
3516
3644
  }
3517
3645
  const here = process.cwd();
@@ -3520,24 +3648,24 @@ function recordProjectDirectory() {
3520
3648
  }
3521
3649
  var projectDirectory = recordProjectDirectory();
3522
3650
  function resolveAgainstProject(file) {
3523
- return path9.resolve(projectDirectory, file);
3651
+ return path10.resolve(projectDirectory, file);
3524
3652
  }
3525
3653
 
3526
3654
  // src/utils/test-file-args.ts
3527
- import path10 from "node:path";
3655
+ import path11 from "node:path";
3528
3656
  var MAX_TEST_FILE_ARGS_BYTES = 131072;
3529
3657
  var ENTRY_OVERHEAD_BYTES = 1 + 8;
3530
3658
  var bytesOf = (args) => args.reduce((sum, arg) => sum + Buffer.byteLength(arg) + ENTRY_OVERHEAD_BYTES, 0);
3531
3659
  function shortestSpelling(absolute, cwd) {
3532
- const relative = path10.relative(cwd, absolute);
3660
+ const relative = path11.relative(cwd, absolute);
3533
3661
  if (relative === "" || relative === "..") {
3534
3662
  return absolute;
3535
3663
  }
3536
- const spelled = relative.startsWith(`..${path10.sep}`) ? relative : `.${path10.sep}${relative}`;
3664
+ const spelled = relative.startsWith(`..${path11.sep}`) ? relative : `.${path11.sep}${relative}`;
3537
3665
  return spelled.length < absolute.length ? spelled : absolute;
3538
3666
  }
3539
3667
  function computeTestFileArgs(files, cwd, budget) {
3540
- const absolute = files.map((file) => path10.resolve(cwd, file));
3668
+ const absolute = files.map((file) => path11.resolve(cwd, file));
3541
3669
  const absoluteBytes = bytesOf(absolute);
3542
3670
  if (absoluteBytes <= budget) {
3543
3671
  return { args: absolute, form: "absolute", bytes: absoluteBytes, fits: true };
@@ -3551,7 +3679,7 @@ function sameEntries(a, b) {
3551
3679
  }
3552
3680
  var lastBuild;
3553
3681
  function buildTestFileArgs(files, cwd = process.cwd(), budget = MAX_TEST_FILE_ARGS_BYTES) {
3554
- if (!path10.isAbsolute(cwd)) {
3682
+ if (!path11.isAbsolute(cwd)) {
3555
3683
  return computeTestFileArgs(files, cwd, budget);
3556
3684
  }
3557
3685
  const cached = lastBuild;
@@ -3893,7 +4021,7 @@ Process error: ${error.message}`,
3893
4021
 
3894
4022
  // src/run-profile.ts
3895
4023
  import { appendFileSync as appendFileSync2 } from "node:fs";
3896
- import path11 from "node:path";
4024
+ import path12 from "node:path";
3897
4025
  import { StringDecoder } from "node:string_decoder";
3898
4026
  var PROFILE_FORMAT_VERSION = 1;
3899
4027
  var SPAWN_MARKS = ["spawnStart", "spawned", "firstStderr", "inspector", "firstFile", "decisive", "exit", "close"];
@@ -4251,7 +4379,7 @@ function createWorkerProfiler(logger, env = process.env) {
4251
4379
  if (value === undefined || value === "" || value === "0" || value === "false") {
4252
4380
  return;
4253
4381
  }
4254
- if (!path11.isAbsolute(value)) {
4382
+ if (!path12.isAbsolute(value)) {
4255
4383
  logger.warn("%s must be the absolute path of a JSONL file to append to (got %s); profiling is off", PROFILE_ENV, value);
4256
4384
  return;
4257
4385
  }
@@ -4624,7 +4752,7 @@ class SyncServer {
4624
4752
  }
4625
4753
  // src/utils/bunfig-sanitizer.ts
4626
4754
  import { readFile as readFile5, unlink as unlink3 } from "node:fs/promises";
4627
- import path12 from "node:path";
4755
+ import path13 from "node:path";
4628
4756
  import { parse, stringify } from "smol-toml";
4629
4757
  var SAFE_TEST_KEYS = new Set([
4630
4758
  "preload",
@@ -4658,7 +4786,7 @@ function absolutizePath(value, projectCwd) {
4658
4786
  if (typeof value !== "string") {
4659
4787
  return value;
4660
4788
  }
4661
- return path12.isAbsolute(value) ? value : path12.resolve(projectCwd, value);
4789
+ return path13.isAbsolute(value) ? value : path13.resolve(projectCwd, value);
4662
4790
  }
4663
4791
  function absolutizePathValue(value, projectCwd) {
4664
4792
  if (Array.isArray(value)) {
@@ -4667,7 +4795,7 @@ function absolutizePathValue(value, projectCwd) {
4667
4795
  return absolutizePath(value, projectCwd);
4668
4796
  }
4669
4797
  async function readSourceBunfig(projectCwd, sourceBunfig) {
4670
- const bunfigPath = sourceBunfig === undefined ? path12.join(projectCwd, "bunfig.toml") : path12.resolve(projectCwd, sourceBunfig);
4798
+ const bunfigPath = sourceBunfig === undefined ? path13.join(projectCwd, "bunfig.toml") : path13.resolve(projectCwd, sourceBunfig);
4671
4799
  try {
4672
4800
  const content = await readFile5(bunfigPath, "utf8");
4673
4801
  return parse(content);
@@ -4682,14 +4810,14 @@ async function readSourceBunfig(projectCwd, sourceBunfig) {
4682
4810
  async function readBunfigTestRoot(projectCwd, sourceBunfig) {
4683
4811
  const rawConfig = await readSourceBunfig(projectCwd, sourceBunfig);
4684
4812
  const root = rawConfig.test?.root;
4685
- return typeof root === "string" ? path12.resolve(projectCwd, root) : undefined;
4813
+ return typeof root === "string" ? path13.resolve(projectCwd, root) : undefined;
4686
4814
  }
4687
4815
  async function readBunfigTestPreloads(projectCwd, sourceBunfig) {
4688
4816
  return testPreloadsOf(await readSourceBunfig(projectCwd, sourceBunfig), projectCwd);
4689
4817
  }
4690
4818
  function testPreloadsOf(rawConfig, projectCwd) {
4691
4819
  const preload = rawConfig.test?.preload;
4692
- return [preload].flat().filter((entry) => typeof entry === "string").map((entry) => path12.resolve(projectCwd, entry));
4820
+ return [preload].flat().filter((entry) => typeof entry === "string").map((entry) => path13.resolve(projectCwd, entry));
4693
4821
  }
4694
4822
  var SCAN_NEUTRAL_BUNFIG_KEYS = new Set(["preload", "smol", "logLevel", "telemetry", "env", "console", "serve", "install", "run", "conditions", "test"]);
4695
4823
  var JSX_BUNFIG_KEYS = new Set(["jsx", "jsxImportSource", "jsxFactory", "jsxFragment"]);
@@ -4771,7 +4899,7 @@ async function generateSanitizedBunfig(projectCwd, tmpDir, sourceBunfig, onDropp
4771
4899
  dropped.push({ key: `test.${key}`, reason: RANDOM_ORDER_REASON, warn: false, mutantRunsOnly: true });
4772
4900
  }
4773
4901
  onDropped?.(dropped);
4774
- const outPath = path12.join(tmpDir, `stryker-bun-runner-bunfig-${process.pid}-${Date.now()}.toml`);
4902
+ const outPath = path13.join(tmpDir, `stryker-bun-runner-bunfig-${process.pid}-${Date.now()}.toml`);
4775
4903
  await writePrivateFile(outPath, stringify(sanitized));
4776
4904
  const mutantRunTest = { ...sanitizedTest, onlyFailures: true };
4777
4905
  if (randomOrderKeys.length > 0) {
@@ -4796,7 +4924,7 @@ async function cleanupSanitizedBunfig(filePath) {
4796
4924
  }
4797
4925
  // src/utils/test-file-discovery.ts
4798
4926
  import * as fsPromises2 from "node:fs/promises";
4799
- import path13 from "node:path";
4927
+ import path14 from "node:path";
4800
4928
  function isExcludedDirName(name) {
4801
4929
  return name.startsWith(".") || name.toLowerCase() === "node_modules";
4802
4930
  }
@@ -4842,7 +4970,7 @@ async function handleSymlinkFile(fullPath, entryName, ctx) {
4842
4970
  }
4843
4971
  const resolvedTarget = await tryRealpath(fullPath);
4844
4972
  if (resolvedTarget && !hasExcludedAncestor(resolvedTarget)) {
4845
- ctx.results.push(path13.relative(ctx.cwd, fullPath));
4973
+ ctx.results.push(path14.relative(ctx.cwd, fullPath));
4846
4974
  }
4847
4975
  }
4848
4976
  async function handleSymlink(fullPath, entryName, ctx) {
@@ -4858,7 +4986,7 @@ async function handleSymlink(fullPath, entryName, ctx) {
4858
4986
  }
4859
4987
  }
4860
4988
  async function processEntry(entry, dir, ctx) {
4861
- const fullPath = path13.join(dir, entry.name);
4989
+ const fullPath = path14.join(dir, entry.name);
4862
4990
  if (entry.isDirectory()) {
4863
4991
  if (!isExcludedDirName(entry.name)) {
4864
4992
  await ctx.walk(fullPath);
@@ -4866,7 +4994,7 @@ async function processEntry(entry, dir, ctx) {
4866
4994
  } else if (entry.isSymbolicLink()) {
4867
4995
  await handleSymlink(fullPath, entry.name, ctx);
4868
4996
  } else if (entry.isFile() && TEST_FILE_SUFFIX_RE.test(entry.name)) {
4869
- ctx.results.push(path13.relative(ctx.cwd, fullPath));
4997
+ ctx.results.push(path14.relative(ctx.cwd, fullPath));
4870
4998
  }
4871
4999
  }
4872
5000
  async function discoverTestFiles(cwd = process.cwd(), logger, sourceBunfig) {
@@ -4910,14 +5038,14 @@ async function walkTestFiles(walkRoot, cwd, logger) {
4910
5038
  }
4911
5039
  async function expandTestFileEntries(entries, cwd, logger) {
4912
5040
  const expanded = await Promise.all(entries.map(async (entry) => {
4913
- const absolute = path13.resolve(cwd, entry);
5041
+ const absolute = path14.resolve(cwd, entry);
4914
5042
  const stat = await tryStat(absolute);
4915
5043
  if (stat?.isFile()) {
4916
5044
  return [absolute];
4917
5045
  }
4918
5046
  if (stat?.isDirectory()) {
4919
5047
  const found = await walkTestFiles(absolute, cwd, logger);
4920
- return found.map((file) => path13.resolve(cwd, file));
5048
+ return found.map((file) => path14.resolve(cwd, file));
4921
5049
  }
4922
5050
  return entry;
4923
5051
  }));
@@ -4956,7 +5084,7 @@ class MutantWarnAggregator {
4956
5084
  }
4957
5085
  }
4958
5086
  // src/utils/likely-killer-order.ts
4959
- import path14 from "node:path";
5087
+ import path15 from "node:path";
4960
5088
  var SWITCH_DECLARATION_RE = /function stryMutAct_([\w$]+)\(/;
4961
5089
  var HELPER_CALL_RE = /(?<![\w$])(?:stryMutAct|stryCov)_([\w$]+)\(([^()]*)\)/g;
4962
5090
  var ID_ARGUMENT_RE = /"([^"\\]+)"/g;
@@ -5046,8 +5174,8 @@ function namedAfter(sourceFile) {
5046
5174
  if (sourceFile === undefined) {
5047
5175
  return () => false;
5048
5176
  }
5049
- const sourceStem = path14.parse(sourceFile).name.toLowerCase();
5050
- return (testFile) => path14.basename(testFile).replace(TEST_FILE_SUFFIX_RE, "").toLowerCase() === sourceStem;
5177
+ const sourceStem = path15.parse(sourceFile).name.toLowerCase();
5178
+ return (testFile) => path15.basename(testFile).replace(TEST_FILE_SUFFIX_RE, "").toLowerCase() === sourceStem;
5051
5179
  }
5052
5180
  function compareKillerRanks(a, b) {
5053
5181
  return a.coverage - b.coverage || b.sourceMutants - a.sourceMutants || Number(b.namedAfter) - Number(a.namedAfter);
@@ -5059,7 +5187,7 @@ function orderLikelyKillersFirst(files, rankOf) {
5059
5187
  // src/utils/dry-run-output-log.ts
5060
5188
  import { randomUUID } from "node:crypto";
5061
5189
  import { lstat as lstat2, mkdir as mkdir2, open, rename as rename2, rm as rm4 } from "node:fs/promises";
5062
- import path15 from "node:path";
5190
+ import path16 from "node:path";
5063
5191
  var MAX_LOG_STREAM_CHARS = 16 * 1024 * 1024;
5064
5192
  var MAX_LOG_COMMAND_CHARS = 4000;
5065
5193
  function capStream(text, max) {
@@ -5154,11 +5282,11 @@ function oneLine(error) {
5154
5282
  async function saveDryRunOutput(file, output, options = {}) {
5155
5283
  try {
5156
5284
  const text = formatDryRunOutputLog(output, new Date(options.now ?? Date.now()), options.maxStreamChars);
5157
- const directory = path15.dirname(file);
5285
+ const directory = path16.dirname(file);
5158
5286
  await mkdir2(directory, { recursive: true });
5159
5287
  throwIfAbandoned(options.signal);
5160
5288
  await checkTarget(file);
5161
- const temporary = path15.join(directory, `.stryker-bun-runner-output-${randomUUID()}.tmp`);
5289
+ const temporary = path16.join(directory, `.stryker-bun-runner-output-${randomUUID()}.tmp`);
5162
5290
  const handle = await open(temporary, "wx", 384);
5163
5291
  try {
5164
5292
  try {
@@ -5278,7 +5406,7 @@ async function writingTo(file, write) {
5278
5406
  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
5407
  var RUN_ORDINALS = ["first", "second", "third"];
5280
5408
  function isGreen(result) {
5281
- return result.status === DryRunStatus2.Complete && !result.tests.some((test) => test.status === TestStatus2.Failed);
5409
+ return result.status === DryRunStatus2.Complete && !result.tests.some((test) => test.status === TestStatus3.Failed);
5282
5410
  }
5283
5411
  function buildTestNameIndex(tests, bunNames) {
5284
5412
  const testNameIndex = new Map;
@@ -5307,7 +5435,6 @@ function defaultFailureMessage(testInfo) {
5307
5435
  }
5308
5436
  var MAX_DRY_RUN_FAILURE_TESTS_LISTED = 20;
5309
5437
  var MAX_COVERAGE_BLEED_WARNINGS = 25;
5310
- var TEST_ID_FILE_SEPARATOR = " > ";
5311
5438
  function sumDurationsByFile(tests) {
5312
5439
  const durations = new Map;
5313
5440
  for (const test of tests) {
@@ -5410,6 +5537,7 @@ class BunTestRunner {
5410
5537
  loggedRandomizeOff = false;
5411
5538
  loggedFileArgNotes = new Set;
5412
5539
  testFileDurations;
5540
+ testIdsByFile;
5413
5541
  testFileCoverage;
5414
5542
  sourceCoverageCounts = new Map;
5415
5543
  sourceBunfig;
@@ -5506,7 +5634,7 @@ class BunTestRunner {
5506
5634
  maxSpawnDepth: this.maxSpawnDepth,
5507
5635
  dryRunOutputFile: this.dryRunOutputFile
5508
5636
  });
5509
- if (this.testFilesOverride?.some((p) => path16.isAbsolute(p))) {
5637
+ if (this.testFilesOverride?.some((p) => path17.isAbsolute(p))) {
5510
5638
  const isSandbox = process.cwd().includes(".stryker-tmp/sandbox-");
5511
5639
  if (isSandbox) {
5512
5640
  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 +5643,7 @@ class BunTestRunner {
5515
5643
  }
5516
5644
  async resolveRegistryPath() {
5517
5645
  this.assertRunOwnerIsParent();
5518
- return path16.join(await resolveRunTempDir(), REGISTRY_FILE);
5646
+ return path17.join(await resolveRunTempDir(), REGISTRY_FILE);
5519
5647
  }
5520
5648
  assertRunOwnerIsParent() {
5521
5649
  if (this.runOwnerPid !== undefined && process.ppid !== this.runOwnerPid) {
@@ -5646,7 +5774,7 @@ class BunTestRunner {
5646
5774
  this.logger.debug("Stryker passed an empty testFiles array; ignoring it");
5647
5775
  }
5648
5776
  } else {
5649
- const files = [...new Set(requested.map((file) => path16.resolve(cwd, file)))].toSorted((a, b) => a.localeCompare(b));
5777
+ const files = [...new Set(requested.map((file) => path17.resolve(cwd, file)))].toSorted((a, b) => a.localeCompare(b));
5650
5778
  this.strykerTestFiles = { cwd, files };
5651
5779
  this.warnIfTestFilesOverridden(files, cwd);
5652
5780
  }
@@ -5708,7 +5836,7 @@ class BunTestRunner {
5708
5836
  if (this.warnedTestFilesConflict || this.testFilesOverride === undefined) {
5709
5837
  return;
5710
5838
  }
5711
- const configured = [...new Set(this.testFilesOverride.map((file) => path16.resolve(cwd, file)))];
5839
+ const configured = [...new Set(this.testFilesOverride.map((file) => path17.resolve(cwd, file)))];
5712
5840
  const selectedSet = new Set(selected);
5713
5841
  if (configured.length === selectedSet.size && configured.every((file) => selectedSet.has(file))) {
5714
5842
  return;
@@ -5781,7 +5909,7 @@ class BunTestRunner {
5781
5909
  this.runOwnerPid ??= process.ppid;
5782
5910
  const tempDir = await this.ensureRunTempDir();
5783
5911
  this.tempDirTouchedAt = Date.now();
5784
- this.coverageFilePath = path16.join(tempDir, `coverage-${Date.now()}.json`);
5912
+ this.coverageFilePath = path17.join(tempDir, `coverage-${Date.now()}.json`);
5785
5913
  this.logger.debug("Generating coverage preload script...");
5786
5914
  const eagerCwd = process.cwd();
5787
5915
  const testFilesPending = this.getOrDiscoverTestFiles();
@@ -5810,7 +5938,7 @@ class BunTestRunner {
5810
5938
  if (marker === undefined) {
5811
5939
  return;
5812
5940
  }
5813
- const campaign = await readRegistryCampaign(path16.join(runDir, REGISTRY_FILE));
5941
+ const campaign = await readRegistryCampaign(path17.join(runDir, REGISTRY_FILE));
5814
5942
  if (campaign?.generation !== marker.generation) {
5815
5943
  this.logger.debug("Ignoring the abort marker in %s: it belongs to an earlier campaign", runDir);
5816
5944
  return;
@@ -5885,11 +6013,12 @@ ${lines}`, ...ignored.flatMap((d) => [d.key.replace(/^test\./, "[test]."), d.rea
5885
6013
  this.strykerTestFiles = { cwd: process.cwd(), files: selectedFiles };
5886
6014
  }
5887
6015
  this.testFileDurations = parseTestFileDurations(parsed.testFileDurations);
6016
+ this.testIdsByFile = parseTestIdsByFile(parsed.testIdsByFile, this.cachedTestNames);
5888
6017
  this.setTestFileCoverage(TestFileCoverage.fromJson(parsed.mutantTestFiles));
5889
6018
  if (this.coverageAnalysis !== "off") {
5890
6019
  this.timeoutCorrectionMs = parsed.timeoutCorrectionMs;
5891
6020
  const campaign = parseCampaignState(parsed.campaign);
5892
- this.campaign = campaign === undefined ? undefined : campaignOf(campaign, path16.dirname(registryPath));
6021
+ this.campaign = campaign === undefined ? undefined : campaignOf(campaign, path17.dirname(registryPath));
5893
6022
  }
5894
6023
  this.logger.debug("Loaded dryRun registry from %s (%d entries)", registryPath, this.cachedTestNames.size);
5895
6024
  } catch (err) {
@@ -5916,7 +6045,7 @@ ${stack}` : baseFailureMessage;
5916
6045
  return {
5917
6046
  id: normalizedName,
5918
6047
  name: normalizedName,
5919
- status: TestStatus2.Failed,
6048
+ status: TestStatus3.Failed,
5920
6049
  failureMessage: t.failureMessage ?? "Test failed",
5921
6050
  timeSpentMs: Math.round(t.duration ?? 1)
5922
6051
  };
@@ -5925,14 +6054,14 @@ ${stack}` : baseFailureMessage;
5925
6054
  return {
5926
6055
  id: normalizedName,
5927
6056
  name: normalizedName,
5928
- status: TestStatus2.Skipped,
6057
+ status: TestStatus3.Skipped,
5929
6058
  timeSpentMs: Math.round(t.duration ?? 1)
5930
6059
  };
5931
6060
  }
5932
6061
  return {
5933
6062
  id: normalizedName,
5934
6063
  name: normalizedName,
5935
- status: TestStatus2.Success,
6064
+ status: TestStatus3.Success,
5936
6065
  timeSpentMs: Math.round(t.duration ?? 1)
5937
6066
  };
5938
6067
  });
@@ -5950,7 +6079,7 @@ ${stack}` : baseFailureMessage;
5950
6079
  return {
5951
6080
  id: `unknown-${inspectorId}`,
5952
6081
  name: `unknown-${inspectorId}`,
5953
- status: TestStatus2.Success,
6082
+ status: TestStatus3.Success,
5954
6083
  timeSpentMs: timePerTest
5955
6084
  };
5956
6085
  }
@@ -5966,7 +6095,7 @@ ${stack}` : baseFailureMessage;
5966
6095
  name: uniqueName,
5967
6096
  fileName,
5968
6097
  startPosition,
5969
- status: TestStatus2.Failed,
6098
+ status: TestStatus3.Failed,
5970
6099
  failureMessage: this.buildFailureMessage(testInfo, parsed),
5971
6100
  timeSpentMs: elapsed
5972
6101
  };
@@ -5977,7 +6106,7 @@ ${stack}` : baseFailureMessage;
5977
6106
  name: uniqueName,
5978
6107
  fileName,
5979
6108
  startPosition,
5980
- status: TestStatus2.Skipped,
6109
+ status: TestStatus3.Skipped,
5981
6110
  timeSpentMs: elapsed
5982
6111
  };
5983
6112
  }
@@ -5986,7 +6115,7 @@ ${stack}` : baseFailureMessage;
5986
6115
  name: uniqueName,
5987
6116
  fileName,
5988
6117
  startPosition,
5989
- status: TestStatus2.Success,
6118
+ status: TestStatus3.Success,
5990
6119
  timeSpentMs: elapsed
5991
6120
  };
5992
6121
  });
@@ -6044,7 +6173,7 @@ ${stack}` : baseFailureMessage;
6044
6173
  handed: []
6045
6174
  };
6046
6175
  if (this.inPlace && this.tempDir !== undefined) {
6047
- await removeQuietly(path16.join(this.tempDir, ABORT_MARKER_FILE));
6176
+ await removeQuietly(path17.join(this.tempDir, ABORT_MARKER_FILE));
6048
6177
  }
6049
6178
  if (coverageAnalysis === "off") {
6050
6179
  return this.runWithoutCoverage(launchContext);
@@ -6094,7 +6223,7 @@ ${stack}` : baseFailureMessage;
6094
6223
  const { expanded } = tests;
6095
6224
  let selected = [];
6096
6225
  if (expanded !== undefined) {
6097
- selected = "files" in expanded ? expanded.files : tests.entries.map((entry) => path16.resolve(ctx.cwd, entry));
6226
+ selected = "files" in expanded ? expanded.files : tests.entries.map((entry) => path17.resolve(ctx.cwd, entry));
6098
6227
  }
6099
6228
  const split = await withoutSelectedTestFiles(ctx.matched, selected);
6100
6229
  if (split.removed.length > 0) {
@@ -6215,7 +6344,7 @@ ${stack}` : baseFailureMessage;
6215
6344
  }
6216
6345
  async applicableTsconfig(cwd) {
6217
6346
  for (const name of ["tsconfig.json", "jsconfig.json"]) {
6218
- const file = path16.join(cwd, name);
6347
+ const file = path17.join(cwd, name);
6219
6348
  const stat = await fsPromises3.stat(file).catch(() => {
6220
6349
  return;
6221
6350
  });
@@ -6259,7 +6388,7 @@ ${stack}` : baseFailureMessage;
6259
6388
  }
6260
6389
  launchFiles(ctx) {
6261
6390
  return {
6262
- planFile: this.preloadScriptPath === undefined ? undefined : newLaunchFile(path16.dirname(this.preloadScriptPath), "dry-run-plan"),
6391
+ planFile: this.preloadScriptPath === undefined ? undefined : newLaunchFile(path17.dirname(this.preloadScriptPath), "dry-run-plan"),
6263
6392
  recordFile: newRecordFile(ctx.runDir)
6264
6393
  };
6265
6394
  }
@@ -6562,7 +6691,7 @@ ${outputLine}`;
6562
6691
  const abortController = new AbortController;
6563
6692
  this.currentAbortController = abortController;
6564
6693
  ctx.profile?.restartLaunch();
6565
- const coverageFile = this.coverageFilePath === undefined ? undefined : newLaunchFile(path16.dirname(this.coverageFilePath), "coverage");
6694
+ const coverageFile = this.coverageFilePath === undefined ? undefined : newLaunchFile(path17.dirname(this.coverageFilePath), "coverage");
6566
6695
  const launched = {};
6567
6696
  try {
6568
6697
  return await this.runInspectedChild(ctx, list, planFile, coverageFile, abortController, launched);
@@ -6791,7 +6920,7 @@ exit=%s timedOut=%s
6791
6920
  }
6792
6921
  checkCoverageData(coverage, tests, run, stderr) {
6793
6922
  const preloadLines = extractPreloadCoverageDiagnostics(stderr);
6794
- if (coverage !== undefined || tests.some((t) => t.status === TestStatus2.Failed)) {
6923
+ if (coverage !== undefined || tests.some((t) => t.status === TestStatus3.Failed)) {
6795
6924
  if (preloadLines.length > 0) {
6796
6925
  this.logger.warn(`The coverage preload reported problems on the dry-run child's stderr:
6797
6926
  %s`, preloadLines.join(`
@@ -6807,7 +6936,7 @@ exit=%s timedOut=%s
6807
6936
  }
6808
6937
  missingCoverageResult(coverageAnalysis, preloadLines, coverageFile) {
6809
6938
  const file = coverageFile ?? "(none configured)";
6810
- const coverageDir = coverageFile === undefined ? tmpdir2() : path16.dirname(coverageFile);
6939
+ const coverageDir = coverageFile === undefined ? tmpdir2() : path17.dirname(coverageFile);
6811
6940
  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
6941
  const diagnostics = preloadLines.length > 0 ? [`Coverage preload diagnostics from the child's stderr:
6813
6942
  ${preloadLines.join(`
@@ -6862,6 +6991,7 @@ ${preloadLines.join(`
6862
6991
  this.testNameIndex = testNameIndex;
6863
6992
  this.testFileDurations = sumDurationsByFile(tests);
6864
6993
  this.logger.debug("Recorded dry-run durations for %d test file(s) to order mutant runs cheapest-first", this.testFileDurations.size);
6994
+ this.testIdsByFile = indexTestIdsByFile(tests);
6865
6995
  this.setTestFileCoverage(testFileCoverage);
6866
6996
  this.timeoutCorrectionMs = campaignInput?.timeoutCorrectionMs;
6867
6997
  if (campaignInput !== undefined) {
@@ -6869,7 +6999,7 @@ ${preloadLines.join(`
6869
6999
  }
6870
7000
  this.campaign = undefined;
6871
7001
  try {
6872
- const indexes = { cachedTestNames: this.cachedTestNames, baseNameIndex: this.baseNameIndex, testNameIndex, testFileDurations: this.testFileDurations };
7002
+ const indexes = { cachedTestNames: this.cachedTestNames, baseNameIndex: this.baseNameIndex, testNameIndex, testFileDurations: this.testFileDurations, testIdsByFile: this.testIdsByFile };
6873
7003
  await this.writeRegistry(indexes, testFileCoverage, campaignInput);
6874
7004
  return;
6875
7005
  } catch (error) {
@@ -6882,7 +7012,7 @@ ${preloadLines.join(`
6882
7012
  return failure instanceof WriteFailure ? unpublishedCampaignMessage(failure.file, failure.message, watched) : unpublishedCampaignMessage("the run's temporary directory", errorText(failure), watched);
6883
7013
  }
6884
7014
  if (campaignInput !== undefined && failure instanceof WriteFailure) {
6885
- const registryPath = path16.join(path16.dirname(failure.file), REGISTRY_FILE);
7015
+ const registryPath = path17.join(path17.dirname(failure.file), REGISTRY_FILE);
6886
7016
  const earlier = await fsPromises3.lstat(registryPath).catch(() => {
6887
7017
  return;
6888
7018
  });
@@ -6895,7 +7025,7 @@ ${preloadLines.join(`
6895
7025
  }
6896
7026
  async writeRegistry(indexes, testFileCoverage, campaignInput) {
6897
7027
  const registryPath = await this.resolveRegistryPath();
6898
- const runDir = path16.dirname(registryPath);
7028
+ const runDir = path17.dirname(registryPath);
6899
7029
  const campaign = campaignInput === undefined ? undefined : await this.writeCampaignFiles(runDir, campaignInput);
6900
7030
  const tmpPath = `${registryPath}.tmp`;
6901
7031
  const registryData = JSON.stringify({
@@ -6906,6 +7036,7 @@ ${preloadLines.join(`
6906
7036
  testNameIndex: [...indexes.testNameIndex.entries()],
6907
7037
  testFiles: this.selectedTestFilesFor(process.cwd()),
6908
7038
  testFileDurations: [...indexes.testFileDurations.entries()],
7039
+ testIdsByFile: [...indexes.testIdsByFile.entries()],
6909
7040
  mutantTestFiles: testFileCoverage?.toJSON(),
6910
7041
  timeoutCorrectionMs: campaignInput?.timeoutCorrectionMs,
6911
7042
  campaign
@@ -6916,13 +7047,13 @@ ${preloadLines.join(`
6916
7047
  await writingTo(registryPath, async () => fsPromises3.rename(tmpPath, registryPath));
6917
7048
  } catch (error) {
6918
7049
  if (campaign?.watchListFile) {
6919
- await removeQuietly(path16.join(runDir, campaign.watchListFile));
7050
+ await removeQuietly(path17.join(runDir, campaign.watchListFile));
6920
7051
  }
6921
7052
  throw error;
6922
7053
  }
6923
7054
  this.lastRegistryTmpPath = undefined;
6924
7055
  if (campaign !== undefined) {
6925
- await removeQuietly(path16.join(runDir, ABORT_MARKER_FILE));
7056
+ await removeQuietly(path17.join(runDir, ABORT_MARKER_FILE));
6926
7057
  this.campaign = campaignOf(campaign, runDir);
6927
7058
  }
6928
7059
  this.logger.debug("Wrote dryRun registry to %s (%d entries)", registryPath, indexes.cachedTestNames.size);
@@ -6939,7 +7070,7 @@ ${preloadLines.join(`
6939
7070
  fingerprint: watchListFile === null || !this.inPlace ? null : await campaignFingerprint(campaignInput.matched)
6940
7071
  };
6941
7072
  if (watchListFile !== null) {
6942
- const file = path16.join(runDir, watchListFile);
7073
+ const file = path17.join(runDir, watchListFile);
6943
7074
  await writingTo(file, async () => writeWatchList(file, watched));
6944
7075
  }
6945
7076
  return campaign;
@@ -7018,7 +7149,7 @@ ${preloadLines.join(`
7018
7149
  if (typeof options.sandboxFileName !== "string") {
7019
7150
  return;
7020
7151
  }
7021
- const file = path16.resolve(options.sandboxFileName);
7152
+ const file = path17.resolve(options.sandboxFileName);
7022
7153
  return this.campaign?.handedFiles.has(file) === true ? file : undefined;
7023
7154
  }
7024
7155
  mutantRunGuards(options) {
@@ -7029,7 +7160,7 @@ ${preloadLines.join(`
7029
7160
  }
7030
7161
  watchListForMutantRuns() {
7031
7162
  const { campaign } = this;
7032
- return campaign?.watchListFile ? path16.join(campaign.dir, campaign.watchListFile) : undefined;
7163
+ return campaign?.watchListFile ? path17.join(campaign.dir, campaign.watchListFile) : undefined;
7033
7164
  }
7034
7165
  async enforceWitness(stderr, hitLimitToken, ctx, testNamePattern) {
7035
7166
  const { campaign } = this;
@@ -7089,7 +7220,7 @@ ${preloadLines.join(`
7089
7220
  const cwd = process.cwd();
7090
7221
  const exist = await Promise.all(entries.map(async (entry) => {
7091
7222
  try {
7092
- const stat = await fsPromises3.stat(path16.resolve(cwd, entry));
7223
+ const stat = await fsPromises3.stat(path17.resolve(cwd, entry));
7093
7224
  return stat.isFile();
7094
7225
  } catch {
7095
7226
  return false;
@@ -7161,10 +7292,10 @@ ${preloadLines.join(`
7161
7292
  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
7293
  return this.executeMutantRun(ctx, undefined);
7163
7294
  }
7164
- return this.buildMutantKilledResult(result, parsed, localRegistry, localBaseIndex, options.activeMutant.id);
7295
+ return this.buildMutantKilledResult(result, parsed, localRegistry, localBaseIndex, testFiles, options.activeMutant.id);
7165
7296
  }
7166
7297
  if (!parsed.summaryPrinted) {
7167
- return this.classifyEarlyCleanExit(result, parsed, localRegistry, localBaseIndex, options.activeMutant.id);
7298
+ return this.classifyEarlyCleanExit(result, parsed, localRegistry, localBaseIndex, testFiles, options.activeMutant.id);
7168
7299
  }
7169
7300
  return {
7170
7301
  status: MutantRunStatus.Survived,
@@ -7198,7 +7329,7 @@ ${preloadLines.join(`
7198
7329
  this.mutantWarnings.warn(MUTANT_WARN_KIND.inconclusiveTimeout, mutantId, "Mutant %s: inconclusive timeout, scoring as Error rather than Timeout: %s", mutantId, errorMessage);
7199
7330
  return { status: MutantRunStatus.Error, errorMessage };
7200
7331
  }
7201
- buildMutantKilledResult(result, parsed, localRegistry, localBaseIndex, mutantId, earlyExit = false) {
7332
+ buildMutantKilledResult(result, parsed, localRegistry, localBaseIndex, testFiles, mutantId, earlyExit = false) {
7202
7333
  const rawFailedNames = parsed.tests.filter((test) => test.status === "failed").map((test) => normalizeTestName(test.name));
7203
7334
  if (result.signal && rawFailedNames.length === 0) {
7204
7335
  return this.buildSignalErrorResult(result, mutantId, `bun test terminated by ${result.signal} before any test reported a failure`);
@@ -7209,7 +7340,7 @@ ${preloadLines.join(`
7209
7340
  return noEvidenceResult;
7210
7341
  }
7211
7342
  }
7212
- const killedBy = this.resolveKilledBy(rawFailedNames, localRegistry, localBaseIndex, mutantId);
7343
+ const killedBy = this.killersOf(rawFailedNames, result, testFiles, localRegistry, localBaseIndex, mutantId);
7213
7344
  if (result.signal && killedBy.length === 0) {
7214
7345
  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
7346
  }
@@ -7261,9 +7392,9 @@ ${preloadLines.join(`
7261
7392
  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
7393
  };
7263
7394
  }
7264
- classifyEarlyCleanExit(result, parsed, localRegistry, localBaseIndex, mutantId) {
7395
+ classifyEarlyCleanExit(result, parsed, localRegistry, localBaseIndex, testFiles, mutantId) {
7265
7396
  if (parsed.tests.some((test) => test.status === "failed")) {
7266
- return this.buildMutantKilledResult(result, parsed, localRegistry, localBaseIndex, mutantId, true);
7397
+ return this.buildMutantKilledResult(result, parsed, localRegistry, localBaseIndex, testFiles, mutantId, true);
7267
7398
  }
7268
7399
  return this.buildEarlyExitErrorResult(result, mutantId, "no test reported a failure");
7269
7400
  }
@@ -7331,7 +7462,7 @@ ${lines.join(`
7331
7462
  `)}`;
7332
7463
  }
7333
7464
  warnOnUnidentifiedDryRunFailure(result, parsed, tests) {
7334
- if (parsed.failed > 0 && !tests.some((t) => t.status === TestStatus2.Failed)) {
7465
+ if (parsed.failed > 0 && !tests.some((t) => t.status === TestStatus3.Failed)) {
7335
7466
  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
7467
  %s`, String(result.exitCode), parsed.failed, result.stderr.slice(-500));
7337
7468
  }
@@ -7376,7 +7507,7 @@ ${lines.join(`
7376
7507
  }
7377
7508
  }
7378
7509
  findCompletenessProblems(facts, summaryFailed, tests, stderr, eagerModules, secrets = []) {
7379
- if (tests.some((t) => t.status === TestStatus2.Failed)) {
7510
+ if (tests.some((t) => t.status === TestStatus3.Failed)) {
7380
7511
  return [];
7381
7512
  }
7382
7513
  const reasons = findDryRunDataLoss(facts);
@@ -7497,6 +7628,23 @@ ${outputLine}`;
7497
7628
  this.warnUnresolvedKilledBy(unresolved, mutantId);
7498
7629
  return [...killedBySet];
7499
7630
  }
7631
+ killersOf(rawFailedNames, result, testFiles, localRegistry, localBaseIndex, mutantId) {
7632
+ return rawFailedNames.length === 0 ? this.creditFilesThatFailedToLoad(result, testFiles, localRegistry, mutantId) : this.resolveKilledBy(rawFailedNames, localRegistry, localBaseIndex, mutantId);
7633
+ }
7634
+ creditFilesThatFailedToLoad(result, testFiles, localRegistry, mutantId) {
7635
+ const credit = creditLoadFailures({
7636
+ stdout: result.stdout,
7637
+ stderr: result.stderr,
7638
+ testFiles,
7639
+ cwd: process.cwd(),
7640
+ byFile: this.testIdsByFile,
7641
+ covering: localRegistry
7642
+ });
7643
+ if (credit.killedBy.length > 0) {
7644
+ 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);
7645
+ }
7646
+ return credit.killedBy;
7647
+ }
7500
7648
  warnUnresolvedKilledBy(unresolved, mutantId) {
7501
7649
  if (unresolved.size === 0) {
7502
7650
  return;
@@ -7557,7 +7705,7 @@ ${outputLine}`;
7557
7705
  // src/checker-tsconfig.ts
7558
7706
  import { readFile as readFile7, rename as rename4, rm as rm5, writeFile as writeFile2 } from "node:fs/promises";
7559
7707
  import { createRequire as createRequire2 } from "node:module";
7560
- import path17 from "node:path";
7708
+ import path18 from "node:path";
7561
7709
  import { glob as glob2 } from "tinyglobby";
7562
7710
  var DEFAULT_MUTATE_PATTERNS = ["{src,lib}/**"];
7563
7711
  var MUTATION_RANGE_RE = /:\d+(?::\d+)?-\d+(?::\d+)?$/;
@@ -7593,7 +7741,7 @@ function checkTypeScript(exported, cwd) {
7593
7741
  }
7594
7742
  function loadTypeScript(cwd) {
7595
7743
  try {
7596
- return checkTypeScript(createRequire2(path17.join(cwd, "package.json"))("typescript"), cwd);
7744
+ return checkTypeScript(createRequire2(path18.join(cwd, "package.json"))("typescript"), cwd);
7597
7745
  } catch {
7598
7746
  return cannotLoad(cwd);
7599
7747
  }
@@ -7620,7 +7768,7 @@ async function findTestFiles(config, cwd) {
7620
7768
  for (const relativeFiles of [await discoverTestFiles(cwd, undefined, sourceBunfig), bun.testFiles]) {
7621
7769
  if (relativeFiles) {
7622
7770
  for (const file of relativeFiles) {
7623
- testFiles.add(path17.resolve(cwd, file));
7771
+ testFiles.add(path18.resolve(cwd, file));
7624
7772
  }
7625
7773
  }
7626
7774
  }
@@ -7698,12 +7846,12 @@ function derivedHeader(source) {
7698
7846
  `);
7699
7847
  }
7700
7848
  function renderDerivedTsconfig(sourcePath, derivedPath, project, entryPoints) {
7701
- const source = path17.basename(sourcePath);
7849
+ const source = path18.basename(sourcePath);
7702
7850
  const body = {
7703
7851
  extends: `./${source}`,
7704
7852
  ...project.options.declarationDir !== undefined && { compilerOptions: { declarationDir: null } },
7705
7853
  include: [],
7706
- files: entryPoints.map((file) => path17.relative(path17.dirname(derivedPath), file))
7854
+ files: entryPoints.map((file) => path18.relative(path18.dirname(derivedPath), file))
7707
7855
  };
7708
7856
  return `${derivedHeader(source)}${JSON.stringify(body, null, 2)}
7709
7857
  `;
@@ -7718,8 +7866,8 @@ async function withTestFilesExcludedFromTypeCheck(config, { cwd = process.cwd()
7718
7866
  return leaveUnchanged(config, loaded.problem);
7719
7867
  }
7720
7868
  const { ts } = loaded;
7721
- const sourcePath = path17.resolve(cwd, config.tsconfigFile ?? "tsconfig.json");
7722
- const shownSource = path17.relative(cwd, sourcePath);
7869
+ const sourcePath = path18.resolve(cwd, config.tsconfigFile ?? "tsconfig.json");
7870
+ const shownSource = path18.relative(cwd, sourcePath);
7723
7871
  const read = readProject(ts, sourcePath, shownSource);
7724
7872
  if ("problem" in read) {
7725
7873
  return leaveUnchanged(config, read.problem);
@@ -7736,10 +7884,10 @@ async function withTestFilesExcludedFromTypeCheck(config, { cwd = process.cwd()
7736
7884
  if (entryPoints.length === 0) {
7737
7885
  return leaveUnchanged(config, `${shownSource} would have no files left once test files are excluded`);
7738
7886
  }
7739
- const derivedPath = path17.join(path17.dirname(sourcePath), `${path17.basename(sourcePath, ".json")}${DERIVED_SUFFIX}`);
7740
- const shownDerived = path17.relative(cwd, derivedPath);
7887
+ const derivedPath = path18.join(path18.dirname(sourcePath), `${path18.basename(sourcePath, ".json")}${DERIVED_SUFFIX}`);
7888
+ const shownDerived = path18.relative(cwd, derivedPath);
7741
7889
  const text = renderDerivedTsconfig(sourcePath, derivedPath, project, entryPoints);
7742
- const derivedProject = ts.parseJsonSourceFileConfigFileContent(ts.parseJsonText(derivedPath, text), ts.sys, path17.dirname(derivedPath), undefined, derivedPath);
7890
+ const derivedProject = ts.parseJsonSourceFileConfigFileContent(ts.parseJsonText(derivedPath, text), ts.sys, path18.dirname(derivedPath), undefined, derivedPath);
7743
7891
  const derived = createProgram(ts, derivedProject, original);
7744
7892
  const newErrors = findNewErrors(derived, original, testFiles);
7745
7893
  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.2",
4
4
  "description": "Stryker mutation testing test runner plugin for Bun (bun test), with per-test coverage",
5
5
  "keywords": [
6
6
  "stryker",