Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
paulacamargo25 committed Apr 9, 2024
1 parent fd9bf90 commit f1be1c1
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 20 deletions.
9 changes: 3 additions & 6 deletions src/client/debugger/extension/adapter/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { Common, Interpreters } from '../../../common/utils/localize';
import { IPersistentStateFactory } from '../../../common/types';
import { Commands } from '../../../common/constants';
import { ICommandManager } from '../../../common/application/types';
import { getDebugpyPath } from '../../pythonDebugger';

// persistent state names, exported to make use of in testing
export enum debugStateKeys {
Expand Down Expand Up @@ -90,13 +91,9 @@ export class DebugAdapterDescriptorFactory implements IDebugAdapterDescriptorFac
traceLog(`DAP Server launched with command: ${executable} ${args.join(' ')}`);
return new DebugAdapterExecutable(executable, args);
}

const debugpyPath = await getDebugpyPath()
const debuggerAdapterPathToUse = path.join(
EXTENSION_ROOT_DIR,
'python_files',
'lib',
'python',
'debugpy',
debugpyPath,
'adapter',
);

Expand Down
12 changes: 6 additions & 6 deletions src/client/debugger/extension/adapter/remoteLaunchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@

'use strict';

import * as path from 'path';
import { EXTENSION_ROOT_DIR } from '../../../common/constants';
import '../../../common/extensions';

const pathToPythonLibDir = path.join(EXTENSION_ROOT_DIR, 'python_files', 'lib', 'python');
// const pathToDebugger = path.join(pathToPythonLibDir, 'debugpy');
import { getDebugpyPath } from '../../pythonDebugger';

type RemoteDebugOptions = {
host: string;
port: number;
waitUntilDebuggerAttaches: boolean;
};

export function getDebugpyLauncherArgs(options: RemoteDebugOptions, debuggerPath: string = pathToDebugger) {
export async function getDebugpyLauncherArgs(options: RemoteDebugOptions, debuggerPath?: string) {
if (!debuggerPath){
debuggerPath = await getDebugpyPath();
}

const waitArgs = options.waitUntilDebuggerAttaches ? ['--wait-for-client'] : [];
return [
debuggerPath.fileToCommandArgumentForPythonExt(),
Expand Down
4 changes: 2 additions & 2 deletions src/test/debugger/extension/adapter/adapter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ suite('Debugger Integration', () => {
}
const [configName, scriptArgs] = tests[kind];
test(kind, async () => {
const session = fix.resolveDebugger(configName, file, scriptArgs, workspaceRoot);
const session = await fix.resolveDebugger(configName, file, scriptArgs, workspaceRoot);
await session.start();
// Any debugger ops would go here.
await new Promise((r) => setTimeout(r, 300)); // 0.3 seconds
Expand All @@ -93,7 +93,7 @@ suite('Debugger Integration', () => {
}
const [configName, scriptArgs] = tests[kind];
test(kind, async () => {
const session = fix.resolveDebugger(configName, file, scriptArgs, workspaceRoot);
const session = await fix.resolveDebugger(configName, file, scriptArgs, workspaceRoot);
const bp = session.addBreakpoint(file, 21); // line: "time.sleep()"
await session.start();
await session.waitForBreakpoint(bp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { expect } from 'chai';
import * as path from 'path';
import { EXTENSION_ROOT_DIR } from '../../../../client/common/constants';
// import { EXTENSION_ROOT_DIR } from '../../../../client/common/constants';
import '../../../../client/common/extensions';
import * as launchers from '../../../../client/debugger/extension/adapter/remoteLaunchers';

Expand Down
10 changes: 5 additions & 5 deletions src/test/debugger/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,12 +277,12 @@ class DebuggerSession {
}

export class DebuggerFixture extends PythonFixture {
public resolveDebugger(
public async resolveDebugger(
configName: string,
file: string,
scriptArgs: string[],
wsRoot?: vscode.WorkspaceFolder,
): DebuggerSession {
): Promise<DebuggerSession> {
const config = getConfig(configName);
let proc: Proc | undefined;
if (config.request === 'launch') {
Expand All @@ -292,7 +292,7 @@ export class DebuggerFixture extends PythonFixture {
// XXX set the file in the current vscode editor?
} else if (config.request === 'attach') {
if (config.port) {
proc = this.runDebugger(config.port, file, ...scriptArgs);
proc = await this.runDebugger(config.port, file, ...scriptArgs);
if (wsRoot && config.name === 'attach to a local port') {
config.pathMappings.localRoot = wsRoot.uri.fsPath;
}
Expand Down Expand Up @@ -352,8 +352,8 @@ export class DebuggerFixture extends PythonFixture {
}
}

public runDebugger(port: number, filename: string, ...scriptArgs: string[]) {
const args = getDebugpyLauncherArgs({
public async runDebugger(port: number, filename: string, ...scriptArgs: string[]) {
const args = await getDebugpyLauncherArgs({
host: 'localhost',
port: port,
// This causes problems if we set it to true.
Expand Down

0 comments on commit f1be1c1

Please sign in to comment.