@hughescr/stryker-bun-runner 1.3.7 → 1.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +20 -1
- package/dist/index.js +60 -45
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -359,10 +359,29 @@ export declare class BunTestRunner implements TestRunner {
|
|
|
359
359
|
* 2. Base-name match in localBaseIndex (built from testFilter)
|
|
360
360
|
* 3. Exact match in this.cachedTestNames (instance registry from dryRun)
|
|
361
361
|
* 4. Base-name match in this.baseNameIndex (instance registry from dryRun)
|
|
362
|
-
*
|
|
362
|
+
*
|
|
363
|
+
* Names resolving through none of these are DROPPED with a single WARN — never
|
|
364
|
+
* emitted raw. Every entry in a Killed result's killedBy must be exactly a
|
|
365
|
+
* dry-run TestResult.id: Stryker core's remapTestId (`id => testIdMap.get(id)
|
|
366
|
+
* ?? id`) writes anything else verbatim into the incremental report, where it
|
|
367
|
+
* orphans against the test registry and the differ silently re-runs the mutant
|
|
368
|
+
* on every incremental pass, forever (and the next accumulation pass launders
|
|
369
|
+
* the orphan into an empty killedBy). Dropping instead degrades that one
|
|
370
|
+
* mutant to correct-but-non-reusable — same re-run cost, but loudly visible
|
|
371
|
+
* and never poisonous. No guessed recovery is attempted: bare console names
|
|
372
|
+
* can collide across files, and --test-name-pattern leakage (see mutantRun)
|
|
373
|
+
* means the killer may not even be a testFilter member, so any inference
|
|
374
|
+
* risks crediting the wrong test and enabling stale cache reuse.
|
|
363
375
|
*/
|
|
364
376
|
private resolveKilledBy;
|
|
365
377
|
/**
|
|
378
|
+
* WARN about failed test names that could not be resolved to dry-run test
|
|
379
|
+
* ids (and are therefore dropped from killedBy by resolveKilledBy). WARN,
|
|
380
|
+
* not debug — the old debug-level log is why the resulting cache poisoning
|
|
381
|
+
* was invisible in CI. No-op when everything resolved.
|
|
382
|
+
*/
|
|
383
|
+
private warnUnresolvedKilledBy;
|
|
384
|
+
/**
|
|
366
385
|
* Cleanup resources
|
|
367
386
|
*/
|
|
368
387
|
dispose(): Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -6332,11 +6332,55 @@ class InspectorClient {
|
|
|
6332
6332
|
}
|
|
6333
6333
|
}
|
|
6334
6334
|
}
|
|
6335
|
+
// src/utils/test-name-pattern.ts
|
|
6336
|
+
var MAX_TEST_NAME_PATTERN_LENGTH = 1e5;
|
|
6337
|
+
var TEST_FILE_EXT_PATTERN = String.raw`(?:test|spec)\.(?:[jt]sx?|[mc][jt]s)`;
|
|
6338
|
+
var fileExtRe = new RegExp(String.raw`\.${TEST_FILE_EXT_PATTERN}$`);
|
|
6339
|
+
var dedupSuffixRe = / \[\d+\]$/;
|
|
6340
|
+
var metaRe = /[.*+?^${}()|[\]\\/]/g;
|
|
6341
|
+
function escapeRegex(str) {
|
|
6342
|
+
return str.replaceAll(metaRe, String.raw`\$&`);
|
|
6343
|
+
}
|
|
6344
|
+
function buildTestNamePattern(testFilter, testNameIndex) {
|
|
6345
|
+
if (testFilter.length === 0) {
|
|
6346
|
+
return;
|
|
6347
|
+
}
|
|
6348
|
+
const alternatives = new Set;
|
|
6349
|
+
for (const id of testFilter) {
|
|
6350
|
+
const exact = testNameIndex?.get(id);
|
|
6351
|
+
if (exact !== undefined && exact.length > 0 && !exact.includes("\x00")) {
|
|
6352
|
+
alternatives.add(escapeRegex(exact));
|
|
6353
|
+
continue;
|
|
6354
|
+
}
|
|
6355
|
+
const firstSepIdx = id.indexOf(" > ");
|
|
6356
|
+
let name = firstSepIdx !== -1 && fileExtRe.test(id.slice(0, firstSepIdx)) ? id.slice(firstSepIdx + 3) : id;
|
|
6357
|
+
name = name.replace(dedupSuffixRe, "");
|
|
6358
|
+
name = name.replaceAll(" > ", " ");
|
|
6359
|
+
name = escapeRegex(name);
|
|
6360
|
+
if (name.length > 0) {
|
|
6361
|
+
alternatives.add(name);
|
|
6362
|
+
}
|
|
6363
|
+
}
|
|
6364
|
+
if (alternatives.size === 0) {
|
|
6365
|
+
return;
|
|
6366
|
+
}
|
|
6367
|
+
const pattern = `^(?:${[...alternatives].join("|")})$`;
|
|
6368
|
+
if (Buffer.byteLength(pattern) > MAX_TEST_NAME_PATTERN_LENGTH) {
|
|
6369
|
+
return;
|
|
6370
|
+
}
|
|
6371
|
+
return pattern;
|
|
6372
|
+
}
|
|
6373
|
+
|
|
6335
6374
|
// src/parsers/console-parser.ts
|
|
6375
|
+
var fileHeaderRe = new RegExp(String.raw`^(?:::group::)?([^:]+\.${TEST_FILE_EXT_PATTERN}):$`);
|
|
6376
|
+
var workflowCommandRe = /^::(?:group|endgroup|error|warning|notice|debug|add-mask|add-matcher|remove-matcher)(?:::|\s|$)/;
|
|
6336
6377
|
function parseFilePath(line) {
|
|
6337
|
-
const fileMatch =
|
|
6378
|
+
const fileMatch = fileHeaderRe.exec(line);
|
|
6338
6379
|
return fileMatch ? fileMatch[1] : null;
|
|
6339
6380
|
}
|
|
6381
|
+
function isWorkflowCommandLine(line) {
|
|
6382
|
+
return workflowCommandRe.test(line);
|
|
6383
|
+
}
|
|
6340
6384
|
function buildTestName(testName, currentFile) {
|
|
6341
6385
|
return currentFile ? `${currentFile} > ${testName}` : testName;
|
|
6342
6386
|
}
|
|
@@ -6459,6 +6503,9 @@ ${stderr}`;
|
|
|
6459
6503
|
currentFile = filePath;
|
|
6460
6504
|
continue;
|
|
6461
6505
|
}
|
|
6506
|
+
if (isWorkflowCommandLine(line)) {
|
|
6507
|
+
continue;
|
|
6508
|
+
}
|
|
6462
6509
|
const parseResult = parseTestLine(line, currentFile);
|
|
6463
6510
|
if (parseResult.test) {
|
|
6464
6511
|
if (currentTest && collectingError) {
|
|
@@ -6474,9 +6521,7 @@ ${stderr}`;
|
|
|
6474
6521
|
errorLines.push(line);
|
|
6475
6522
|
}
|
|
6476
6523
|
}
|
|
6477
|
-
|
|
6478
|
-
finalizeErrorMessage(currentTest, errorLines);
|
|
6479
|
-
}
|
|
6524
|
+
finalizeErrorMessage(currentTest, errorLines);
|
|
6480
6525
|
const summaryCounts = parseSummaryLines(output);
|
|
6481
6526
|
counters.passed = Math.max(counters.passed, summaryCounts.passed);
|
|
6482
6527
|
counters.failed = Math.max(counters.failed, summaryCounts.failed);
|
|
@@ -8016,43 +8061,6 @@ async function cleanupSanitizedBunfig(filePath) {
|
|
|
8016
8061
|
}
|
|
8017
8062
|
}
|
|
8018
8063
|
}
|
|
8019
|
-
// src/utils/test-name-pattern.ts
|
|
8020
|
-
var MAX_TEST_NAME_PATTERN_LENGTH = 1e5;
|
|
8021
|
-
var fileExtRe = /\.(?:test|spec)\.(?:[jt]sx?|m[jt]s)$/;
|
|
8022
|
-
var dedupSuffixRe = / \[\d+\]$/;
|
|
8023
|
-
var metaRe = /[.*+?^${}()|[\]\\/]/g;
|
|
8024
|
-
function escapeRegex(str) {
|
|
8025
|
-
return str.replaceAll(metaRe, String.raw`\$&`);
|
|
8026
|
-
}
|
|
8027
|
-
function buildTestNamePattern(testFilter, testNameIndex) {
|
|
8028
|
-
if (testFilter.length === 0) {
|
|
8029
|
-
return;
|
|
8030
|
-
}
|
|
8031
|
-
const alternatives = new Set;
|
|
8032
|
-
for (const id of testFilter) {
|
|
8033
|
-
const exact = testNameIndex?.get(id);
|
|
8034
|
-
if (exact !== undefined && exact.length > 0 && !exact.includes("\x00")) {
|
|
8035
|
-
alternatives.add(escapeRegex(exact));
|
|
8036
|
-
continue;
|
|
8037
|
-
}
|
|
8038
|
-
const firstSepIdx = id.indexOf(" > ");
|
|
8039
|
-
let name = firstSepIdx !== -1 && fileExtRe.test(id.slice(0, firstSepIdx)) ? id.slice(firstSepIdx + 3) : id;
|
|
8040
|
-
name = name.replace(dedupSuffixRe, "");
|
|
8041
|
-
name = name.replaceAll(" > ", " ");
|
|
8042
|
-
name = escapeRegex(name);
|
|
8043
|
-
if (name.length > 0) {
|
|
8044
|
-
alternatives.add(name);
|
|
8045
|
-
}
|
|
8046
|
-
}
|
|
8047
|
-
if (alternatives.size === 0) {
|
|
8048
|
-
return;
|
|
8049
|
-
}
|
|
8050
|
-
const pattern = `^(?:${[...alternatives].join("|")})$`;
|
|
8051
|
-
if (Buffer.byteLength(pattern) > MAX_TEST_NAME_PATTERN_LENGTH) {
|
|
8052
|
-
return;
|
|
8053
|
-
}
|
|
8054
|
-
return pattern;
|
|
8055
|
-
}
|
|
8056
8064
|
// src/utils/test-file-discovery.ts
|
|
8057
8065
|
import * as fsPromises from "node:fs/promises";
|
|
8058
8066
|
import path3 from "node:path";
|
|
@@ -8821,13 +8829,12 @@ exit=%s timedOut=%s
|
|
|
8821
8829
|
}
|
|
8822
8830
|
const killedBy = this.resolveKilledBy(rawFailedNames, localRegistry, localBaseIndex, mutantId);
|
|
8823
8831
|
if (killedBy.length === 0) {
|
|
8824
|
-
this.logger.warn("
|
|
8832
|
+
this.logger.warn("Mutant %s: no killing test identifiable — emitting empty killedBy; " + `this mutant will re-run on every incremental run
|
|
8825
8833
|
` + `exit=%s
|
|
8826
8834
|
--- STDOUT (first 600 chars) ---
|
|
8827
8835
|
%s
|
|
8828
8836
|
` + `--- STDERR (first 600 chars) ---
|
|
8829
8837
|
%s`, mutantId, String(result.exitCode), result.stdout.slice(0, 600) || "(empty)", result.stderr.slice(0, 600) || "(empty)");
|
|
8830
|
-
killedBy.push("unknown");
|
|
8831
8838
|
}
|
|
8832
8839
|
return {
|
|
8833
8840
|
status: MutantRunStatus.Killed,
|
|
@@ -8993,6 +9000,7 @@ ${lines.join(`
|
|
|
8993
9000
|
}
|
|
8994
9001
|
resolveKilledBy(rawFailedNames, localRegistry, localBaseIndex, mutantId) {
|
|
8995
9002
|
const killedBySet = new Set;
|
|
9003
|
+
const unresolved = new Set;
|
|
8996
9004
|
for (const name of rawFailedNames) {
|
|
8997
9005
|
if (localRegistry.has(name)) {
|
|
8998
9006
|
killedBySet.add(name);
|
|
@@ -9018,11 +9026,18 @@ ${lines.join(`
|
|
|
9018
9026
|
}
|
|
9019
9027
|
continue;
|
|
9020
9028
|
}
|
|
9021
|
-
|
|
9022
|
-
killedBySet.add(name);
|
|
9029
|
+
unresolved.add(name);
|
|
9023
9030
|
}
|
|
9031
|
+
this.warnUnresolvedKilledBy(unresolved, mutantId);
|
|
9024
9032
|
return [...killedBySet];
|
|
9025
9033
|
}
|
|
9034
|
+
warnUnresolvedKilledBy(unresolved, mutantId) {
|
|
9035
|
+
if (unresolved.size === 0) {
|
|
9036
|
+
return;
|
|
9037
|
+
}
|
|
9038
|
+
const sample = [...unresolved];
|
|
9039
|
+
this.logger.warn("Mutant %s: %d failed test name(s) could not be resolved to dry-run test ids and will not be recorded in killedBy — this mutant's Killed verdict will not be reusable from the incremental cache: %s%s", mutantId, unresolved.size, sample.slice(0, 5).join(", "), sample.length > 5 ? ", …" : "");
|
|
9040
|
+
}
|
|
9026
9041
|
async dispose() {
|
|
9027
9042
|
this.logger.debug("Disposing BunTestRunner");
|
|
9028
9043
|
if (this.currentAbortController) {
|