diff --git a/news/2 Fixes/8685.md b/news/2 Fixes/8685.md new file mode 100644 index 000000000000..08ecca0439e7 --- /dev/null +++ b/news/2 Fixes/8685.md @@ -0,0 +1 @@ +Ensure arguments are generated correctly for `getRemoteLauncherCommand` when in debugger experiment. diff --git a/src/client/debugger/extension/adapter/factory.ts b/src/client/debugger/extension/adapter/factory.ts index 06391f8aa7db..aa4c32a86909 100644 --- a/src/client/debugger/extension/adapter/factory.ts +++ b/src/client/debugger/extension/adapter/factory.ts @@ -7,7 +7,7 @@ import { inject, injectable } from 'inversify'; import * as path from 'path'; import { DebugAdapterDescriptor, DebugAdapterExecutable, DebugAdapterServer, DebugSession, WorkspaceFolder } from 'vscode'; import { IApplicationShell } from '../../../common/application/types'; -import { DebugAdapterNewPtvsd } from '../../../common/experimentGroups'; +import { DebugAdapterDescriptorFactory as DebugAdapterExperiment, DebugAdapterNewPtvsd } from '../../../common/experimentGroups'; import { traceVerbose } from '../../../common/logger'; import { IExperimentsManager } from '../../../common/types'; import { EXTENSION_ROOT_DIR } from '../../../constants'; @@ -26,7 +26,7 @@ export class DebugAdapterDescriptorFactory implements IDebugAdapterDescriptorFac @inject(IInterpreterService) private readonly interpreterService: IInterpreterService, @inject(IApplicationShell) private readonly appShell: IApplicationShell, @inject(IExperimentsManager) private readonly experimentsManager: IExperimentsManager - ) {} + ) { } public async createDebugAdapterDescriptor(session: DebugSession, executable: DebugAdapterExecutable | undefined): Promise { const configuration = session.configuration as (LaunchRequestArguments | AttachRequestArguments); @@ -86,6 +86,9 @@ export class DebugAdapterDescriptorFactory implements IDebugAdapterDescriptorFac public getRemotePtvsdArgs(remoteDebugOptions: RemoteDebugOptions): string[] { const waitArgs = remoteDebugOptions.waitUntilDebuggerAttaches ? ['--wait'] : []; + if (this.experimentsManager.inExperiment(DebugAdapterExperiment.experiment) && this.experimentsManager.inExperiment(DebugAdapterNewPtvsd.experiment)) { + return ['--host', remoteDebugOptions.host, '--port', remoteDebugOptions.port.toString(), ...waitArgs]; + } return ['--default', '--host', remoteDebugOptions.host, '--port', remoteDebugOptions.port.toString(), ...waitArgs]; } diff --git a/src/test/extension.unit.test.ts b/src/test/extension.unit.test.ts index d6d4f878b677..dd5a931894bd 100644 --- a/src/test/extension.unit.test.ts +++ b/src/test/extension.unit.test.ts @@ -59,14 +59,14 @@ suite('Extension API Debugger', () => { test('Test debug launcher args (no-wait and in experiment)', async () => { mockInExperiment(); - when(debugAdapterFactory.getRemotePtvsdArgs(anything())).thenReturn(['--default', '--host', 'something', '--port', '1234']); + when(debugAdapterFactory.getRemotePtvsdArgs(anything())).thenReturn(['--host', 'something', '--port', '1234']); const args = await buildApi(Promise.resolve(), instance(experimentsManager), instance(debugAdapterFactory), instance(configurationService)).debug.getRemoteLauncherCommand( 'something', 1234, false ); - const expectedArgs = [ptvsdPath, '--default', '--host', 'something', '--port', '1234']; + const expectedArgs = [ptvsdPath, '--host', 'something', '--port', '1234']; expect(args).to.be.deep.equal(expectedArgs); }); @@ -86,14 +86,14 @@ suite('Extension API Debugger', () => { test('Test debug launcher args (wait and in experiment)', async () => { mockInExperiment(); - when(debugAdapterFactory.getRemotePtvsdArgs(anything())).thenReturn(['--default', '--host', 'something', '--port', '1234', '--wait']); + when(debugAdapterFactory.getRemotePtvsdArgs(anything())).thenReturn(['--host', 'something', '--port', '1234', '--wait']); const args = await buildApi(Promise.resolve(), instance(experimentsManager), instance(debugAdapterFactory), instance(configurationService)).debug.getRemoteLauncherCommand( 'something', 1234, true ); - const expectedArgs = [ptvsdPath, '--default', '--host', 'something', '--port', '1234', '--wait']; + const expectedArgs = [ptvsdPath, '--host', 'something', '--port', '1234', '--wait']; expect(args).to.be.deep.equal(expectedArgs); });