diff --git a/package.json b/package.json index aa2a85f44083..b80589c88802 100644 --- a/package.json +++ b/package.json @@ -1232,6 +1232,18 @@ "description": "Whether to install Python modules globally when not using an environment.", "scope": "resource" }, + "python.pythiaEnabled": { + "type": "boolean", + "default": true, + "description": "Enables AI-driven additions to the completion list. Does not apply to Jedi.", + "scope": "resource" + }, + "python.jediEnabled": { + "type": "boolean", + "default": true, + "description": "Enables Jedi as IntelliSense engine instead of Microsoft Python Analysis Engine.", + "scope": "resource" + }, "python.jediMemoryLimit": { "type": "number", "default": 0, diff --git a/src/client/activation/analysis.ts b/src/client/activation/analysis.ts index 239dbef44edb..8418b2c20c77 100644 --- a/src/client/activation/analysis.ts +++ b/src/client/activation/analysis.ts @@ -13,6 +13,7 @@ import { IProcessServiceFactory } from '../common/process/types'; import { StopWatch } from '../common/stopWatch'; import { IConfigurationService, IOutputChannel, IPythonSettings } from '../common/types'; import { IEnvironmentVariablesProvider } from '../common/variables/types'; +import { IInterpreterService } from '../interpreter/contracts'; import { IServiceContainer } from '../ioc/types'; import { PYTHON_ANALYSIS_ENGINE_DOWNLOADED, @@ -35,11 +36,11 @@ class LanguageServerStartupErrorHandler implements ErrorHandler { constructor(private readonly deferred: Deferred) { } public error(error: Error, message: Message, count: number): ErrorAction { this.deferred.reject(error); - return ErrorAction.Shutdown; + return ErrorAction.Continue; } public closed(): CloseAction { this.deferred.reject(); - return CloseAction.DoNotRestart; + return CloseAction.Restart; } } @@ -50,7 +51,11 @@ export class AnalysisExtensionActivator implements IExtensionActivator { private readonly fs: IFileSystem; private readonly sw = new StopWatch(); private readonly platformData: PlatformData; + private readonly interpreterService: IInterpreterService; + private readonly disposables: Disposable[] = []; private languageClient: LanguageClient | undefined; + private context: ExtensionContext | undefined; + private interpreterHash: string = ''; constructor(private readonly services: IServiceContainer, pythonSettings: IPythonSettings) { this.configuration = this.services.get(IConfigurationService); @@ -58,13 +63,17 @@ export class AnalysisExtensionActivator implements IExtensionActivator { this.output = this.services.get(IOutputChannel, STANDARD_OUTPUT_CHANNEL); this.fs = this.services.get(IFileSystem); this.platformData = new PlatformData(services.get(IPlatformService), this.fs); + this.interpreterService = this.services.get(IInterpreterService); } public async activate(context: ExtensionContext): Promise { + this.sw.reset(); + this.context = context; const clientOptions = await this.getAnalysisOptions(context); if (!clientOptions) { return false; } + this.disposables.push(this.interpreterService.onDidChangeInterpreter(() => this.restartLanguageServer())); return this.startLanguageServer(context, clientOptions); } @@ -72,17 +81,36 @@ export class AnalysisExtensionActivator implements IExtensionActivator { if (this.languageClient) { await this.languageClient.stop(); } + for (const d of this.disposables) { + d.dispose(); + } + } + + private async restartLanguageServer(): Promise { + if (!this.context) { + return; + } + const ids = new InterpreterDataService(this.context, this.services); + const idata = await ids.getInterpreterData(); + if (!idata || idata.hash !== this.interpreterHash) { + this.interpreterHash = idata ? idata.hash : ''; + await this.deactivate(); + await this.activate(this.context); + } } private async startLanguageServer(context: ExtensionContext, clientOptions: LanguageClientOptions): Promise { // Determine if we are running MSIL/Universal via dotnet or self-contained app. const mscorlib = path.join(context.extensionPath, analysisEngineFolder, 'mscorlib.dll'); + const downloader = new AnalysisEngineDownloader(this.services, analysisEngineFolder); let downloadPackage = false; const reporter = getTelemetryReporter(); reporter.sendTelemetryEvent(PYTHON_ANALYSIS_ENGINE_ENABLED); - if (!await this.fs.fileExistsAsync(mscorlib)) { + await this.checkPythiaModel(context, downloader); + + if (!await this.fs.fileExists(mscorlib)) { // Depends on .NET Runtime or SDK this.languageClient = this.createSimpleLanguageClient(context, clientOptions); try { @@ -100,7 +128,7 @@ export class AnalysisExtensionActivator implements IExtensionActivator { } if (downloadPackage) { - const downloader = new AnalysisEngineDownloader(this.services, analysisEngineFolder); + this.appShell.showWarningMessage('.NET Runtime is not found, platform-specific Python Analysis Engine will be downloaded.'); await downloader.downloadAnalysisEngine(context); reporter.sendTelemetryEvent(PYTHON_ANALYSIS_ENGINE_DOWNLOADED); } @@ -128,7 +156,9 @@ export class AnalysisExtensionActivator implements IExtensionActivator { disposable = lc.start(); lc.onReady() .then(() => deferred.resolve()) - .catch(deferred.reject); + .catch((reason) => { + deferred.reject(reason); + }); await deferred.promise; this.output.appendLine(`Language server ready: ${this.sw.elapsedTime} ms`); @@ -172,20 +202,19 @@ export class AnalysisExtensionActivator implements IExtensionActivator { const interpreterData = await interpreterDataService.getInterpreterData(); if (!interpreterData) { const appShell = this.services.get(IApplicationShell); - appShell.showErrorMessage('Unable to determine path to Python interpreter.'); - return; + appShell.showWarningMessage('Unable to determine path to Python interpreter. IntelliSense will be limited.'); } - // tslint:disable-next-line:no-string-literal - properties['InterpreterPath'] = interpreterData.path; - // tslint:disable-next-line:no-string-literal - properties['Version'] = interpreterData.version; - // tslint:disable-next-line:no-string-literal - properties['PrefixPath'] = interpreterData.prefix; - // tslint:disable-next-line:no-string-literal - properties['DatabasePath'] = path.join(context.extensionPath, analysisEngineFolder); + if (interpreterData) { + // tslint:disable-next-line:no-string-literal + properties['InterpreterPath'] = interpreterData.path; + // tslint:disable-next-line:no-string-literal + properties['Version'] = interpreterData.version; + // tslint:disable-next-line:no-string-literal + properties['PrefixPath'] = interpreterData.prefix; + } - let searchPaths = interpreterData.searchPaths; + let searchPaths = interpreterData ? interpreterData.searchPaths : ''; const settings = this.configuration.getSettings(); if (settings.autoComplete) { const extraPaths = settings.autoComplete.extraPaths; @@ -194,12 +223,15 @@ export class AnalysisExtensionActivator implements IExtensionActivator { } } + // tslint:disable-next-line:no-string-literal + properties['DatabasePath'] = path.join(context.extensionPath, analysisEngineFolder); + const envProvider = this.services.get(IEnvironmentVariablesProvider); const pythonPath = (await envProvider.getEnvironmentVariables()).PYTHONPATH; + this.interpreterHash = interpreterData ? interpreterData.hash : ''; // tslint:disable-next-line:no-string-literal properties['SearchPaths'] = `${searchPaths};${pythonPath ? pythonPath : ''}`; - const selector: string[] = [PYTHON]; // Options to control the language client @@ -215,12 +247,14 @@ export class AnalysisExtensionActivator implements IExtensionActivator { properties }, displayOptions: { + preferredFormat: 1, // Markdown trimDocumentationLines: false, maxDocumentationLineLength: 0, trimDocumentationText: false, maxDocumentationTextLength: 0 }, asyncStartup: true, + pythiaEnabled: settings.pythiaEnabled, testEnvironment: isTestExecution() } }; @@ -231,4 +265,11 @@ export class AnalysisExtensionActivator implements IExtensionActivator { const result = await ps.exec('dotnet', ['--version']).catch(() => { return { stdout: '' }; }); return result.stdout.trim().startsWith('2.'); } + + private async checkPythiaModel(context: ExtensionContext, downloader: AnalysisEngineDownloader): Promise { + const settings = this.configuration.getSettings(); + if (settings.pythiaEnabled) { + await downloader.downloadPythiaModel(context); + } + } } diff --git a/src/client/activation/downloader.ts b/src/client/activation/downloader.ts index 98a2d2e1bfc2..52e9136a4951 100644 --- a/src/client/activation/downloader.ts +++ b/src/client/activation/downloader.ts @@ -1,13 +1,12 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import * as fs from 'fs'; +import * as fileSystem from 'fs'; import * as path from 'path'; import * as request from 'request'; import * as requestProgress from 'request-progress'; import { ExtensionContext, OutputChannel, ProgressLocation, window } from 'vscode'; import { STANDARD_OUTPUT_CHANNEL } from '../common/constants'; -import { noop } from '../common/core.utils'; import { createDeferred, createTemporaryFile } from '../common/helpers'; import { IFileSystem, IPlatformService } from '../common/platform/types'; import { IOutputChannel } from '../common/types'; @@ -22,41 +21,71 @@ const downloadUriPrefix = 'https://pvsc.blob.core.windows.net/python-analysis'; const downloadBaseFileName = 'python-analysis-vscode'; const downloadVersion = '0.1.0'; const downloadFileExtension = '.nupkg'; +const pythiaModelName = 'model-sequence.json.gz'; export class AnalysisEngineDownloader { private readonly output: OutputChannel; private readonly platform: IPlatformService; private readonly platformData: PlatformData; + private readonly fs: IFileSystem; constructor(private readonly services: IServiceContainer, private engineFolder: string) { this.output = this.services.get(IOutputChannel, STANDARD_OUTPUT_CHANNEL); + this.fs = this.services.get(IFileSystem); this.platform = this.services.get(IPlatformService); - this.platformData = new PlatformData(this.platform, this.services.get(IFileSystem)); + this.platformData = new PlatformData(this.platform, this.fs); } public async downloadAnalysisEngine(context: ExtensionContext): Promise { - const localTempFilePath = await this.downloadFile(); + const platformString = await this.platformData.getPlatformName(); + const enginePackageFileName = `${downloadBaseFileName}-${platformString}.${downloadVersion}${downloadFileExtension}`; + + let localTempFilePath = ''; try { - await this.verifyDownload(localTempFilePath); + localTempFilePath = await this.downloadFile(downloadUriPrefix, enginePackageFileName, 'Downloading Python Analysis Engine... '); + await this.verifyDownload(localTempFilePath, platformString); await this.unpackArchive(context.extensionPath, localTempFilePath); } catch (err) { this.output.appendLine('failed.'); this.output.appendLine(err); throw new Error(err); } finally { - fs.unlink(localTempFilePath, noop); + if (localTempFilePath.length > 0) { + await this.fs.deleteFile(localTempFilePath); + } } } - private async downloadFile(): Promise { - const platformString = await this.platformData.getPlatformName(); - const remoteFileName = `${downloadBaseFileName}-${platformString}.${downloadVersion}${downloadFileExtension}`; - const uri = `${downloadUriPrefix}/${remoteFileName}`; + public async downloadPythiaModel(context: ExtensionContext): Promise { + const modelFolder = path.join(context.extensionPath, 'analysis', 'Pythia', 'model'); + const localPath = path.join(modelFolder, pythiaModelName); + if (await this.fs.fileExists(localPath)) { + return; + } + + let localTempFilePath = ''; + try { + localTempFilePath = await this.downloadFile(downloadUriPrefix, pythiaModelName, 'Downloading IntelliSense Model File... '); + await this.fs.createDirectory(modelFolder); + await this.fs.copyFile(localTempFilePath, localPath); + } catch (err) { + this.output.appendLine('failed.'); + this.output.appendLine(err); + throw new Error(err); + } finally { + if (localTempFilePath.length > 0) { + await this.fs.deleteFile(localTempFilePath); + } + } + } + + private async downloadFile(location: string, fileName: string, title: string): Promise { + const uri = `${location}/${fileName}`; this.output.append(`Downloading ${uri}... `); const tempFile = await createTemporaryFile(downloadFileExtension); const deferred = createDeferred(); - const fileStream = fs.createWriteStream(tempFile.filePath); + const fileStream = fileSystem.createWriteStream(tempFile.filePath); fileStream.on('finish', () => { fileStream.close(); }).on('error', (err) => { @@ -64,7 +93,6 @@ export class AnalysisEngineDownloader { deferred.reject(err); }); - const title = 'Downloading Python Analysis Engine... '; await window.withProgress({ location: ProgressLocation.Window, title @@ -94,11 +122,11 @@ export class AnalysisEngineDownloader { return tempFile.filePath; } - private async verifyDownload(filePath: string): Promise { + private async verifyDownload(filePath: string, platformString: string): Promise { this.output.appendLine(''); this.output.append('Verifying download... '); const verifier = new HashVerifier(); - if (!await verifier.verifyHash(filePath, await this.platformData.getExpectedHash())) { + if (!await verifier.verifyHash(filePath, platformString, await this.platformData.getExpectedHash())) { throw new Error('Hash of the downloaded file does not match.'); } this.output.append('valid.'); @@ -123,10 +151,10 @@ export class AnalysisEngineDownloader { let totalFiles = 0; let extractedFiles = 0; - zip.on('ready', () => { + zip.on('ready', async () => { totalFiles = zip.entriesCount; - if (!fs.existsSync(installFolder)) { - fs.mkdirSync(installFolder); + if (!await this.fs.directoryExists(installFolder)) { + await this.fs.createDirectory(installFolder); } zip.extract(null, installFolder, (err, count) => { if (err) { @@ -147,7 +175,7 @@ export class AnalysisEngineDownloader { // Set file to executable if (!this.platform.isWindows) { const executablePath = path.join(installFolder, this.platformData.getEngineExecutableName()); - fs.chmodSync(executablePath, '0764'); // -rwxrw-r-- + fileSystem.chmodSync(executablePath, '0764'); // -rwxrw-r-- } } } diff --git a/src/client/activation/hashVerifier.ts b/src/client/activation/hashVerifier.ts index 950f02d869f9..c62cb36484f7 100644 --- a/src/client/activation/hashVerifier.ts +++ b/src/client/activation/hashVerifier.ts @@ -6,7 +6,7 @@ import * as fs from 'fs'; import { createDeferred } from '../common/helpers'; export class HashVerifier { - public async verifyHash(filePath: string, expectedDigest: string): Promise { + public async verifyHash(filePath: string, platformString: string, expectedDigest: string): Promise { const readStream = fs.createReadStream(filePath); const deferred = createDeferred(); const hash = createHash('sha512'); @@ -23,6 +23,6 @@ export class HashVerifier { readStream.pipe(hash); await deferred.promise; const actual = hash.read(); - return expectedDigest === '' ? true : actual === expectedDigest; + return expectedDigest === platformString ? true : actual === expectedDigest; } } diff --git a/src/client/activation/interpreterDataService.ts b/src/client/activation/interpreterDataService.ts index 45cf9749e6cf..45c7e42006c4 100644 --- a/src/client/activation/interpreterDataService.ts +++ b/src/client/activation/interpreterDataService.ts @@ -64,6 +64,22 @@ export class InterpreterDataService { return interpreterData; } + public getInterpreterHash(interpreterPath: string): Promise { + const platform = this.serviceContainer.get(IPlatformService); + const pythonExecutable = path.join(path.dirname(interpreterPath), platform.isWindows ? 'python.exe' : 'python'); + // Hash mod time and creation time + const deferred = createDeferred(); + fs.lstat(pythonExecutable, (err, stats) => { + if (err) { + deferred.resolve(''); + } else { + const actual = createHash('sha512').update(`${stats.ctime}-${stats.mtime}`).digest('hex'); + deferred.resolve(actual); + } + }); + return deferred.promise; + } + private async getInterpreterDataFromPython(execService: IPythonExecutionService, interpreterPath: string): Promise { const result = await execService.exec(['-c', 'import sys; print(sys.version_info); print(sys.prefix)'], {}); // 2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:19:30) <> @@ -87,22 +103,6 @@ export class InterpreterDataService { return new InterpreterData(DataVersion, interpreterPath, `${majorMatches[1]}.${minorMatches[1]}`, prefix, searchPaths, hash); } - private getInterpreterHash(interpreterPath: string): Promise { - const platform = this.serviceContainer.get(IPlatformService); - const pythonExecutable = path.join(path.dirname(interpreterPath), platform.isWindows ? 'python.exe' : 'python'); - // Hash mod time and creation time - const deferred = createDeferred(); - fs.lstat(pythonExecutable, (err, stats) => { - if (err) { - deferred.resolve(''); - } else { - const actual = createHash('sha512').update(`${stats.ctimeMs}-${stats.mtimeMs}`).digest('hex'); - deferred.resolve(actual); - } - }); - return deferred.promise; - } - private async getSearchPaths(execService: IPythonExecutionService): Promise { const result = await execService.exec(['-c', 'import sys; print(sys.path);'], {}); if (!result.stdout) { diff --git a/src/client/common/configSettings.ts b/src/client/common/configSettings.ts index 85a6ac61bc14..e659fe1f0a2f 100644 --- a/src/client/common/configSettings.ts +++ b/src/client/common/configSettings.ts @@ -25,6 +25,7 @@ export const IS_WINDOWS = /^win/.test(process.platform); // tslint:disable-next-line:completed-docs export class PythonSettings extends EventEmitter implements IPythonSettings { private static pythonSettings: Map = new Map(); + public pythiaEnabled = true; public jediEnabled = true; public jediPath = ''; public jediMemoryLimit = 1024; @@ -124,6 +125,8 @@ export class PythonSettings extends EventEmitter implements IPythonSettings { this.jediPath = ''; } this.jediMemoryLimit = pythonSettings.get('jediMemoryLimit')!; + } else { + this.pythiaEnabled = systemVariables.resolveAny(pythonSettings.get('pythiaEnabled', true))!; } // tslint:disable-next-line:no-backbone-get-set-outside-model no-non-null-assertion diff --git a/src/client/common/platform/fileSystem.ts b/src/client/common/platform/fileSystem.ts index 463b1089b6fe..ecc9c564f446 100644 --- a/src/client/common/platform/fileSystem.ts +++ b/src/client/common/platform/fileSystem.ts @@ -5,6 +5,7 @@ import * as fs from 'fs-extra'; import { inject, injectable } from 'inversify'; import * as path from 'path'; +import { createDeferred } from '../helpers'; import { IFileSystem, IPlatformService } from './types'; @injectable() @@ -15,7 +16,7 @@ export class FileSystem implements IFileSystem { return path.sep; } - public objectExistsAsync(filePath: string, statCheck: (s: fs.Stats) => boolean): Promise { + public objectExists(filePath: string, statCheck: (s: fs.Stats) => boolean): Promise { return new Promise(resolve => { fs.stat(filePath, (error, stats) => { if (error) { @@ -26,8 +27,8 @@ export class FileSystem implements IFileSystem { }); } - public fileExistsAsync(filePath: string): Promise { - return this.objectExistsAsync(filePath, (stats) => stats.isFile()); + public fileExists(filePath: string): Promise { + return this.objectExists(filePath, (stats) => stats.isFile()); } public fileExistsSync(filePath: string): boolean { return fs.existsSync(filePath); @@ -42,15 +43,15 @@ export class FileSystem implements IFileSystem { return fs.readFile(filePath).then(buffer => buffer.toString()); } - public directoryExistsAsync(filePath: string): Promise { - return this.objectExistsAsync(filePath, (stats) => stats.isDirectory()); + public directoryExists(filePath: string): Promise { + return this.objectExists(filePath, (stats) => stats.isDirectory()); } - public createDirectoryAsync(directoryPath: string): Promise { + public createDirectory(directoryPath: string): Promise { return fs.mkdirp(directoryPath); } - public getSubDirectoriesAsync(rootDir: string): Promise { + public getSubDirectories(rootDir: string): Promise { return new Promise(resolve => { fs.readdir(rootDir, (error, files) => { if (error) { @@ -89,11 +90,31 @@ export class FileSystem implements IFileSystem { return fs.appendFileSync(filename, data, optionsOrEncoding); } - public getRealPathAsync(filePath: string): Promise { + public getRealPath(filePath: string): Promise { return new Promise(resolve => { fs.realpath(filePath, (err, realPath) => { resolve(err ? filePath : realPath); }); }); } + + public copyFile(src: string, dest: string): Promise { + const deferred = createDeferred(); + const rs = fs.createReadStream(src).on('error', (err) => { + deferred.reject(err); + }); + const ws = fs.createWriteStream(dest).on('error', (err) => { + deferred.reject(err); + }).on('close', () => { + deferred.resolve(); + }); + rs.pipe(ws); + return deferred.promise; + } + + public deleteFile(filename: string): Promise { + const deferred = createDeferred(); + fs.unlink(filename, err => err ? deferred.reject(err) : deferred.resolve()); + return deferred.promise; + } } diff --git a/src/client/common/platform/types.ts b/src/client/common/platform/types.ts index 6c40a7a6a068..ce3836eb59a2 100644 --- a/src/client/common/platform/types.ts +++ b/src/client/common/platform/types.ts @@ -31,17 +31,19 @@ export interface IPlatformService { export const IFileSystem = Symbol('IFileSystem'); export interface IFileSystem { directorySeparatorChar: string; - objectExistsAsync(path: string, statCheck: (s: fs.Stats) => boolean): Promise; - fileExistsAsync(path: string): Promise; + objectExists(path: string, statCheck: (s: fs.Stats) => boolean): Promise; + fileExists(path: string): Promise; fileExistsSync(path: string): boolean; - directoryExistsAsync(path: string): Promise; - createDirectoryAsync(path: string): Promise; - getSubDirectoriesAsync(rootDir: string): Promise; + directoryExists(path: string): Promise; + createDirectory(path: string): Promise; + getSubDirectories(rootDir: string): Promise; arePathsSame(path1: string, path2: string): boolean; readFile(filePath: string): Promise; appendFileSync(filename: string, data: {}, encoding: string): void; appendFileSync(filename: string, data: {}, options?: { encoding?: string; mode?: number; flag?: string }): void; // tslint:disable-next-line:unified-signatures appendFileSync(filename: string, data: {}, options?: { encoding?: string; mode?: string; flag?: string }): void; - getRealPathAsync(path: string): Promise; + getRealPath(path: string): Promise; + copyFile(src: string, dest: string): Promise; + deleteFile(filename: string): Promise; } diff --git a/src/client/common/process/pythonProcess.ts b/src/client/common/process/pythonProcess.ts index 419b5d88dcba..8a7894dc4f54 100644 --- a/src/client/common/process/pythonProcess.ts +++ b/src/client/common/process/pythonProcess.ts @@ -28,7 +28,7 @@ export class PythonExecutionService implements IPythonExecutionService { public async getExecutablePath(): Promise { // If we've passed the python file, then return the file. // This is because on mac if using the interpreter /usr/bin/python2.7 we can get a different value for the path - if (await this.fileSystem.fileExistsAsync(this.pythonPath)) { + if (await this.fileSystem.fileExists(this.pythonPath)) { return this.pythonPath; } return this.procService.exec(this.pythonPath, ['-c', 'import sys;print(sys.executable)'], { throwOnStdErr: true }) diff --git a/src/client/common/terminal/environmentActivationProviders/baseActivationProvider.ts b/src/client/common/terminal/environmentActivationProviders/baseActivationProvider.ts index 5ba858d624f4..ee45d5948c93 100644 --- a/src/client/common/terminal/environmentActivationProviders/baseActivationProvider.ts +++ b/src/client/common/terminal/environmentActivationProviders/baseActivationProvider.ts @@ -4,12 +4,10 @@ import { injectable } from 'inversify'; import * as path from 'path'; import { Uri } from 'vscode'; -import { PythonInterpreter } from '../../../interpreter/contracts'; import { IServiceContainer } from '../../../ioc/types'; import { IFileSystem } from '../../platform/types'; import { IConfigurationService } from '../../types'; -import { TerminalShellType } from '../types'; -import { ITerminalActivationCommandProvider } from '../types'; +import { ITerminalActivationCommandProvider, TerminalShellType } from '../types'; @injectable() export abstract class BaseActivationCommandProvider implements ITerminalActivationCommandProvider { @@ -25,7 +23,7 @@ export abstract class BaseActivationCommandProvider implements ITerminalActivati for (const scriptFileName of scriptFileNames) { // Generate scripts are found in the same directory as the interpreter. const scriptFile = path.join(path.dirname(pythonPath), scriptFileName); - const found = await fs.fileExistsAsync(scriptFile); + const found = await fs.fileExists(scriptFile); if (found) { return scriptFile; } diff --git a/src/client/common/types.ts b/src/client/common/types.ts index 027437f169cc..11ff9b508d6b 100644 --- a/src/client/common/types.ts +++ b/src/client/common/types.ts @@ -99,6 +99,7 @@ export interface IPythonSettings { readonly pythonPath: string; readonly venvPath: string; readonly venvFolders: string[]; + readonly pythiaEnabled: boolean; readonly jediEnabled: boolean; readonly jediPath: string; readonly jediMemoryLimit: number; diff --git a/src/client/debugger/configProviders/configurationProviderUtils.ts b/src/client/debugger/configProviders/configurationProviderUtils.ts index e5ce625517f5..6bc13f0bf53f 100644 --- a/src/client/debugger/configProviders/configurationProviderUtils.ts +++ b/src/client/debugger/configProviders/configurationProviderUtils.ts @@ -27,7 +27,7 @@ export class ConfigurationProviderUtils implements IConfigurationProviderUtils { const executionService = await this.executionFactory.create(resource); const output = await executionService.exec(['-c', 'import pyramid;print(pyramid.__file__)'], { throwOnStdErr: true }); const pserveFilePath = path.join(path.dirname(output.stdout.trim()), 'scripts', PSERVE_SCRIPT_FILE_NAME); - return await this.fs.fileExistsAsync(pserveFilePath) ? pserveFilePath : undefined; + return await this.fs.fileExists(pserveFilePath) ? pserveFilePath : undefined; } catch (ex) { const message = 'Unable to locate \'pserve.py\' required for debugging of Pyramid applications.'; console.error(message, ex); diff --git a/src/client/interpreter/display/index.ts b/src/client/interpreter/display/index.ts index 1c19a75f2e70..e419691b31d2 100644 --- a/src/client/interpreter/display/index.ts +++ b/src/client/interpreter/display/index.ts @@ -65,7 +65,7 @@ export class InterpreterDisplay implements IInterpreterDisplay { } else { const defaultDisplayName = `${path.basename(pythonPath)} [Environment]`; await Promise.all([ - this.fileSystem.fileExistsAsync(pythonPath), + this.fileSystem.fileExists(pythonPath), this.versionProvider.getVersion(pythonPath, defaultDisplayName), this.getVirtualEnvironmentName(pythonPath).catch(() => '') ]) diff --git a/src/client/interpreter/locators/services/baseVirtualEnvService.ts b/src/client/interpreter/locators/services/baseVirtualEnvService.ts index 06b57b939436..4499a3a38acf 100644 --- a/src/client/interpreter/locators/services/baseVirtualEnvService.ts +++ b/src/client/interpreter/locators/services/baseVirtualEnvService.ts @@ -34,7 +34,7 @@ export class BaseVirtualEnvService extends CacheableLocatorService { .then(listOfInterpreters => _.flatten(listOfInterpreters)); } private async lookForInterpretersInVenvs(pathToCheck: string) { - return this.fileSystem.getSubDirectoriesAsync(pathToCheck) + return this.fileSystem.getSubDirectories(pathToCheck) .then(subDirs => Promise.all(this.getProspectiveDirectoriesForLookup(subDirs))) .then(dirs => dirs.filter(dir => dir.length > 0)) .then(dirs => Promise.all(dirs.map(lookForInterpretersInDirectory))) @@ -50,7 +50,7 @@ export class BaseVirtualEnvService extends CacheableLocatorService { const platform = this.serviceContainer.get(IPlatformService); const dirToLookFor = platform.virtualEnvBinName; return subDirs.map(subDir => - this.fileSystem.getSubDirectoriesAsync(subDir) + this.fileSystem.getSubDirectories(subDir) .then(dirs => { const scriptOrBinDirs = dirs.filter(dir => { const folderName = path.basename(dir); diff --git a/src/client/interpreter/locators/services/condaEnvFileService.ts b/src/client/interpreter/locators/services/condaEnvFileService.ts index 49cbc2eec935..2f9e681abb3f 100644 --- a/src/client/interpreter/locators/services/condaEnvFileService.ts +++ b/src/client/interpreter/locators/services/condaEnvFileService.ts @@ -15,7 +15,7 @@ import { AnacondaCompanyName, AnacondaCompanyNames, AnacondaDisplayName } from ' @injectable() export class CondaEnvFileService extends CacheableLocatorService { - constructor( @inject(IInterpreterVersionService) private versionService: IInterpreterVersionService, + constructor(@inject(IInterpreterVersionService) private versionService: IInterpreterVersionService, @inject(ICondaService) private condaService: ICondaService, @inject(IFileSystem) private fileSystem: IFileSystem, @inject(IServiceContainer) serviceContainer: IServiceContainer, @@ -31,7 +31,7 @@ export class CondaEnvFileService extends CacheableLocatorService { if (!this.condaService.condaEnvironmentsFile) { return []; } - return this.fileSystem.fileExistsAsync(this.condaService.condaEnvironmentsFile!) + return this.fileSystem.fileExists(this.condaService.condaEnvironmentsFile!) .then(exists => exists ? this.getEnvironmentsFromFile(this.condaService.condaEnvironmentsFile!) : Promise.resolve([])); } private async getEnvironmentsFromFile(envFile: string) { @@ -66,7 +66,7 @@ export class CondaEnvFileService extends CacheableLocatorService { } private async getInterpreterDetails(environmentPath: string): Promise { const interpreter = this.condaService.getInterpreterPath(environmentPath); - if (!interpreter || !await this.fileSystem.fileExistsAsync(interpreter)) { + if (!interpreter || !await this.fileSystem.fileExists(interpreter)) { return; } diff --git a/src/client/interpreter/locators/services/condaEnvService.ts b/src/client/interpreter/locators/services/condaEnvService.ts index 7e2d5c616fcc..781f3b286f75 100644 --- a/src/client/interpreter/locators/services/condaEnvService.ts +++ b/src/client/interpreter/locators/services/condaEnvService.ts @@ -14,7 +14,7 @@ import { CondaHelper } from './condaHelper'; @injectable() export class CondaEnvService extends CacheableLocatorService { private readonly condaHelper = new CondaHelper(); - constructor( @inject(ICondaService) private condaService: ICondaService, + constructor(@inject(ICondaService) private condaService: ICondaService, @inject(IInterpreterVersionService) private versionService: IInterpreterVersionService, @inject(ILogger) private logger: ILogger, @inject(IServiceContainer) serviceContainer: IServiceContainer, @@ -37,7 +37,7 @@ export class CondaEnvService extends CacheableLocatorService { .map(async envPath => { const pythonPath = this.condaService.getInterpreterPath(envPath); - const existsPromise = pythonPath ? this.fileSystem.fileExistsAsync(pythonPath) : Promise.resolve(false); + const existsPromise = pythonPath ? this.fileSystem.fileExists(pythonPath) : Promise.resolve(false); const versionPromise = this.versionService.getVersion(pythonPath, ''); const [exists, version] = await Promise.all([existsPromise, versionPromise]); diff --git a/src/client/interpreter/locators/services/condaService.ts b/src/client/interpreter/locators/services/condaService.ts index 2e990c30fcbe..969b5a1ca0ff 100644 --- a/src/client/interpreter/locators/services/condaService.ts +++ b/src/client/interpreter/locators/services/condaService.ts @@ -91,7 +91,7 @@ export class CondaService implements ICondaService { const dir = path.dirname(interpreterPath); const isWindows = this.serviceContainer.get(IPlatformService).isWindows; const condaMetaDirectory = isWindows ? path.join(dir, 'conda-meta') : path.join(dir, '..', 'conda-meta'); - return fs.directoryExistsAsync(condaMetaDirectory); + return fs.directoryExists(condaMetaDirectory); } public async getCondaEnvironment(interpreterPath: string): Promise<{ name: string; path: string } | undefined> { const isCondaEnv = await this.isCondaEnvironment(interpreterPath); @@ -175,7 +175,7 @@ export class CondaService implements ICondaService { return condaInterpreter ? path.join(path.dirname(condaInterpreter.path), 'conda.exe') : 'conda'; }) .then(async condaPath => { - return this.fileSystem.fileExistsAsync(condaPath).then(exists => exists ? condaPath : 'conda'); + return this.fileSystem.fileExists(condaPath).then(exists => exists ? condaPath : 'conda'); }); } return this.getCondaFileFromKnownLocations(); @@ -183,7 +183,7 @@ export class CondaService implements ICondaService { private async getCondaFileFromKnownLocations(): Promise { const condaFiles = await Promise.all(KNOWN_CONDA_LOCATIONS .map(untildify) - .map(async (condaPath: string) => this.fileSystem.fileExistsAsync(condaPath).then(exists => exists ? condaPath : ''))); + .map(async (condaPath: string) => this.fileSystem.fileExists(condaPath).then(exists => exists ? condaPath : ''))); const validCondaFiles = condaFiles.filter(condaPath => condaPath.length > 0); return validCondaFiles.length === 0 ? 'conda' : validCondaFiles[0]; diff --git a/src/client/interpreter/locators/services/currentPathService.ts b/src/client/interpreter/locators/services/currentPathService.ts index cf2f5dc8d321..5d8c6fc1b636 100644 --- a/src/client/interpreter/locators/services/currentPathService.ts +++ b/src/client/interpreter/locators/services/currentPathService.ts @@ -58,7 +58,7 @@ export class CurrentPathService extends CacheableLocatorService { return processService.exec(pythonPath, ['-c', 'import sys;print(sys.executable)'], {}) .then(output => output.stdout.trim()) .then(async value => { - if (value.length > 0 && await this.fs.fileExistsAsync(value)) { + if (value.length > 0 && await this.fs.fileExists(value)) { return value; } return defaultValue; diff --git a/src/client/interpreter/locators/services/pipEnvService.ts b/src/client/interpreter/locators/services/pipEnvService.ts index 10d4d451a44a..46985a70c81d 100644 --- a/src/client/interpreter/locators/services/pipEnvService.ts +++ b/src/client/interpreter/locators/services/pipEnvService.ts @@ -78,15 +78,15 @@ export class PipEnvService extends CacheableLocatorService { return; } const venvFolder = await this.invokePipenv('--venv', cwd); - return venvFolder && await this.fs.directoryExistsAsync(venvFolder) ? venvFolder : undefined; + return venvFolder && await this.fs.directoryExists(venvFolder) ? venvFolder : undefined; } private async checkIfPipFileExists(cwd: string): Promise { const currentProcess = this.serviceContainer.get(ICurrentProcess); const pipFileName = currentProcess.env[pipEnvFileNameVariable]; - if (typeof pipFileName === 'string' && await this.fs.fileExistsAsync(path.join(cwd, pipFileName))) { + if (typeof pipFileName === 'string' && await this.fs.fileExists(path.join(cwd, pipFileName))) { return true; } - if (await this.fs.fileExistsAsync(path.join(cwd, 'Pipfile'))) { + if (await this.fs.fileExists(path.join(cwd, 'Pipfile'))) { return true; } return false; diff --git a/src/client/linters/lintingEngine.ts b/src/client/linters/lintingEngine.ts index d5323c697c43..93b424780278 100644 --- a/src/client/linters/lintingEngine.ts +++ b/src/client/linters/lintingEngine.ts @@ -66,7 +66,7 @@ export class LintingEngine implements ILintingEngine { public async lintOpenPythonFiles(): Promise { this.diagnosticCollection.clear(); - const promises = this.documents.textDocuments.map(async document => await this.lintDocument(document, 'auto')); + const promises = this.documents.textDocuments.map(async document => this.lintDocument(document, 'auto')); await Promise.all(promises); return this.diagnosticCollection; } @@ -197,6 +197,6 @@ export class LintingEngine implements ILintingEngine { if (document.uri.scheme !== 'file' || !document.uri.fsPath) { return false; } - return await this.fileSystem.fileExistsAsync(document.uri.fsPath); + return this.fileSystem.fileExists(document.uri.fsPath); } } diff --git a/src/client/linters/pylint.ts b/src/client/linters/pylint.ts index 1e830283127d..ef015a260c46 100644 --- a/src/client/linters/pylint.ts +++ b/src/client/linters/pylint.ts @@ -99,17 +99,17 @@ export class Pylint extends BaseLinter { return true; } - if (await fs.fileExistsAsync(path.join(folder, pylintrc)) || await fs.fileExistsAsync(path.join(folder, dotPylintrc))) { + if (await fs.fileExists(path.join(folder, pylintrc)) || await fs.fileExists(path.join(folder, dotPylintrc))) { return true; } let current = folder; let above = path.dirname(folder); do { - if (!await fs.fileExistsAsync(path.join(current, '__init__.py'))) { + if (!await fs.fileExists(path.join(current, '__init__.py'))) { break; } - if (await fs.fileExistsAsync(path.join(current, pylintrc)) || await fs.fileExistsAsync(path.join(current, dotPylintrc))) { + if (await fs.fileExists(path.join(current, pylintrc)) || await fs.fileExists(path.join(current, dotPylintrc))) { return true; } current = above; @@ -117,15 +117,15 @@ export class Pylint extends BaseLinter { } while (!fs.arePathsSame(current, above)); const home = os.homedir(); - if (await fs.fileExistsAsync(path.join(home, dotPylintrc))) { + if (await fs.fileExists(path.join(home, dotPylintrc))) { return true; } - if (await fs.fileExistsAsync(path.join(home, '.config', pylintrc))) { + if (await fs.fileExists(path.join(home, '.config', pylintrc))) { return true; } if (!platformService.isWindows) { - if (await fs.fileExistsAsync(path.join('/etc', pylintrc))) { + if (await fs.fileExists(path.join('/etc', pylintrc))) { return true; } } @@ -138,7 +138,7 @@ export class Pylint extends BaseLinter { let current = folder; let above = path.dirname(current); do { - if (await fs.fileExistsAsync(path.join(current, pylintrc)) || await fs.fileExistsAsync(path.join(current, dotPylintrc))) { + if (await fs.fileExists(path.join(current, pylintrc)) || await fs.fileExists(path.join(current, dotPylintrc))) { return true; } current = above; diff --git a/src/client/terminals/codeExecution/djangoContext.ts b/src/client/terminals/codeExecution/djangoContext.ts index 00a5dd8e437b..d6f8755d447b 100644 --- a/src/client/terminals/codeExecution/djangoContext.ts +++ b/src/client/terminals/codeExecution/djangoContext.ts @@ -54,7 +54,7 @@ export class DjangoContextInitializer implements Disposable { private async ensureContextStateIsSet(): Promise { const activeWorkspace = this.getActiveWorkspace(); if (!activeWorkspace) { - return await this.isDjangoProject.set(false); + return this.isDjangoProject.set(false); } if (this.lastCheckedWorkspace === activeWorkspace) { return; @@ -62,7 +62,7 @@ export class DjangoContextInitializer implements Disposable { if (this.workspaceContextKeyValues.has(activeWorkspace)) { await this.isDjangoProject.set(this.workspaceContextKeyValues.get(activeWorkspace)!); } else { - const exists = await this.fileSystem.fileExistsAsync(path.join(activeWorkspace, 'manage.py')); + const exists = await this.fileSystem.fileExists(path.join(activeWorkspace, 'manage.py')); await this.isDjangoProject.set(exists); this.workspaceContextKeyValues.set(activeWorkspace, exists); this.lastCheckedWorkspace = activeWorkspace; diff --git a/src/test/common/process/execFactory.test.ts b/src/test/common/process/execFactory.test.ts index 2802a38cb749..21eea8523d86 100644 --- a/src/test/common/process/execFactory.test.ts +++ b/src/test/common/process/execFactory.test.ts @@ -25,7 +25,7 @@ suite('PythonExecutableService', () => { procService = TypeMoq.Mock.ofType(); configService = TypeMoq.Mock.ofType(); const fileSystem = TypeMoq.Mock.ofType(); - fileSystem.setup(f => f.fileExistsAsync(TypeMoq.It.isAny())).returns(() => Promise.resolve(false)); + fileSystem.setup(f => f.fileExists(TypeMoq.It.isAny())).returns(() => Promise.resolve(false)); serviceContainer.setup(c => c.get(TypeMoq.It.isValue(IFileSystem))).returns(() => fileSystem.object); serviceContainer.setup(c => c.get(TypeMoq.It.isValue(IEnvironmentVariablesProvider))).returns(() => envVarsProvider.object); serviceContainer.setup(c => c.get(TypeMoq.It.isValue(IProcessServiceFactory))).returns(() => procServiceFactory.object); diff --git a/src/test/common/terminals/activation.bash.test.ts b/src/test/common/terminals/activation.bash.test.ts index c321528140ea..88f677f5dc21 100644 --- a/src/test/common/terminals/activation.bash.test.ts +++ b/src/test/common/terminals/activation.bash.test.ts @@ -75,7 +75,7 @@ suite('Terminal Environment Activation (bash)', () => { } const pathToScriptFile = path.join(path.dirname(pythonPath), scriptFileName); - fileSystem.setup(fs => fs.fileExistsAsync(TypeMoq.It.isValue(pathToScriptFile))).returns(() => Promise.resolve(true)); + fileSystem.setup(fs => fs.fileExists(TypeMoq.It.isValue(pathToScriptFile))).returns(() => Promise.resolve(true)); const command = await bash.getActivationCommands(undefined, shellType.value); if (isScriptFileSupported) { diff --git a/src/test/common/terminals/activation.commandPrompt.test.ts b/src/test/common/terminals/activation.commandPrompt.test.ts index ce1942bc3b88..8f6f743b6063 100644 --- a/src/test/common/terminals/activation.commandPrompt.test.ts +++ b/src/test/common/terminals/activation.commandPrompt.test.ts @@ -85,7 +85,7 @@ suite('Terminal Environment Activation (cmd/powershell)', () => { const bash = new CommandPromptAndPowerShell(serviceContainer.object); const pathToScriptFile = path.join(path.dirname(pythonPath), 'activate.bat'); - fileSystem.setup(fs => fs.fileExistsAsync(TypeMoq.It.isValue(pathToScriptFile))).returns(() => Promise.resolve(true)); + fileSystem.setup(fs => fs.fileExists(TypeMoq.It.isValue(pathToScriptFile))).returns(() => Promise.resolve(true)); const commands = await bash.getActivationCommands(resource, TerminalShellType.commandPrompt); // Ensure the script file is of the following form: @@ -101,7 +101,7 @@ suite('Terminal Environment Activation (cmd/powershell)', () => { platform.setup(p => p.isWindows).returns(() => true); const pathToScriptFile = path.join(path.dirname(pythonPath), 'activate.bat'); - fileSystem.setup(fs => fs.fileExistsAsync(TypeMoq.It.isValue(pathToScriptFile))).returns(() => Promise.resolve(true)); + fileSystem.setup(fs => fs.fileExists(TypeMoq.It.isValue(pathToScriptFile))).returns(() => Promise.resolve(true)); const command = await batch.getActivationCommands(resource, TerminalShellType.powershell); // Executing batch files from powershell requires going back to cmd, then into powershell @@ -116,7 +116,7 @@ suite('Terminal Environment Activation (cmd/powershell)', () => { platform.setup(p => p.isWindows).returns(() => true); const pathToScriptFile = path.join(path.dirname(pythonPath), 'activate.bat'); - fileSystem.setup(fs => fs.fileExistsAsync(TypeMoq.It.isValue(pathToScriptFile))).returns(() => Promise.resolve(true)); + fileSystem.setup(fs => fs.fileExists(TypeMoq.It.isValue(pathToScriptFile))).returns(() => Promise.resolve(true)); const command = await bash.getActivationCommands(resource, TerminalShellType.powershellCore); // Executing batch files from powershell requires going back to cmd, then into powershell @@ -131,7 +131,7 @@ suite('Terminal Environment Activation (cmd/powershell)', () => { platform.setup(p => p.isWindows).returns(() => false); const pathToScriptFile = path.join(path.dirname(pythonPath), 'activate.bat'); - fileSystem.setup(fs => fs.fileExistsAsync(TypeMoq.It.isValue(pathToScriptFile))).returns(() => Promise.resolve(true)); + fileSystem.setup(fs => fs.fileExists(TypeMoq.It.isValue(pathToScriptFile))).returns(() => Promise.resolve(true)); const command = await bash.getActivationCommands(resource, TerminalShellType.powershell); expect(command).to.be.equal(undefined, 'Invalid command'); @@ -142,7 +142,7 @@ suite('Terminal Environment Activation (cmd/powershell)', () => { platform.setup(p => p.isWindows).returns(() => false); const pathToScriptFile = path.join(path.dirname(pythonPath), 'activate.bat'); - fileSystem.setup(fs => fs.fileExistsAsync(TypeMoq.It.isValue(pathToScriptFile))).returns(() => Promise.resolve(true)); + fileSystem.setup(fs => fs.fileExists(TypeMoq.It.isValue(pathToScriptFile))).returns(() => Promise.resolve(true)); const command = await bash.getActivationCommands(resource, TerminalShellType.powershellCore); expect(command).to.be.equal(undefined, 'Invalid command'); @@ -172,7 +172,7 @@ suite('Terminal Environment Activation (cmd/powershell)', () => { platform.setup(p => p.isWindows).returns(() => true); const pathToScriptFile = path.join(path.dirname(pythonPath), 'activate.ps1'); - fileSystem.setup(fs => fs.fileExistsAsync(TypeMoq.It.isValue(pathToScriptFile))).returns(() => Promise.resolve(true)); + fileSystem.setup(fs => fs.fileExists(TypeMoq.It.isValue(pathToScriptFile))).returns(() => Promise.resolve(true)); const command = await bash.getActivationCommands(resource, TerminalShellType.commandPrompt); expect(command).to.be.deep.equal([], 'Invalid command (running powershell files are not supported on command prompt)'); @@ -183,7 +183,7 @@ suite('Terminal Environment Activation (cmd/powershell)', () => { platform.setup(p => p.isWindows).returns(() => true); const pathToScriptFile = path.join(path.dirname(pythonPath), 'activate.ps1'); - fileSystem.setup(fs => fs.fileExistsAsync(TypeMoq.It.isValue(pathToScriptFile))).returns(() => Promise.resolve(true)); + fileSystem.setup(fs => fs.fileExists(TypeMoq.It.isValue(pathToScriptFile))).returns(() => Promise.resolve(true)); const command = await bash.getActivationCommands(resource, TerminalShellType.powershell); expect(command).to.be.deep.equal([`& ${pathToScriptFile.fileToCommandArgument()}`.trim()], 'Invalid command'); @@ -194,7 +194,7 @@ suite('Terminal Environment Activation (cmd/powershell)', () => { platform.setup(p => p.isWindows).returns(() => true); const pathToScriptFile = path.join(path.dirname(pythonPath), 'activate.ps1'); - fileSystem.setup(fs => fs.fileExistsAsync(TypeMoq.It.isValue(pathToScriptFile))).returns(() => Promise.resolve(true)); + fileSystem.setup(fs => fs.fileExists(TypeMoq.It.isValue(pathToScriptFile))).returns(() => Promise.resolve(true)); const command = await bash.getActivationCommands(resource, TerminalShellType.powershellCore); expect(command).to.be.deep.equal([`& ${pathToScriptFile.fileToCommandArgument()}`.trim()], 'Invalid command'); diff --git a/src/test/common/terminals/activation.conda.test.ts b/src/test/common/terminals/activation.conda.test.ts index b4498ce8edeb..87d10d7c2b38 100644 --- a/src/test/common/terminals/activation.conda.test.ts +++ b/src/test/common/terminals/activation.conda.test.ts @@ -152,19 +152,19 @@ suite('Terminal Environment Activation conda', () => { test('If environment is a conda environment, ensure conda activation command is sent (windows)', async () => { const pythonPath = path.join('c', 'users', 'xyz', '.conda', 'envs', 'enva', 'python.exe'); - fileSystem.setup(f => f.directoryExistsAsync(TypeMoq.It.isValue(path.join(path.dirname(pythonPath), 'conda-meta')))).returns(() => Promise.resolve(true)); + fileSystem.setup(f => f.directoryExists(TypeMoq.It.isValue(path.join(path.dirname(pythonPath), 'conda-meta')))).returns(() => Promise.resolve(true)); await expectCondaActivationCommand(true, false, false, pythonPath); }); test('If environment is a conda environment, ensure conda activation command is sent (linux)', async () => { const pythonPath = path.join('users', 'xyz', '.conda', 'envs', 'enva', 'bin', 'python'); - fileSystem.setup(f => f.directoryExistsAsync(TypeMoq.It.isValue(path.join(path.dirname(pythonPath), '..', 'conda-meta')))).returns(() => Promise.resolve(true)); + fileSystem.setup(f => f.directoryExists(TypeMoq.It.isValue(path.join(path.dirname(pythonPath), '..', 'conda-meta')))).returns(() => Promise.resolve(true)); await expectCondaActivationCommand(false, false, true, pythonPath); }); test('If environment is a conda environment, ensure conda activation command is sent (osx)', async () => { const pythonPath = path.join('users', 'xyz', '.conda', 'envs', 'enva', 'bin', 'python'); - fileSystem.setup(f => f.directoryExistsAsync(TypeMoq.It.isValue(path.join(path.dirname(pythonPath), '..', 'conda-meta')))).returns(() => Promise.resolve(true)); + fileSystem.setup(f => f.directoryExists(TypeMoq.It.isValue(path.join(path.dirname(pythonPath), '..', 'conda-meta')))).returns(() => Promise.resolve(true)); await expectCondaActivationCommand(false, true, false, pythonPath); }); @@ -205,21 +205,21 @@ suite('Terminal Environment Activation conda', () => { test('If environment is a conda environment and environment detection fails, ensure activatino of script is sent (windows)', async () => { const pythonPath = path.join('c', 'users', 'xyz', '.conda', 'envs', 'enva', 'python.exe'); const condaEnvDir = path.join('c', 'users', 'xyz', '.conda', 'envs'); - fileSystem.setup(f => f.directoryExistsAsync(TypeMoq.It.isValue(path.join(path.dirname(pythonPath), 'conda-meta')))).returns(() => Promise.resolve(true)); + fileSystem.setup(f => f.directoryExists(TypeMoq.It.isValue(path.join(path.dirname(pythonPath), 'conda-meta')))).returns(() => Promise.resolve(true)); await expectActivationCommandIfCondaDetectionFails(true, false, false, pythonPath, condaEnvDir); }); test('If environment is a conda environment and environment detection fails, ensure activatino of script is sent (osx)', async () => { const pythonPath = path.join('users', 'xyz', '.conda', 'envs', 'enva', 'python'); const condaEnvDir = path.join('users', 'xyz', '.conda', 'envs'); - fileSystem.setup(f => f.directoryExistsAsync(TypeMoq.It.isValue(path.join(path.dirname(pythonPath), '..', 'conda-meta')))).returns(() => Promise.resolve(true)); + fileSystem.setup(f => f.directoryExists(TypeMoq.It.isValue(path.join(path.dirname(pythonPath), '..', 'conda-meta')))).returns(() => Promise.resolve(true)); await expectActivationCommandIfCondaDetectionFails(false, true, false, pythonPath, condaEnvDir); }); test('If environment is a conda environment and environment detection fails, ensure activatino of script is sent (linux)', async () => { const pythonPath = path.join('users', 'xyz', '.conda', 'envs', 'enva', 'python'); const condaEnvDir = path.join('users', 'xyz', '.conda', 'envs'); - fileSystem.setup(f => f.directoryExistsAsync(TypeMoq.It.isValue(path.join(path.dirname(pythonPath), '..', 'conda-meta')))).returns(() => Promise.resolve(true)); + fileSystem.setup(f => f.directoryExists(TypeMoq.It.isValue(path.join(path.dirname(pythonPath), '..', 'conda-meta')))).returns(() => Promise.resolve(true)); await expectActivationCommandIfCondaDetectionFails(false, false, true, pythonPath, condaEnvDir); }); diff --git a/src/test/configuration/interpreterSelector.test.ts b/src/test/configuration/interpreterSelector.test.ts index 5dbb7f7bd70d..98ea1fd27cc9 100644 --- a/src/test/configuration/interpreterSelector.test.ts +++ b/src/test/configuration/interpreterSelector.test.ts @@ -54,7 +54,7 @@ suite('Interpreters - selector', () => { .setup(x => x.arePathsSame(TypeMoq.It.isAnyString(), TypeMoq.It.isAnyString())) .returns((a: string, b: string) => a === b); fileSystem - .setup(x => x.getRealPathAsync(TypeMoq.It.isAnyString())) + .setup(x => x.getRealPath(TypeMoq.It.isAnyString())) .returns((a: string) => new Promise(resolve => resolve(a))); serviceManager.addSingletonInstance(IFileSystem, fileSystem.object); diff --git a/src/test/debugger/configProvider/provider.test.ts b/src/test/debugger/configProvider/provider.test.ts index 94ca215e76db..fbc51cd3c762 100644 --- a/src/test/debugger/configProvider/provider.test.ts +++ b/src/test/debugger/configProvider/provider.test.ts @@ -345,7 +345,7 @@ import { IServiceContainer } from '../../../client/ioc/types'; pythonExecutionService.setup(e => e.exec(TypeMoq.It.isValue(args), TypeMoq.It.isAny())) .returns(() => execOutput) .verifiable(TypeMoq.Times.exactly(addPyramidDebugOption ? 1 : 0)); - fileSystem.setup(f => f.fileExistsAsync(TypeMoq.It.isValue(pserveFilePath))) + fileSystem.setup(f => f.fileExists(TypeMoq.It.isValue(pserveFilePath))) .returns(() => Promise.resolve(pyramidExists)) .verifiable(TypeMoq.Times.exactly(pyramidExists && addPyramidDebugOption ? 1 : 0)); appShell.setup(a => a.showErrorMessage(TypeMoq.It.isAny())) diff --git a/src/test/definitions/hover.ptvs.test.ts b/src/test/definitions/hover.ptvs.test.ts index 4f0f014c7bff..089245836090 100644 --- a/src/test/definitions/hover.ptvs.test.ts +++ b/src/test/definitions/hover.ptvs.test.ts @@ -52,7 +52,9 @@ suite('Hover Definition (Analysis Engine)', () => { const actual = normalizeMarkedString(def[0].contents[0]).splitLines(); const expected = [ 'obj.method1:', + '```python', 'method method1 of one.Class1 objects', + '```', 'This is method1' ]; verifySignatureLines(actual, expected); @@ -67,7 +69,9 @@ suite('Hover Definition (Analysis Engine)', () => { const actual = normalizeMarkedString(def[0].contents[0]).splitLines(); const expected = [ 'two.ct().fun:', + '```python', 'method fun of two.ct objects', + '```', 'This is fun' ]; verifySignatureLines(actual, expected); @@ -81,12 +85,13 @@ suite('Hover Definition (Analysis Engine)', () => { const actual = normalizeMarkedString(def[0].contents[0]).splitLines(); const expected = [ - 'Foo.bar:', + '```python', 'four.Foo.bar() -> bool', + 'declared in Foo', + '```', '说明 - keep this line, it works', 'delete following line, it works', - '如果存在需要等待审批或正在执行的任务,将不刷新页面', - 'declared in Foo' + '如果存在需要等待审批或正在执行的任务,将不刷新页面' ]; verifySignatureLines(actual, expected); }); @@ -99,8 +104,9 @@ suite('Hover Definition (Analysis Engine)', () => { const actual = normalizeMarkedString(def[0].contents[0]).splitLines(); const expected = [ - 'four.showMessage:', + '```python', 'four.showMessage()', + '```', 'Кюм ут жэмпэр пошжим льаборэж, коммюны янтэрэсщэт нам ед, декта игнота ныморэ жят эи.', 'Шэа декам экшырки эи, эи зыд эррэм докэндё, векж факэтэ пэрчыквюэрёж ку.' ]; @@ -131,8 +137,9 @@ suite('Hover Definition (Analysis Engine)', () => { const actual = normalizeMarkedString(def[0].contents[0]).splitLines(); const expected = [ - 'misc.Random:', + '```python', 'class misc.Random(_random.Random)', + '```', 'Random number generator base class used by bound module functions.', 'Used to instantiate instances of Random to get generators that don\'t', 'share state.', @@ -154,7 +161,9 @@ suite('Hover Definition (Analysis Engine)', () => { const actual = normalizeMarkedString(def[0].contents[0]).splitLines(); const expected = [ 'rnd2.randint:', + '```python', 'method randint of misc.Random objects -> int', + '```', 'Return random integer in range [a, b], including both end points.' ]; verifySignatureLines(actual, expected); @@ -168,8 +177,9 @@ suite('Hover Definition (Analysis Engine)', () => { const actual = normalizeMarkedString(def[0].contents[0]).splitLines(); const expected = [ - 'math.acos:', - 'built-in function acos(x)', + '```python', + 'acos(x)', + '```', 'acos(x)', 'Return the arc cosine (measured in radians) of x.' ]; @@ -184,8 +194,9 @@ suite('Hover Definition (Analysis Engine)', () => { const actual = normalizeMarkedString(def[0].contents[0]).splitLines(); const expected = [ - 'misc.Thread:', + '```python', 'class misc.Thread(_Verbose)', + '```', 'A class that represents a thread of control.', 'This class can be safely subclassed in a limited fashion.' ]; @@ -222,6 +233,7 @@ suite('Hover Definition (Analysis Engine)', () => { function verifySignatureLines(actual: string[], expected: string[]) { assert.equal(actual.length, expected.length, 'incorrect number of lines'); for (let i = 0; i < actual.length; i += 1) { + actual[i] = actual[i].replace(new RegExp(' ', 'g'), ' '); assert.equal(actual[i].trim(), expected[i], `signature line ${i + 1} is incorrect`); } } diff --git a/src/test/interpreters/condaEnvFileService.test.ts b/src/test/interpreters/condaEnvFileService.test.ts index 2207be82732a..92783ddf3bc9 100644 --- a/src/test/interpreters/condaEnvFileService.test.ts +++ b/src/test/interpreters/condaEnvFileService.test.ts @@ -44,7 +44,7 @@ suite('Interpreters from Conda Environments Text File', () => { }); test('Must return an empty list for an empty file', async () => { condaService.setup(c => c.condaEnvironmentsFile).returns(() => environmentsFilePath); - fileSystem.setup(fs => fs.fileExistsAsync(TypeMoq.It.isValue(environmentsFilePath))).returns(() => Promise.resolve(true)); + fileSystem.setup(fs => fs.fileExists(TypeMoq.It.isValue(environmentsFilePath))).returns(() => Promise.resolve(true)); fileSystem.setup(fs => fs.readFile(TypeMoq.It.isValue(environmentsFilePath))).returns(() => Promise.resolve('')); interpreterVersion.setup(i => i.getVersion(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => Promise.resolve('Mock Name')); const interpreters = await condaFileProvider.getInterpreters(); @@ -73,11 +73,11 @@ suite('Interpreters from Conda Environments Text File', () => { }); return Promise.resolve(condaEnvironments); }); - fileSystem.setup(fs => fs.fileExistsAsync(TypeMoq.It.isValue(environmentsFilePath))).returns(() => Promise.resolve(true)); + fileSystem.setup(fs => fs.fileExists(TypeMoq.It.isValue(environmentsFilePath))).returns(() => Promise.resolve(true)); fileSystem.setup(fs => fs.arePathsSame(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns((p1: string, p2: string) => isWindows ? p1 === p2 : p1.toUpperCase() === p2.toUpperCase()); validPaths.forEach(validPath => { const pythonPath = isWindows ? path.join(validPath, 'python.exe') : path.join(validPath, 'bin', 'python'); - fileSystem.setup(fs => fs.fileExistsAsync(TypeMoq.It.isValue(pythonPath))).returns(() => Promise.resolve(true)); + fileSystem.setup(fs => fs.fileExists(TypeMoq.It.isValue(pythonPath))).returns(() => Promise.resolve(true)); }); fileSystem.setup(fs => fs.readFile(TypeMoq.It.isValue(environmentsFilePath))).returns(() => Promise.resolve(interpreterPaths.join(EOL))); @@ -107,8 +107,8 @@ suite('Interpreters from Conda Environments Text File', () => { const pythonPath = path.join(interpreterPaths[0], 'pythonPath'); condaService.setup(c => c.condaEnvironmentsFile).returns(() => environmentsFilePath); condaService.setup(c => c.getInterpreterPath(TypeMoq.It.isAny())).returns(() => pythonPath); - fileSystem.setup(fs => fs.fileExistsAsync(TypeMoq.It.isValue(pythonPath))).returns(() => Promise.resolve(true)); - fileSystem.setup(fs => fs.fileExistsAsync(TypeMoq.It.isValue(environmentsFilePath))).returns(() => Promise.resolve(true)); + fileSystem.setup(fs => fs.fileExists(TypeMoq.It.isValue(pythonPath))).returns(() => Promise.resolve(true)); + fileSystem.setup(fs => fs.fileExists(TypeMoq.It.isValue(environmentsFilePath))).returns(() => Promise.resolve(true)); fileSystem.setup(fs => fs.readFile(TypeMoq.It.isValue(environmentsFilePath))).returns(() => Promise.resolve(interpreterPaths.join(EOL))); for (const companyName of AnacondaCompanyNames) { diff --git a/src/test/interpreters/condaEnvService.test.ts b/src/test/interpreters/condaEnvService.test.ts index a3c7b93c7acc..82da233fb9e9 100644 --- a/src/test/interpreters/condaEnvService.test.ts +++ b/src/test/interpreters/condaEnvService.test.ts @@ -63,7 +63,7 @@ suite('Interpreters from Conda Environments', () => { }); info.envs.forEach(validPath => { const pythonPath = isWindows ? path.join(validPath, 'python.exe') : path.join(validPath, 'bin', 'python'); - fileSystem.setup(fs => fs.fileExistsAsync(TypeMoq.It.isValue(pythonPath))).returns(() => Promise.resolve(true)); + fileSystem.setup(fs => fs.fileExists(TypeMoq.It.isValue(pythonPath))).returns(() => Promise.resolve(true)); }); interpreterVersion.setup(i => i.getVersion(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns((_p, defaultValue) => Promise.resolve(defaultValue)); @@ -100,7 +100,7 @@ suite('Interpreters from Conda Environments', () => { }); info.envs.forEach(validPath => { const pythonPath = isWindows ? path.join(validPath, 'python.exe') : path.join(validPath, 'bin', 'python'); - fileSystem.setup(fs => fs.fileExistsAsync(TypeMoq.It.isValue(pythonPath))).returns(() => Promise.resolve(true)); + fileSystem.setup(fs => fs.fileExists(TypeMoq.It.isValue(pythonPath))).returns(() => Promise.resolve(true)); }); interpreterVersion.setup(i => i.getVersion(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns((_p, defaultValue) => Promise.resolve(defaultValue)); condaService.setup(c => c.getCondaFile()).returns(() => Promise.resolve('conda')); @@ -145,7 +145,7 @@ suite('Interpreters from Conda Environments', () => { }); info.envs.forEach(validPath => { const pythonPath = isWindows ? path.join(validPath, 'python.exe') : path.join(validPath, 'bin', 'python'); - fileSystem.setup(fs => fs.fileExistsAsync(TypeMoq.It.isValue(pythonPath))).returns(() => Promise.resolve(true)); + fileSystem.setup(fs => fs.fileExists(TypeMoq.It.isValue(pythonPath))).returns(() => Promise.resolve(true)); }); interpreterVersion.setup(i => i.getVersion(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns((_p, defaultValue) => Promise.resolve(defaultValue)); @@ -183,7 +183,7 @@ suite('Interpreters from Conda Environments', () => { }); info.envs.forEach(validPath => { const pythonPath = isWindows ? path.join(validPath, 'python.exe') : path.join(validPath, 'bin', 'python'); - fileSystem.setup(fs => fs.fileExistsAsync(TypeMoq.It.isValue(pythonPath))).returns(() => Promise.resolve(true)); + fileSystem.setup(fs => fs.fileExists(TypeMoq.It.isValue(pythonPath))).returns(() => Promise.resolve(true)); }); interpreterVersion.setup(i => i.getVersion(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns((_p, defaultValue) => Promise.resolve(defaultValue)); fileSystem.setup(fs => fs.arePathsSame(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns((p1: string, p2: string) => isWindows ? p1 === p2 : p1.toUpperCase() === p2.toUpperCase()); @@ -213,7 +213,7 @@ suite('Interpreters from Conda Environments', () => { }); info.envs.forEach(validPath => { const pythonPath = isWindows ? path.join(validPath, 'python.exe') : path.join(validPath, 'bin', 'python'); - fileSystem.setup(fs => fs.fileExistsAsync(TypeMoq.It.isValue(pythonPath))).returns(() => Promise.resolve(true)); + fileSystem.setup(fs => fs.fileExists(TypeMoq.It.isValue(pythonPath))).returns(() => Promise.resolve(true)); }); interpreterVersion.setup(i => i.getVersion(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns((_p, defaultValue) => Promise.resolve(defaultValue)); @@ -243,7 +243,7 @@ suite('Interpreters from Conda Environments', () => { }); info.envs.forEach(validPath => { const pythonPath = isWindows ? path.join(validPath, 'python.exe') : path.join(validPath, 'bin', 'python'); - fileSystem.setup(fs => fs.fileExistsAsync(TypeMoq.It.isValue(pythonPath))).returns(() => Promise.resolve(true)); + fileSystem.setup(fs => fs.fileExists(TypeMoq.It.isValue(pythonPath))).returns(() => Promise.resolve(true)); }); interpreterVersion.setup(i => i.getVersion(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns((_p, defaultValue) => Promise.resolve(defaultValue)); condaService.setup(c => c.getCondaFile()).returns(() => Promise.resolve('conda')); @@ -279,7 +279,7 @@ suite('Interpreters from Conda Environments', () => { return isWindows ? path.join(environmentPath, 'python.exe') : path.join(environmentPath, 'bin', 'python'); }); const pythonPath = isWindows ? path.join(info.default_prefix, 'python.exe') : path.join(info.default_prefix, 'bin', 'python'); - fileSystem.setup(fs => fs.fileExistsAsync(TypeMoq.It.isValue(pythonPath))).returns(() => Promise.resolve(true)); + fileSystem.setup(fs => fs.fileExists(TypeMoq.It.isValue(pythonPath))).returns(() => Promise.resolve(true)); interpreterVersion.setup(i => i.getVersion(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns((_p, defaultValue) => Promise.resolve(defaultValue)); const interpreters = await condaProvider.parseCondaInfo(info); @@ -314,7 +314,7 @@ suite('Interpreters from Conda Environments', () => { return isWindows ? path.join(environmentPath, 'python.exe') : path.join(environmentPath, 'bin', 'python'); }); const pythonPath = isWindows ? path.join(envPath, 'python.exe') : path.join(envPath, 'bin', 'python'); - fileSystem.setup(fs => fs.fileExistsAsync(TypeMoq.It.isValue(pythonPath))).returns(() => Promise.resolve(true)); + fileSystem.setup(fs => fs.fileExists(TypeMoq.It.isValue(pythonPath))).returns(() => Promise.resolve(true)); }); const interpreters = await condaProvider.parseCondaInfo(info); diff --git a/src/test/interpreters/condaService.test.ts b/src/test/interpreters/condaService.test.ts index 21059a94e537..cbcdcf5642da 100644 --- a/src/test/interpreters/condaService.test.ts +++ b/src/test/interpreters/condaService.test.ts @@ -58,19 +58,19 @@ suite('Interpreters Conda Service', () => { test('Correctly identifies a python path as a conda environment (windows)', async () => { const pythonPath = path.join('c', 'users', 'xyz', '.conda', 'envs', 'enva', 'python.exe'); - fileSystem.setup(f => f.directoryExistsAsync(TypeMoq.It.isValue(path.join(path.dirname(pythonPath), 'conda-meta')))).returns(() => Promise.resolve(true)); + fileSystem.setup(f => f.directoryExists(TypeMoq.It.isValue(path.join(path.dirname(pythonPath), 'conda-meta')))).returns(() => Promise.resolve(true)); await identifyPythonPathAsCondaEnvironment(true, false, false, pythonPath); }); test('Correctly identifies a python path as a conda environment (linux)', async () => { const pythonPath = path.join('users', 'xyz', '.conda', 'envs', 'enva', 'bin', 'python'); - fileSystem.setup(f => f.directoryExistsAsync(TypeMoq.It.isValue(path.join(path.dirname(pythonPath), '..', 'conda-meta')))).returns(() => Promise.resolve(true)); + fileSystem.setup(f => f.directoryExists(TypeMoq.It.isValue(path.join(path.dirname(pythonPath), '..', 'conda-meta')))).returns(() => Promise.resolve(true)); await identifyPythonPathAsCondaEnvironment(false, false, true, pythonPath); }); test('Correctly identifies a python path as a conda environment (osx)', async () => { const pythonPath = path.join('users', 'xyz', '.conda', 'envs', 'enva', 'bin', 'python'); - fileSystem.setup(f => f.directoryExistsAsync(TypeMoq.It.isValue(path.join(path.dirname(pythonPath), '..', 'conda-meta')))).returns(() => Promise.resolve(true)); + fileSystem.setup(f => f.directoryExists(TypeMoq.It.isValue(path.join(path.dirname(pythonPath), '..', 'conda-meta')))).returns(() => Promise.resolve(true)); await identifyPythonPathAsCondaEnvironment(false, true, false, pythonPath); }); @@ -79,8 +79,8 @@ suite('Interpreters Conda Service', () => { platformService.setup(p => p.isWindows).returns(() => isWindows); platformService.setup(p => p.isMac).returns(() => isOsx); - fileSystem.setup(f => f.directoryExistsAsync(TypeMoq.It.isValue(path.join(path.dirname(pythonPath), 'conda-meta')))).returns(() => Promise.resolve(false)); - fileSystem.setup(f => f.directoryExistsAsync(TypeMoq.It.isValue(path.join(path.dirname(pythonPath), '..', 'conda-meta')))).returns(() => Promise.resolve(false)); + fileSystem.setup(f => f.directoryExists(TypeMoq.It.isValue(path.join(path.dirname(pythonPath), 'conda-meta')))).returns(() => Promise.resolve(false)); + fileSystem.setup(f => f.directoryExists(TypeMoq.It.isValue(path.join(path.dirname(pythonPath), '..', 'conda-meta')))).returns(() => Promise.resolve(false)); const isCondaEnv = await condaService.isCondaEnvironment(pythonPath); expect(isCondaEnv).to.be.equal(false, 'Path incorrectly identified as a conda path'); @@ -127,7 +127,7 @@ suite('Interpreters Conda Service', () => { const pythonPath = path.join('c', 'users', 'xyz', '.conda', 'envs', 'one', 'python.exe'); const condaEnvDir = path.join('c', 'users', 'xyz', '.conda', 'envs'); - fileSystem.setup(f => f.directoryExistsAsync(TypeMoq.It.isValue(path.join(path.dirname(pythonPath), 'conda-meta')))).returns(() => Promise.resolve(true)); + fileSystem.setup(f => f.directoryExists(TypeMoq.It.isValue(path.join(path.dirname(pythonPath), 'conda-meta')))).returns(() => Promise.resolve(true)); await checkCondaNameAndPathForCondaEnvironments(true, false, false, pythonPath, condaEnvDir, { name: 'One', path: path.dirname(pythonPath) }); }); @@ -135,7 +135,7 @@ suite('Interpreters Conda Service', () => { const pythonPath = path.join('c', 'users', 'xyz', '.conda', 'envs', 'eight 8', 'python.exe'); const condaEnvDir = path.join('c', 'users', 'xyz', '.conda', 'envs'); - fileSystem.setup(f => f.directoryExistsAsync(TypeMoq.It.isValue(path.join(path.dirname(pythonPath), 'conda-meta')))).returns(() => Promise.resolve(true)); + fileSystem.setup(f => f.directoryExists(TypeMoq.It.isValue(path.join(path.dirname(pythonPath), 'conda-meta')))).returns(() => Promise.resolve(true)); await checkCondaNameAndPathForCondaEnvironments(true, false, false, pythonPath, condaEnvDir, { name: 'Eight', path: path.dirname(pythonPath) }); }); @@ -143,7 +143,7 @@ suite('Interpreters Conda Service', () => { const pythonPath = path.join('c', 'users', 'xyz', '.conda', 'envs', 'one', 'bin', 'python'); const condaEnvDir = path.join('c', 'users', 'xyz', '.conda', 'envs'); - fileSystem.setup(f => f.directoryExistsAsync(TypeMoq.It.isValue(path.join(path.dirname(pythonPath), '..', 'conda-meta')))).returns(() => Promise.resolve(true)); + fileSystem.setup(f => f.directoryExists(TypeMoq.It.isValue(path.join(path.dirname(pythonPath), '..', 'conda-meta')))).returns(() => Promise.resolve(true)); await checkCondaNameAndPathForCondaEnvironments(false, true, false, pythonPath, condaEnvDir, { name: 'One', path: path.join(path.dirname(pythonPath), '..') }); }); @@ -151,7 +151,7 @@ suite('Interpreters Conda Service', () => { const pythonPath = path.join('c', 'users', 'xyz', '.conda', 'envs', 'Eight 8', 'bin', 'python'); const condaEnvDir = path.join('c', 'users', 'xyz', '.conda', 'envs'); - fileSystem.setup(f => f.directoryExistsAsync(TypeMoq.It.isValue(path.join(path.dirname(pythonPath), '..', 'conda-meta')))).returns(() => Promise.resolve(true)); + fileSystem.setup(f => f.directoryExists(TypeMoq.It.isValue(path.join(path.dirname(pythonPath), '..', 'conda-meta')))).returns(() => Promise.resolve(true)); await checkCondaNameAndPathForCondaEnvironments(false, true, false, pythonPath, condaEnvDir, { name: 'Eight', path: path.join(path.dirname(pythonPath), '..') }); }); @@ -159,7 +159,7 @@ suite('Interpreters Conda Service', () => { const pythonPath = path.join('c', 'users', 'xyz', '.conda', 'envs', 'one', 'bin', 'python'); const condaEnvDir = path.join('c', 'users', 'xyz', '.conda', 'envs'); - fileSystem.setup(f => f.directoryExistsAsync(TypeMoq.It.isValue(path.join(path.dirname(pythonPath), '..', 'conda-meta')))).returns(() => Promise.resolve(true)); + fileSystem.setup(f => f.directoryExists(TypeMoq.It.isValue(path.join(path.dirname(pythonPath), '..', 'conda-meta')))).returns(() => Promise.resolve(true)); await checkCondaNameAndPathForCondaEnvironments(false, false, true, pythonPath, condaEnvDir, { name: 'One', path: path.join(path.dirname(pythonPath), '..') }); }); @@ -167,7 +167,7 @@ suite('Interpreters Conda Service', () => { const pythonPath = path.join('c', 'users', 'xyz', '.conda', 'envs', 'Eight 8', 'bin', 'python'); const condaEnvDir = path.join('c', 'users', 'xyz', '.conda', 'envs'); - fileSystem.setup(f => f.directoryExistsAsync(TypeMoq.It.isValue(path.join(path.dirname(pythonPath), '..', 'conda-meta')))).returns(() => Promise.resolve(true)); + fileSystem.setup(f => f.directoryExists(TypeMoq.It.isValue(path.join(path.dirname(pythonPath), '..', 'conda-meta')))).returns(() => Promise.resolve(true)); await checkCondaNameAndPathForCondaEnvironments(false, false, true, pythonPath, condaEnvDir, { name: 'Eight', path: path.join(path.dirname(pythonPath), '..') }); }); @@ -187,7 +187,7 @@ suite('Interpreters Conda Service', () => { platformService.setup(p => p.isWindows).returns(() => true); platformService.setup(p => p.isMac).returns(() => false); - fileSystem.setup(f => f.directoryExistsAsync(TypeMoq.It.isValue(path.join(path.dirname(pythonPath), 'conda-meta')))).returns(() => Promise.resolve(true)); + fileSystem.setup(f => f.directoryExists(TypeMoq.It.isValue(path.join(path.dirname(pythonPath), 'conda-meta')))).returns(() => Promise.resolve(true)); const stateFactory = TypeMoq.Mock.ofType(); serviceContainer.setup(c => c.get(TypeMoq.It.isValue(IPersistentStateFactory))).returns(() => stateFactory.object); const state = new MockState({ data: condaEnvironments }); @@ -228,7 +228,7 @@ suite('Interpreters Conda Service', () => { platformService.setup(p => p.isWindows).returns(() => true); platformService.setup(p => p.isMac).returns(() => false); - fileSystem.setup(f => f.directoryExistsAsync(TypeMoq.It.isValue(path.join(path.dirname(pythonPath), 'conda-meta')))).returns(() => Promise.resolve(true)); + fileSystem.setup(f => f.directoryExists(TypeMoq.It.isValue(path.join(path.dirname(pythonPath), 'conda-meta')))).returns(() => Promise.resolve(true)); const stateFactory = TypeMoq.Mock.ofType(); serviceContainer.setup(c => c.get(TypeMoq.It.isValue(IPersistentStateFactory))).returns(() => stateFactory.object); const state = new MockState({ data: condaEnvironments }); @@ -265,7 +265,7 @@ suite('Interpreters Conda Service', () => { platformService.setup(p => p.isWindows).returns(() => true); processService.setup(p => p.exec(TypeMoq.It.isValue('conda'), TypeMoq.It.isValue(['--version']), TypeMoq.It.isAny())).returns(() => Promise.reject(new Error('Not Found'))); registryInterpreterLocatorService.setup(r => r.getInterpreters(TypeMoq.It.isAny())).returns(() => Promise.resolve(registryInterpreters)); - fileSystem.setup(fs => fs.fileExistsAsync(TypeMoq.It.isAny())).returns((file: string) => Promise.resolve(file === expectedCodnaPath)); + fileSystem.setup(fs => fs.fileExists(TypeMoq.It.isAny())).returns((file: string) => Promise.resolve(file === expectedCodnaPath)); const condaExe = await condaService.getCondaFile(); assert.equal(condaExe, expectedCodnaPath, 'Failed to identify conda.exe'); @@ -287,7 +287,7 @@ suite('Interpreters Conda Service', () => { platformService.setup(p => p.isWindows).returns(() => true); processService.setup(p => p.exec(TypeMoq.It.isValue('conda'), TypeMoq.It.isValue(['--version']), TypeMoq.It.isAny())).returns(() => Promise.reject(new Error('Not Found'))); registryInterpreterLocatorService.setup(r => r.getInterpreters(TypeMoq.It.isAny())).returns(() => Promise.resolve(registryInterpreters)); - fileSystem.setup(fs => fs.fileExistsAsync(TypeMoq.It.isAny())).returns((file: string) => Promise.resolve(file === expectedCodnaPath)); + fileSystem.setup(fs => fs.fileExists(TypeMoq.It.isAny())).returns((file: string) => Promise.resolve(file === expectedCodnaPath)); const condaExe = await condaService.getCondaFile(); assert.equal(condaExe, expectedCodnaPath, 'Failed to identify conda.exe'); @@ -307,7 +307,7 @@ suite('Interpreters Conda Service', () => { platformService.setup(p => p.isWindows).returns(() => true); processService.setup(p => p.exec(TypeMoq.It.isValue('conda'), TypeMoq.It.isValue(['--version']), TypeMoq.It.isAny())).returns(() => Promise.reject(new Error('Not Found'))); registryInterpreterLocatorService.setup(r => r.getInterpreters(TypeMoq.It.isAny())).returns(() => Promise.resolve(registryInterpreters)); - fileSystem.setup(fs => fs.fileExistsAsync(TypeMoq.It.isAny())).returns((file: string) => Promise.resolve(false)); + fileSystem.setup(fs => fs.fileExists(TypeMoq.It.isAny())).returns((file: string) => Promise.resolve(false)); const condaExe = await condaService.getCondaFile(); assert.equal(condaExe, 'conda', 'Failed to identify conda.exe'); @@ -344,7 +344,7 @@ suite('Interpreters Conda Service', () => { const expectedCondaLocation = untildify(knownLocation); platformService.setup(p => p.isWindows).returns(() => false); processService.setup(p => p.exec(TypeMoq.It.isValue('conda'), TypeMoq.It.isValue(['--version']), TypeMoq.It.isAny())).returns(() => Promise.reject(new Error('Not Found'))); - fileSystem.setup(fs => fs.fileExistsAsync(TypeMoq.It.isAny())).returns((file: string) => Promise.resolve(file === expectedCondaLocation)); + fileSystem.setup(fs => fs.fileExists(TypeMoq.It.isAny())).returns((file: string) => Promise.resolve(file === expectedCondaLocation)); const condaExe = await condaService.getCondaFile(); assert.equal(condaExe, expectedCondaLocation, 'Failed to identify'); @@ -354,7 +354,7 @@ suite('Interpreters Conda Service', () => { test('Must return \'conda\' if conda could not be found in known locations', async () => { platformService.setup(p => p.isWindows).returns(() => false); processService.setup(p => p.exec(TypeMoq.It.isValue('conda'), TypeMoq.It.isValue(['--version']), TypeMoq.It.isAny())).returns(() => Promise.reject(new Error('Not Found'))); - fileSystem.setup(fs => fs.fileExistsAsync(TypeMoq.It.isAny())).returns((file: string) => Promise.resolve(false)); + fileSystem.setup(fs => fs.fileExists(TypeMoq.It.isAny())).returns((file: string) => Promise.resolve(false)); const condaExe = await condaService.getCondaFile(); assert.equal(condaExe, 'conda', 'Failed to identify'); @@ -470,7 +470,7 @@ suite('Interpreters Conda Service', () => { platformService.setup(p => p.isWindows).returns(() => true); processService.setup(p => p.exec(TypeMoq.It.isValue('conda'), TypeMoq.It.isValue(['--version']), TypeMoq.It.isAny())).returns(() => Promise.reject(new Error('Not Found'))); - fileSystem.setup(fs => fs.fileExistsAsync(TypeMoq.It.isValue(expectedCodaExe))).returns(() => Promise.resolve(true)); + fileSystem.setup(fs => fs.fileExists(TypeMoq.It.isValue(expectedCodaExe))).returns(() => Promise.resolve(true)); registryInterpreterLocatorService.setup(r => r.getInterpreters(TypeMoq.It.isAny())).returns(() => Promise.resolve(registryInterpreters)); const condaExe = await condaService.getCondaFile(); @@ -485,7 +485,7 @@ suite('Interpreters Conda Service', () => { test('isAvailable will return false if conda is not available', async () => { processService.setup(p => p.exec(TypeMoq.It.isValue('conda'), TypeMoq.It.isValue(['--version']), TypeMoq.It.isAny())).returns(() => Promise.reject(new Error('not found'))); - fileSystem.setup(fs => fs.fileExistsAsync(TypeMoq.It.isAny())).returns(() => Promise.resolve(false)); + fileSystem.setup(fs => fs.fileExists(TypeMoq.It.isAny())).returns(() => Promise.resolve(false)); platformService.setup(p => p.isWindows).returns(() => false); const isAvailable = await condaService.isCondaAvailable(); @@ -508,7 +508,7 @@ suite('Interpreters Conda Service', () => { test('isCondaInCurrentPath will return false if conda is not available', async () => { processService.setup(p => p.exec(TypeMoq.It.isValue('conda'), TypeMoq.It.isValue(['--version']), TypeMoq.It.isAny())).returns(() => Promise.reject(new Error('not found'))); - fileSystem.setup(fs => fs.fileExistsAsync(TypeMoq.It.isAny())).returns(() => Promise.resolve(false)); + fileSystem.setup(fs => fs.fileExists(TypeMoq.It.isAny())).returns(() => Promise.resolve(false)); platformService.setup(p => p.isWindows).returns(() => false); const isAvailable = await condaService.isCondaInCurrentPath(); @@ -531,17 +531,17 @@ suite('Interpreters Conda Service', () => { } test('Fails to identify an environment as a conda env (windows)', async () => { const pythonPath = path.join('c', 'users', 'xyz', '.conda', 'envs', 'one', 'python.exe'); - fileSystem.setup(f => f.directoryExistsAsync(TypeMoq.It.isValue(path.join(path.dirname(pythonPath), 'conda-meta')))).returns(() => Promise.resolve(true)); + fileSystem.setup(f => f.directoryExists(TypeMoq.It.isValue(path.join(path.dirname(pythonPath), 'conda-meta')))).returns(() => Promise.resolve(true)); await testFailureOfGettingCondaEnvironments(true, false, false, pythonPath); }); test('Fails to identify an environment as a conda env (linux)', async () => { const pythonPath = path.join('c', 'users', 'xyz', '.conda', 'envs', 'one', 'python'); - fileSystem.setup(f => f.directoryExistsAsync(TypeMoq.It.isValue(path.join(path.dirname(pythonPath), 'conda-meta')))).returns(() => Promise.resolve(true)); + fileSystem.setup(f => f.directoryExists(TypeMoq.It.isValue(path.join(path.dirname(pythonPath), 'conda-meta')))).returns(() => Promise.resolve(true)); await testFailureOfGettingCondaEnvironments(false, false, true, pythonPath); }); test('Fails to identify an environment as a conda env (osx)', async () => { const pythonPath = path.join('c', 'users', 'xyz', '.conda', 'envs', 'one', 'python'); - fileSystem.setup(f => f.directoryExistsAsync(TypeMoq.It.isValue(path.join(path.dirname(pythonPath), 'conda-meta')))).returns(() => Promise.resolve(true)); + fileSystem.setup(f => f.directoryExists(TypeMoq.It.isValue(path.join(path.dirname(pythonPath), 'conda-meta')))).returns(() => Promise.resolve(true)); await testFailureOfGettingCondaEnvironments(false, true, false, pythonPath); }); }); diff --git a/src/test/interpreters/currentPathService.test.ts b/src/test/interpreters/currentPathService.test.ts index 19e44c6eca76..dec8298fb205 100644 --- a/src/test/interpreters/currentPathService.test.ts +++ b/src/test/interpreters/currentPathService.test.ts @@ -65,10 +65,10 @@ suite('Interpreters CurrentPath Service', () => { processService.setup(p => p.exec(TypeMoq.It.isValue('python2'), TypeMoq.It.isValue(execArgs), TypeMoq.It.isAny())).returns(() => Promise.resolve({ stdout: 'c:/python2' })).verifiable(TypeMoq.Times.once()); processService.setup(p => p.exec(TypeMoq.It.isValue('python3'), TypeMoq.It.isValue(execArgs), TypeMoq.It.isAny())).returns(() => Promise.resolve({ stdout: 'c:/python3' })).verifiable(TypeMoq.Times.once()); - fileSystem.setup(fs => fs.fileExistsAsync(TypeMoq.It.isValue('c:/root:python'))).returns(() => Promise.resolve(true)).verifiable(TypeMoq.Times.once()); - fileSystem.setup(fs => fs.fileExistsAsync(TypeMoq.It.isValue('c:/python1'))).returns(() => Promise.resolve(false)).verifiable(TypeMoq.Times.once()); - fileSystem.setup(fs => fs.fileExistsAsync(TypeMoq.It.isValue('c:/python2'))).returns(() => Promise.resolve(false)).verifiable(TypeMoq.Times.once()); - fileSystem.setup(fs => fs.fileExistsAsync(TypeMoq.It.isValue('c:/python3'))).returns(() => Promise.resolve(true)).verifiable(TypeMoq.Times.once()); + fileSystem.setup(fs => fs.fileExists(TypeMoq.It.isValue('c:/root:python'))).returns(() => Promise.resolve(true)).verifiable(TypeMoq.Times.once()); + fileSystem.setup(fs => fs.fileExists(TypeMoq.It.isValue('c:/python1'))).returns(() => Promise.resolve(false)).verifiable(TypeMoq.Times.once()); + fileSystem.setup(fs => fs.fileExists(TypeMoq.It.isValue('c:/python2'))).returns(() => Promise.resolve(false)).verifiable(TypeMoq.Times.once()); + fileSystem.setup(fs => fs.fileExists(TypeMoq.It.isValue('c:/python3'))).returns(() => Promise.resolve(true)).verifiable(TypeMoq.Times.once()); const interpreters = await currentPathService.getInterpreters(); processService.verifyAll(); diff --git a/src/test/interpreters/display.test.ts b/src/test/interpreters/display.test.ts index fad85341c2a4..2d9d212d41a5 100644 --- a/src/test/interpreters/display.test.ts +++ b/src/test/interpreters/display.test.ts @@ -149,7 +149,7 @@ suite('Interpreters Display', () => { interpreterService.setup(i => i.getActiveInterpreter(TypeMoq.It.isValue(workspaceFolder))).returns(() => Promise.resolve(undefined)); configurationService.setup(c => c.getSettings(TypeMoq.It.isAny())).returns(() => pythonSettings.object); pythonSettings.setup(p => p.pythonPath).returns(() => pythonPath); - fileSystem.setup(f => f.fileExistsAsync(TypeMoq.It.isValue(pythonPath))).returns(() => Promise.resolve(false)); + fileSystem.setup(f => f.fileExists(TypeMoq.It.isValue(pythonPath))).returns(() => Promise.resolve(false)); const defaultDisplayName = `${path.basename(pythonPath)} [Environment]`; versionProvider.setup(v => v.getVersion(TypeMoq.It.isValue(pythonPath), TypeMoq.It.isAny())).returns(() => Promise.resolve(defaultDisplayName)); virtualEnvMgr.setup(v => v.getEnvironmentName(TypeMoq.It.isValue(pythonPath))).returns(() => Promise.resolve('')); @@ -169,7 +169,7 @@ suite('Interpreters Display', () => { interpreterService.setup(i => i.getActiveInterpreter(TypeMoq.It.isValue(workspaceFolder))).returns(() => Promise.resolve(undefined)); configurationService.setup(c => c.getSettings(TypeMoq.It.isAny())).returns(() => pythonSettings.object); pythonSettings.setup(p => p.pythonPath).returns(() => pythonPath); - fileSystem.setup(f => f.fileExistsAsync(TypeMoq.It.isValue(pythonPath))).returns(() => Promise.resolve(true)); + fileSystem.setup(f => f.fileExists(TypeMoq.It.isValue(pythonPath))).returns(() => Promise.resolve(true)); const defaultDisplayName = `${path.basename(pythonPath)} [Environment]`; versionProvider.setup(v => v.getVersion(TypeMoq.It.isValue(pythonPath), TypeMoq.It.isAny())).returns(() => Promise.resolve(defaultDisplayName)); // tslint:disable-next-line:no-any @@ -190,7 +190,7 @@ suite('Interpreters Display', () => { interpreterService.setup(i => i.getActiveInterpreter(TypeMoq.It.isValue(workspaceFolder))).returns(() => Promise.resolve(undefined)); configurationService.setup(c => c.getSettings(TypeMoq.It.isAny())).returns(() => pythonSettings.object); pythonSettings.setup(p => p.pythonPath).returns(() => pythonPath); - fileSystem.setup(f => f.fileExistsAsync(TypeMoq.It.isValue(pythonPath))).returns(() => Promise.resolve(true)); + fileSystem.setup(f => f.fileExists(TypeMoq.It.isValue(pythonPath))).returns(() => Promise.resolve(true)); const displayName = 'Version from Interperter'; versionProvider.setup(v => v.getVersion(TypeMoq.It.isValue(pythonPath), TypeMoq.It.isAny())).returns(() => Promise.resolve(displayName)); // tslint:disable-next-line:no-any diff --git a/src/test/interpreters/pipEnvService.test.ts b/src/test/interpreters/pipEnvService.test.ts index 4571dd14b939..b32b6c4c74a3 100644 --- a/src/test/interpreters/pipEnvService.test.ts +++ b/src/test/interpreters/pipEnvService.test.ts @@ -85,7 +85,7 @@ suite('Interpreters - PipEnv', () => { const env = {}; envVarsProvider.setup(e => e.getEnvironmentVariables(TypeMoq.It.isAny())).returns(() => Promise.resolve({})).verifiable(TypeMoq.Times.once()); currentProcess.setup(c => c.env).returns(() => env); - fileSystem.setup(fs => fs.fileExistsAsync(TypeMoq.It.isValue(path.join(rootWorkspace, 'Pipfile')))).returns(() => Promise.resolve(false)).verifiable(TypeMoq.Times.once()); + fileSystem.setup(fs => fs.fileExists(TypeMoq.It.isValue(path.join(rootWorkspace, 'Pipfile')))).returns(() => Promise.resolve(false)).verifiable(TypeMoq.Times.once()); const environments = await pipEnvService.getInterpreters(resource); expect(environments).to.be.deep.equal([]); @@ -95,7 +95,7 @@ suite('Interpreters - PipEnv', () => { const env = {}; currentProcess.setup(c => c.env).returns(() => env); processService.setup(p => p.exec(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => Promise.reject('')); - fileSystem.setup(fs => fs.fileExistsAsync(TypeMoq.It.isValue(path.join(rootWorkspace, 'Pipfile')))).returns(() => Promise.resolve(true)); + fileSystem.setup(fs => fs.fileExists(TypeMoq.It.isValue(path.join(rootWorkspace, 'Pipfile')))).returns(() => Promise.resolve(true)); appShell.setup(a => a.showWarningMessage(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => Promise.resolve('')).verifiable(TypeMoq.Times.once()); const environments = await pipEnvService.getInterpreters(resource); @@ -107,7 +107,7 @@ suite('Interpreters - PipEnv', () => { const env = {}; currentProcess.setup(c => c.env).returns(() => env); processService.setup(p => p.exec(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => Promise.resolve({ stderr: 'PipEnv Failed', stdout: '' })); - fileSystem.setup(fs => fs.fileExistsAsync(TypeMoq.It.isValue(path.join(rootWorkspace, 'Pipfile')))).returns(() => Promise.resolve(true)); + fileSystem.setup(fs => fs.fileExists(TypeMoq.It.isValue(path.join(rootWorkspace, 'Pipfile')))).returns(() => Promise.resolve(true)); appShell.setup(a => a.showWarningMessage(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => Promise.resolve('')).verifiable(TypeMoq.Times.once()); const environments = await pipEnvService.getInterpreters(resource); @@ -120,8 +120,8 @@ suite('Interpreters - PipEnv', () => { currentProcess.setup(c => c.env).returns(() => env); processService.setup(p => p.exec(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => Promise.resolve({ stdout: venvDir })); interpreterVersionService.setup(v => v.getVersion(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => Promise.resolve('xyz')); - fileSystem.setup(fs => fs.fileExistsAsync(TypeMoq.It.isValue(path.join(rootWorkspace, 'Pipfile')))).returns(() => Promise.resolve(true)).verifiable(); - fileSystem.setup(fs => fs.directoryExistsAsync(TypeMoq.It.isValue(venvDir))).returns(() => Promise.resolve(true)).verifiable(); + fileSystem.setup(fs => fs.fileExists(TypeMoq.It.isValue(path.join(rootWorkspace, 'Pipfile')))).returns(() => Promise.resolve(true)).verifiable(); + fileSystem.setup(fs => fs.directoryExists(TypeMoq.It.isValue(venvDir))).returns(() => Promise.resolve(true)).verifiable(); const environments = await pipEnvService.getInterpreters(resource); expect(environments).to.be.lengthOf(1); @@ -136,9 +136,9 @@ suite('Interpreters - PipEnv', () => { currentProcess.setup(c => c.env).returns(() => env); processService.setup(p => p.exec(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => Promise.resolve({ stdout: venvDir })); interpreterVersionService.setup(v => v.getVersion(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => Promise.resolve('xyz')); - fileSystem.setup(fs => fs.fileExistsAsync(TypeMoq.It.isValue(path.join(rootWorkspace, 'Pipfile')))).returns(() => Promise.resolve(false)).verifiable(TypeMoq.Times.never()); - fileSystem.setup(fs => fs.fileExistsAsync(TypeMoq.It.isValue(path.join(rootWorkspace, envPipFile)))).returns(() => Promise.resolve(true)).verifiable(TypeMoq.Times.once()); - fileSystem.setup(fs => fs.directoryExistsAsync(TypeMoq.It.isValue(venvDir))).returns(() => Promise.resolve(true)).verifiable(); + fileSystem.setup(fs => fs.fileExists(TypeMoq.It.isValue(path.join(rootWorkspace, 'Pipfile')))).returns(() => Promise.resolve(false)).verifiable(TypeMoq.Times.never()); + fileSystem.setup(fs => fs.fileExists(TypeMoq.It.isValue(path.join(rootWorkspace, envPipFile)))).returns(() => Promise.resolve(true)).verifiable(TypeMoq.Times.once()); + fileSystem.setup(fs => fs.directoryExists(TypeMoq.It.isValue(venvDir))).returns(() => Promise.resolve(true)).verifiable(); const environments = await pipEnvService.getInterpreters(resource); expect(environments).to.be.lengthOf(1); diff --git a/src/test/linters/lint.args.test.ts b/src/test/linters/lint.args.test.ts index 780aefb2fe61..4475ef2d94bf 100644 --- a/src/test/linters/lint.args.test.ts +++ b/src/test/linters/lint.args.test.ts @@ -52,7 +52,7 @@ suite('Linting - Arguments', () => { outputChannel = TypeMoq.Mock.ofType(); const fs = TypeMoq.Mock.ofType(); - fs.setup(x => x.fileExistsAsync(TypeMoq.It.isAny())).returns(() => new Promise((resolve, reject) => resolve(true))); + fs.setup(x => x.fileExists(TypeMoq.It.isAny())).returns(() => new Promise((resolve, reject) => resolve(true))); fs.setup(x => x.arePathsSame(TypeMoq.It.isAnyString(), TypeMoq.It.isAnyString())).returns(() => true); serviceManager.addSingletonInstance(IFileSystem, fs.object); diff --git a/src/test/linters/lint.provider.test.ts b/src/test/linters/lint.provider.test.ts index 023ee86223be..ee893b73db8f 100644 --- a/src/test/linters/lint.provider.test.ts +++ b/src/test/linters/lint.provider.test.ts @@ -39,7 +39,7 @@ suite('Linting - Provider', () => { context = TypeMoq.Mock.ofType(); fs = TypeMoq.Mock.ofType(); - fs.setup(x => x.fileExistsAsync(TypeMoq.It.isAny())).returns(() => new Promise((resolve, reject) => resolve(true))); + fs.setup(x => x.fileExists(TypeMoq.It.isAny())).returns(() => new Promise((resolve, reject) => resolve(true))); fs.setup(x => x.arePathsSame(TypeMoq.It.isAnyString(), TypeMoq.It.isAnyString())).returns(() => true); serviceManager.addSingletonInstance(IFileSystem, fs.object); diff --git a/src/test/linters/lintengine.test.ts b/src/test/linters/lintengine.test.ts index e11c2dcdc5c4..92bb25d17ba4 100644 --- a/src/test/linters/lintengine.test.ts +++ b/src/test/linters/lintengine.test.ts @@ -106,7 +106,7 @@ suite('Linting - LintingEngine', () => { }); function mockTextDocument(fileName: string, language: string, exists: boolean, ignorePattern: string[] = [], scheme?: string): TextDocument { - fileSystem.setup(x => x.fileExistsAsync(TypeMoq.It.isAnyString())).returns(() => Promise.resolve(exists)); + fileSystem.setup(x => x.fileExists(TypeMoq.It.isAnyString())).returns(() => Promise.resolve(exists)); lintSettings.setup(l => l.ignorePatterns).returns(() => ignorePattern); settings.setup(x => x.linting).returns(() => lintSettings.object); diff --git a/src/test/linters/pylint.test.ts b/src/test/linters/pylint.test.ts index ca51e7150834..66bc7fdb956d 100644 --- a/src/test/linters/pylint.test.ts +++ b/src/test/linters/pylint.test.ts @@ -63,11 +63,11 @@ suite('Linting - Pylint', () => { }); test('pylintrc in the file folder', async () => { - fileSystem.setup(x => x.fileExistsAsync(path.join(basePath, pylintrc))).returns(() => Promise.resolve(true)); + fileSystem.setup(x => x.fileExists(path.join(basePath, pylintrc))).returns(() => Promise.resolve(true)); let result = await Pylint.hasConfigurationFile(fileSystem.object, basePath, platformService.object); expect(result).to.be.equal(true, `'${pylintrc}' not detected in the file folder.`); - fileSystem.setup(x => x.fileExistsAsync(path.join(basePath, dotPylintrc))).returns(() => Promise.resolve(true)); + fileSystem.setup(x => x.fileExists(path.join(basePath, dotPylintrc))).returns(() => Promise.resolve(true)); result = await Pylint.hasConfigurationFile(fileSystem.object, basePath, platformService.object); expect(result).to.be.equal(true, `'${dotPylintrc}' not detected in the file folder.`); }); @@ -77,10 +77,10 @@ suite('Linting - Pylint', () => { const module3 = path.join('/user/a/b', '__init__.py'); const rc = path.join('/user/a/b/c', pylintrc); - fileSystem.setup(x => x.fileExistsAsync(module1)).returns(() => Promise.resolve(true)); - fileSystem.setup(x => x.fileExistsAsync(module2)).returns(() => Promise.resolve(true)); - fileSystem.setup(x => x.fileExistsAsync(module3)).returns(() => Promise.resolve(true)); - fileSystem.setup(x => x.fileExistsAsync(rc)).returns(() => Promise.resolve(true)); + fileSystem.setup(x => x.fileExists(module1)).returns(() => Promise.resolve(true)); + fileSystem.setup(x => x.fileExists(module2)).returns(() => Promise.resolve(true)); + fileSystem.setup(x => x.fileExists(module3)).returns(() => Promise.resolve(true)); + fileSystem.setup(x => x.fileExists(rc)).returns(() => Promise.resolve(true)); const result = await Pylint.hasConfigurationFile(fileSystem.object, basePath, platformService.object); expect(result).to.be.equal(true, `'${pylintrc}' not detected in the module tree.`); @@ -92,10 +92,10 @@ suite('Linting - Pylint', () => { const module3 = path.join('/user/a/b', '__init__.py'); const rc = path.join('/user/a/b/c', pylintrc); - fileSystem.setup(x => x.fileExistsAsync(module1)).returns(() => Promise.resolve(true)); - fileSystem.setup(x => x.fileExistsAsync(module2)).returns(() => Promise.resolve(true)); - fileSystem.setup(x => x.fileExistsAsync(module3)).returns(() => Promise.resolve(true)); - fileSystem.setup(x => x.fileExistsAsync(rc)).returns(() => Promise.resolve(true)); + fileSystem.setup(x => x.fileExists(module1)).returns(() => Promise.resolve(true)); + fileSystem.setup(x => x.fileExists(module2)).returns(() => Promise.resolve(true)); + fileSystem.setup(x => x.fileExists(module3)).returns(() => Promise.resolve(true)); + fileSystem.setup(x => x.fileExists(rc)).returns(() => Promise.resolve(true)); const result = await Pylint.hasConfigurationFile(fileSystem.object, basePath, platformService.object); expect(result).to.be.equal(true, `'${dotPylintrc}' not detected in the module tree.`); @@ -103,7 +103,7 @@ suite('Linting - Pylint', () => { test('.pylintrc up the ~ folder', async () => { const home = os.homedir(); const rc = path.join(home, dotPylintrc); - fileSystem.setup(x => x.fileExistsAsync(rc)).returns(() => Promise.resolve(true)); + fileSystem.setup(x => x.fileExists(rc)).returns(() => Promise.resolve(true)); const result = await Pylint.hasConfigurationFile(fileSystem.object, basePath, platformService.object); expect(result).to.be.equal(true, `'${dotPylintrc}' not detected in the ~ folder.`); @@ -111,14 +111,14 @@ suite('Linting - Pylint', () => { test('pylintrc up the ~/.config folder', async () => { const home = os.homedir(); const rc = path.join(home, '.config', pylintrc); - fileSystem.setup(x => x.fileExistsAsync(rc)).returns(() => Promise.resolve(true)); + fileSystem.setup(x => x.fileExists(rc)).returns(() => Promise.resolve(true)); const result = await Pylint.hasConfigurationFile(fileSystem.object, basePath, platformService.object); expect(result).to.be.equal(true, `'${pylintrc}' not detected in the ~/.config folder.`); }); test('pylintrc in the /etc folder', async () => { const rc = path.join('/etc', pylintrc); - fileSystem.setup(x => x.fileExistsAsync(rc)).returns(() => Promise.resolve(true)); + fileSystem.setup(x => x.fileExists(rc)).returns(() => Promise.resolve(true)); const result = await Pylint.hasConfigurationFile(fileSystem.object, basePath, platformService.object); expect(result).to.be.equal(true, `'${pylintrc}' not detected in the /etc folder.`); @@ -127,7 +127,7 @@ suite('Linting - Pylint', () => { const root = '/user/a'; const midFolder = '/user/a/b'; fileSystem - .setup(x => x.fileExistsAsync(path.join(midFolder, pylintrc))) + .setup(x => x.fileExists(path.join(midFolder, pylintrc))) .returns(() => Promise.resolve(true)); const result = await Pylint.hasConfigrationFileInWorkspace(fileSystem.object, basePath, root); @@ -136,7 +136,7 @@ suite('Linting - Pylint', () => { test('minArgs - pylintrc between the file and the workspace root', async () => { fileSystem - .setup(x => x.fileExistsAsync(path.join('/user/a/b', pylintrc))) + .setup(x => x.fileExists(path.join('/user/a/b', pylintrc))) .returns(() => Promise.resolve(true)); await testPylintArguments('/user/a/b/c', '/user/a', false); @@ -149,7 +149,7 @@ suite('Linting - Pylint', () => { test('minArgs - pylintrc next to the file', async () => { const fileFolder = '/user/a/b/c'; fileSystem - .setup(x => x.fileExistsAsync(path.join(fileFolder, pylintrc))) + .setup(x => x.fileExists(path.join(fileFolder, pylintrc))) .returns(() => Promise.resolve(true)); await testPylintArguments(fileFolder, '/user/a', false); @@ -158,7 +158,7 @@ suite('Linting - Pylint', () => { test('minArgs - pylintrc at the workspace root', async () => { const root = '/user/a'; fileSystem - .setup(x => x.fileExistsAsync(path.join(root, pylintrc))) + .setup(x => x.fileExists(path.join(root, pylintrc))) .returns(() => Promise.resolve(true)); await testPylintArguments('/user/a/b/c', root, false); diff --git a/src/test/signature/signature.ptvs.test.ts b/src/test/signature/signature.ptvs.test.ts index 8e2f630756d4..823433b50093 100644 --- a/src/test/signature/signature.ptvs.test.ts +++ b/src/test/signature/signature.ptvs.test.ts @@ -95,7 +95,7 @@ suite('Signatures (Analysis Engine)', () => { return; } const expected = [ - new SignatureHelpResult(0, 5, 0, 0, null), + new SignatureHelpResult(0, 5, 1, -1, null), new SignatureHelpResult(0, 6, 1, 0, 'value'), new SignatureHelpResult(0, 7, 1, 0, 'value'), new SignatureHelpResult(0, 8, 1, 1, '...'),