Skip to content

Commit cf91dc8

Browse files
authored
remove ITestLogChannel (#24954)
1 parent cd714bf commit cf91dc8

21 files changed

+86
-274
lines changed

python_files/vscode_pytest/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def pytest_internalerror(excrepr, excinfo): # noqa: ARG001
121121
excinfo -- the exception information of type ExceptionInfo.
122122
"""
123123
# call.excinfo.exconly() returns the exception as a string.
124-
ERRORS.append(excinfo.exconly() + "\n Check Python Test Logs for more details.")
124+
ERRORS.append(excinfo.exconly() + "\n Check Python Logs for more details.")
125125

126126

127127
def pytest_exception_interact(node, call, report):
@@ -139,9 +139,9 @@ def pytest_exception_interact(node, call, report):
139139
if call.excinfo and call.excinfo.typename != "AssertionError":
140140
if report.outcome == "skipped" and "SkipTest" in str(call):
141141
return
142-
ERRORS.append(call.excinfo.exconly() + "\n Check Python Test Logs for more details.")
142+
ERRORS.append(call.excinfo.exconly() + "\n Check Python Logs for more details.")
143143
else:
144-
ERRORS.append(report.longreprtext + "\n Check Python Test Logs for more details.")
144+
ERRORS.append(report.longreprtext + "\n Check Python Logs for more details.")
145145
else:
146146
# If during execution, send this data that the given node failed.
147147
report_value = "error"
@@ -204,7 +204,7 @@ def pytest_keyboard_interrupt(excinfo):
204204
excinfo -- the exception information of type ExceptionInfo.
205205
"""
206206
# The function execonly() returns the exception as a string.
207-
ERRORS.append(excinfo.exconly() + "\n Check Python Test Logs for more details.")
207+
ERRORS.append(excinfo.exconly() + "\n Check Python Logs for more details.")
208208

209209

210210
class TestOutcome(Dict):

src/client/common/types.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import {
1616
Memento,
1717
LogOutputChannel,
1818
Uri,
19-
OutputChannel,
2019
} from 'vscode';
2120
import { LanguageServerType } from '../activation/types';
2221
import type { InstallOptions, InterpreterUri, ModuleInstallFlags } from './installer/types';
@@ -29,8 +28,6 @@ export interface IDisposable {
2928

3029
export const ILogOutputChannel = Symbol('ILogOutputChannel');
3130
export interface ILogOutputChannel extends LogOutputChannel {}
32-
export const ITestOutputChannel = Symbol('ITestOutputChannel');
33-
export interface ITestOutputChannel extends OutputChannel {}
3431
export const IDocumentSymbolProvider = Symbol('IDocumentSymbolProvider');
3532
export interface IDocumentSymbolProvider extends DocumentSymbolProvider {}
3633
export const IsWindows = Symbol('IS_WINDOWS');

src/client/common/utils/localize.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,6 @@ export namespace InterpreterQuickPickList {
257257
export namespace OutputChannelNames {
258258
export const languageServer = l10n.t('Python Language Server');
259259
export const python = l10n.t('Python');
260-
export const pythonTest = l10n.t('Python Test Log');
261260
}
262261

263262
export namespace Linters {

src/client/extensionInit.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
'use strict';
55

66
import { Container } from 'inversify';
7-
import { Disposable, l10n, Memento, window } from 'vscode';
7+
import { Disposable, Memento, window } from 'vscode';
88
import { registerTypes as platformRegisterTypes } from './common/platform/serviceRegistry';
99
import { registerTypes as processRegisterTypes } from './common/process/serviceRegistry';
1010
import { registerTypes as commonRegisterTypes } from './common/serviceRegistry';
@@ -15,7 +15,6 @@ import {
1515
IExtensionContext,
1616
IMemento,
1717
ILogOutputChannel,
18-
ITestOutputChannel,
1918
WORKSPACE_MEMENTO,
2019
} from './common/types';
2120
import { registerTypes as variableRegisterTypes } from './common/variables/serviceRegistry';
@@ -28,7 +27,6 @@ import * as pythonEnvironments from './pythonEnvironments';
2827
import { IDiscoveryAPI } from './pythonEnvironments/base/locator';
2928
import { registerLogger } from './logging';
3029
import { OutputChannelLogger } from './logging/outputChannelLogger';
31-
import { isTrusted, isVirtualWorkspace } from './common/vscodeApis/workspaceApis';
3230

3331
// The code in this module should do nothing more complex than register
3432
// objects to DI and simple init (e.g. no side effects). That implies
@@ -56,14 +54,7 @@ export function initializeGlobals(
5654
disposables.push(standardOutputChannel);
5755
disposables.push(registerLogger(new OutputChannelLogger(standardOutputChannel)));
5856

59-
const unitTestOutChannel = window.createOutputChannel(OutputChannelNames.pythonTest);
60-
disposables.push(unitTestOutChannel);
61-
if (isVirtualWorkspace() || !isTrusted()) {
62-
unitTestOutChannel.appendLine(l10n.t('Unit tests are not supported in this environment.'));
63-
}
64-
6557
serviceManager.addSingletonInstance<ILogOutputChannel>(ILogOutputChannel, standardOutputChannel);
66-
serviceManager.addSingletonInstance<ITestOutputChannel>(ITestOutputChannel, unitTestOutChannel);
6758

6859
return {
6960
context,

src/client/testing/testController/common/utils.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,6 @@ export function fixLogLinesNoTrailing(content: string): string {
2323
const lines = content.split(/\r?\n/g);
2424
return `${lines.join('\r\n')}`;
2525
}
26-
27-
export const MESSAGE_ON_TESTING_OUTPUT_MOVE =
28-
'Starting now, all test run output will be sent to the Test Result panel,' +
29-
' while test discovery output will be sent to the "Python" output channel instead of the "Python Test Log" channel.' +
30-
' The "Python Test Log" channel will be deprecated within the next month.' +
31-
' See https://github.com/microsoft/vscode-python/wiki/New-Method-for-Output-Handling-in-Python-Testing for details.';
32-
3326
export function createTestingDeferred(): Deferred<void> {
3427
return createDeferred<void>();
3528
}

src/client/testing/testController/controller.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { IExtensionSingleActivationService } from '../../activation/types';
2525
import { ICommandManager, IWorkspaceService } from '../../common/application/types';
2626
import * as constants from '../../common/constants';
2727
import { IPythonExecutionFactory } from '../../common/process/types';
28-
import { IConfigurationService, IDisposableRegistry, ITestOutputChannel, Resource } from '../../common/types';
28+
import { IConfigurationService, IDisposableRegistry, Resource } from '../../common/types';
2929
import { DelayedTrigger, IDelayedTrigger } from '../../common/utils/delayTrigger';
3030
import { noop } from '../../common/utils/misc';
3131
import { IInterpreterService } from '../../interpreter/contracts';
@@ -98,7 +98,6 @@ export class PythonTestController implements ITestController, IExtensionSingleAc
9898
@inject(ICommandManager) private readonly commandManager: ICommandManager,
9999
@inject(IPythonExecutionFactory) private readonly pythonExecFactory: IPythonExecutionFactory,
100100
@inject(ITestDebugLauncher) private readonly debugLauncher: ITestDebugLauncher,
101-
@inject(ITestOutputChannel) private readonly testOutputChannel: ITestOutputChannel,
102101
@inject(IEnvironmentVariablesProvider) private readonly envVarsService: IEnvironmentVariablesProvider,
103102
) {
104103
this.refreshCancellation = new CancellationTokenSource();
@@ -176,13 +175,11 @@ export class PythonTestController implements ITestController, IExtensionSingleAc
176175
resultResolver = new PythonResultResolver(this.testController, testProvider, workspace.uri);
177176
discoveryAdapter = new UnittestTestDiscoveryAdapter(
178177
this.configSettings,
179-
this.testOutputChannel,
180178
resultResolver,
181179
this.envVarsService,
182180
);
183181
executionAdapter = new UnittestTestExecutionAdapter(
184182
this.configSettings,
185-
this.testOutputChannel,
186183
resultResolver,
187184
this.envVarsService,
188185
);
@@ -191,13 +188,11 @@ export class PythonTestController implements ITestController, IExtensionSingleAc
191188
resultResolver = new PythonResultResolver(this.testController, testProvider, workspace.uri);
192189
discoveryAdapter = new PytestTestDiscoveryAdapter(
193190
this.configSettings,
194-
this.testOutputChannel,
195191
resultResolver,
196192
this.envVarsService,
197193
);
198194
executionAdapter = new PytestTestExecutionAdapter(
199195
this.configSettings,
200-
this.testOutputChannel,
201196
resultResolver,
202197
this.envVarsService,
203198
);

src/client/testing/testController/pytest/pytestDiscoveryAdapter.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,12 @@ import {
99
IPythonExecutionFactory,
1010
SpawnOptions,
1111
} from '../../../common/process/types';
12-
import { IConfigurationService, ITestOutputChannel } from '../../../common/types';
12+
import { IConfigurationService } from '../../../common/types';
1313
import { createDeferred, Deferred } from '../../../common/utils/async';
1414
import { EXTENSION_ROOT_DIR } from '../../../constants';
1515
import { traceError, traceInfo, traceVerbose, traceWarn } from '../../../logging';
1616
import { DiscoveredTestPayload, ITestDiscoveryAdapter, ITestResultResolver } from '../common/types';
1717
import {
18-
MESSAGE_ON_TESTING_OUTPUT_MOVE,
1918
createDiscoveryErrorPayload,
2019
createTestingDeferred,
2120
fixLogLinesNoTrailing,
@@ -33,7 +32,6 @@ import { useEnvExtension, getEnvironment, runInBackground } from '../../../envEx
3332
export class PytestTestDiscoveryAdapter implements ITestDiscoveryAdapter {
3433
constructor(
3534
public configSettings: IConfigurationService,
36-
private readonly outputChannel: ITestOutputChannel,
3735
private readonly resultResolver?: ITestResultResolver,
3836
private readonly envVarsService?: IEnvironmentVariablesProvider,
3937
) {}
@@ -138,15 +136,12 @@ export class PytestTestDiscoveryAdapter implements ITestDiscoveryAdapter {
138136
proc.stdout.on('data', (data) => {
139137
const out = fixLogLinesNoTrailing(data.toString());
140138
traceInfo(out);
141-
this.outputChannel?.append(out);
142139
});
143140
proc.stderr.on('data', (data) => {
144141
const out = fixLogLinesNoTrailing(data.toString());
145142
traceError(out);
146-
this.outputChannel?.append(out);
147143
});
148144
proc.onExit((code, signal) => {
149-
this.outputChannel?.append(MESSAGE_ON_TESTING_OUTPUT_MOVE);
150145
if (code !== 0) {
151146
traceError(
152147
`Subprocess exited unsuccessfully with exit code ${code} and signal ${signal} on workspace ${uri.fsPath}`,
@@ -165,7 +160,6 @@ export class PytestTestDiscoveryAdapter implements ITestDiscoveryAdapter {
165160
const spawnOptions: SpawnOptions = {
166161
cwd,
167162
throwOnStdErr: true,
168-
outputChannel: this.outputChannel,
169163
env: mutableEnv,
170164
token,
171165
};
@@ -200,20 +194,16 @@ export class PytestTestDiscoveryAdapter implements ITestDiscoveryAdapter {
200194

201195
// Take all output from the subprocess and add it to the test output channel. This will be the pytest output.
202196
// Displays output to user and ensure the subprocess doesn't run into buffer overflow.
203-
// TODO: after a release, remove discovery output from the "Python Test Log" channel and send it to the "Python" channel instead.
204197

205198
result?.proc?.stdout?.on('data', (data) => {
206199
const out = fixLogLinesNoTrailing(data.toString());
207200
traceInfo(out);
208-
spawnOptions?.outputChannel?.append(`${out}`);
209201
});
210202
result?.proc?.stderr?.on('data', (data) => {
211203
const out = fixLogLinesNoTrailing(data.toString());
212204
traceError(out);
213-
spawnOptions?.outputChannel?.append(`${out}`);
214205
});
215206
result?.proc?.on('exit', (code, signal) => {
216-
this.outputChannel?.append(MESSAGE_ON_TESTING_OUTPUT_MOVE);
217207
if (code !== 0) {
218208
traceError(
219209
`Subprocess exited unsuccessfully with exit code ${code} and signal ${signal} on workspace ${uri.fsPath}.`,

src/client/testing/testController/pytest/pytestExecutionAdapter.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import { CancellationTokenSource, DebugSessionOptions, TestRun, TestRunProfileKind, Uri } from 'vscode';
55
import * as path from 'path';
66
import { ChildProcess } from 'child_process';
7-
import { IConfigurationService, ITestOutputChannel } from '../../../common/types';
7+
import { IConfigurationService } from '../../../common/types';
88
import { Deferred } from '../../../common/utils/async';
99
import { traceError, traceInfo, traceVerbose } from '../../../logging';
1010
import { ExecutionTestPayload, ITestExecutionAdapter, ITestResultResolver } from '../common/types';
@@ -25,7 +25,6 @@ import { getEnvironment, runInBackground, useEnvExtension } from '../../../envEx
2525
export class PytestTestExecutionAdapter implements ITestExecutionAdapter {
2626
constructor(
2727
public configSettings: IConfigurationService,
28-
private readonly outputChannel: ITestOutputChannel,
2928
private readonly resultResolver?: ITestResultResolver,
3029
private readonly envVarsService?: IEnvironmentVariablesProvider,
3130
) {}
@@ -144,7 +143,6 @@ export class PytestTestExecutionAdapter implements ITestExecutionAdapter {
144143
const spawnOptions: SpawnOptions = {
145144
cwd,
146145
throwOnStdErr: true,
147-
outputChannel: this.outputChannel,
148146
env: mutableEnv,
149147
token: runInstance?.token,
150148
};
@@ -192,15 +190,12 @@ export class PytestTestExecutionAdapter implements ITestExecutionAdapter {
192190
proc.stdout.on('data', (data) => {
193191
const out = utils.fixLogLinesNoTrailing(data.toString());
194192
runInstance?.appendOutput(out);
195-
this.outputChannel?.append(out);
196193
});
197194
proc.stderr.on('data', (data) => {
198195
const out = utils.fixLogLinesNoTrailing(data.toString());
199196
runInstance?.appendOutput(out);
200-
this.outputChannel?.append(out);
201197
});
202198
proc.onExit((code, signal) => {
203-
this.outputChannel?.append(utils.MESSAGE_ON_TESTING_OUTPUT_MOVE);
204199
if (code !== 0) {
205200
traceError(
206201
`Subprocess exited unsuccessfully with exit code ${code} and signal ${signal} on workspace ${uri.fsPath}`,
@@ -238,19 +233,15 @@ export class PytestTestExecutionAdapter implements ITestExecutionAdapter {
238233

239234
// Take all output from the subprocess and add it to the test output channel. This will be the pytest output.
240235
// Displays output to user and ensure the subprocess doesn't run into buffer overflow.
241-
// TODO: after a release, remove run output from the "Python Test Log" channel and send it to the "Test Result" channel instead.
242236
result?.proc?.stdout?.on('data', (data) => {
243237
const out = utils.fixLogLinesNoTrailing(data.toString());
244238
runInstance?.appendOutput(out);
245-
this.outputChannel?.append(out);
246239
});
247240
result?.proc?.stderr?.on('data', (data) => {
248241
const out = utils.fixLogLinesNoTrailing(data.toString());
249242
runInstance?.appendOutput(out);
250-
this.outputChannel?.append(out);
251243
});
252244
result?.proc?.on('exit', (code, signal) => {
253-
this.outputChannel?.append(utils.MESSAGE_ON_TESTING_OUTPUT_MOVE);
254245
if (code !== 0) {
255246
traceError(
256247
`Subprocess exited unsuccessfully with exit code ${code} and signal ${signal} on workspace ${uri.fsPath}`,

src/client/testing/testController/unittest/testDiscoveryAdapter.ts

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import * as path from 'path';
55
import { CancellationTokenSource, Uri } from 'vscode';
66
import { CancellationToken } from 'vscode-jsonrpc';
77
import { ChildProcess } from 'child_process';
8-
import { IConfigurationService, ITestOutputChannel } from '../../../common/types';
8+
import { IConfigurationService } from '../../../common/types';
99
import { EXTENSION_ROOT_DIR } from '../../../constants';
1010
import {
1111
DiscoveredTestPayload,
@@ -22,12 +22,7 @@ import {
2222
IPythonExecutionFactory,
2323
SpawnOptions,
2424
} from '../../../common/process/types';
25-
import {
26-
MESSAGE_ON_TESTING_OUTPUT_MOVE,
27-
createDiscoveryErrorPayload,
28-
fixLogLinesNoTrailing,
29-
startDiscoveryNamedPipe,
30-
} from '../common/utils';
25+
import { createDiscoveryErrorPayload, fixLogLinesNoTrailing, startDiscoveryNamedPipe } from '../common/utils';
3126
import { traceError, traceInfo, traceLog, traceVerbose } from '../../../logging';
3227
import { getEnvironment, runInBackground, useEnvExtension } from '../../../envExt/api.internal';
3328

@@ -37,7 +32,6 @@ import { getEnvironment, runInBackground, useEnvExtension } from '../../../envEx
3732
export class UnittestTestDiscoveryAdapter implements ITestDiscoveryAdapter {
3833
constructor(
3934
public configSettings: IConfigurationService,
40-
private readonly outputChannel: ITestOutputChannel,
4135
private readonly resultResolver?: ITestResultResolver,
4236
private readonly envVarsService?: IEnvironmentVariablesProvider,
4337
) {}
@@ -79,7 +73,6 @@ export class UnittestTestDiscoveryAdapter implements ITestDiscoveryAdapter {
7973
workspaceFolder: uri,
8074
command,
8175
cwd,
82-
outChannel: this.outputChannel,
8376
token,
8477
};
8578

@@ -128,15 +121,12 @@ export class UnittestTestDiscoveryAdapter implements ITestDiscoveryAdapter {
128121
proc.stdout.on('data', (data) => {
129122
const out = fixLogLinesNoTrailing(data.toString());
130123
traceInfo(out);
131-
this.outputChannel?.append(out);
132124
});
133125
proc.stderr.on('data', (data) => {
134126
const out = fixLogLinesNoTrailing(data.toString());
135127
traceError(out);
136-
this.outputChannel?.append(out);
137128
});
138129
proc.onExit((code, signal) => {
139-
this.outputChannel?.append(MESSAGE_ON_TESTING_OUTPUT_MOVE);
140130
if (code !== 0) {
141131
traceError(
142132
`Subprocess exited unsuccessfully with exit code ${code} and signal ${signal} on workspace ${uri.fsPath}`,
@@ -155,7 +145,6 @@ export class UnittestTestDiscoveryAdapter implements ITestDiscoveryAdapter {
155145
token: options.token,
156146
cwd: options.cwd,
157147
throwOnStdErr: true,
158-
outputChannel: options.outChannel,
159148
env: mutableEnv,
160149
};
161150

@@ -187,22 +176,17 @@ export class UnittestTestDiscoveryAdapter implements ITestDiscoveryAdapter {
187176
resultProc = result?.proc;
188177

189178
// Displays output to user and ensure the subprocess doesn't run into buffer overflow.
190-
// TODO: after a release, remove discovery output from the "Python Test Log" channel and send it to the "Python" channel instead.
191-
// TODO: after a release, remove run output from the "Python Test Log" channel and send it to the "Test Result" channel instead.
192179
result?.proc?.stdout?.on('data', (data) => {
193180
const out = fixLogLinesNoTrailing(data.toString());
194-
spawnOptions?.outputChannel?.append(`${out}`);
195181
traceInfo(out);
196182
});
197183
result?.proc?.stderr?.on('data', (data) => {
198184
const out = fixLogLinesNoTrailing(data.toString());
199-
spawnOptions?.outputChannel?.append(`${out}`);
200185
traceError(out);
201186
});
202187

203188
result?.proc?.on('exit', (code, signal) => {
204189
// if the child has testIds then this is a run request
205-
spawnOptions?.outputChannel?.append(MESSAGE_ON_TESTING_OUTPUT_MOVE);
206190

207191
if (code !== 0) {
208192
// This occurs when we are running discovery

0 commit comments

Comments
 (0)