From 3263955992e1208b5bd112937efffe3229199a4b Mon Sep 17 00:00:00 2001 From: Karthik Nadig Date: Tue, 27 Jul 2021 22:03:13 -0700 Subject: [PATCH] Fix issues with multi-root workspace runs --- .../testController/pytest/pytestController.ts | 12 +++++++++--- src/client/testing/testController/unittest/runner.ts | 6 +++++- .../testController/unittest/unittestController.ts | 12 +++++++++--- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/client/testing/testController/pytest/pytestController.ts b/src/client/testing/testController/pytest/pytestController.ts index d306dd6b0f232..1da6ae7ea2c2f 100644 --- a/src/client/testing/testController/pytest/pytestController.ts +++ b/src/client/testing/testController/pytest/pytestController.ts @@ -241,9 +241,15 @@ export class PytestController implements ITestFrameworkController { ): Promise { let runRequest = request; if (!runRequest.include) { - const testItem = testController.items.get(workspace.uri.fsPath); - if (testItem) { - runRequest = new TestRunRequest([testItem], undefined, request.profile); + const testItems: TestItem[] = []; + testController.items.forEach((i) => { + const w = this.workspaceService.getWorkspaceFolder(i.uri); + if (w?.uri.fsPath === workspace.uri.fsPath) { + testItems.push(i); + } + }); + if (testItems.length > 0) { + runRequest = new TestRunRequest(testItems, undefined, request.profile); } } diff --git a/src/client/testing/testController/unittest/runner.ts b/src/client/testing/testController/unittest/runner.ts index 82cfa140178e2..766af36816109 100644 --- a/src/client/testing/testController/unittest/runner.ts +++ b/src/client/testing/testController/unittest/runner.ts @@ -44,7 +44,11 @@ export class UnittestRunner implements ITestsRunner { debug, }; - const runInstance = testController.createTestRun(request); + const runInstance = testController.createTestRun( + request, + `Running Tests for Workspace ${runOptions.workspaceFolder.fsPath}`, + true, + ); const dispose = options.token.onCancellationRequested(() => { runInstance.end(); }); diff --git a/src/client/testing/testController/unittest/unittestController.ts b/src/client/testing/testController/unittest/unittestController.ts index 5991948b6964a..5954dbaa4831e 100644 --- a/src/client/testing/testController/unittest/unittestController.ts +++ b/src/client/testing/testController/unittest/unittestController.ts @@ -213,9 +213,15 @@ for s in generate_test_cases(suite): ): Promise { let runRequest = request; if (!runRequest.include) { - const testItem = testController.items.get(workspace.uri.fsPath); - if (testItem) { - runRequest = new TestRunRequest([testItem], undefined, request.profile); + const testItems: TestItem[] = []; + testController.items.forEach((i) => { + const w = this.workspaceService.getWorkspaceFolder(i.uri); + if (w?.uri.fsPath === workspace.uri.fsPath) { + testItems.push(i); + } + }); + if (testItems.length > 0) { + runRequest = new TestRunRequest(testItems, undefined, request.profile); } }