|
7 | 7 |
|
8 | 8 | import { assert, expect } from 'chai';
|
9 | 9 | import * as path from 'path';
|
10 |
| -import { anyString, instance, mock, when } from 'ts-mockito'; |
| 10 | +import { instance, mock, when } from 'ts-mockito'; |
11 | 11 | import { Uri } from 'vscode';
|
12 | 12 | import { buildApi } from '../client/api';
|
13 | 13 | import { ConfigurationService } from '../client/common/configuration/service';
|
14 | 14 | 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'; |
17 | 16 | import { ServiceContainer } from '../client/ioc/container';
|
18 | 17 | import { ServiceManager } from '../client/ioc/serviceManager';
|
19 | 18 | import { IServiceContainer, IServiceManager } from '../client/ioc/types';
|
20 | 19 |
|
21 | 20 | suite('Extension API', () => {
|
22 |
| - const expectedLauncherPath = path |
23 |
| - .join(EXTENSION_ROOT_DIR, 'pythonFiles', 'ptvsd_launcher.py') |
24 |
| - .fileToCommandArgument(); |
25 | 21 | 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; |
28 | 24 |
|
29 | 25 | let serviceContainer: IServiceContainer;
|
30 | 26 | let serviceManager: IServiceManager;
|
31 |
| - let experimentsManager: IExperimentsManager; |
32 | 27 | let configurationService: IConfigurationService;
|
33 | 28 |
|
34 | 29 | setup(() => {
|
35 | 30 | serviceContainer = mock(ServiceContainer);
|
36 | 31 | serviceManager = mock(ServiceManager);
|
37 |
| - experimentsManager = mock(ExperimentsManager); |
38 | 32 | configurationService = mock(ConfigurationService);
|
39 | 33 |
|
40 | 34 | when(serviceContainer.get<IConfigurationService>(IConfigurationService)).thenReturn(
|
41 | 35 | instance(configurationService)
|
42 | 36 | );
|
43 |
| - when(serviceContainer.get<IExperimentsManager>(IExperimentsManager)).thenReturn(instance(experimentsManager)); |
44 | 37 | });
|
45 | 38 |
|
46 | 39 | test('Execution command settings API returns expected array if interpreter is set', async () => {
|
@@ -69,97 +62,44 @@ suite('Extension API', () => {
|
69 | 62 | expect(interpreterPath).to.equal(undefined, '');
|
70 | 63 | });
|
71 | 64 |
|
72 |
| - test('Test debug launcher args (no-wait and not in experiment)', async () => { |
| 65 | + test('Test debug launcher args (no-wait)', async () => { |
73 | 66 | const waitForAttach = false;
|
74 |
| - when(experimentsManager.inExperiment(anyString())).thenReturn(false); |
75 | 67 |
|
76 | 68 | const args = await buildApi(
|
77 | 69 | Promise.resolve(),
|
78 | 70 | instance(serviceManager),
|
79 | 71 | 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}`]; |
82 | 74 |
|
83 | 75 | expect(args).to.be.deep.equal(expectedArgs);
|
84 | 76 | });
|
85 | 77 |
|
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 () => { |
123 | 79 | const waitForAttach = true;
|
124 |
| - when(experimentsManager.inExperiment(anyString())).thenReturn(true); |
125 | 80 |
|
126 | 81 | const args = await buildApi(
|
127 | 82 | Promise.resolve(),
|
128 | 83 | instance(serviceManager),
|
129 | 84 | instance(serviceContainer)
|
130 |
| - ).debug.getRemoteLauncherCommand(ptvsdHost, ptvsdPort, waitForAttach); |
| 85 | + ).debug.getRemoteLauncherCommand(debuggerHost, debuggerPort, waitForAttach); |
131 | 86 | const expectedArgs = [
|
132 | 87 | debuggerPath.fileToCommandArgument(),
|
133 | 88 | '--listen',
|
134 |
| - `${ptvsdHost}:${ptvsdPort}`, |
| 89 | + `${debuggerHost}:${debuggerPort}`, |
135 | 90 | '--wait-for-client'
|
136 | 91 | ];
|
137 | 92 |
|
138 | 93 | expect(args).to.be.deep.equal(expectedArgs);
|
139 | 94 | });
|
140 | 95 |
|
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 () => { |
156 | 97 | const pkgPath = await buildApi(
|
157 | 98 | Promise.resolve(),
|
158 | 99 | instance(serviceManager),
|
159 | 100 | instance(serviceContainer)
|
160 | 101 | ).debug.getDebuggerPackagePath();
|
161 | 102 |
|
162 |
| - const expected = path.join(EXTENSION_ROOT_DIR, 'pythonFiles', 'lib', 'python', 'debugpy'); |
163 |
| - assert.equal(pkgPath, expected); |
| 103 | + assert.equal(pkgPath, debuggerPath); |
164 | 104 | });
|
165 | 105 | });
|
0 commit comments