diff --git a/src/client/api.ts b/src/client/api.ts index 61328de72ae6..bd4226fdaa57 100644 --- a/src/client/api.ts +++ b/src/client/api.ts @@ -4,14 +4,9 @@ 'use strict'; import { isTestExecution } from './common/constants'; -import { DebugAdapterNewPtvsd } from './common/experimentGroups'; import { traceError } from './common/logger'; -import { IConfigurationService, IExperimentsManager, Resource } from './common/types'; -import { - getDebugpyLauncherArgs, - getDebugpyPackagePath, - getPtvsdLauncherScriptArgs -} from './debugger/extension/adapter/remoteLaunchers'; +import { IConfigurationService, Resource } from './common/types'; +import { getDebugpyLauncherArgs, getDebugpyPackagePath } from './debugger/extension/adapter/remoteLaunchers'; import { IServiceContainer, IServiceManager } from './ioc/types'; /* @@ -72,7 +67,6 @@ export function buildApi( serviceManager: IServiceManager, serviceContainer: IServiceContainer ): IExtensionApi { - const experimentsManager = serviceContainer.get(IExperimentsManager); const configurationService = serviceContainer.get(IConfigurationService); const api = { // 'ready' will propagate the exception, but we must log it here first. @@ -86,30 +80,14 @@ export function buildApi( port: number, waitUntilDebuggerAttaches: boolean = true ): Promise { - const useNewDADebugger = experimentsManager.inExperiment(DebugAdapterNewPtvsd.experiment); - - if (useNewDADebugger) { - return getDebugpyLauncherArgs({ - host, - port, - waitUntilDebuggerAttaches - }); - } - - return getPtvsdLauncherScriptArgs({ + return getDebugpyLauncherArgs({ host, port, waitUntilDebuggerAttaches }); }, async getDebuggerPackagePath(): Promise { - const useNewDADebugger = experimentsManager.inExperiment(DebugAdapterNewPtvsd.experiment); - - if (useNewDADebugger) { - return getDebugpyPackagePath(); - } - - return undefined; + return getDebugpyPackagePath(); } }, settings: { diff --git a/src/client/debugger/extension/adapter/remoteLaunchers.ts b/src/client/debugger/extension/adapter/remoteLaunchers.ts index 8871f8fa3967..8f1eab6f9b51 100644 --- a/src/client/debugger/extension/adapter/remoteLaunchers.ts +++ b/src/client/debugger/extension/adapter/remoteLaunchers.ts @@ -8,7 +8,6 @@ import { EXTENSION_ROOT_DIR } from '../../../common/constants'; import '../../../common/extensions'; const pathToPythonLibDir = path.join(EXTENSION_ROOT_DIR, 'pythonFiles', 'lib', 'python'); -const pathToScript = path.join(EXTENSION_ROOT_DIR, 'pythonFiles', 'ptvsd_launcher.py'); const pathToDebugger = path.join(pathToPythonLibDir, 'debugpy'); export type RemoteDebugOptions = { @@ -17,19 +16,6 @@ export type RemoteDebugOptions = { waitUntilDebuggerAttaches: boolean; }; -export function getPtvsdLauncherScriptArgs(options: RemoteDebugOptions, script: string = pathToScript): string[] { - const waitArgs = options.waitUntilDebuggerAttaches ? ['--wait'] : []; - return [ - script.fileToCommandArgument(), - '--default', - '--host', - options.host, - '--port', - options.port.toString(), - ...waitArgs - ]; -} - export function getDebugpyLauncherArgs(options: RemoteDebugOptions, debuggerPath: string = pathToDebugger) { const waitArgs = options.waitUntilDebuggerAttaches ? ['--wait-for-client'] : []; return [debuggerPath.fileToCommandArgument(), '--listen', `${options.host}:${options.port}`, ...waitArgs]; diff --git a/src/test/api.functional.test.ts b/src/test/api.functional.test.ts index 2d9bf970ca24..c25dd8cb2d50 100644 --- a/src/test/api.functional.test.ts +++ b/src/test/api.functional.test.ts @@ -7,40 +7,33 @@ import { assert, expect } from 'chai'; import * as path from 'path'; -import { anyString, instance, mock, when } from 'ts-mockito'; +import { instance, mock, when } from 'ts-mockito'; import { Uri } from 'vscode'; import { buildApi } from '../client/api'; import { ConfigurationService } from '../client/common/configuration/service'; import { EXTENSION_ROOT_DIR } from '../client/common/constants'; -import { ExperimentsManager } from '../client/common/experiments'; -import { IConfigurationService, IExperimentsManager } from '../client/common/types'; +import { IConfigurationService } from '../client/common/types'; import { ServiceContainer } from '../client/ioc/container'; import { ServiceManager } from '../client/ioc/serviceManager'; import { IServiceContainer, IServiceManager } from '../client/ioc/types'; suite('Extension API', () => { - const expectedLauncherPath = path - .join(EXTENSION_ROOT_DIR, 'pythonFiles', 'ptvsd_launcher.py') - .fileToCommandArgument(); const debuggerPath = path.join(EXTENSION_ROOT_DIR, 'pythonFiles', 'lib', 'python', 'debugpy'); - const ptvsdHost = 'somehost'; - const ptvsdPort = 12345; + const debuggerHost = 'somehost'; + const debuggerPort = 12345; let serviceContainer: IServiceContainer; let serviceManager: IServiceManager; - let experimentsManager: IExperimentsManager; let configurationService: IConfigurationService; setup(() => { serviceContainer = mock(ServiceContainer); serviceManager = mock(ServiceManager); - experimentsManager = mock(ExperimentsManager); configurationService = mock(ConfigurationService); when(serviceContainer.get(IConfigurationService)).thenReturn( instance(configurationService) ); - when(serviceContainer.get(IExperimentsManager)).thenReturn(instance(experimentsManager)); }); test('Execution command settings API returns expected array if interpreter is set', async () => { @@ -69,97 +62,44 @@ suite('Extension API', () => { expect(interpreterPath).to.equal(undefined, ''); }); - test('Test debug launcher args (no-wait and not in experiment)', async () => { + test('Test debug launcher args (no-wait)', async () => { const waitForAttach = false; - when(experimentsManager.inExperiment(anyString())).thenReturn(false); const args = await buildApi( Promise.resolve(), instance(serviceManager), instance(serviceContainer) - ).debug.getRemoteLauncherCommand(ptvsdHost, ptvsdPort, waitForAttach); - const expectedArgs = [expectedLauncherPath, '--default', '--host', ptvsdHost, '--port', ptvsdPort.toString()]; + ).debug.getRemoteLauncherCommand(debuggerHost, debuggerPort, waitForAttach); + const expectedArgs = [debuggerPath.fileToCommandArgument(), '--listen', `${debuggerHost}:${debuggerPort}`]; expect(args).to.be.deep.equal(expectedArgs); }); - test('Test debug launcher args (no-wait and in experiment)', async () => { - const waitForAttach = false; - when(experimentsManager.inExperiment(anyString())).thenReturn(true); - - const args = await buildApi( - Promise.resolve(), - instance(serviceManager), - instance(serviceContainer) - ).debug.getRemoteLauncherCommand(ptvsdHost, ptvsdPort, waitForAttach); - const expectedArgs = [debuggerPath.fileToCommandArgument(), '--listen', `${ptvsdHost}:${ptvsdPort}`]; - - expect(args).to.be.deep.equal(expectedArgs); - }); - - test('Test debug launcher args (wait and not in experiment)', async () => { - const waitForAttach = true; - when(experimentsManager.inExperiment(anyString())).thenReturn(false); - - const args = await buildApi( - Promise.resolve(), - instance(serviceManager), - instance(serviceContainer) - ).debug.getRemoteLauncherCommand(ptvsdHost, ptvsdPort, waitForAttach); - const expectedArgs = [ - expectedLauncherPath, - '--default', - '--host', - ptvsdHost, - '--port', - ptvsdPort.toString(), - '--wait' - ]; - - expect(args).to.be.deep.equal(expectedArgs); - }); - - test('Test debug launcher args (wait and in experiment)', async () => { + test('Test debug launcher args (wait)', async () => { const waitForAttach = true; - when(experimentsManager.inExperiment(anyString())).thenReturn(true); const args = await buildApi( Promise.resolve(), instance(serviceManager), instance(serviceContainer) - ).debug.getRemoteLauncherCommand(ptvsdHost, ptvsdPort, waitForAttach); + ).debug.getRemoteLauncherCommand(debuggerHost, debuggerPort, waitForAttach); const expectedArgs = [ debuggerPath.fileToCommandArgument(), '--listen', - `${ptvsdHost}:${ptvsdPort}`, + `${debuggerHost}:${debuggerPort}`, '--wait-for-client' ]; expect(args).to.be.deep.equal(expectedArgs); }); - test('Test debugger package path when not in experiment', async () => { - when(experimentsManager.inExperiment(anyString())).thenReturn(false); - - const pkgPath = await buildApi( - Promise.resolve(), - instance(serviceManager), - instance(serviceContainer) - ).debug.getDebuggerPackagePath(); - - assert.isUndefined(pkgPath); - }); - - test('Test debugger package path when in experiment', async () => { - when(experimentsManager.inExperiment(anyString())).thenReturn(true); - + test('Test debugger package path', async () => { const pkgPath = await buildApi( Promise.resolve(), instance(serviceManager), instance(serviceContainer) ).debug.getDebuggerPackagePath(); - const expected = path.join(EXTENSION_ROOT_DIR, 'pythonFiles', 'lib', 'python', 'debugpy'); - assert.equal(pkgPath, expected); + assert.equal(pkgPath, debuggerPath); }); }); diff --git a/src/test/debugger/extension/adapter/remoteLaunchers.unit.test.ts b/src/test/debugger/extension/adapter/remoteLaunchers.unit.test.ts index d0e63390bac1..f1782d5e0429 100644 --- a/src/test/debugger/extension/adapter/remoteLaunchers.unit.test.ts +++ b/src/test/debugger/extension/adapter/remoteLaunchers.unit.test.ts @@ -9,56 +9,6 @@ import { EXTENSION_ROOT_DIR } from '../../../../client/common/constants'; import '../../../../client/common/extensions'; import * as launchers from '../../../../client/debugger/extension/adapter/remoteLaunchers'; -suite('External ptvsd Debugger Launcher', () => { - [ - { - testName: 'When path to ptvsd launcher does not contains spaces', - path: path.join('path', 'to', 'ptvsd_launcher'), - expectedPath: 'path/to/ptvsd_launcher' - }, - { - testName: 'When path to ptvsd launcher contains spaces', - path: path.join('path', 'to', 'ptvsd_launcher', 'with spaces'), - expectedPath: '"path/to/ptvsd_launcher/with spaces"' - } - ].forEach((testParams) => { - suite(testParams.testName, async () => { - test('Test remote debug launcher args (and do not wait for debugger to attach)', async () => { - const args = launchers.getPtvsdLauncherScriptArgs( - { - host: 'something', - port: 1234, - waitUntilDebuggerAttaches: false - }, - testParams.path - ); - const expectedArgs = [testParams.expectedPath, '--default', '--host', 'something', '--port', '1234']; - expect(args).to.be.deep.equal(expectedArgs); - }); - test('Test remote debug launcher args (and wait for debugger to attach)', async () => { - const args = launchers.getPtvsdLauncherScriptArgs( - { - host: 'something', - port: 1234, - waitUntilDebuggerAttaches: true - }, - testParams.path - ); - const expectedArgs = [ - testParams.expectedPath, - '--default', - '--host', - 'something', - '--port', - '1234', - '--wait' - ]; - expect(args).to.be.deep.equal(expectedArgs); - }); - }); - }); -}); - suite('External debugpy Debugger Launcher', () => { [ {