diff --git a/src/client/common/process/decoder.ts b/src/client/common/process/decoder.ts index 4e03b48501d0..76cc7a349816 100644 --- a/src/client/common/process/decoder.ts +++ b/src/client/common/process/decoder.ts @@ -2,14 +2,9 @@ // Licensed under the MIT License. import * as iconv from 'iconv-lite'; -import { injectable } from 'inversify'; import { DEFAULT_ENCODING } from './constants'; -import { IBufferDecoder } from './types'; -@injectable() -export class BufferDecoder implements IBufferDecoder { - public decode(buffers: Buffer[], encoding: string = DEFAULT_ENCODING): string { - encoding = iconv.encodingExists(encoding) ? encoding : DEFAULT_ENCODING; - return iconv.decode(Buffer.concat(buffers), encoding); - } +export function decodeBuffer(buffers: Buffer[], encoding: string = DEFAULT_ENCODING): string { + encoding = iconv.encodingExists(encoding) ? encoding : DEFAULT_ENCODING; + return iconv.decode(Buffer.concat(buffers), encoding); } diff --git a/src/client/common/process/proc.ts b/src/client/common/process/proc.ts index 22795cd2b20f..0ac610e3eac9 100644 --- a/src/client/common/process/proc.ts +++ b/src/client/common/process/proc.ts @@ -6,19 +6,12 @@ import { traceError } from '../../logging'; import { IDisposable } from '../types'; import { EnvironmentVariables } from '../variables/types'; import { execObservable, killPid, plainExec, shellExec } from './rawProcessApis'; -import { - ExecutionResult, - IBufferDecoder, - IProcessService, - ObservableExecutionResult, - ShellOptions, - SpawnOptions, -} from './types'; +import { ExecutionResult, IProcessService, ObservableExecutionResult, ShellOptions, SpawnOptions } from './types'; export class ProcessService extends EventEmitter implements IProcessService { private processesToKill = new Set(); - constructor(private readonly decoder: IBufferDecoder, private readonly env?: EnvironmentVariables) { + constructor(private readonly env?: EnvironmentVariables) { super(); } @@ -47,13 +40,13 @@ export class ProcessService extends EventEmitter implements IProcessService { } public execObservable(file: string, args: string[], options: SpawnOptions = {}): ObservableExecutionResult { - const result = execObservable(file, args, options, this.decoder, this.env, this.processesToKill); + const result = execObservable(file, args, options, this.env, this.processesToKill); this.emit('exec', file, args, options); return result; } public exec(file: string, args: string[], options: SpawnOptions = {}): Promise> { - const promise = plainExec(file, args, options, this.decoder, this.env, this.processesToKill); + const promise = plainExec(file, args, options, this.env, this.processesToKill); this.emit('exec', file, args, options); return promise; } diff --git a/src/client/common/process/processFactory.ts b/src/client/common/process/processFactory.ts index 13bf4f09a250..8681d5073d8e 100644 --- a/src/client/common/process/processFactory.ts +++ b/src/client/common/process/processFactory.ts @@ -8,19 +8,18 @@ import { Uri } from 'vscode'; import { IDisposableRegistry } from '../types'; import { IEnvironmentVariablesProvider } from '../variables/types'; import { ProcessService } from './proc'; -import { IBufferDecoder, IProcessLogger, IProcessService, IProcessServiceFactory } from './types'; +import { IProcessLogger, IProcessService, IProcessServiceFactory } from './types'; @injectable() export class ProcessServiceFactory implements IProcessServiceFactory { constructor( @inject(IEnvironmentVariablesProvider) private readonly envVarsService: IEnvironmentVariablesProvider, @inject(IProcessLogger) private readonly processLogger: IProcessLogger, - @inject(IBufferDecoder) private readonly decoder: IBufferDecoder, @inject(IDisposableRegistry) private readonly disposableRegistry: IDisposableRegistry, ) {} public async create(resource?: Uri): Promise { const customEnvVars = await this.envVarsService.getEnvironmentVariables(resource); - const proc: IProcessService = new ProcessService(this.decoder, customEnvVars); + const proc: IProcessService = new ProcessService(customEnvVars); this.disposableRegistry.push(proc); return proc.on('exec', this.processLogger.logProcess.bind(this.processLogger)); } diff --git a/src/client/common/process/pythonExecutionFactory.ts b/src/client/common/process/pythonExecutionFactory.ts index 569d3595ce19..02c42beb1400 100644 --- a/src/client/common/process/pythonExecutionFactory.ts +++ b/src/client/common/process/pythonExecutionFactory.ts @@ -15,7 +15,6 @@ import { createPythonProcessService } from './pythonProcess'; import { ExecutionFactoryCreateWithEnvironmentOptions, ExecutionFactoryCreationOptions, - IBufferDecoder, IProcessLogger, IProcessService, IProcessServiceFactory, @@ -40,7 +39,6 @@ export class PythonExecutionFactory implements IPythonExecutionFactory { @inject(IEnvironmentActivationService) private readonly activationHelper: IEnvironmentActivationService, @inject(IProcessServiceFactory) private readonly processServiceFactory: IProcessServiceFactory, @inject(IConfigurationService) private readonly configService: IConfigurationService, - @inject(IBufferDecoder) private readonly decoder: IBufferDecoder, @inject(IComponentAdapter) private readonly pyenvs: IComponentAdapter, @inject(IInterpreterAutoSelectionService) private readonly autoSelection: IInterpreterAutoSelectionService, @inject(IInterpreterPathService) private readonly interpreterPathExpHelper: IInterpreterPathService, @@ -110,7 +108,7 @@ export class PythonExecutionFactory implements IPythonExecutionFactory { const pythonPath = options.interpreter ? options.interpreter.path : this.configService.getSettings(options.resource).pythonPath; - const processService: IProcessService = new ProcessService(this.decoder, { ...envVars }); + const processService: IProcessService = new ProcessService({ ...envVars }); processService.on('exec', this.logger.logProcess.bind(this.logger)); this.disposables.push(processService); diff --git a/src/client/common/process/rawProcessApis.ts b/src/client/common/process/rawProcessApis.ts index b07c640c2e95..43f73e671e94 100644 --- a/src/client/common/process/rawProcessApis.ts +++ b/src/client/common/process/rawProcessApis.ts @@ -8,16 +8,9 @@ import { IDisposable } from '../types'; import { createDeferred } from '../utils/async'; import { EnvironmentVariables } from '../variables/types'; import { DEFAULT_ENCODING } from './constants'; -import { - ExecutionResult, - IBufferDecoder, - ObservableExecutionResult, - Output, - ShellOptions, - SpawnOptions, - StdErrError, -} from './types'; +import { ExecutionResult, ObservableExecutionResult, Output, ShellOptions, SpawnOptions, StdErrError } from './types'; import { noop } from '../utils/misc'; +import { decodeBuffer } from './decoder'; function getDefaultOptions(options: T, defaultEnv?: EnvironmentVariables): T { const defaultOptions = { ...options }; @@ -90,7 +83,6 @@ export function plainExec( file: string, args: string[], options: SpawnOptions = {}, - decoder?: IBufferDecoder, defaultEnv?: EnvironmentVariables, disposables?: Set, ): Promise> { @@ -141,11 +133,11 @@ export function plainExec( return; } const stderr: string | undefined = - stderrBuffers.length === 0 ? undefined : decoder?.decode(stderrBuffers, encoding); + stderrBuffers.length === 0 ? undefined : decodeBuffer(stderrBuffers, encoding); if (stderr && stderr.length > 0 && options.throwOnStdErr) { deferred.reject(new StdErrError(stderr)); } else { - let stdout = decoder ? decoder.decode(stdoutBuffers, encoding) : ''; + let stdout = decodeBuffer(stdoutBuffers, encoding); stdout = filterOutputUsingCondaRunMarkers(stdout); deferred.resolve({ stdout, stderr }); } @@ -177,7 +169,6 @@ export function execObservable( file: string, args: string[], options: SpawnOptions = {}, - decoder?: IBufferDecoder, defaultEnv?: EnvironmentVariables, disposables?: Set, ): ObservableExecutionResult { @@ -220,7 +211,7 @@ export function execObservable( } const sendOutput = (source: 'stdout' | 'stderr', data: Buffer) => { - let out = decoder ? decoder.decode([data], encoding) : ''; + let out = decodeBuffer([data], encoding); if (source === 'stderr' && options.throwOnStdErr) { subscriber.error(new StdErrError(out)); } else { diff --git a/src/client/common/process/serviceRegistry.ts b/src/client/common/process/serviceRegistry.ts index 27684a20cc32..0ea57231148a 100644 --- a/src/client/common/process/serviceRegistry.ts +++ b/src/client/common/process/serviceRegistry.ts @@ -2,14 +2,12 @@ // Licensed under the MIT License. import { IServiceManager } from '../../ioc/types'; -import { BufferDecoder } from './decoder'; import { ProcessServiceFactory } from './processFactory'; import { PythonExecutionFactory } from './pythonExecutionFactory'; import { PythonToolExecutionService } from './pythonToolService'; -import { IBufferDecoder, IProcessServiceFactory, IPythonExecutionFactory, IPythonToolExecutionService } from './types'; +import { IProcessServiceFactory, IPythonExecutionFactory, IPythonToolExecutionService } from './types'; export function registerTypes(serviceManager: IServiceManager) { - serviceManager.addSingleton(IBufferDecoder, BufferDecoder); serviceManager.addSingleton(IProcessServiceFactory, ProcessServiceFactory); serviceManager.addSingleton(IPythonExecutionFactory, PythonExecutionFactory); serviceManager.addSingleton(IPythonToolExecutionService, PythonToolExecutionService); diff --git a/src/client/common/process/types.ts b/src/client/common/process/types.ts index 13a73c2cd60f..bcab76e66b09 100644 --- a/src/client/common/process/types.ts +++ b/src/client/common/process/types.ts @@ -8,11 +8,6 @@ import { PythonExecInfo } from '../../pythonEnvironments/exec'; import { InterpreterInformation, PythonEnvironment } from '../../pythonEnvironments/info'; import { ExecutionInfo, IDisposable } from '../types'; -export const IBufferDecoder = Symbol('IBufferDecoder'); -export interface IBufferDecoder { - decode(buffers: Buffer[], encoding: string): string; -} - export type Output = { source: 'stdout' | 'stderr'; out: T; diff --git a/src/test/common.ts b/src/test/common.ts index 8c075671d07c..e58830b7f236 100644 --- a/src/test/common.ts +++ b/src/test/common.ts @@ -303,10 +303,9 @@ export function correctPathForOsType(pathToCorrect: string, os?: OSType): string * @return `SemVer` version of the Python interpreter, or `undefined` if an error occurs. */ export async function getPythonSemVer(procService?: IProcessService): Promise { - const decoder = await import('../client/common/process/decoder'); const proc = await import('../client/common/process/proc'); - const pythonProcRunner = procService ? procService : new proc.ProcessService(new decoder.BufferDecoder()); + const pythonProcRunner = procService ? procService : new proc.ProcessService(); const pyVerArgs = ['-c', 'import sys;print("{0}.{1}.{2}".format(*sys.version_info[:3]))']; return pythonProcRunner diff --git a/src/test/common/process/decoder.test.ts b/src/test/common/process/decoder.test.ts index c200227cde54..6123ce2a447c 100644 --- a/src/test/common/process/decoder.test.ts +++ b/src/test/common/process/decoder.test.ts @@ -3,7 +3,7 @@ import { expect } from 'chai'; import { encode, encodingExists } from 'iconv-lite'; -import { BufferDecoder } from '../../../client/common/process/decoder'; +import { decodeBuffer } from '../../../client/common/process/decoder'; import { initialize } from './../../initialize'; suite('Decoder', () => { @@ -13,8 +13,7 @@ suite('Decoder', () => { test('Test decoding utf8 strings', () => { const value = 'Sample input string Сделать это'; const buffer = encode(value, 'utf8'); - const decoder = new BufferDecoder(); - const decodedValue = decoder.decode([buffer]); + const decodedValue = decodeBuffer([buffer]); expect(decodedValue).equal(value, 'Decoded string is incorrect'); }); @@ -24,11 +23,10 @@ suite('Decoder', () => { } const value = 'Sample input string Сделать это'; const buffer = encode(value, 'cp866'); - const decoder = new BufferDecoder(); - let decodedValue = decoder.decode([buffer]); + let decodedValue = decodeBuffer([buffer]); expect(decodedValue).not.equal(value, 'Decoded string is the same'); - decodedValue = decoder.decode([buffer], 'cp866'); + decodedValue = decodeBuffer([buffer], 'cp866'); expect(decodedValue).equal(value, 'Decoded string is incorrect'); }); }); diff --git a/src/test/common/process/proc.exec.test.ts b/src/test/common/process/proc.exec.test.ts index 40f7e668b198..c193df95d080 100644 --- a/src/test/common/process/proc.exec.test.ts +++ b/src/test/common/process/proc.exec.test.ts @@ -6,7 +6,6 @@ import { expect, use } from 'chai'; import * as chaiAsPromised from 'chai-as-promised'; import { CancellationTokenSource } from 'vscode'; -import { BufferDecoder } from '../../../client/common/process/decoder'; import { ProcessService } from '../../../client/common/process/proc'; import { StdErrError } from '../../../client/common/process/types'; import { OSType } from '../../../client/common/utils/platform'; @@ -26,7 +25,7 @@ suite('ProcessService Observable', () => { teardown(initialize); test('exec should output print statements', async () => { - const procService = new ProcessService(new BufferDecoder()); + const procService = new ProcessService(); const printOutput = '1234'; const result = await procService.exec(pythonPath, ['-c', `print("${printOutput}")`]); @@ -42,7 +41,7 @@ suite('ProcessService Observable', () => { return this.skip(); } - const procService = new ProcessService(new BufferDecoder()); + const procService = new ProcessService(); const printOutput = 'öä'; const result = await procService.exec(pythonPath, ['-c', `print("${printOutput}")`]); @@ -53,7 +52,7 @@ suite('ProcessService Observable', () => { test('exec should wait for completion of program with new lines', async function () { this.timeout(5000); - const procService = new ProcessService(new BufferDecoder()); + const procService = new ProcessService(); const pythonCode = [ 'import sys', 'import time', @@ -79,7 +78,7 @@ suite('ProcessService Observable', () => { test('exec should wait for completion of program without new lines', async function () { this.timeout(5000); - const procService = new ProcessService(new BufferDecoder()); + const procService = new ProcessService(); const pythonCode = [ 'import sys', 'import time', @@ -105,7 +104,7 @@ suite('ProcessService Observable', () => { test('exec should end when cancellationToken is cancelled', async function () { this.timeout(15000); - const procService = new ProcessService(new BufferDecoder()); + const procService = new ProcessService(); const pythonCode = [ 'import sys', 'import time', @@ -133,7 +132,7 @@ suite('ProcessService Observable', () => { test('exec should stream stdout and stderr separately and filter output using conda related markers', async function () { this.timeout(7000); - const procService = new ProcessService(new BufferDecoder()); + const procService = new ProcessService(); const pythonCode = [ 'print(">>>PYTHON-EXEC-OUTPUT")', 'import sys', @@ -176,7 +175,7 @@ suite('ProcessService Observable', () => { test('exec should merge stdout and stderr streams', async function () { this.timeout(7000); - const procService = new ProcessService(new BufferDecoder()); + const procService = new ProcessService(); const pythonCode = [ 'import sys', 'import time', @@ -210,7 +209,7 @@ suite('ProcessService Observable', () => { }); test('exec should throw an error with stderr output', async () => { - const procService = new ProcessService(new BufferDecoder()); + const procService = new ProcessService(); const pythonCode = ['import sys', 'sys.stderr.write("a")', 'sys.stderr.flush()']; const result = procService.exec(pythonPath, ['-c', pythonCode.join(';')], { throwOnStdErr: true }); @@ -218,21 +217,21 @@ suite('ProcessService Observable', () => { }); test('exec should throw an error when spawn file not found', async () => { - const procService = new ProcessService(new BufferDecoder()); + const procService = new ProcessService(); const result = procService.exec(Date.now().toString(), []); await expect(result).to.eventually.be.rejected.and.to.have.property('code', 'ENOENT', 'Invalid error code'); }); test('exec should exit without no output', async () => { - const procService = new ProcessService(new BufferDecoder()); + const procService = new ProcessService(); const result = await procService.exec(pythonPath, ['-c', 'import sys', 'sys.exit()']); expect(result.stdout).equals('', 'stdout is invalid'); expect(result.stderr).equals(undefined, 'stderr is invalid'); }); test('shellExec should be able to run python and filter output using conda related markers', async () => { - const procService = new ProcessService(new BufferDecoder()); + const procService = new ProcessService(); const printOutput = '1234'; const result = await procService.shellExec( `"${pythonPath}" -c "print('>>>PYTHON-EXEC-OUTPUT');print('${printOutput}');print('<< { expect(result.stdout.trim()).to.be.equal(printOutput, 'Invalid output'); }); test('shellExec should fail on invalid command', async () => { - const procService = new ProcessService(new BufferDecoder()); + const procService = new ProcessService(); const result = procService.shellExec('invalid command'); await expect(result).to.eventually.be.rejectedWith(Error, 'a', 'Expected error to be thrown'); }); test('variables can be changed after the fact', async () => { - const procService = new ProcessService(new BufferDecoder(), process.env); + const procService = new ProcessService(process.env); let result = await procService.exec(pythonPath, ['-c', `import os;print(os.environ.get("MY_TEST_VARIABLE"))`], { extraVariables: { MY_TEST_VARIABLE: 'foo' }, }); diff --git a/src/test/common/process/proc.observable.test.ts b/src/test/common/process/proc.observable.test.ts index 1df100bdc1b5..74a613f0ec1d 100644 --- a/src/test/common/process/proc.observable.test.ts +++ b/src/test/common/process/proc.observable.test.ts @@ -4,7 +4,6 @@ import { expect, use } from 'chai'; import * as chaiAsPromised from 'chai-as-promised'; import { CancellationTokenSource } from 'vscode'; -import { BufferDecoder } from '../../../client/common/process/decoder'; import { ProcessService } from '../../../client/common/process/proc'; import { createDeferred } from '../../../client/common/utils/async'; import { isOs, OSType } from '../../common'; @@ -24,7 +23,7 @@ suite('ProcessService', () => { test('execObservable should stream output with new lines', function (done) { this.timeout(10000); - const procService = new ProcessService(new BufferDecoder()); + const procService = new ProcessService(); const pythonCode = [ 'import sys', 'import time', @@ -68,7 +67,7 @@ suite('ProcessService', () => { this.skip(); this.timeout(10000); - const procService = new ProcessService(new BufferDecoder()); + const procService = new ProcessService(); const pythonCode = [ 'import sys', 'import time', @@ -107,7 +106,7 @@ suite('ProcessService', () => { test('execObservable should end when cancellationToken is cancelled', function (done) { this.timeout(15000); - const procService = new ProcessService(new BufferDecoder()); + const procService = new ProcessService(); const pythonCode = [ 'import sys', 'import time', @@ -153,7 +152,7 @@ suite('ProcessService', () => { test('execObservable should end when process is killed', function (done) { this.timeout(15000); - const procService = new ProcessService(new BufferDecoder()); + const procService = new ProcessService(); const pythonCode = [ 'import sys', 'import time', @@ -197,7 +196,7 @@ suite('ProcessService', () => { test('execObservable should stream stdout and stderr separately and removes markers related to conda run', function (done) { this.timeout(20000); - const procService = new ProcessService(new BufferDecoder()); + const procService = new ProcessService(); const pythonCode = [ 'print(">>>PYTHON-EXEC-OUTPUT")', 'import sys', @@ -257,7 +256,7 @@ suite('ProcessService', () => { }); test('execObservable should throw an error with stderr output', (done) => { - const procService = new ProcessService(new BufferDecoder()); + const procService = new ProcessService(); const pythonCode = ['import sys', 'sys.stderr.write("a")', 'sys.stderr.flush()']; const result = procService.execObservable(pythonPath, ['-c', pythonCode.join(';')], { throwOnStdErr: true }); @@ -277,7 +276,7 @@ suite('ProcessService', () => { }); test('execObservable should throw an error when spawn file not found', (done) => { - const procService = new ProcessService(new BufferDecoder()); + const procService = new ProcessService(); const result = procService.execObservable(Date.now().toString(), []); expect(result).not.to.be.an('undefined', 'result is undefined.'); @@ -296,7 +295,7 @@ suite('ProcessService', () => { }); test('execObservable should exit without no output', (done) => { - const procService = new ProcessService(new BufferDecoder()); + const procService = new ProcessService(); const result = procService.execObservable(pythonPath, ['-c', 'import sys', 'sys.exit()']); expect(result).not.to.be.an('undefined', 'result is undefined.'); diff --git a/src/test/common/process/processFactory.unit.test.ts b/src/test/common/process/processFactory.unit.test.ts index c9d9c1f9803b..5adcdeccecfd 100644 --- a/src/test/common/process/processFactory.unit.test.ts +++ b/src/test/common/process/processFactory.unit.test.ts @@ -5,11 +5,10 @@ import { expect } from 'chai'; import { instance, mock, verify, when } from 'ts-mockito'; import { Disposable, Uri } from 'vscode'; -import { BufferDecoder } from '../../../client/common/process/decoder'; import { ProcessLogger } from '../../../client/common/process/logger'; import { ProcessService } from '../../../client/common/process/proc'; import { ProcessServiceFactory } from '../../../client/common/process/processFactory'; -import { IBufferDecoder, IProcessLogger } from '../../../client/common/process/types'; +import { IProcessLogger } from '../../../client/common/process/types'; import { IDisposableRegistry } from '../../../client/common/types'; import { EnvironmentVariablesProvider } from '../../../client/common/variables/environmentVariablesProvider'; import { IEnvironmentVariablesProvider } from '../../../client/common/variables/types'; @@ -17,13 +16,11 @@ import { IEnvironmentVariablesProvider } from '../../../client/common/variables/ suite('Process - ProcessServiceFactory', () => { let factory: ProcessServiceFactory; let envVariablesProvider: IEnvironmentVariablesProvider; - let bufferDecoder: IBufferDecoder; let processLogger: IProcessLogger; let processService: ProcessService; let disposableRegistry: IDisposableRegistry; setup(() => { - bufferDecoder = mock(BufferDecoder); envVariablesProvider = mock(EnvironmentVariablesProvider); processLogger = mock(ProcessLogger); when(processLogger.logProcess('', [], {})).thenReturn(); @@ -37,7 +34,6 @@ suite('Process - ProcessServiceFactory', () => { factory = new ProcessServiceFactory( instance(envVariablesProvider), instance(processLogger), - instance(bufferDecoder), disposableRegistry, ); }); diff --git a/src/test/common/process/pythonExecutionFactory.unit.test.ts b/src/test/common/process/pythonExecutionFactory.unit.test.ts index 41413bb3632e..8035c676c188 100644 --- a/src/test/common/process/pythonExecutionFactory.unit.test.ts +++ b/src/test/common/process/pythonExecutionFactory.unit.test.ts @@ -13,12 +13,10 @@ import { Uri } from 'vscode'; import { PythonSettings } from '../../../client/common/configSettings'; import { ConfigurationService } from '../../../client/common/configuration/service'; -import { BufferDecoder } from '../../../client/common/process/decoder'; import { ProcessLogger } from '../../../client/common/process/logger'; import { ProcessServiceFactory } from '../../../client/common/process/processFactory'; import { PythonExecutionFactory } from '../../../client/common/process/pythonExecutionFactory'; import { - IBufferDecoder, IProcessLogger, IProcessService, IProcessServiceFactory, @@ -75,7 +73,6 @@ suite('Process - PythonExecutionFactory', () => { suite(title(resource, interpreter), () => { let factory: PythonExecutionFactory; let activationHelper: IEnvironmentActivationService; - let bufferDecoder: IBufferDecoder; let processFactory: IProcessServiceFactory; let configService: IConfigurationService; let processLogger: IProcessLogger; @@ -89,7 +86,6 @@ suite('Process - PythonExecutionFactory', () => { setup(() => { sinon.stub(Conda, 'getConda').resolves(new Conda('conda')); sinon.stub(Conda.prototype, 'getInterpreterPathForEnvironment').resolves(pythonPath); - bufferDecoder = mock(BufferDecoder); activationHelper = mock(EnvironmentActivationService); processFactory = mock(ProcessServiceFactory); configService = mock(ConfigurationService); @@ -135,7 +131,6 @@ suite('Process - PythonExecutionFactory', () => { instance(activationHelper), instance(processFactory), instance(configService), - instance(bufferDecoder), instance(pyenvs), instance(autoSelection), instance(interpreterPathExpHelper), diff --git a/src/test/common/process/serviceRegistry.unit.test.ts b/src/test/common/process/serviceRegistry.unit.test.ts index 1ee0a3ddb59f..a0187aeedffc 100644 --- a/src/test/common/process/serviceRegistry.unit.test.ts +++ b/src/test/common/process/serviceRegistry.unit.test.ts @@ -4,13 +4,11 @@ 'use strict'; import { instance, mock, verify } from 'ts-mockito'; -import { BufferDecoder } from '../../../client/common/process/decoder'; import { ProcessServiceFactory } from '../../../client/common/process/processFactory'; import { PythonExecutionFactory } from '../../../client/common/process/pythonExecutionFactory'; import { PythonToolExecutionService } from '../../../client/common/process/pythonToolService'; import { registerTypes } from '../../../client/common/process/serviceRegistry'; import { - IBufferDecoder, IProcessServiceFactory, IPythonExecutionFactory, IPythonToolExecutionService, @@ -27,7 +25,6 @@ suite('Common Process Service Registry', () => { test('Ensure services are registered', async () => { registerTypes(instance(serviceManager)); - verify(serviceManager.addSingleton(IBufferDecoder, BufferDecoder)).once(); verify( serviceManager.addSingleton(IProcessServiceFactory, ProcessServiceFactory), ).once(); diff --git a/src/test/linters/lint.functional.test.ts b/src/test/linters/lint.functional.test.ts index 3421cafe40be..217db6b7b47b 100644 --- a/src/test/linters/lint.functional.test.ts +++ b/src/test/linters/lint.functional.test.ts @@ -16,12 +16,10 @@ import { Product } from '../../client/common/installer/productInstaller'; import { FileSystem } from '../../client/common/platform/fileSystem'; import { PlatformService } from '../../client/common/platform/platformService'; import { IFileSystem } from '../../client/common/platform/types'; -import { BufferDecoder } from '../../client/common/process/decoder'; import { ProcessServiceFactory } from '../../client/common/process/processFactory'; import { PythonExecutionFactory } from '../../client/common/process/pythonExecutionFactory'; import { PythonToolExecutionService } from '../../client/common/process/pythonToolService'; import { - IBufferDecoder, IProcessLogger, IPythonExecutionFactory, IPythonToolExecutionService, @@ -694,11 +692,6 @@ class TestFixture extends BaseTestFixture { TypeMoq.MockBehavior.Strict, ); - const decoder = new BufferDecoder(); - serviceContainer - .setup((c) => c.get(TypeMoq.It.isValue(IBufferDecoder), TypeMoq.It.isAny())) - .returns(() => decoder); - const interpreterService = TypeMoq.Mock.ofType(undefined, TypeMoq.MockBehavior.Strict); interpreterService.setup((i) => i.hasInterpreters()).returns(() => Promise.resolve(true)); serviceContainer @@ -717,7 +710,6 @@ class TestFixture extends BaseTestFixture { const procServiceFactory = new ProcessServiceFactory( envVarsService.object, processLogger.object, - decoder, disposableRegistry, ); const pyenvs: IComponentAdapter = mock(); @@ -731,7 +723,6 @@ class TestFixture extends BaseTestFixture { envActivationService.object, procServiceFactory, configService, - decoder, instance(pyenvs), instance(autoSelection), instance(interpreterPathExpHelper), diff --git a/src/test/serviceRegistry.ts b/src/test/serviceRegistry.ts index d97670782d96..e3c6763eace7 100644 --- a/src/test/serviceRegistry.ts +++ b/src/test/serviceRegistry.ts @@ -13,13 +13,11 @@ import { PlatformService } from '../client/common/platform/platformService'; import { RegistryImplementation } from '../client/common/platform/registry'; import { registerTypes as platformRegisterTypes } from '../client/common/platform/serviceRegistry'; import { IFileSystem, IPlatformService, IRegistry } from '../client/common/platform/types'; -import { BufferDecoder } from '../client/common/process/decoder'; import { ProcessService } from '../client/common/process/proc'; import { PythonExecutionFactory } from '../client/common/process/pythonExecutionFactory'; import { PythonToolExecutionService } from '../client/common/process/pythonToolService'; import { registerTypes as processRegisterTypes } from '../client/common/process/serviceRegistry'; import { - IBufferDecoder, IProcessServiceFactory, IPythonExecutionFactory, IPythonToolExecutionService, @@ -169,11 +167,10 @@ export class IocContainer { } public registerMockProcessTypes(): void { - this.serviceManager.addSingleton(IBufferDecoder, BufferDecoder); const processServiceFactory = TypeMoq.Mock.ofType(); // eslint-disable-next-line @typescript-eslint/no-explicit-any - const processService = new MockProcessService(new ProcessService(new BufferDecoder(), process.env as any)); + const processService = new MockProcessService(new ProcessService(process.env as any)); processServiceFactory.setup((f) => f.create(TypeMoq.It.isAny())).returns(() => Promise.resolve(processService)); this.serviceManager.addSingletonInstance( IProcessServiceFactory, diff --git a/src/test/terminals/codeExecution/helper.test.ts b/src/test/terminals/codeExecution/helper.test.ts index 9771a0b8713f..07a91f8e10de 100644 --- a/src/test/terminals/codeExecution/helper.test.ts +++ b/src/test/terminals/codeExecution/helper.test.ts @@ -12,7 +12,6 @@ import { Position, Range, Selection, TextDocument, TextEditor, TextLine, Uri } f import { IApplicationShell, IDocumentManager } from '../../../client/common/application/types'; import { EXTENSION_ROOT_DIR, PYTHON_LANGUAGE } from '../../../client/common/constants'; import '../../../client/common/extensions'; -import { BufferDecoder } from '../../../client/common/process/decoder'; import { ProcessService } from '../../../client/common/process/proc'; import { IProcessService, @@ -106,7 +105,7 @@ suite('Terminal - Code Execution Helper', () => { }); async function ensureCodeIsNormalized(source: string, expectedSource: string) { - const actualProcessService = new ProcessService(new BufferDecoder()); + const actualProcessService = new ProcessService(); processService .setup((p) => p.execObservable(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny())) .returns((file, args, options) =>