Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
paulacamargo25 committed Nov 20, 2023
1 parent 06d9887 commit def2d14
Show file tree
Hide file tree
Showing 24 changed files with 51 additions and 3,432 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
"activationEvents": [
"onDebugInitialConfigurations",
"onLanguage:python",
"onDebugDynamicConfigurations:python",
"onDebugResolve:python",
"workspaceContains:mspythonconfig.json",
"workspaceContains:pyproject.toml",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

'use strict';

import { inject, injectable } from 'inversify';
import { Uri } from 'vscode';
import { IExtensionSingleActivationService } from '../../../../activation/types';
import { Commands } from '../../../../common/constants';
import { IDisposable, IDisposableRegistry } from '../../../../common/types';
import { registerCommand } from '../../../../common/vscodeApis/commandApis';
import { IInterpreterService } from '../../../../interpreter/contracts';

@injectable()
export class InterpreterPathCommand implements IExtensionSingleActivationService {
public readonly supportedWorkspaceTypes = { untrustedWorkspace: false, virtualWorkspace: false };

constructor(
@inject(IInterpreterService) private readonly interpreterService: IInterpreterService,
@inject(IDisposableRegistry) private readonly disposables: IDisposable[],
) {}

public async activate(): Promise<void> {
this.disposables.push(
registerCommand(Commands.GetSelectedInterpreterPath, (args) => this._getSelectedInterpreterPath(args)),
);
}

public async _getSelectedInterpreterPath(args: { workspaceFolder: string } | string[]): Promise<string> {
// If `launch.json` is launching this command, `args.workspaceFolder` carries the workspaceFolder
// If `tasks.json` is launching this command, `args[1]` carries the workspaceFolder
let workspaceFolder;
if ('workspaceFolder' in args) {
workspaceFolder = args.workspaceFolder;
} else if (args[1]) {
const [, second] = args;
workspaceFolder = second;
} else {
workspaceFolder = undefined;
}

let workspaceFolderUri;
try {
workspaceFolderUri = workspaceFolder ? Uri.file(workspaceFolder) : undefined;
} catch (ex) {
workspaceFolderUri = undefined;
}

return (await this.interpreterService.getActiveInterpreter(workspaceFolderUri))?.path ?? 'python';
}
}
91 changes: 0 additions & 91 deletions src/test/debugger/extension/adapter/activator.unit.test.ts

This file was deleted.

Loading

0 comments on commit def2d14

Please sign in to comment.