Skip to content

Commit 1f3cb73

Browse files
committed
fix: snapshot array mutation, overly broad noise regex, and Swift Testing failure duration
- Deep-copy arrays in snapshot() and finalize() so returned state is truly immutable and won't be mutated by subsequent push() calls - Replace overly broad noise regex that matched any 'identifier: content' line (swallowing compiler note: diagnostics) with a targeted pattern that only matches SPM resolved dependency lines (PackageName: https://...) - Attach failure duration from Swift Testing result lines by checking the result line before flushing the pending issue diagnostic. Previously all Swift Testing failure durations were silently dropped.
1 parent ccb2ed9 commit 1f3cb73

File tree

3 files changed

+40
-8
lines changed

3 files changed

+40
-8
lines changed

src/utils/swift-testing-event-parser.ts

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
parseTestCaseLine,
1010
parseTotalsLine,
1111
parseFailureDiagnostic,
12+
parseDurationMs,
1213
} from './xcodebuild-line-parsers.ts';
1314

1415
export interface SwiftTestingEventParser {
@@ -84,6 +85,27 @@ export function createSwiftTestingEventParser(
8485
return;
8586
}
8687

88+
// Check result line BEFORE flushing so we can attach duration to pending issue
89+
const stResult = parseSwiftTestingResultLine(line);
90+
if (stResult && stResult.status === 'failed' && lastIssueDiagnostic) {
91+
const durationMs = parseDurationMs(stResult.durationText);
92+
onEvent({
93+
type: 'test-failure',
94+
timestamp: now(),
95+
operation: 'TEST',
96+
suite: lastIssueDiagnostic.suiteName,
97+
test: lastIssueDiagnostic.testName,
98+
message: lastIssueDiagnostic.message,
99+
location: lastIssueDiagnostic.location,
100+
durationMs,
101+
});
102+
lastIssueDiagnostic = null;
103+
completedCount += 1;
104+
failedCount += 1;
105+
emitTestProgress();
106+
return;
107+
}
108+
87109
flushPendingIssue();
88110

89111
// Swift Testing issue line: ✘ Test "Name" recorded an issue at file:line:col: message
@@ -98,13 +120,9 @@ export function createSwiftTestingEventParser(
98120
return;
99121
}
100122

101-
// Swift Testing result line: ✔/✘/◇ Test "Name" passed/failed/skipped
102-
const stResult = parseSwiftTestingResultLine(line);
123+
// Swift Testing result line: ✔/✘/◇ Test "Name" passed/failed/skipped (non-failure or no pending issue)
103124
if (stResult) {
104125
completedCount += 1;
105-
if (stResult.status === 'failed') {
106-
failedCount += 1;
107-
}
108126
if (stResult.status === 'skipped') {
109127
skippedCount += 1;
110128
}

src/utils/xcodebuild-event-parser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ const IGNORED_NOISE_PATTERNS = [
7676
/^(?:COMPILER_INDEX_STORE_ENABLE|ONLY_ACTIVE_ARCH)\s*=\s*.+$/u,
7777
/^Resolve Package Graph$/u,
7878
/^Resolved source packages:$/u,
79-
/^\s*[A-Za-z0-9_.-]+:\s+.+$/u,
79+
/^\s*[A-Za-z0-9_.-]+:\s+https?:\/\/.+$/u,
8080
/^--- xcodebuild: WARNING: Using the first of multiple matching destinations:$/u,
8181
/^\{\s*platform:.+\}$/u,
8282
/^(?:ComputePackagePrebuildTargetDependencyGraph|Prepare packages|CreateBuildRequest|SendProjectDescription|CreateBuildOperation|ComputeTargetDependencyGraph|GatherProvisioningInputs|CreateBuildDescription)$/u,

src/utils/xcodebuild-run-state.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,25 @@ export function createXcodebuildRunState(options: RunStateOptions): XcodebuildRu
225225
accept(tailEvent);
226226
}
227227

228-
return { ...state };
228+
return {
229+
...state,
230+
events: [...state.events],
231+
milestones: [...state.milestones],
232+
warnings: [...state.warnings],
233+
errors: [...state.errors],
234+
testFailures: [...state.testFailures],
235+
};
229236
},
230237

231238
snapshot(): Readonly<XcodebuildRunState> {
232-
return { ...state };
239+
return {
240+
...state,
241+
events: [...state.events],
242+
milestones: [...state.milestones],
243+
warnings: [...state.warnings],
244+
errors: [...state.errors],
245+
testFailures: [...state.testFailures],
246+
};
233247
},
234248

235249
highestStageRank(): number {

0 commit comments

Comments
 (0)