Skip to content

Commit

Permalink
remove unneeded multiroot code (#21295)
Browse files Browse the repository at this point in the history
removed extra steps to wrap data since this creates duplicate folders in
the controller and only keeps the most recent instead of all the roots
from different workspaces.
  • Loading branch information
eleanorjboyd authored May 24, 2023
1 parent e2a9cec commit b916981
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 46 deletions.
5 changes: 1 addition & 4 deletions src/client/testing/testController/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,6 @@ export class PythonTestController implements ITestController, IExtensionSingleAc
testAdapter.discoverTests(
this.testController,
this.refreshCancellation.token,
this.testAdapters.size > 1,
this.workspaceService.workspaceFile?.fsPath,
this.pythonExecFactory,
);
} else {
Expand All @@ -274,8 +272,7 @@ export class PythonTestController implements ITestController, IExtensionSingleAc
testAdapter.discoverTests(
this.testController,
this.refreshCancellation.token,
this.testAdapters.size > 1,
this.workspaceService.workspaceFile?.fsPath,
this.pythonExecFactory,
);
} else {
// else use OLD test discovery mechanism
Expand Down
43 changes: 1 addition & 42 deletions src/client/testing/testController/workspaceTestAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,7 @@ import {
getTestCaseNodes,
RunTestTag,
} from './common/testItemUtilities';
import {
DiscoveredTestItem,
DiscoveredTestNode,
DiscoveredTestType,
ITestDiscoveryAdapter,
ITestExecutionAdapter,
} from './common/types';
import { DiscoveredTestItem, DiscoveredTestNode, ITestDiscoveryAdapter, ITestExecutionAdapter } from './common/types';
import { fixLogLines } from './common/utils';
import { IPythonExecutionFactory } from '../../common/process/types';
import { ITestDebugLauncher } from '../common/types';
Expand Down Expand Up @@ -288,8 +282,6 @@ export class WorkspaceTestAdapter {
public async discoverTests(
testController: TestController,
token?: CancellationToken,
isMultiroot?: boolean,
workspaceFilePath?: string,
executionFactory?: IPythonExecutionFactory,
): Promise<void> {
sendTelemetryEvent(EventName.UNITTEST_DISCOVERING, undefined, { tool: this.testProvider });
Expand Down Expand Up @@ -366,39 +358,6 @@ export class WorkspaceTestAdapter {
// then parse and insert test data.
testController.items.delete(`DiscoveryError:${workspacePath}`);

// Wrap the data under a root node named after the test provider.
const wrappedTests = rawTestData.tests;

// If we are in a multiroot workspace scenario, wrap the current folder's test result in a tree under the overall root + the current folder name.
let rootPath = workspacePath;
let childrenRootPath = rootPath;
let childrenRootName = path.basename(rootPath);

if (isMultiroot) {
rootPath = workspaceFilePath!;
childrenRootPath = workspacePath;
childrenRootName = path.basename(workspacePath);
}

const children = [
{
path: childrenRootPath,
name: childrenRootName,
type_: 'folder' as DiscoveredTestType,
id_: childrenRootPath,
children: wrappedTests ? [wrappedTests] : [],
},
];

// Update the raw test data with the wrapped data.
rawTestData.tests = {
path: rootPath,
name: this.testProvider,
type_: 'folder',
id_: rootPath,
children,
};

if (rawTestData.tests) {
// If the test root for this folder exists: Workspace refresh, update its children.
// Otherwise, it is a freshly discovered workspace, and we need to create a new test root and populate the test tree.
Expand Down

0 comments on commit b916981

Please sign in to comment.