diff --git a/src/client/activation/downloader.ts b/src/client/activation/downloader.ts index 8b7ed686babe..0bb6b9dbcf20 100644 --- a/src/client/activation/downloader.ts +++ b/src/client/activation/downloader.ts @@ -20,10 +20,10 @@ const StreamZip = require('node-stream-zip'); const downloadUriPrefix = 'https://pvsc.blob.core.windows.net/python-language-server'; const downloadBaseFileName = 'Python-Language-Server'; -const downloadVersion = '0.1.0'; +const downloadVersion = '0.1.18204.3'; const downloadFileExtension = '.nupkg'; -const DownloadLinks = { +export const DownloadLinks = { [PlatformName.Windows32Bit]: `${downloadUriPrefix}/${downloadBaseFileName}-${PlatformName.Windows32Bit}.${downloadVersion}${downloadFileExtension}`, [PlatformName.Windows64Bit]: `${downloadUriPrefix}/${downloadBaseFileName}-${PlatformName.Windows64Bit}.${downloadVersion}${downloadFileExtension}`, [PlatformName.Linux64Bit]: `${downloadUriPrefix}/${downloadBaseFileName}-${PlatformName.Linux64Bit}.${downloadVersion}${downloadFileExtension}`, diff --git a/src/client/activation/platformData.ts b/src/client/activation/platformData.ts index 8564b8625b44..39cce79cc82f 100644 --- a/src/client/activation/platformData.ts +++ b/src/client/activation/platformData.ts @@ -16,6 +16,12 @@ export enum PlatformName { Linux64Bit = 'linux-x64' } +export enum PlatformLSExecutables { + Windows = 'Microsoft.Python.LanguageServer.exe', + MacOS = 'Microsoft.Python.LanguageServer', + Linux = 'Microsoft.Python.LanguageServer' +} + export class PlatformData { constructor(private platform: IPlatformService, fs: IFileSystem) { } public async getPlatformName(): Promise { @@ -39,9 +45,15 @@ export class PlatformData { } public getEngineExecutableName(): string { - return this.platform.isWindows - ? 'Microsoft.Python.LanguageServer.exe' - : 'Microsoft.Python.LanguageServer.LanguageServer'; + if (this.platform.isWindows) { + return PlatformLSExecutables.Windows; + } else if (this.platform.isLinux) { + return PlatformLSExecutables.Linux; + } else if (this.platform.isMac) { + return PlatformLSExecutables.MacOS; + } else { + return 'unknown-platform'; + } } public async getExpectedHash(): Promise { diff --git a/src/client/interpreter/interpreterVersion.ts b/src/client/interpreter/interpreterVersion.ts index 4b00ddadead2..2bfb72c4f98f 100644 --- a/src/client/interpreter/interpreterVersion.ts +++ b/src/client/interpreter/interpreterVersion.ts @@ -3,7 +3,7 @@ import '../common/extensions'; import { IProcessServiceFactory } from '../common/process/types'; import { IInterpreterVersionService } from './contracts'; -export const PIP_VERSION_REGEX = '\\d+\\.\\d+(\\.\\d+)'; +export const PIP_VERSION_REGEX = '\\d+\\.\\d+(\\.\\d+)?'; @injectable() export class InterpreterVersionService implements IInterpreterVersionService { diff --git a/src/test/activation/downloader.unit.test.ts b/src/test/activation/downloader.unit.test.ts index c75b5e3b3d49..edee2e828f3c 100644 --- a/src/test/activation/downloader.unit.test.ts +++ b/src/test/activation/downloader.unit.test.ts @@ -7,16 +7,12 @@ import * as assert from 'assert'; import * as TypeMoq from 'typemoq'; -import { LanguageServerDownloader } from '../../client/activation/downloader'; +import { DownloadLinks, LanguageServerDownloader } from '../../client/activation/downloader'; +import { PlatformName } from '../../client/activation/platformData'; import { IFileSystem, IPlatformService } from '../../client/common/platform/types'; import { IOutputChannel } from '../../client/common/types'; import { IServiceContainer } from '../../client/ioc/types'; -const downloadUriPrefix = 'https://pvsc.blob.core.windows.net/python-language-server'; -const downloadBaseFileName = 'Python-Language-Server'; -const downloadVersion = '0.1.0'; -const downloadFileExtension = '.nupkg'; - suite('Activation - Downloader', () => { let languageServerDownloader: LanguageServerDownloader; let serviceContainer: TypeMoq.IMock; @@ -48,21 +44,21 @@ suite('Activation - Downloader', () => { test('Windows 32Bit', async () => { setupPlatform({ windows: true }); const link = await languageServerDownloader.getDownloadUri(); - assert.equal(link, `${downloadUriPrefix}/${downloadBaseFileName}-win-x86.${downloadVersion}${downloadFileExtension}`); + assert.equal(link, DownloadLinks[PlatformName.Windows32Bit]); }); test('Windows 64Bit', async () => { setupPlatform({ windows: true, is64Bit: true }); const link = await languageServerDownloader.getDownloadUri(); - assert.equal(link, `${downloadUriPrefix}/${downloadBaseFileName}-win-x64.${downloadVersion}${downloadFileExtension}`); + assert.equal(link, DownloadLinks[PlatformName.Windows64Bit]); }); test('Mac 64Bit', async () => { setupPlatform({ mac: true, is64Bit: true }); const link = await languageServerDownloader.getDownloadUri(); - assert.equal(link, `${downloadUriPrefix}/${downloadBaseFileName}-osx-x64.${downloadVersion}${downloadFileExtension}`); + assert.equal(link, DownloadLinks[PlatformName.Mac64Bit]); }); test('Linux 64Bit', async () => { setupPlatform({ linux: true, is64Bit: true }); const link = await languageServerDownloader.getDownloadUri(); - assert.equal(link, `${downloadUriPrefix}/${downloadBaseFileName}-linux-x64.${downloadVersion}${downloadFileExtension}`); + assert.equal(link, DownloadLinks[PlatformName.Linux64Bit]); }); }); diff --git a/src/test/activation/platformData.unit.test.ts b/src/test/activation/platformData.unit.test.ts index 80ce2ce494be..0044c27b0182 100644 --- a/src/test/activation/platformData.unit.test.ts +++ b/src/test/activation/platformData.unit.test.ts @@ -4,7 +4,7 @@ // tslint:disable:no-unused-variable import * as assert from 'assert'; import * as TypeMoq from 'typemoq'; -import { PlatformData } from '../../client/activation/platformData'; +import { PlatformData, PlatformLSExecutables } from '../../client/activation/platformData'; import { IFileSystem, IPlatformService } from '../../client/common/platform/types'; const testDataWinMac = [ @@ -24,8 +24,9 @@ const testDataLinux = [ ]; const testDataModuleName = [ - { isWindows: true, expectedName: 'Microsoft.Python.LanguageServer.exe' }, - { isWindows: false, expectedName: 'Microsoft.Python.LanguageServer.LanguageServer' } + { isWindows: true, isMac: false, isLinux: false, expectedName: PlatformLSExecutables.Windows }, + { isWindows: false, isMac: true, isLinux: false, expectedName: PlatformLSExecutables.MacOS }, + { isWindows: false, isMac: false, isLinux: true, expectedName: PlatformLSExecutables.Linux } ]; // tslint:disable-next-line:max-func-body-length @@ -70,6 +71,8 @@ suite('Activation - platform data', () => { for (const t of testDataModuleName) { const platformService = TypeMoq.Mock.ofType(); platformService.setup(x => x.isWindows).returns(() => t.isWindows); + platformService.setup(x => x.isLinux).returns(() => t.isLinux); + platformService.setup(x => x.isMac).returns(() => t.isMac); const fs = TypeMoq.Mock.ofType(); const pd = new PlatformData(platformService.object, fs.object); diff --git a/src/test/interpreters/interpreterVersion.test.ts b/src/test/interpreters/interpreterVersion.test.ts index 6b9c9da81ad7..63b0dc45b3b9 100644 --- a/src/test/interpreters/interpreterVersion.test.ts +++ b/src/test/interpreters/interpreterVersion.test.ts @@ -43,7 +43,7 @@ suite('Interpreters display version', () => { const pyVersion = await interpreterVersion.getVersion('INVALID_INTERPRETER', 'DEFAULT_TEST_VALUE'); assert.equal(pyVersion, 'DEFAULT_TEST_VALUE', 'Incorrect version'); }); - test('Must return the pip Version', async () => { + test('Must return the pip Version.', async () => { const pythonProcess = await ioc.serviceContainer.get(IProcessServiceFactory).create(); const result = await pythonProcess.exec(PYTHON_PATH, ['-m', 'pip', '--version'], { cwd: __dirname, mergeStdOutErr: true }); const output = result.stdout.splitLines()[0]; @@ -60,7 +60,7 @@ suite('Interpreters display version', () => { // tslint:disable-next-line:no-non-null-assertion await expect(pipVersionPromise).to.eventually.equal(matches![0].trim()); }); - test('Must throw an exceptionn when pip version cannot be determine', async () => { + test('Must throw an exception when pip version cannot be determined', async () => { const interpreterVersion = ioc.serviceContainer.get(IInterpreterVersionService); const pipVersionPromise = interpreterVersion.getPipVersion('INVALID_INTERPRETER'); await expect(pipVersionPromise).to.be.rejectedWith();