From cd03e46744b2d07f71486ea39862bb6ed282cd6d Mon Sep 17 00:00:00 2001 From: Derek Keeler Date: Mon, 23 Jul 2018 15:06:54 -0600 Subject: [PATCH 1/5] Update to latest Language Server - change the download version to latest build - change the name of the executable bit of the LS --- src/client/activation/downloader.ts | 2 +- src/client/activation/platformData.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client/activation/downloader.ts b/src/client/activation/downloader.ts index 8b7ed686babe..a9713ad5510d 100644 --- a/src/client/activation/downloader.ts +++ b/src/client/activation/downloader.ts @@ -20,7 +20,7 @@ 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 = { diff --git a/src/client/activation/platformData.ts b/src/client/activation/platformData.ts index 8564b8625b44..0d7d30283476 100644 --- a/src/client/activation/platformData.ts +++ b/src/client/activation/platformData.ts @@ -41,7 +41,7 @@ export class PlatformData { public getEngineExecutableName(): string { return this.platform.isWindows ? 'Microsoft.Python.LanguageServer.exe' - : 'Microsoft.Python.LanguageServer.LanguageServer'; + : 'Microsoft.Python.LanguageServer'; } public async getExpectedHash(): Promise { From e2432cac174a5042b9af2e38842747e72d1e23ca Mon Sep 17 00:00:00 2001 From: Derek Keeler Date: Mon, 23 Jul 2018 16:06:25 -0600 Subject: [PATCH 2/5] Fix unit tests - Remove hardcoded strings causing issues - Expose information from downloader/platform - Update tests for explicit OS types --- src/client/activation/downloader.ts | 8 ++++---- src/client/activation/platformData.ts | 18 +++++++++++++++--- src/test/activation/downloader.unit.test.ts | 16 ++++++---------- src/test/activation/platformData.unit.test.ts | 9 ++++++--- 4 files changed, 31 insertions(+), 20 deletions(-) diff --git a/src/client/activation/downloader.ts b/src/client/activation/downloader.ts index a9713ad5510d..f2280899f09f 100644 --- a/src/client/activation/downloader.ts +++ b/src/client/activation/downloader.ts @@ -18,10 +18,10 @@ import { PlatformData, PlatformName } from './platformData'; // tslint:disable-next-line:no-require-imports no-var-requires 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.18204.3'; -const downloadFileExtension = '.nupkg'; +export const downloadUriPrefix = 'https://pvsc.blob.core.windows.net/python-language-server'; +export const downloadBaseFileName = 'Python-Language-Server'; +export const downloadVersion = '0.1.18204.3'; +export const downloadFileExtension = '.nupkg'; const DownloadLinks = { [PlatformName.Windows32Bit]: `${downloadUriPrefix}/${downloadBaseFileName}-${PlatformName.Windows32Bit}.${downloadVersion}${downloadFileExtension}`, diff --git a/src/client/activation/platformData.ts b/src/client/activation/platformData.ts index 0d7d30283476..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'; + 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/test/activation/downloader.unit.test.ts b/src/test/activation/downloader.unit.test.ts index c75b5e3b3d49..a8dd6b61cc15 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 { downloadBaseFileName, downloadFileExtension, downloadUriPrefix, downloadVersion, 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, `${downloadUriPrefix}/${downloadBaseFileName}-${PlatformName.Windows32Bit}.${downloadVersion}${downloadFileExtension}`); }); 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, `${downloadUriPrefix}/${downloadBaseFileName}-${PlatformName.Windows64Bit}.${downloadVersion}${downloadFileExtension}`); }); 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, `${downloadUriPrefix}/${downloadBaseFileName}-${PlatformName.Mac64Bit}.${downloadVersion}${downloadFileExtension}`); }); 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, `${downloadUriPrefix}/${downloadBaseFileName}-${PlatformName.Linux64Bit}.${downloadVersion}${downloadFileExtension}`); }); }); 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); From 57e9b64ff946944215379dce000a41b8829d00d3 Mon Sep 17 00:00:00 2001 From: Derek Keeler Date: Mon, 23 Jul 2018 17:14:42 -0600 Subject: [PATCH 3/5] Update PIP version regex - make it allow 2, or 3, version segments - handles old M.m.r or new Y.r version patterns --- src/client/interpreter/interpreterVersion.ts | 2 +- src/test/interpreters/interpreterVersion.test.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/client/interpreter/interpreterVersion.ts b/src/client/interpreter/interpreterVersion.ts index 4b00ddadead2..d90b4b5a7011 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+\\.){1,2}\\d+$'; @injectable() export class InterpreterVersionService implements IInterpreterVersionService { 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(); From 33b3a0ff5ea9c2c0f88b7612621b61b048447d9e Mon Sep 17 00:00:00 2001 From: Derek Keeler Date: Mon, 23 Jul 2018 17:45:34 -0600 Subject: [PATCH 4/5] Remove hard-coded strings /and/ formats from tests. --- src/client/activation/downloader.ts | 10 +++++----- src/test/activation/downloader.unit.test.ts | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/client/activation/downloader.ts b/src/client/activation/downloader.ts index f2280899f09f..0bb6b9dbcf20 100644 --- a/src/client/activation/downloader.ts +++ b/src/client/activation/downloader.ts @@ -18,12 +18,12 @@ import { PlatformData, PlatformName } from './platformData'; // tslint:disable-next-line:no-require-imports no-var-requires const StreamZip = require('node-stream-zip'); -export const downloadUriPrefix = 'https://pvsc.blob.core.windows.net/python-language-server'; -export const downloadBaseFileName = 'Python-Language-Server'; -export const downloadVersion = '0.1.18204.3'; -export const downloadFileExtension = '.nupkg'; +const downloadUriPrefix = 'https://pvsc.blob.core.windows.net/python-language-server'; +const downloadBaseFileName = 'Python-Language-Server'; +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/test/activation/downloader.unit.test.ts b/src/test/activation/downloader.unit.test.ts index a8dd6b61cc15..edee2e828f3c 100644 --- a/src/test/activation/downloader.unit.test.ts +++ b/src/test/activation/downloader.unit.test.ts @@ -7,7 +7,7 @@ import * as assert from 'assert'; import * as TypeMoq from 'typemoq'; -import { downloadBaseFileName, downloadFileExtension, downloadUriPrefix, downloadVersion, 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'; @@ -44,21 +44,21 @@ suite('Activation - Downloader', () => { test('Windows 32Bit', async () => { setupPlatform({ windows: true }); const link = await languageServerDownloader.getDownloadUri(); - assert.equal(link, `${downloadUriPrefix}/${downloadBaseFileName}-${PlatformName.Windows32Bit}.${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}-${PlatformName.Windows64Bit}.${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}-${PlatformName.Mac64Bit}.${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}-${PlatformName.Linux64Bit}.${downloadVersion}${downloadFileExtension}`); + assert.equal(link, DownloadLinks[PlatformName.Linux64Bit]); }); }); From 7549082b1c287c20349dcd7acf9a729cb0c25f22 Mon Sep 17 00:00:00 2001 From: Derek Keeler Date: Mon, 23 Jul 2018 18:01:47 -0600 Subject: [PATCH 5/5] Correction to the PIP_VERSION_REGEX - keep it simple, keeler. --- src/client/interpreter/interpreterVersion.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/interpreter/interpreterVersion.ts b/src/client/interpreter/interpreterVersion.ts index d90b4b5a7011..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+\\.){1,2}\\d+$'; +export const PIP_VERSION_REGEX = '\\d+\\.\\d+(\\.\\d+)?'; @injectable() export class InterpreterVersionService implements IInterpreterVersionService {