Skip to content

Commit

Permalink
Fix compile errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Kartik Raj committed Feb 25, 2023
1 parent 8e3908c commit 6afb2f9
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 26 deletions.
5 changes: 0 additions & 5 deletions src/client/interpreter/activation/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,6 @@ export class EnvironmentActivationServiceCache {

@injectable()
export class EnvironmentActivationService implements IEnvironmentActivationService, IDisposable {
public readonly supportedWorkspaceTypes: { untrustedWorkspace: boolean; virtualWorkspace: boolean } = {
untrustedWorkspace: false,
virtualWorkspace: false,
};

private readonly disposables: IDisposable[] = [];

private readonly activatedEnvVariablesCache = new EnvironmentActivationServiceCache();
Expand Down
17 changes: 15 additions & 2 deletions src/test/common/terminals/activator/index.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,45 @@ import {
ITerminalActivator,
ITerminalHelper,
} from '../../../../client/common/terminal/types';
import { IConfigurationService, IPythonSettings, ITerminalSettings } from '../../../../client/common/types';
import {
IConfigurationService,
IExperimentService,
IPythonSettings,
ITerminalSettings,
} from '../../../../client/common/types';

suite('Terminal Activator', () => {
let activator: TerminalActivator;
let baseActivator: TypeMoq.IMock<ITerminalActivator>;
let handler1: TypeMoq.IMock<ITerminalActivationHandler>;
let handler2: TypeMoq.IMock<ITerminalActivationHandler>;
let terminalSettings: TypeMoq.IMock<ITerminalSettings>;
let experimentService: TypeMoq.IMock<IExperimentService>;
setup(() => {
baseActivator = TypeMoq.Mock.ofType<ITerminalActivator>();
terminalSettings = TypeMoq.Mock.ofType<ITerminalSettings>();
handler1 = TypeMoq.Mock.ofType<ITerminalActivationHandler>();
handler2 = TypeMoq.Mock.ofType<ITerminalActivationHandler>();
const configService = TypeMoq.Mock.ofType<IConfigurationService>();
experimentService = TypeMoq.Mock.ofType<IExperimentService>();
configService
.setup((c) => c.getSettings(TypeMoq.It.isAny()))
.returns(() => {
return ({
terminal: terminalSettings.object,
} as unknown) as IPythonSettings;
});
experimentService.setup((e) => e.inExperimentSync(TypeMoq.It.isAny())).returns(() => false);
activator = new (class extends TerminalActivator {
protected initialize() {
this.baseActivator = baseActivator.object;
}
})(TypeMoq.Mock.ofType<ITerminalHelper>().object, [handler1.object, handler2.object], configService.object);
})(
TypeMoq.Mock.ofType<ITerminalHelper>().object,
[handler1.object, handler2.object],
configService.object,
experimentService.object,
);
});
async function testActivationAndHandlers(
activationSuccessful: boolean,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { getInfoPerOS } from './common';
import * as platform from '../../../../../client/common/utils/platform';
import * as windowApis from '../../../../../client/common/vscodeApis/windowApis';
import * as workspaceApis from '../../../../../client/common/vscodeApis/workspaceApis';
import { IEnvironmentActivationService } from '../../../../../client/interpreter/activation/types';

getInfoPerOS().forEach(([osName, osType, path]) => {
if (osType === platform.OSType.Unknown) {
Expand All @@ -31,12 +32,13 @@ getInfoPerOS().forEach(([osName, osType, path]) => {
let debugProvider: DebugConfigurationProvider;
let pythonExecutionService: TypeMoq.IMock<IPythonExecutionService>;
let helper: TypeMoq.IMock<IInterpreterHelper>;
const envVars = { FOO: 'BAR' };

let diagnosticsService: TypeMoq.IMock<IInvalidPythonPathInDebuggerService>;
let configService: TypeMoq.IMock<IConfigurationService>;
let debugEnvHelper: TypeMoq.IMock<IDebugEnvironmentVariablesService>;
let interpreterService: TypeMoq.IMock<IInterpreterService>;

let environmentActivationService: TypeMoq.IMock<IEnvironmentActivationService>;
let getActiveTextEditorStub: sinon.SinonStub;
let getOSTypeStub: sinon.SinonStub;
let getWorkspaceFolderStub: sinon.SinonStub;
Expand All @@ -59,6 +61,10 @@ getInfoPerOS().forEach(([osName, osType, path]) => {
}

function setupIoc(pythonPath: string, workspaceFolder?: WorkspaceFolder) {
environmentActivationService = TypeMoq.Mock.ofType<IEnvironmentActivationService>();
environmentActivationService
.setup((e) => e.getActivatedEnvironmentVariables(TypeMoq.It.isAny()))
.returns(() => Promise.resolve(envVars));
configService = TypeMoq.Mock.ofType<IConfigurationService>();
diagnosticsService = TypeMoq.Mock.ofType<IInvalidPythonPathInDebuggerService>();
debugEnvHelper = TypeMoq.Mock.ofType<IDebugEnvironmentVariablesService>();
Expand All @@ -84,14 +90,15 @@ getInfoPerOS().forEach(([osName, osType, path]) => {
}
configService.setup((c) => c.getSettings(TypeMoq.It.isAny())).returns(() => settings.object);
debugEnvHelper
.setup((x) => x.getEnvironmentVariables(TypeMoq.It.isAny()))
.setup((x) => x.getEnvironmentVariables(TypeMoq.It.isAny(), TypeMoq.It.isAny()))
.returns(() => Promise.resolve({}));

debugProvider = new LaunchConfigurationResolver(
diagnosticsService.object,
configService.object,
debugEnvHelper.object,
interpreterService.object,
environmentActivationService.object,
);
}

Expand Down
10 changes: 9 additions & 1 deletion src/test/testing/common/debugLauncher.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { LaunchOptions } from '../../../client/testing/common/types';
import { ITestingSettings } from '../../../client/testing/configuration/types';
import { TestProvider } from '../../../client/testing/types';
import { isOs, OSType } from '../../common';
import { IEnvironmentActivationService } from '../../../client/interpreter/activation/types';

use(chaiAsPromised);

Expand All @@ -39,12 +40,18 @@ suite('Unit Tests - Debug Launcher', () => {
let settings: TypeMoq.IMock<IPythonSettings>;
let debugEnvHelper: TypeMoq.IMock<IDebugEnvironmentVariablesService>;
let interpreterService: TypeMoq.IMock<IInterpreterService>;
let environmentActivationService: TypeMoq.IMock<IEnvironmentActivationService>;
let getWorkspaceFolderStub: sinon.SinonStub;
let getWorkspaceFoldersStub: sinon.SinonStub;
let pathExistsStub: sinon.SinonStub;
let readFileStub: sinon.SinonStub;
const envVars = { FOO: 'BAR' };

setup(async () => {
environmentActivationService = TypeMoq.Mock.ofType<IEnvironmentActivationService>();
environmentActivationService
.setup((e) => e.getActivatedEnvironmentVariables(TypeMoq.It.isAny()))
.returns(() => Promise.resolve(envVars));
interpreterService = TypeMoq.Mock.ofType<IInterpreterService>();
serviceContainer = TypeMoq.Mock.ofType<IServiceContainer>(undefined, TypeMoq.MockBehavior.Strict);
const configService = TypeMoq.Mock.ofType<IConfigurationService>(undefined, TypeMoq.MockBehavior.Strict);
Expand Down Expand Up @@ -94,6 +101,7 @@ suite('Unit Tests - Debug Launcher', () => {
configService,
debugEnvHelper.object,
interpreterService.object,
environmentActivationService.object,
);
}
function setupDebugManager(
Expand All @@ -110,7 +118,7 @@ suite('Unit Tests - Debug Launcher', () => {
expected.args = debugArgs;

debugEnvHelper
.setup((d) => d.getEnvironmentVariables(TypeMoq.It.isAny()))
.setup((x) => x.getEnvironmentVariables(TypeMoq.It.isAny(), TypeMoq.It.isAny()))
.returns(() => Promise.resolve(expected.env));

debugService
Expand Down
32 changes: 16 additions & 16 deletions types/vscode.proposed.testObserver.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,22 @@ declare module 'vscode' {
readonly removed: ReadonlyArray<TestItem>;
}

/**
* A test item is an item shown in the "test explorer" view. It encompasses
* both a suite and a test, since they have almost or identical capabilities.
*/
export interface TestItem {
/**
* Marks the test as outdated. This can happen as a result of file changes,
* for example. In "auto run" mode, tests that are outdated will be
* automatically rerun after a short delay. Invoking this on a
* test with children will mark the entire subtree as outdated.
*
* Extensions should generally not override this method.
*/
// todo@api still unsure about this
invalidateResults(): void;
}
/**
* A test item is an item shown in the "test explorer" view. It encompasses
* both a suite and a test, since they have almost or identical capabilities.
*/
export interface TestItem {
/**
* Marks the test as outdated. This can happen as a result of file changes,
* for example. In "auto run" mode, tests that are outdated will be
* automatically rerun after a short delay. Invoking this on a
* test with children will mark the entire subtree as outdated.
*
* Extensions should generally not override this method.
*/
// todo@api still unsure about this
invalidateResults(): void;
}


/**
Expand Down

0 comments on commit 6afb2f9

Please sign in to comment.