Skip to content

Commit f3dedd9

Browse files
committed
The _testCase field is no longer provided for non paramtereized tests
swiftlang/swift-testing#482 removes the `_testCase` field if the test isn't parameterized. The code that recorded issues relied on this being present. If the issue for a parameterized test case then just extract the test from the testID.
1 parent 2404373 commit f3dedd9

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/TestExplorer/TestParsers/SwiftTestingOutputParser.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ interface BaseEvent {
106106

107107
interface TestCaseEvent {
108108
sourceLocation: SourceLocation;
109-
_testCase: TestCase;
109+
_testCase?: TestCase;
110110
}
111111

112112
interface TestStarted extends BaseEvent {
@@ -225,6 +225,12 @@ export class SwiftTestingOutputParser {
225225
return testCase.id === "argumentIDs: nil" ? testCase.displayName : testCase.id;
226226
}
227227

228+
private idFromOptionalTestCase(testID: string, testCase?: TestCase): string {
229+
return testCase
230+
? this.testCaseId(testID, this.idFromTestCase(testCase))
231+
: this.testName(testID);
232+
}
233+
228234
private parameterizedFunctionTestCaseToTestClass(
229235
testId: string,
230236
testCase: TestCase,
@@ -300,9 +306,9 @@ export class SwiftTestingOutputParser {
300306
const testIndex = runState.getTestItemIndex(testName, undefined);
301307
runState.started(testIndex, item.payload.instant.absolute);
302308
} else if (item.payload.kind === "testCaseStarted") {
303-
const testID = this.testCaseId(
309+
const testID = this.idFromOptionalTestCase(
304310
item.payload.testID,
305-
this.idFromTestCase(item.payload._testCase)
311+
item.payload._testCase
306312
);
307313
const testIndex = this.getTestCaseIndex(runState, testID);
308314
runState.started(testIndex, item.payload.instant.absolute);
@@ -311,11 +317,12 @@ export class SwiftTestingOutputParser {
311317
const testIndex = runState.getTestItemIndex(testName, undefined);
312318
runState.skipped(testIndex);
313319
} else if (item.payload.kind === "issueRecorded") {
314-
const testID = this.testCaseId(
320+
const testID = this.idFromOptionalTestCase(
315321
item.payload.testID,
316-
this.idFromTestCase(item.payload._testCase)
322+
item.payload._testCase
317323
);
318324
const testIndex = this.getTestCaseIndex(runState, testID);
325+
319326
const isKnown = item.payload.issue.isKnown;
320327
const sourceLocation = item.payload.issue.sourceLocation;
321328
const location = sourceLocationToVSCodeLocation(
@@ -345,9 +352,9 @@ export class SwiftTestingOutputParser {
345352
this.completionMap.set(testIndex, true);
346353
runState.completed(testIndex, { timestamp: item.payload.instant.absolute });
347354
} else if (item.payload.kind === "testCaseEnded") {
348-
const testID = this.testCaseId(
355+
const testID = this.idFromOptionalTestCase(
349356
item.payload.testID,
350-
this.idFromTestCase(item.payload._testCase)
357+
item.payload._testCase
351358
);
352359
const testIndex = this.getTestCaseIndex(runState, testID);
353360

0 commit comments

Comments
 (0)