Skip to content

Commit 8415cd7

Browse files
committed
fix: delete consumed pendingFailureDurations entries to prevent stale leaks
The pendingFailureDurations map was never cleaned up after a duration was consumed, allowing stale entries to attach incorrect durations to later failures with the same suite/test key in retry scenarios. Also adds a clarifying comment on the Swift Testing issue-count-as- failed-count approximation.
1 parent 904c110 commit 8415cd7

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/utils/swift-testing-line-parsers.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@ export function parseSwiftTestingRunSummary(line: string): ParsedTotals | null {
110110
const total = Number(match[1]);
111111
const durationText = `${match[2]}s`;
112112

113+
// Swift Testing reports "issues" not "failed tests" -- a single test can produce
114+
// multiple issues (e.g. multiple #expect failures). This is the best available
115+
// approximation; the framework doesn't report a distinct failed-test count in its
116+
// summary line. Downstream reconciliation via Math.max(failedTests, testFailures.length)
117+
// partially mitigates overcounting.
113118
const issueMatch = line.match(/with (\d+) issues?/u);
114119
const failed = issueMatch ? Number(issueMatch[1]) : 0;
115120

src/utils/xcodebuild-event-parser.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ export function createXcodebuildEventParser(options: EventParserOptions): Xcodeb
176176

177177
const durationMs = pendingFailureDurations.get(key);
178178
if (durationMs !== undefined) {
179+
pendingFailureDurations.delete(key);
179180
emitFailureEvent({ ...failure, durationMs });
180181
return;
181182
}
@@ -211,6 +212,7 @@ export function createXcodebuildEventParser(options: EventParserOptions): Xcodeb
211212
emitFailureEvent({ ...failure, durationMs });
212213
}
213214
pendingFailureDiagnostics.delete(key);
215+
pendingFailureDurations.delete(key);
214216
}
215217

216218
function emitTestProgress(): void {

0 commit comments

Comments
 (0)