Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/test/datascience/dataScienceIocContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ import { PersistentStateFactory } from '../../client/common/persistentState';
import { IS_WINDOWS } from '../../client/common/platform/constants';
import { PathUtils } from '../../client/common/platform/pathUtils';
import { RegistryImplementation } from '../../client/common/platform/registry';
import { IRegistry } from '../../client/common/platform/types';
import { IFileSystem, IRegistry } from '../../client/common/platform/types';
import { CurrentProcess } from '../../client/common/process/currentProcess';
import { BufferDecoder } from '../../client/common/process/decoder';
import { ProcessLogger } from '../../client/common/process/logger';
Expand Down Expand Up @@ -289,6 +289,7 @@ import { MockCustomEditorService } from './mockCustomEditorService';
import { MockDebuggerService } from './mockDebugService';
import { MockDocumentManager } from './mockDocumentManager';
import { MockExtensions } from './mockExtensions';
import { MockFileSystem } from './mockFileSystem';
import { MockJupyterManager, SupportedCommands } from './mockJupyterManager';
import { MockJupyterManagerFactory } from './mockJupyterManagerFactory';
import { MockLanguageServerAnalysisOptions } from './mockLanguageServerAnalysisOptions';
Expand Down Expand Up @@ -408,6 +409,7 @@ export class DataScienceIocContainer extends UnitTestIocContainer {
const testWorkspaceFolder = path.join(EXTENSION_ROOT_DIR, 'src', 'test', 'datascience');

this.registerFileSystemTypes();
this.serviceManager.rebindInstance<IFileSystem>(IFileSystem, new MockFileSystem());
this.serviceManager.addSingleton<IJupyterExecution>(IJupyterExecution, JupyterExecutionFactory);
this.serviceManager.addSingleton<IInteractiveWindowProvider>(IInteractiveWindowProvider, TestInteractiveWindowProvider);
this.serviceManager.addSingleton<IDataViewerProvider>(IDataViewerProvider, DataViewerProvider);
Expand Down Expand Up @@ -763,6 +765,10 @@ export class DataScienceIocContainer extends UnitTestIocContainer {
this.addInterpreter(this.workingPython2, SupportedCommands.all);
this.addInterpreter(this.workingPython, SupportedCommands.all);
}
public setFileContents(uri: Uri, contents: string) {
const fileSystem = this.serviceManager.get<IFileSystem>(IFileSystem) as MockFileSystem;
fileSystem.addFileContents(uri.fsPath, contents);
}

public async activate(): Promise<void> {
// Activate all of the extension activation services
Expand Down
4 changes: 2 additions & 2 deletions src/test/datascience/mockFileSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// Licensed under the MIT License.
'use strict';

import { FileSystem } from '../../client/common/platform/fileSystem';
import { LegacyFileSystem } from '../serviceRegistry';

export class MockFileSystem extends FileSystem {
export class MockFileSystem extends LegacyFileSystem {
private contentOverloads = new Map<string, string>();

constructor() {
Expand Down
7 changes: 1 addition & 6 deletions src/test/serviceRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ import { IServiceContainer, IServiceManager } from '../client/ioc/types';
import { registerTypes as lintersRegisterTypes } from '../client/linters/serviceRegistry';
import { TEST_OUTPUT_CHANNEL } from '../client/testing/common/constants';
import { registerTypes as unittestsRegisterTypes } from '../client/testing/serviceRegistry';
import { MockFileSystem } from './datascience/mockFileSystem';
import { MockOutputChannel } from './mockClasses';
import { MockAutoSelectionService } from './mocks/autoSelector';
import { MockMemento } from './mocks/mementos';
Expand Down Expand Up @@ -95,7 +94,7 @@ class FakeVSCodeFileSystemAPI {
return convertStat(stat, filetype);
}
}
class LegacyFileSystem extends FileSystem {
export class LegacyFileSystem extends FileSystem {
constructor() {
super();
const vscfs = new FakeVSCodeFileSystemAPI();
Expand Down Expand Up @@ -154,10 +153,6 @@ export class IocContainer {
this.registerFileSystemTypes();
}
}
public setFileContents(uri: Uri, contents: string) {
const fileSystem = this.serviceManager.get<IFileSystem>(IFileSystem) as MockFileSystem;
fileSystem.addFileContents(uri.fsPath, contents);
}
public registerFileSystemTypes() {
this.serviceManager.addSingleton<IPlatformService>(IPlatformService, PlatformService);
this.serviceManager.addSingleton<IFileSystem>(
Expand Down