Skip to content

Commit f1be1c1

Browse files
fix tests
1 parent fd9bf90 commit f1be1c1

File tree

5 files changed

+17
-20
lines changed

5 files changed

+17
-20
lines changed

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

+3-6
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { Common, Interpreters } from '../../../common/utils/localize';
2626
import { IPersistentStateFactory } from '../../../common/types';
2727
import { Commands } from '../../../common/constants';
2828
import { ICommandManager } from '../../../common/application/types';
29+
import { getDebugpyPath } from '../../pythonDebugger';
2930

3031
// persistent state names, exported to make use of in testing
3132
export enum debugStateKeys {
@@ -90,13 +91,9 @@ export class DebugAdapterDescriptorFactory implements IDebugAdapterDescriptorFac
9091
traceLog(`DAP Server launched with command: ${executable} ${args.join(' ')}`);
9192
return new DebugAdapterExecutable(executable, args);
9293
}
93-
94+
const debugpyPath = await getDebugpyPath()
9495
const debuggerAdapterPathToUse = path.join(
95-
EXTENSION_ROOT_DIR,
96-
'python_files',
97-
'lib',
98-
'python',
99-
'debugpy',
96+
debugpyPath,
10097
'adapter',
10198
);
10299

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@
33

44
'use strict';
55

6-
import * as path from 'path';
7-
import { EXTENSION_ROOT_DIR } from '../../../common/constants';
86
import '../../../common/extensions';
9-
10-
const pathToPythonLibDir = path.join(EXTENSION_ROOT_DIR, 'python_files', 'lib', 'python');
11-
// const pathToDebugger = path.join(pathToPythonLibDir, 'debugpy');
7+
import { getDebugpyPath } from '../../pythonDebugger';
128

139
type RemoteDebugOptions = {
1410
host: string;
1511
port: number;
1612
waitUntilDebuggerAttaches: boolean;
1713
};
1814

19-
export function getDebugpyLauncherArgs(options: RemoteDebugOptions, debuggerPath: string = pathToDebugger) {
15+
export async function getDebugpyLauncherArgs(options: RemoteDebugOptions, debuggerPath?: string) {
16+
if (!debuggerPath){
17+
debuggerPath = await getDebugpyPath();
18+
}
19+
2020
const waitArgs = options.waitUntilDebuggerAttaches ? ['--wait-for-client'] : [];
2121
return [
2222
debuggerPath.fileToCommandArgumentForPythonExt(),

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ suite('Debugger Integration', () => {
7070
}
7171
const [configName, scriptArgs] = tests[kind];
7272
test(kind, async () => {
73-
const session = fix.resolveDebugger(configName, file, scriptArgs, workspaceRoot);
73+
const session = await fix.resolveDebugger(configName, file, scriptArgs, workspaceRoot);
7474
await session.start();
7575
// Any debugger ops would go here.
7676
await new Promise((r) => setTimeout(r, 300)); // 0.3 seconds
@@ -93,7 +93,7 @@ suite('Debugger Integration', () => {
9393
}
9494
const [configName, scriptArgs] = tests[kind];
9595
test(kind, async () => {
96-
const session = fix.resolveDebugger(configName, file, scriptArgs, workspaceRoot);
96+
const session = await fix.resolveDebugger(configName, file, scriptArgs, workspaceRoot);
9797
const bp = session.addBreakpoint(file, 21); // line: "time.sleep()"
9898
await session.start();
9999
await session.waitForBreakpoint(bp);

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import { expect } from 'chai';
77
import * as path from 'path';
8-
import { EXTENSION_ROOT_DIR } from '../../../../client/common/constants';
8+
// import { EXTENSION_ROOT_DIR } from '../../../../client/common/constants';
99
import '../../../../client/common/extensions';
1010
import * as launchers from '../../../../client/debugger/extension/adapter/remoteLaunchers';
1111

src/test/debugger/utils.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -277,12 +277,12 @@ class DebuggerSession {
277277
}
278278

279279
export class DebuggerFixture extends PythonFixture {
280-
public resolveDebugger(
280+
public async resolveDebugger(
281281
configName: string,
282282
file: string,
283283
scriptArgs: string[],
284284
wsRoot?: vscode.WorkspaceFolder,
285-
): DebuggerSession {
285+
): Promise<DebuggerSession> {
286286
const config = getConfig(configName);
287287
let proc: Proc | undefined;
288288
if (config.request === 'launch') {
@@ -292,7 +292,7 @@ export class DebuggerFixture extends PythonFixture {
292292
// XXX set the file in the current vscode editor?
293293
} else if (config.request === 'attach') {
294294
if (config.port) {
295-
proc = this.runDebugger(config.port, file, ...scriptArgs);
295+
proc = await this.runDebugger(config.port, file, ...scriptArgs);
296296
if (wsRoot && config.name === 'attach to a local port') {
297297
config.pathMappings.localRoot = wsRoot.uri.fsPath;
298298
}
@@ -352,8 +352,8 @@ export class DebuggerFixture extends PythonFixture {
352352
}
353353
}
354354

355-
public runDebugger(port: number, filename: string, ...scriptArgs: string[]) {
356-
const args = getDebugpyLauncherArgs({
355+
public async runDebugger(port: number, filename: string, ...scriptArgs: string[]) {
356+
const args = await getDebugpyLauncherArgs({
357357
host: 'localhost',
358358
port: port,
359359
// This causes problems if we set it to true.

0 commit comments

Comments
 (0)