Skip to content

Commit cf62c2a

Browse files
authored
Remove APIs related to ptvsd paths (#11757)
1 parent 063c33d commit cf62c2a

File tree

4 files changed

+16
-162
lines changed

4 files changed

+16
-162
lines changed

src/client/api.ts

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,9 @@
44
'use strict';
55

66
import { isTestExecution } from './common/constants';
7-
import { DebugAdapterNewPtvsd } from './common/experimentGroups';
87
import { traceError } from './common/logger';
9-
import { IConfigurationService, IExperimentsManager, Resource } from './common/types';
10-
import {
11-
getDebugpyLauncherArgs,
12-
getDebugpyPackagePath,
13-
getPtvsdLauncherScriptArgs
14-
} from './debugger/extension/adapter/remoteLaunchers';
8+
import { IConfigurationService, Resource } from './common/types';
9+
import { getDebugpyLauncherArgs, getDebugpyPackagePath } from './debugger/extension/adapter/remoteLaunchers';
1510
import { IServiceContainer, IServiceManager } from './ioc/types';
1611

1712
/*
@@ -72,7 +67,6 @@ export function buildApi(
7267
serviceManager: IServiceManager,
7368
serviceContainer: IServiceContainer
7469
): IExtensionApi {
75-
const experimentsManager = serviceContainer.get<IExperimentsManager>(IExperimentsManager);
7670
const configurationService = serviceContainer.get<IConfigurationService>(IConfigurationService);
7771
const api = {
7872
// 'ready' will propagate the exception, but we must log it here first.
@@ -86,30 +80,14 @@ export function buildApi(
8680
port: number,
8781
waitUntilDebuggerAttaches: boolean = true
8882
): Promise<string[]> {
89-
const useNewDADebugger = experimentsManager.inExperiment(DebugAdapterNewPtvsd.experiment);
90-
91-
if (useNewDADebugger) {
92-
return getDebugpyLauncherArgs({
93-
host,
94-
port,
95-
waitUntilDebuggerAttaches
96-
});
97-
}
98-
99-
return getPtvsdLauncherScriptArgs({
83+
return getDebugpyLauncherArgs({
10084
host,
10185
port,
10286
waitUntilDebuggerAttaches
10387
});
10488
},
10589
async getDebuggerPackagePath(): Promise<string | undefined> {
106-
const useNewDADebugger = experimentsManager.inExperiment(DebugAdapterNewPtvsd.experiment);
107-
108-
if (useNewDADebugger) {
109-
return getDebugpyPackagePath();
110-
}
111-
112-
return undefined;
90+
return getDebugpyPackagePath();
11391
}
11492
},
11593
settings: {

src/client/debugger/extension/adapter/remoteLaunchers.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { EXTENSION_ROOT_DIR } from '../../../common/constants';
88
import '../../../common/extensions';
99

1010
const pathToPythonLibDir = path.join(EXTENSION_ROOT_DIR, 'pythonFiles', 'lib', 'python');
11-
const pathToScript = path.join(EXTENSION_ROOT_DIR, 'pythonFiles', 'ptvsd_launcher.py');
1211
const pathToDebugger = path.join(pathToPythonLibDir, 'debugpy');
1312

1413
export type RemoteDebugOptions = {
@@ -17,19 +16,6 @@ export type RemoteDebugOptions = {
1716
waitUntilDebuggerAttaches: boolean;
1817
};
1918

20-
export function getPtvsdLauncherScriptArgs(options: RemoteDebugOptions, script: string = pathToScript): string[] {
21-
const waitArgs = options.waitUntilDebuggerAttaches ? ['--wait'] : [];
22-
return [
23-
script.fileToCommandArgument(),
24-
'--default',
25-
'--host',
26-
options.host,
27-
'--port',
28-
options.port.toString(),
29-
...waitArgs
30-
];
31-
}
32-
3319
export function getDebugpyLauncherArgs(options: RemoteDebugOptions, debuggerPath: string = pathToDebugger) {
3420
const waitArgs = options.waitUntilDebuggerAttaches ? ['--wait-for-client'] : [];
3521
return [debuggerPath.fileToCommandArgument(), '--listen', `${options.host}:${options.port}`, ...waitArgs];

src/test/api.functional.test.ts

Lines changed: 12 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -7,40 +7,33 @@
77

88
import { assert, expect } from 'chai';
99
import * as path from 'path';
10-
import { anyString, instance, mock, when } from 'ts-mockito';
10+
import { instance, mock, when } from 'ts-mockito';
1111
import { Uri } from 'vscode';
1212
import { buildApi } from '../client/api';
1313
import { ConfigurationService } from '../client/common/configuration/service';
1414
import { EXTENSION_ROOT_DIR } from '../client/common/constants';
15-
import { ExperimentsManager } from '../client/common/experiments';
16-
import { IConfigurationService, IExperimentsManager } from '../client/common/types';
15+
import { IConfigurationService } from '../client/common/types';
1716
import { ServiceContainer } from '../client/ioc/container';
1817
import { ServiceManager } from '../client/ioc/serviceManager';
1918
import { IServiceContainer, IServiceManager } from '../client/ioc/types';
2019

2120
suite('Extension API', () => {
22-
const expectedLauncherPath = path
23-
.join(EXTENSION_ROOT_DIR, 'pythonFiles', 'ptvsd_launcher.py')
24-
.fileToCommandArgument();
2521
const debuggerPath = path.join(EXTENSION_ROOT_DIR, 'pythonFiles', 'lib', 'python', 'debugpy');
26-
const ptvsdHost = 'somehost';
27-
const ptvsdPort = 12345;
22+
const debuggerHost = 'somehost';
23+
const debuggerPort = 12345;
2824

2925
let serviceContainer: IServiceContainer;
3026
let serviceManager: IServiceManager;
31-
let experimentsManager: IExperimentsManager;
3227
let configurationService: IConfigurationService;
3328

3429
setup(() => {
3530
serviceContainer = mock(ServiceContainer);
3631
serviceManager = mock(ServiceManager);
37-
experimentsManager = mock(ExperimentsManager);
3832
configurationService = mock(ConfigurationService);
3933

4034
when(serviceContainer.get<IConfigurationService>(IConfigurationService)).thenReturn(
4135
instance(configurationService)
4236
);
43-
when(serviceContainer.get<IExperimentsManager>(IExperimentsManager)).thenReturn(instance(experimentsManager));
4437
});
4538

4639
test('Execution command settings API returns expected array if interpreter is set', async () => {
@@ -69,97 +62,44 @@ suite('Extension API', () => {
6962
expect(interpreterPath).to.equal(undefined, '');
7063
});
7164

72-
test('Test debug launcher args (no-wait and not in experiment)', async () => {
65+
test('Test debug launcher args (no-wait)', async () => {
7366
const waitForAttach = false;
74-
when(experimentsManager.inExperiment(anyString())).thenReturn(false);
7567

7668
const args = await buildApi(
7769
Promise.resolve(),
7870
instance(serviceManager),
7971
instance(serviceContainer)
80-
).debug.getRemoteLauncherCommand(ptvsdHost, ptvsdPort, waitForAttach);
81-
const expectedArgs = [expectedLauncherPath, '--default', '--host', ptvsdHost, '--port', ptvsdPort.toString()];
72+
).debug.getRemoteLauncherCommand(debuggerHost, debuggerPort, waitForAttach);
73+
const expectedArgs = [debuggerPath.fileToCommandArgument(), '--listen', `${debuggerHost}:${debuggerPort}`];
8274

8375
expect(args).to.be.deep.equal(expectedArgs);
8476
});
8577

86-
test('Test debug launcher args (no-wait and in experiment)', async () => {
87-
const waitForAttach = false;
88-
when(experimentsManager.inExperiment(anyString())).thenReturn(true);
89-
90-
const args = await buildApi(
91-
Promise.resolve(),
92-
instance(serviceManager),
93-
instance(serviceContainer)
94-
).debug.getRemoteLauncherCommand(ptvsdHost, ptvsdPort, waitForAttach);
95-
const expectedArgs = [debuggerPath.fileToCommandArgument(), '--listen', `${ptvsdHost}:${ptvsdPort}`];
96-
97-
expect(args).to.be.deep.equal(expectedArgs);
98-
});
99-
100-
test('Test debug launcher args (wait and not in experiment)', async () => {
101-
const waitForAttach = true;
102-
when(experimentsManager.inExperiment(anyString())).thenReturn(false);
103-
104-
const args = await buildApi(
105-
Promise.resolve(),
106-
instance(serviceManager),
107-
instance(serviceContainer)
108-
).debug.getRemoteLauncherCommand(ptvsdHost, ptvsdPort, waitForAttach);
109-
const expectedArgs = [
110-
expectedLauncherPath,
111-
'--default',
112-
'--host',
113-
ptvsdHost,
114-
'--port',
115-
ptvsdPort.toString(),
116-
'--wait'
117-
];
118-
119-
expect(args).to.be.deep.equal(expectedArgs);
120-
});
121-
122-
test('Test debug launcher args (wait and in experiment)', async () => {
78+
test('Test debug launcher args (wait)', async () => {
12379
const waitForAttach = true;
124-
when(experimentsManager.inExperiment(anyString())).thenReturn(true);
12580

12681
const args = await buildApi(
12782
Promise.resolve(),
12883
instance(serviceManager),
12984
instance(serviceContainer)
130-
).debug.getRemoteLauncherCommand(ptvsdHost, ptvsdPort, waitForAttach);
85+
).debug.getRemoteLauncherCommand(debuggerHost, debuggerPort, waitForAttach);
13186
const expectedArgs = [
13287
debuggerPath.fileToCommandArgument(),
13388
'--listen',
134-
`${ptvsdHost}:${ptvsdPort}`,
89+
`${debuggerHost}:${debuggerPort}`,
13590
'--wait-for-client'
13691
];
13792

13893
expect(args).to.be.deep.equal(expectedArgs);
13994
});
14095

141-
test('Test debugger package path when not in experiment', async () => {
142-
when(experimentsManager.inExperiment(anyString())).thenReturn(false);
143-
144-
const pkgPath = await buildApi(
145-
Promise.resolve(),
146-
instance(serviceManager),
147-
instance(serviceContainer)
148-
).debug.getDebuggerPackagePath();
149-
150-
assert.isUndefined(pkgPath);
151-
});
152-
153-
test('Test debugger package path when in experiment', async () => {
154-
when(experimentsManager.inExperiment(anyString())).thenReturn(true);
155-
96+
test('Test debugger package path', async () => {
15697
const pkgPath = await buildApi(
15798
Promise.resolve(),
15899
instance(serviceManager),
159100
instance(serviceContainer)
160101
).debug.getDebuggerPackagePath();
161102

162-
const expected = path.join(EXTENSION_ROOT_DIR, 'pythonFiles', 'lib', 'python', 'debugpy');
163-
assert.equal(pkgPath, expected);
103+
assert.equal(pkgPath, debuggerPath);
164104
});
165105
});

src/test/debugger/extension/adapter/remoteLaunchers.unit.test.ts

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -9,56 +9,6 @@ import { EXTENSION_ROOT_DIR } from '../../../../client/common/constants';
99
import '../../../../client/common/extensions';
1010
import * as launchers from '../../../../client/debugger/extension/adapter/remoteLaunchers';
1111

12-
suite('External ptvsd Debugger Launcher', () => {
13-
[
14-
{
15-
testName: 'When path to ptvsd launcher does not contains spaces',
16-
path: path.join('path', 'to', 'ptvsd_launcher'),
17-
expectedPath: 'path/to/ptvsd_launcher'
18-
},
19-
{
20-
testName: 'When path to ptvsd launcher contains spaces',
21-
path: path.join('path', 'to', 'ptvsd_launcher', 'with spaces'),
22-
expectedPath: '"path/to/ptvsd_launcher/with spaces"'
23-
}
24-
].forEach((testParams) => {
25-
suite(testParams.testName, async () => {
26-
test('Test remote debug launcher args (and do not wait for debugger to attach)', async () => {
27-
const args = launchers.getPtvsdLauncherScriptArgs(
28-
{
29-
host: 'something',
30-
port: 1234,
31-
waitUntilDebuggerAttaches: false
32-
},
33-
testParams.path
34-
);
35-
const expectedArgs = [testParams.expectedPath, '--default', '--host', 'something', '--port', '1234'];
36-
expect(args).to.be.deep.equal(expectedArgs);
37-
});
38-
test('Test remote debug launcher args (and wait for debugger to attach)', async () => {
39-
const args = launchers.getPtvsdLauncherScriptArgs(
40-
{
41-
host: 'something',
42-
port: 1234,
43-
waitUntilDebuggerAttaches: true
44-
},
45-
testParams.path
46-
);
47-
const expectedArgs = [
48-
testParams.expectedPath,
49-
'--default',
50-
'--host',
51-
'something',
52-
'--port',
53-
'1234',
54-
'--wait'
55-
];
56-
expect(args).to.be.deep.equal(expectedArgs);
57-
});
58-
});
59-
});
60-
});
61-
6212
suite('External debugpy Debugger Launcher', () => {
6313
[
6414
{

0 commit comments

Comments
 (0)