Skip to content

Commit

Permalink
Ensure arguments are generated correctly for `getRemoteLauncherComman…
Browse files Browse the repository at this point in the history
…d` when in debugger experiment (#8712)

* Return new debugger arguments when in experiment

* Add news item
  • Loading branch information
karthiknadig authored Nov 21, 2019
1 parent 9f4e400 commit 8363ec0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions news/2 Fixes/8685.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ensure arguments are generated correctly for `getRemoteLauncherCommand` when in debugger experiment.
7 changes: 5 additions & 2 deletions src/client/debugger/extension/adapter/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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<DebugAdapterDescriptor> {
const configuration = session.configuration as (LaunchRequestArguments | AttachRequestArguments);

Expand Down Expand Up @@ -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];
}

Expand Down
8 changes: 4 additions & 4 deletions src/test/extension.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand All @@ -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);
});
Expand Down

0 comments on commit 8363ec0

Please sign in to comment.