Skip to content

Commit fdad5b6

Browse files
committed
fix: handle colons in parameterized argument values and fix formatting
The issue regex used [^:]*? to match argument values before 'at', which failed when argument values contained colons (e.g. key:value). Changed to .*? and rely on the file:line:col anchor to correctly backtrack. Also fixes prettier formatting from previous commit.
1 parent e3e04ac commit fdad5b6

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ describe('Swift Testing line parsers', () => {
8383
});
8484
});
8585

86-
8786
it('should parse a skipped test (arrow format)', () => {
8887
const result = parseSwiftTestingResultLine('➜ Test disabledTest() skipped: "Not ready yet"');
8988
expect(result).toEqual({
@@ -154,6 +153,18 @@ describe('Swift Testing line parsers', () => {
154153
});
155154
});
156155

156+
it('should parse a parameterized issue with colon in argument value', () => {
157+
const result = parseSwiftTestingIssueLine(
158+
'✘ Test "Dict test" recorded an issue with 1 argument value → key:value at DictTests.swift:5:3: failed',
159+
);
160+
expect(result).toEqual({
161+
rawTestName: 'Dict test',
162+
testName: 'Dict test',
163+
location: 'DictTests.swift:5',
164+
message: 'failed',
165+
});
166+
});
167+
157168
it('should parse an issue without location', () => {
158169
const result = parseSwiftTestingIssueLine(
159170
'✘ Test "Some test" recorded an issue: Something went wrong',

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export function parseSwiftTestingResultLine(line: string): ParsedTestCase | null
9191
export function parseSwiftTestingIssueLine(line: string): ParsedFailureDiagnostic | null {
9292
// Match with location -- handle both aka suffix and parameterized argument values before "at"
9393
const locationRegex = new RegExp(
94-
`^[✘] Test "(.+)"${OPTIONAL_AKA} recorded an issue(?:\\s+with \\d+ argument values?[^:]*?)? at (.+?):(\\d+):\\d+: (.+)$`,
94+
`^[✘] Test "(.+)"${OPTIONAL_AKA} recorded an issue(?:\\s+with \\d+ argument values?.*?)? at (.+?):(\\d+):\\d+: (.+)$`,
9595
'u',
9696
);
9797
const locationMatch = line.match(locationRegex);

0 commit comments

Comments
 (0)