Skip to content

Commit 2a60a51

Browse files
authored
Support swift-testing issue severity (#1814)
Add support for swift-testing issue severity, added in swiftlang/swift-testing#1279 If an issue is recorded with a severity that does not meet the threshold for a failure then don't record the issue.
1 parent 6c55d30 commit 2a60a51

File tree

3 files changed

+51
-2
lines changed

3 files changed

+51
-2
lines changed

src/TestExplorer/TestParsers/SwiftTestingOutputParser.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,16 @@ interface IssueRecorded extends BaseEvent, TestCaseEvent {
155155
issue: {
156156
isKnown: boolean;
157157
sourceLocation: SourceLocation;
158+
isFailure?: boolean;
159+
severity?: string;
158160
};
159161
}
160162

161163
export enum TestSymbol {
162164
default = "default",
163165
skip = "skip",
164166
passWithKnownIssue = "passWithKnownIssue",
167+
passWithWarnings = "passWithWarnings",
165168
fail = "fail",
166169
pass = "pass",
167170
difference = "difference",
@@ -378,6 +381,10 @@ export class SwiftTestingOutputParser {
378381
.map(message => MessageRenderer.render(message))
379382
.join("\n");
380383

384+
if (payload.issue.isFailure === false) {
385+
return;
386+
}
387+
381388
issues.forEach(message => {
382389
runState.recordIssue(
383390
testIndex,
@@ -601,6 +608,7 @@ export class SymbolRenderer {
601608
return "\u{25CA}"; // Unicode: LOZENGE
602609
case TestSymbol.skip:
603610
case TestSymbol.passWithKnownIssue:
611+
case TestSymbol.passWithWarnings:
604612
case TestSymbol.fail:
605613
return "\u{279C}"; // Unicode: HEAVY ROUND-TIPPED RIGHTWARDS ARROW
606614
case TestSymbol.pass:
@@ -622,6 +630,7 @@ export class SymbolRenderer {
622630
return "\u{25C7}"; // Unicode: WHITE DIAMOND
623631
case TestSymbol.skip:
624632
case TestSymbol.passWithKnownIssue:
633+
case TestSymbol.passWithWarnings:
625634
case TestSymbol.fail:
626635
return "\u{279C}"; // Unicode: HEAVY ROUND-TIPPED RIGHTWARDS ARROW
627636
case TestSymbol.pass:

src/debugger/buildConfig.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -538,11 +538,17 @@ export class TestingConfigurationFactory {
538538
);
539539
}
540540

541+
// Starting in 6.3 the version string should match the toolchain version.
542+
let versionString = "0";
543+
if (this.ctx.toolchain.swiftVersion.isGreaterThanOrEqual(new Version(6, 3, 0))) {
544+
versionString = `${this.ctx.toolchain.swiftVersion.major}.${this.ctx.toolchain.swiftVersion.minor}`;
545+
}
546+
541547
const swiftTestingArgs = [
542548
...this.ctx.toolchain.buildFlags.withAdditionalFlags(args),
543549
"--enable-swift-testing",
544-
"--event-stream-version",
545-
"0",
550+
"--experimental-event-stream-version",
551+
versionString,
546552
"--event-stream-output-path",
547553
this.swiftTestingArguments.fifoPipePath,
548554
];

test/integration-tests/testexplorer/SwiftTestingOutputParser.test.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,4 +302,38 @@ suite("SwiftTestingOutputParser Suite", () => {
302302
},
303303
]);
304304
});
305+
306+
test("Issue with isFailure: false isn't recorded", async () => {
307+
const issueLocation = {
308+
_filePath: "file:///some/file.swift",
309+
line: 1,
310+
column: 2,
311+
};
312+
const issueEvent = testEvent(
313+
"issueRecorded",
314+
"MyTests.MyTests/testWarning()",
315+
[{ text: "This is a warning", symbol: TestSymbol.warning }],
316+
issueLocation
317+
);
318+
(issueEvent.payload as any).issue.isFailure = false;
319+
320+
const events = new TestEventStream([
321+
testEvent("runStarted"),
322+
testEvent("testCaseStarted", "MyTests.MyTests/testWarning()"),
323+
issueEvent,
324+
testEvent("testCaseEnded", "MyTests.MyTests/testWarning()"),
325+
testEvent("runEnded"),
326+
]);
327+
328+
await outputParser.watch("file:///mock/named/pipe", testRunState, events);
329+
330+
assert.deepEqual(testRunState.tests, [
331+
{
332+
name: "MyTests.MyTests/testWarning()",
333+
status: TestStatus.passed,
334+
timing: { timestamp: 0 },
335+
output: [],
336+
},
337+
]);
338+
});
305339
});

0 commit comments

Comments
 (0)