Skip to content

Commit

Permalink
v2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
eleanorjboyd committed Dec 9, 2024
1 parent e220045 commit 6c78788
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 370 deletions.
135 changes: 0 additions & 135 deletions src/client/testing/common/socketServer.ts

This file was deleted.

21 changes: 1 addition & 20 deletions src/client/testing/common/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CancellationToken, DebugSessionOptions, Disposable, OutputChannel, Uri } from 'vscode';
import { CancellationToken, DebugSessionOptions, OutputChannel, Uri } from 'vscode';
import { Product } from '../../common/types';
import { TestSettingsPropertyNames } from '../configuration/types';
import { TestProvider } from '../types';
Expand All @@ -17,7 +17,6 @@ export type TestDiscoveryOptions = {
outChannel?: OutputChannel;
};

export type UnitTestParserOptions = TestDiscoveryOptions & { startDirectory: string };

export type LaunchOptions = {
cwd: string;
Expand All @@ -30,15 +29,6 @@ export type LaunchOptions = {
runTestIdsPort?: string;
};

export type ParserOptions = TestDiscoveryOptions;

export type Options = {
workspaceFolder: Uri;
cwd: string;
args: string[];
outChannel?: OutputChannel;
token?: CancellationToken;
};

export enum TestFilter {
removeTests = 'removeTests',
Expand Down Expand Up @@ -91,12 +81,3 @@ export const ITestDebugLauncher = Symbol('ITestDebugLauncher');
export interface ITestDebugLauncher {
launchDebugger(options: LaunchOptions, callback?: () => void, sessionOptions?: DebugSessionOptions): Promise<void>;
}

export const IUnitTestSocketServer = Symbol('IUnitTestSocketServer');
export interface IUnitTestSocketServer extends Disposable {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
on(event: string | symbol, listener: (...args: any[]) => void): this;
removeAllListeners(event?: string | symbol): this;
start(options?: { port?: number; host?: string }): Promise<number>;
stop(): void;
}
3 changes: 0 additions & 3 deletions src/client/testing/serviceRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,17 @@ import {
ITestConfigurationService,
ITestDebugLauncher,
ITestsHelper,
IUnitTestSocketServer,
} from './common/types';
import { UnitTestConfigurationService } from './configuration';
import { TestConfigurationManagerFactory } from './configurationFactory';
import { TestingService, UnitTestManagementService } from './main';
import { ITestingService } from './types';
import { UnitTestSocketServer } from './common/socketServer';
import { registerTestControllerTypes } from './testController/serviceRegistry';

export function registerTypes(serviceManager: IServiceManager) {
serviceManager.addSingleton<ITestDebugLauncher>(ITestDebugLauncher, DebugLauncher);

serviceManager.add<ITestsHelper>(ITestsHelper, TestsHelper);
serviceManager.add<IUnitTestSocketServer>(IUnitTestSocketServer, UnitTestSocketServer);

serviceManager.addSingleton<ITestConfigurationService>(ITestConfigurationService, UnitTestConfigurationService);
serviceManager.addSingleton<ITestingService>(ITestingService, TestingService);
Expand Down
82 changes: 27 additions & 55 deletions src/client/testing/testController/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,8 @@ import {
} from 'vscode';
import { ITestDebugLauncher } from '../../common/types';
import { IPythonExecutionFactory } from '../../../common/process/types';
import { EnvironmentVariables } from '../../../common/variables/types';
import { PythonEnvironment } from '../../../pythonEnvironments/info';

export type TestRunInstanceOptions = TestRunOptions & {
exclude?: readonly TestItem[];
debug: boolean;
};

export enum TestDataKinds {
Workspace,
FolderOrFile,
Expand Down Expand Up @@ -50,13 +44,6 @@ export interface ITestController {
onRunWithoutConfiguration: Event<WorkspaceFolder[]>;
}

export interface ITestRun {
includes: readonly TestItem[];
excludes: readonly TestItem[];
runKind: TestRunProfileKind;
runInstance: TestRun;
}

export const ITestFrameworkController = Symbol('ITestFrameworkController');
export interface ITestFrameworkController {
resolveChildren(testController: TestController, item: TestItem, token?: CancellationToken): Promise<void>;
Expand All @@ -65,12 +52,7 @@ export interface ITestFrameworkController {
export const ITestsRunner = Symbol('ITestsRunner');
export interface ITestsRunner {}

export type TestRunOptions = {
workspaceFolder: Uri;
cwd: string;
args: string[];
token: CancellationToken;
};


// We expose these here as a convenience and to cut down on churn
// elsewhere in the code.
Expand Down Expand Up @@ -136,43 +118,33 @@ export type TestCommandOptions = {
testIds?: string[];
};

export type TestCommandOptionsPytest = {
workspaceFolder: Uri;
cwd: string;
commandStr: string;
token?: CancellationToken;
outChannel?: OutputChannel;
debugBool?: boolean;
testIds?: string[];
env: { [key: string]: string | undefined };
};

/**
* Interface describing the server that will send test commands to the Python side, and process responses.
*
* Consumers will call sendCommand in order to execute Python-related code,
* and will subscribe to the onDataReceived event to wait for the results.
*/
export interface ITestServer {
readonly onDataReceived: Event<DataReceivedEvent>;
readonly onRunDataReceived: Event<DataReceivedEvent>;
readonly onDiscoveryDataReceived: Event<DataReceivedEvent>;
sendCommand(
options: TestCommandOptions,
env: EnvironmentVariables,
runTestIdsPort?: string,
runInstance?: TestRun,
testIds?: string[],
callback?: () => void,
executionFactory?: IPythonExecutionFactory,
): Promise<void>;
serverReady(): Promise<void>;
getPort(): number;
createUUID(cwd: string): string;
deleteUUID(uuid: string): void;
triggerRunDataReceivedEvent(data: DataReceivedEvent): void;
triggerDiscoveryDataReceivedEvent(data: DataReceivedEvent): void;
}
// /**
// * Interface describing the server that will send test commands to the Python side, and process responses.
// *
// * Consumers will call sendCommand in order to execute Python-related code,
// * and will subscribe to the onDataReceived event to wait for the results.
// */
// export interface ITestServer {
// readonly onDataReceived: Event<DataReceivedEvent>;
// readonly onRunDataReceived: Event<DataReceivedEvent>;
// readonly onDiscoveryDataReceived: Event<DataReceivedEvent>;
// sendCommand(
// options: TestCommandOptions,
// env: EnvironmentVariables,
// runTestIdsPort?: string,
// runInstance?: TestRun,
// testIds?: string[],
// callback?: () => void,
// executionFactory?: IPythonExecutionFactory,
// ): Promise<void>;
// serverReady(): Promise<void>;
// getPort(): number;
// createUUID(cwd: string): string;
// deleteUUID(uuid: string): void;
// triggerRunDataReceivedEvent(data: DataReceivedEvent): void;
// triggerDiscoveryDataReceivedEvent(data: DataReceivedEvent): void;
// }
export interface ITestResultResolver {
runIdToVSid: Map<string, string>;
runIdToTestItem: Map<string, TestItem>;
Expand Down
23 changes: 1 addition & 22 deletions src/client/testing/testController/pytest/arguments.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

import { TestDiscoveryOptions, TestFilter } from '../../common/types';
import { TestFilter } from '../../common/types';
import { getPositionalArguments, filterArguments } from '../common/argumentsHelper';

const OptionsWithArguments = [
Expand Down Expand Up @@ -134,11 +134,6 @@ const OptionsWithoutArguments = [
'-d',
];

export function pytestGetTestFilesAndFolders(args: string[]): string[] {
// If users enter test modules/methods, then its not supported.
return getPositionalArguments(args, OptionsWithArguments, OptionsWithoutArguments);
}

export function removePositionalFoldersAndFiles(args: string[]): string[] {
return pytestFilterArguments(args, TestFilter.removeTests);
}
Expand Down Expand Up @@ -259,19 +254,3 @@ function pytestFilterArguments(args: string[], argumentToRemoveOrFilter: string[
return filterArguments(filteredArgs, optionsWithArgsToRemove, optionsWithoutArgsToRemove);
}

export function preparePytestArgumentsForDiscovery(options: TestDiscoveryOptions): string[] {
// Remove unwanted arguments (which happen to be test directories & test specific args).
const args = pytestFilterArguments(options.args, TestFilter.discovery);
if (options.ignoreCache && args.indexOf('--cache-clear') === -1) {
args.splice(0, 0, '--cache-clear');
}
if (args.indexOf('-s') === -1) {
args.splice(0, 0, '-s');
}

// Only add --rootdir if user has not already provided one
if (args.filter((a) => a.startsWith('--rootdir')).length === 0) {
args.splice(0, 0, '--rootdir', options.cwd);
}
return args;
}
Loading

0 comments on commit 6c78788

Please sign in to comment.