Skip to content

Commit

Permalink
Fix failing multiroot test (microsoft#24049)
Browse files Browse the repository at this point in the history
  • Loading branch information
rchiodo authored and anthonykim1 committed Sep 13, 2024
1 parent dce3d09 commit 0c0d371
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test"
],
"env": {
"VSC_PYTHON_CI_TEST_GREP": "" // Modify this to run a subset of the single workspace tests
},
"sourceMaps": true,
"smartStep": true,
"outFiles": ["${workspaceFolder}/out/**/*", "!${workspaceFolder}/**/node_modules**/*"],
Expand Down
25 changes: 17 additions & 8 deletions src/test/common/variables/envVarsProvider.multiroot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { expect, use } from 'chai';
import * as chaiAsPromised from 'chai-as-promised';
import * as path from 'path';
import { anything, instance, mock, when } from 'ts-mockito';
import { anything } from 'ts-mockito';
import { ConfigurationTarget, Disposable, Uri, workspace } from 'vscode';
import { WorkspaceService } from '../../../client/common/application/workspace';
import { PlatformService } from '../../../client/common/platform/platformService';
Expand All @@ -14,14 +14,14 @@ import { getSearchPathEnvVarNames } from '../../../client/common/utils/exec';
import { EnvironmentVariablesService } from '../../../client/common/variables/environment';
import { EnvironmentVariablesProvider } from '../../../client/common/variables/environmentVariablesProvider';
import { EnvironmentVariables } from '../../../client/common/variables/types';
import { EnvironmentActivationService } from '../../../client/interpreter/activation/service';
import { IEnvironmentActivationService } from '../../../client/interpreter/activation/types';
import { IInterpreterAutoSelectionService } from '../../../client/interpreter/autoSelection/types';
import { clearPythonPathInWorkspaceFolder, isOs, OSType, updateSetting } from '../../common';
import { closeActiveWindows, initialize, initializeTest, IS_MULTI_ROOT_TEST } from '../../initialize';
import { MockAutoSelectionService } from '../../mocks/autoSelector';
import { MockProcess } from '../../mocks/process';
import { UnitTestIocContainer } from '../../testing/serviceRegistry';
import { createTypeMoq } from '../../mocks/helper';

use(chaiAsPromised.default);

Expand All @@ -47,12 +47,21 @@ suite('Multiroot Environment Variables Provider', () => {
ioc.registerProcessTypes();
ioc.registerInterpreterStorageTypes();
await ioc.registerMockInterpreterTypes();
const mockEnvironmentActivationService = mock(EnvironmentActivationService);
when(mockEnvironmentActivationService.getActivatedEnvironmentVariables(anything())).thenResolve();
ioc.serviceManager.rebindInstance<IEnvironmentActivationService>(
IEnvironmentActivationService,
instance(mockEnvironmentActivationService),
);
const mockEnvironmentActivationService = createTypeMoq<IEnvironmentActivationService>();
mockEnvironmentActivationService
.setup((m) => m.getActivatedEnvironmentVariables(anything()))
.returns(() => Promise.resolve({}));
if (ioc.serviceManager.tryGet<IEnvironmentActivationService>(IEnvironmentActivationService)) {
ioc.serviceManager.rebindInstance<IEnvironmentActivationService>(
IEnvironmentActivationService,
mockEnvironmentActivationService.object,
);
} else {
ioc.serviceManager.addSingletonInstance(
IEnvironmentActivationService,
mockEnvironmentActivationService.object,
);
}
return initializeTest();
});
suiteTeardown(closeActiveWindows);
Expand Down

0 comments on commit 0c0d371

Please sign in to comment.