Skip to content

Commit 28f725c

Browse files
cameroncookecodex
andcommitted
fix(test): Reconcile xcodebuild Swift Testing lines
Lowercase xcodebuild test case lines can represent Swift Testing results when they use slash-separated Swift test identifiers. Treat those lines as Swift Testing observations so a following Swift Testing run summary does not count the same tests again. Fixes GH-384 Co-Authored-By: OpenAI Codex <codex@openai.com>
1 parent c01c4ca commit 28f725c

2 files changed

Lines changed: 26 additions & 3 deletions

File tree

src/utils/__tests__/xcodebuild-event-parser.test.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -624,11 +624,11 @@ describe('xcodebuild-event-parser', () => {
624624
]);
625625
});
626626

627-
it('keeps xcodebuild-formatted test lines independent from Swift Testing summaries', () => {
627+
it('keeps XCTest-style test case lines independent from Swift Testing summaries', () => {
628628
const events = collectEvents('TEST', [
629629
{
630630
source: 'stdout',
631-
text: "Test case 'WeatherTests/emptySearchReturnsNoResults()' passed on 'Clone 1' (0.001 seconds)\n",
631+
text: "Test case 'WeatherUITests.testSearch()' passed on 'Clone 1' (0.001 seconds)\n",
632632
},
633633
{
634634
source: 'stdout',
@@ -643,6 +643,25 @@ describe('xcodebuild-event-parser', () => {
643643
]);
644644
});
645645

646+
it('does not double-count xcodebuild-formatted Swift Testing lines before a summary', () => {
647+
const events = collectEvents('TEST', [
648+
{
649+
source: 'stdout',
650+
text: "Test case 'WeatherTests/emptySearchReturnsNoResults()' passed on 'Clone 1' (0.001 seconds)\n",
651+
},
652+
{
653+
source: 'stdout',
654+
text: '✔ Test run with 1 test in 1 suite passed after 0.001 seconds.\n',
655+
},
656+
]);
657+
658+
const progress = events.filter((event) => event.fragment === 'test-progress');
659+
expect(progress).toEqual([
660+
expect.objectContaining({ completed: 1, failed: 0, skipped: 0 }),
661+
expect.objectContaining({ completed: 1, failed: 0, skipped: 0 }),
662+
]);
663+
});
664+
646665
it('counts additional failures reported only by a Swift Testing summary', () => {
647666
const events = collectEvents('TEST', [
648667
{

src/utils/xcodebuild-event-parser.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,11 @@ export function createXcodebuildEventParser(options: EventParserOptions): Xcodeb
310310

311311
const testCase = parseTestCaseLine(line);
312312
if (testCase) {
313-
recordTestCaseResult(testCase);
313+
const source =
314+
/^Test case /u.test(line) && /\/.+\(\)$/u.test(testCase.rawName)
315+
? 'swift-testing'
316+
: 'xcodebuild';
317+
recordTestCaseResult(testCase, source);
314318
return;
315319
}
316320

0 commit comments

Comments
 (0)