Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure arguments are generated correctly for getRemoteLauncherCommand when in debugger experiment #8712

Merged
merged 2 commits into from
Nov 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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