Skip to content

Commit 4b80164

Browse files
authored
Mark XCTests as passed without a second pass over the output (#1034)
The lastTestItem was not being set right away when a test succeeded because tests were being marked as passed in a second pass of the XCTest output after a run completed. Going by the removed comment this second pass was added to disambiguate passing tests with the same suite/test name across multiple targets. However, the test target is present in the `testName` used to look up a test's index. For instance, it may look like `TestTargetA/Suite/testFoo` and so would not be identical to `TestTargetB/Suite/testFoo`, and so we get the correct `testIndex` for either test.
1 parent d7b377c commit 4b80164

File tree

2 files changed

+9
-24
lines changed

2 files changed

+9
-24
lines changed

src/TestExplorer/TestParsers/XCTestOutputParser.ts

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ export class XCTestOutputParser implements IXCTestOutputParser {
195195
this.failTest(testIndex, { duration }, runState);
196196
break;
197197
case TestCompletionState.passed:
198-
// Tests are passed in the second pass below.
198+
this.passTest(testIndex, { duration }, runState);
199199
break;
200200
case TestCompletionState.skipped:
201201
this.skipTest(testIndex, runState);
@@ -253,21 +253,6 @@ export class XCTestOutputParser implements IXCTestOutputParser {
253253
// unrecognised output could be the continuation of a previous error message
254254
this.continueErrorMessage(line, runState);
255255
}
256-
257-
// We need to run the passed checks in a separate pass to ensure we aren't in the situation
258-
// where there is a symbol clash between different test targets and set the wrong test
259-
// to be passed.
260-
for (const line of lines) {
261-
// Regex "Test Case '<class>.<function>' passed (<duration> seconds)"
262-
const passedMatch = this.regex.finished.exec(line);
263-
if (passedMatch && passedMatch[3] === TestCompletionState.passed) {
264-
const testName = `${passedMatch[1]}/${passedMatch[2]}`;
265-
const duration: number = +passedMatch[4];
266-
const passedTestIndex = runState.getTestItemIndex(testName, undefined);
267-
this.passTest(passedTestIndex, { duration }, runState);
268-
continue;
269-
}
270-
}
271256
}
272257

273258
/** Get Test parsing regex for current platform */

test/suite/testexplorer/TestExplorerIntegration.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -370,14 +370,14 @@ suite("Test Explorer Suite", function () {
370370
});
371371

372372
suite(runProfile, () => {
373-
suite("swift-testing", function () {
373+
suite(`swift-testing (${runProfile})`, function () {
374374
suiteSetup(function () {
375375
if (workspaceContext.swiftVersion.isLessThan(new Version(6, 0, 0))) {
376376
this.skip();
377377
}
378378
});
379379

380-
test("Runs passing test", async function () {
380+
test(`Runs passing test ${runProfile}`, async function () {
381381
const testRun = await runTest(
382382
testExplorer.controller,
383383
runProfile,
@@ -394,7 +394,7 @@ suite("Test Explorer Suite", function () {
394394
);
395395
});
396396

397-
test("Runs failing test", async function () {
397+
test(`Runs failing test ${runProfile}`, async function () {
398398
const testRun = await runTest(
399399
testExplorer.controller,
400400
runProfile,
@@ -416,7 +416,7 @@ suite("Test Explorer Suite", function () {
416416
});
417417
});
418418

419-
test("Runs Suite", async function () {
419+
test(`Runs Suite ${runProfile}`, async function () {
420420
const testRun = await runTest(
421421
testExplorer.controller,
422422
runProfile,
@@ -441,7 +441,7 @@ suite("Test Explorer Suite", function () {
441441
});
442442
});
443443

444-
test("Runs parameterized test", async function () {
444+
test(`Runs parameterized test ${runProfile}`, async function () {
445445
const testRun = await runTest(
446446
testExplorer.controller,
447447
runProfile,
@@ -471,7 +471,7 @@ suite("Test Explorer Suite", function () {
471471
});
472472
});
473473

474-
test("Runs Suite", async function () {
474+
test(`Runs Suite (${runProfile})`, async function () {
475475
const testRun = await runTest(
476476
testExplorer.controller,
477477
runProfile,
@@ -496,7 +496,7 @@ suite("Test Explorer Suite", function () {
496496
});
497497
});
498498

499-
test("Runs All", async function () {
499+
test(`Runs All (${runProfile})`, async function () {
500500
const testRun = await runTest(
501501
testExplorer.controller,
502502
runProfile,
@@ -534,7 +534,7 @@ suite("Test Explorer Suite", function () {
534534
});
535535
});
536536

537-
suite("XCTests", () => {
537+
suite(`XCTests (${runProfile})`, () => {
538538
test("Runs passing test", async function () {
539539
const testRun = await runTest(
540540
testExplorer.controller,

0 commit comments

Comments
 (0)