Skip to content

Commit 22290e7

Browse files
author
Eric Snow
authored
Use more-specific types for test results and diagnostics. (#15387)
(for #14866) Some of the problems we've run into relate to how we are using the same broad types for all the different kinds of test results (passing, failing, active and unknown). This change addresses that by switching to specific types tailored to the relevant kinds of test results.
1 parent cbdbe0a commit 22290e7

File tree

119 files changed

+1082
-811
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+1082
-811
lines changed

.eslintignore

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,6 @@ src/test/testing/codeLenses/testFiles.unit.test.ts
127127
src/test/testing/nosetest/nosetest.test.ts
128128
src/test/testing/nosetest/nosetest.disovery.test.ts
129129
src/test/testing/nosetest/nosetest.run.test.ts
130-
src/test/testing/pytest/pytest.testMessageService.test.ts
131-
src/test/testing/pytest/pytest_unittest_parser_data.ts
132-
src/test/testing/pytest/pytest.test.ts
133-
src/test/testing/pytest/pytest_run_tests_data.ts
134-
src/test/testing/pytest/services/discoveryService.unit.test.ts
135130
src/test/testing/rediscover.test.ts
136131
src/test/testing/helper.ts
137132
src/test/testing/navigation/fileNavigator.unit.test.ts
@@ -140,7 +135,6 @@ src/test/testing/navigation/suiteNavigator.unit.test.ts
140135
src/test/testing/navigation/commandHandlers.unit.test.ts
141136
src/test/testing/navigation/helper.unit.test.ts
142137
src/test/testing/navigation/symbolNavigator.unit.test.ts
143-
src/test/testing/configuration.unit.test.ts
144138
src/test/testing/explorer/treeView.unit.test.ts
145139
src/test/testing/explorer/testExplorerCommandHandler.unit.test.ts
146140
src/test/testing/explorer/failedTestHandler.unit.test.ts
@@ -151,8 +145,6 @@ src/test/testing/banners/proposeNewLanguageServerBanner.unit.test.ts
151145
src/test/testing/common/argsHelper.unit.test.ts
152146
src/test/testing/common/trackEnablement.unit.test.ts
153147
src/test/testing/common/debugLauncher.unit.test.ts
154-
src/test/testing/common/managers/baseTestManager.unit.test.ts
155-
src/test/testing/common/managers/testConfigurationManager.unit.test.ts
156148
src/test/testing/common/testUtils.unit.test.ts
157149
src/test/testing/common/testVisitors/resultResetVisitor.unit.test.ts
158150
src/test/testing/common/services/discoveredTestParser.unit.test.ts
@@ -443,12 +435,6 @@ src/client/testing/nosetest/services/parserService.ts
443435
src/client/testing/nosetest/services/argsService.ts
444436
src/client/testing/nosetest/services/discoveryService.ts
445437
src/client/testing/main.ts
446-
src/client/testing/pytest/main.ts
447-
src/client/testing/pytest/testConfigurationManager.ts
448-
src/client/testing/pytest/runner.ts
449-
src/client/testing/pytest/services/argsService.ts
450-
src/client/testing/pytest/services/discoveryService.ts
451-
src/client/testing/pytest/services/testMessageService.ts
452438
src/client/testing/configurationFactory.ts
453439
src/client/testing/navigation/serviceRegistry.ts
454440
src/client/testing/navigation/symbolProvider.ts
@@ -462,13 +448,9 @@ src/client/testing/explorer/testTreeViewProvider.ts
462448
src/client/testing/explorer/commandHandlers.ts
463449
src/client/testing/explorer/failedTestHandler.ts
464450
src/client/testing/explorer/treeView.ts
465-
src/client/testing/types.ts
466451
src/client/testing/common/argumentsHelper.ts
467452
src/client/testing/common/enablementTracker.ts
468453
src/client/testing/common/debugLauncher.ts
469-
src/client/testing/common/managers/testConfigurationManager.ts
470-
src/client/testing/common/managers/baseTestManager.ts
471-
src/client/testing/common/types.ts
472454
src/client/testing/common/constants.ts
473455
src/client/testing/common/testUtils.ts
474456
src/client/testing/common/xUnitParser.ts
@@ -481,7 +463,6 @@ src/client/testing/common/services/contextService.ts
481463
src/client/testing/common/services/testResultsService.ts
482464
src/client/testing/common/services/storageService.ts
483465
src/client/testing/common/services/types.ts
484-
src/client/testing/common/services/unitTestDiagnosticService.ts
485466
src/client/testing/common/services/testsStatusService.ts
486467
src/client/testing/common/services/discovery.ts
487468
src/client/testing/common/services/configSettingService.ts

src/client/activation/jedi.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import { PythonRenameProvider } from '../providers/renameProvider';
4040
import { PythonSignatureProvider } from '../providers/signatureProvider';
4141
import { JediSymbolProvider } from '../providers/symbolProvider';
4242
import { PythonEnvironment } from '../pythonEnvironments/info';
43-
import { ITestManagementService } from '../testing/types';
43+
import { ITestingService } from '../testing/types';
4444
import { BlockFormatProviders } from '../typeFormatters/blockFormatProvider';
4545
import { OnTypeFormattingDispatcher } from '../typeFormatters/dispatcher';
4646
import { OnEnterFormatter } from '../typeFormatters/onEnterFormatter';
@@ -94,7 +94,7 @@ export class JediExtensionActivator implements ILanguageServerActivator {
9494
context.subscriptions.push(JediExtensionActivator.workspaceSymbols);
9595
}
9696

97-
const testManagementService = this.serviceManager.get<ITestManagementService>(ITestManagementService);
97+
const testManagementService = this.serviceManager.get<ITestingService>(ITestingService);
9898
testManagementService
9999
.activate(this.symbolProvider)
100100
.catch((ex) => traceError('Failed to activate Unit Tests', ex));

src/client/activation/jedi/languageServerProxy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { LanguageServerSymbolProvider } from '../../providers/symbolProvider';
2121
import { PythonEnvironment } from '../../pythonEnvironments/info';
2222
import { captureTelemetry } from '../../telemetry';
2323
import { EventName } from '../../telemetry/constants';
24-
import { ITestManagementService } from '../../testing/types';
24+
import { ITestingService } from '../../testing/types';
2525
import { FileBasedCancellationStrategy } from '../common/cancellationUtils';
2626
import { LanguageClientMiddleware } from '../languageClientMiddleware';
2727
import { ProgressReporting } from '../progress';
@@ -43,7 +43,7 @@ export class JediLanguageServerProxy implements ILanguageServerProxy {
4343

4444
constructor(
4545
@inject(ILanguageClientFactory) private readonly factory: ILanguageClientFactory,
46-
@inject(ITestManagementService) private readonly testManager: ITestManagementService,
46+
@inject(ITestingService) private readonly testManager: ITestingService,
4747
@inject(IExperimentsManager) private readonly experiments: IExperimentsManager,
4848
@inject(IInterpreterPathService) private readonly interpreterPathService: IInterpreterPathService,
4949
) {

src/client/activation/languageServer/languageServerProxy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { LanguageServerSymbolProvider } from '../../providers/symbolProvider';
1414
import { PythonEnvironment } from '../../pythonEnvironments/info';
1515
import { captureTelemetry, sendTelemetryEvent } from '../../telemetry';
1616
import { EventName } from '../../telemetry/constants';
17-
import { ITestManagementService } from '../../testing/types';
17+
import { ITestingService } from '../../testing/types';
1818
import { ProgressReporting } from '../progress';
1919
import { ILanguageClientFactory, ILanguageServerProxy } from '../types';
2020

@@ -28,7 +28,7 @@ export class DotNetLanguageServerProxy implements ILanguageServerProxy {
2828

2929
constructor(
3030
@inject(ILanguageClientFactory) private readonly factory: ILanguageClientFactory,
31-
@inject(ITestManagementService) private readonly testManager: ITestManagementService,
31+
@inject(ITestingService) private readonly testManager: ITestingService,
3232
@inject(IConfigurationService) private readonly configurationService: IConfigurationService,
3333
) {
3434
this.startupCompleted = createDeferred<void>();

src/client/activation/node/languageServerProxy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { LanguageServerSymbolProvider } from '../../providers/symbolProvider';
2828
import { PythonEnvironment } from '../../pythonEnvironments/info';
2929
import { captureTelemetry, sendTelemetryEvent } from '../../telemetry';
3030
import { EventName } from '../../telemetry/constants';
31-
import { ITestManagementService } from '../../testing/types';
31+
import { ITestingService } from '../../testing/types';
3232
import { FileBasedCancellationStrategy } from '../common/cancellationUtils';
3333
import { ProgressReporting } from '../progress';
3434
import { ILanguageClientFactory, ILanguageServerFolderService, ILanguageServerProxy } from '../types';
@@ -68,7 +68,7 @@ export class NodeLanguageServerProxy implements ILanguageServerProxy {
6868

6969
constructor(
7070
@inject(ILanguageClientFactory) private readonly factory: ILanguageClientFactory,
71-
@inject(ITestManagementService) private readonly testManager: ITestManagementService,
71+
@inject(ITestingService) private readonly testManager: ITestingService,
7272
@inject(IConfigurationService) private readonly configurationService: IConfigurationService,
7373
@inject(ILanguageServerFolderService) private readonly folderService: ILanguageServerFolderService,
7474
@inject(IExperimentsManager) private readonly experiments: IExperimentsManager,

src/client/common/application/commands.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@
33

44
'use strict';
55

6-
import { CancellationToken, Position, TextDocument, Uri } from 'vscode';
6+
import { CancellationToken, Disposable, Position, TextDocument, Uri } from 'vscode';
77
import { Commands as LSCommands } from '../../activation/commands';
88
import { TensorBoardEntrypoint, TensorBoardEntrypointTrigger } from '../../tensorBoard/constants';
9-
import { CommandSource } from '../../testing/common/constants';
10-
import { TestFunction, TestsToRun } from '../../testing/common/types';
11-
import { TestDataItem, TestWorkspaceFolder } from '../../testing/types';
9+
import { TestDataItem, TestFunction, TestsToRun, TestWorkspaceFolder } from '../../testing/common/types';
1210
import { Commands } from '../constants';
13-
import { Channel } from './types';
11+
import { Channel, CommandSource, ICommandManager } from './types';
1412

1513
export type CommandsWithoutArgs = keyof ICommandNameWithoutArgumentTypeMapping;
1614

@@ -129,3 +127,17 @@ export interface ICommandNameArgumentTypeMapping extends ICommandNameWithoutArgu
129127
[Commands.navigateToTestSuite]: [Uri, TestDataItem, boolean];
130128
[Commands.LaunchTensorBoard]: [TensorBoardEntrypoint, TensorBoardEntrypointTrigger];
131129
}
130+
131+
//export const IPythonCommandManager = Symbol('IPythonCommandManager');
132+
export interface IPythonCommandManager extends ICommandManager {
133+
registerCommand<E extends keyof ICommandNameArgumentTypeMapping, U extends ICommandNameArgumentTypeMapping[E]>(
134+
command: E,
135+
callback: (...args: U) => any,
136+
thisArg?: any,
137+
): Disposable;
138+
139+
executeCommand<T, E extends keyof ICommandNameArgumentTypeMapping, U extends ICommandNameArgumentTypeMapping[E]>(
140+
command: E,
141+
...rest: U
142+
): Thenable<T | undefined>;
143+
}

src/client/common/application/types.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,14 @@ import type {
7676
} from 'vscode-proposed';
7777

7878
import { IAsyncDisposable, Resource } from '../types';
79-
import { ICommandNameArgumentTypeMapping } from './commands';
79+
80+
export enum CommandSource {
81+
auto = 'auto',
82+
ui = 'ui',
83+
codelens = 'codelens',
84+
commandPalette = 'commandpalette',
85+
testExplorer = 'testExplorer',
86+
}
8087

8188
export const IApplicationShell = Symbol('IApplicationShell');
8289
export interface IApplicationShell {
@@ -445,11 +452,7 @@ export interface ICommandManager {
445452
* @param thisArg The `this` context used when invoking the handler function.
446453
* @return Disposable which unregisters this command on disposal.
447454
*/
448-
registerCommand<E extends keyof ICommandNameArgumentTypeMapping, U extends ICommandNameArgumentTypeMapping[E]>(
449-
command: E,
450-
callback: (...args: U) => any,
451-
thisArg?: any,
452-
): Disposable;
455+
registerCommand(command: string, callback: (...args: any[]) => any, thisArg?: any): Disposable;
453456

454457
/**
455458
* Registers a text editor command that can be invoked via a keyboard shortcut,
@@ -485,10 +488,7 @@ export interface ICommandManager {
485488
* @return A thenable that resolves to the returned value of the given command. `undefined` when
486489
* the command handler function doesn't return anything.
487490
*/
488-
executeCommand<T, E extends keyof ICommandNameArgumentTypeMapping, U extends ICommandNameArgumentTypeMapping[E]>(
489-
command: E,
490-
...rest: U
491-
): Thenable<T | undefined>;
491+
executeCommand<T>(command: string, ...rest: any[]): Thenable<T | undefined>;
492492

493493
/**
494494
* Retrieve the list of all available commands. Commands starting an underscore are

src/client/common/configSettings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { LogLevel } from '../logging/levels';
2020
import { sendTelemetryEvent } from '../telemetry';
2121
import { EventName } from '../telemetry/constants';
2222
import { sendSettingTelemetry } from '../telemetry/envFileTelemetry';
23+
import { ITestingSettings } from '../testing/configuration/types';
2324
import { IWorkspaceService } from './application/types';
2425
import { WorkspaceService } from './application/workspace';
2526
import { DEFAULT_INTERPRETER_SETTING, isTestExecution } from './constants';
@@ -40,7 +41,6 @@ import {
4041
IPythonSettings,
4142
ISortImportSettings,
4243
ITerminalSettings,
43-
ITestingSettings,
4444
IWorkspaceSymbolSettings,
4545
LoggingLevelSettingType,
4646
Resource,

src/client/common/installer/productPath.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { Uri } from 'vscode';
99
import { IFormatterHelper } from '../../formatters/types';
1010
import { IServiceContainer } from '../../ioc/types';
1111
import { ILinterManager } from '../../linters/types';
12-
import { ITestsHelper } from '../../testing/common/types';
12+
import { ITestingService } from '../../testing/types';
1313
import { IConfigurationService, IInstaller, ModuleNamePurpose, Product } from '../types';
1414
import { IProductPathService } from './types';
1515

@@ -78,7 +78,7 @@ export class TestFrameworkProductPathService extends BaseProductPathsService {
7878
super(serviceContainer);
7979
}
8080
public getExecutableNameFromSettings(product: Product, resource?: Uri): string {
81-
const testHelper = this.serviceContainer.get<ITestsHelper>(ITestsHelper);
81+
const testHelper = this.serviceContainer.get<ITestingService>(ITestingService);
8282
const settingsPropNames = testHelper.getSettingsPropertyNames(product);
8383
if (!settingsPropNames.pathName) {
8484
// E.g. in the case of UnitTests we don't allow customizing the paths.

src/client/common/serviceRegistry.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { ApplicationEnvironment } from './application/applicationEnvironment';
1818
import { ApplicationShell } from './application/applicationShell';
1919
import { ClipboardService } from './application/clipboard';
2020
import { CommandManager } from './application/commandManager';
21+
import { IPythonCommandManager } from './application/commands';
2122
import { ReloadVSCodeCommandHandler } from './application/commands/reloadCommand';
2223
import { CustomEditorService } from './application/customEditorService';
2324
import { DebugService } from './application/debugService';
@@ -143,7 +144,7 @@ export function registerTypes(serviceManager: IServiceManager) {
143144
IJupyterExtensionDependencyManager,
144145
JupyterExtensionDependencyManager,
145146
);
146-
serviceManager.addSingleton<ICommandManager>(ICommandManager, CommandManager);
147+
serviceManager.addSingleton<IPythonCommandManager>(ICommandManager, CommandManager);
147148
serviceManager.addSingleton<IConfigurationService>(IConfigurationService, ConfigurationService);
148149
serviceManager.addSingleton<IWorkspaceService>(IWorkspaceService, WorkspaceService);
149150
serviceManager.addSingleton<IProcessLogger>(IProcessLogger, ProcessLogger);

0 commit comments

Comments
 (0)