Skip to content

Commit def2d14

Browse files
update tests
1 parent 06d9887 commit def2d14

24 files changed

+51
-3432
lines changed

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@
6666
"activationEvents": [
6767
"onDebugInitialConfigurations",
6868
"onLanguage:python",
69-
"onDebugDynamicConfigurations:python",
7069
"onDebugResolve:python",
7170
"workspaceContains:mspythonconfig.json",
7271
"workspaceContains:pyproject.toml",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
'use strict';
5+
6+
import { inject, injectable } from 'inversify';
7+
import { Uri } from 'vscode';
8+
import { IExtensionSingleActivationService } from '../../../../activation/types';
9+
import { Commands } from '../../../../common/constants';
10+
import { IDisposable, IDisposableRegistry } from '../../../../common/types';
11+
import { registerCommand } from '../../../../common/vscodeApis/commandApis';
12+
import { IInterpreterService } from '../../../../interpreter/contracts';
13+
14+
@injectable()
15+
export class InterpreterPathCommand implements IExtensionSingleActivationService {
16+
public readonly supportedWorkspaceTypes = { untrustedWorkspace: false, virtualWorkspace: false };
17+
18+
constructor(
19+
@inject(IInterpreterService) private readonly interpreterService: IInterpreterService,
20+
@inject(IDisposableRegistry) private readonly disposables: IDisposable[],
21+
) {}
22+
23+
public async activate(): Promise<void> {
24+
this.disposables.push(
25+
registerCommand(Commands.GetSelectedInterpreterPath, (args) => this._getSelectedInterpreterPath(args)),
26+
);
27+
}
28+
29+
public async _getSelectedInterpreterPath(args: { workspaceFolder: string } | string[]): Promise<string> {
30+
// If `launch.json` is launching this command, `args.workspaceFolder` carries the workspaceFolder
31+
// If `tasks.json` is launching this command, `args[1]` carries the workspaceFolder
32+
let workspaceFolder;
33+
if ('workspaceFolder' in args) {
34+
workspaceFolder = args.workspaceFolder;
35+
} else if (args[1]) {
36+
const [, second] = args;
37+
workspaceFolder = second;
38+
} else {
39+
workspaceFolder = undefined;
40+
}
41+
42+
let workspaceFolderUri;
43+
try {
44+
workspaceFolderUri = workspaceFolder ? Uri.file(workspaceFolder) : undefined;
45+
} catch (ex) {
46+
workspaceFolderUri = undefined;
47+
}
48+
49+
return (await this.interpreterService.getActiveInterpreter(workspaceFolderUri))?.path ?? 'python';
50+
}
51+
}

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

-91
This file was deleted.

0 commit comments

Comments
 (0)