Skip to content

Commit e56fb1c

Browse files
d3r3kkbrettcannon
authored andcommitted
Update to latest Language Server (#2234)
* Update to latest Language Server - change the download version to latest build - change the name of the executable bit of the LS * Fix unit tests - Remove hardcoded strings causing issues - Expose information from downloader/platform - Update tests for explicit OS types * Update PIP version regex - make it allow 2, or 3, version segments - handles old M.m.r or new Y.r version patterns * Remove hard-coded strings /and/ formats from tests. * Correction to the PIP_VERSION_REGEX - keep it simple, keeler.
1 parent 6af8f99 commit e56fb1c

File tree

6 files changed

+32
-21
lines changed

6 files changed

+32
-21
lines changed

src/client/activation/downloader.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ const StreamZip = require('node-stream-zip');
2020

2121
const downloadUriPrefix = 'https://pvsc.blob.core.windows.net/python-language-server';
2222
const downloadBaseFileName = 'Python-Language-Server';
23-
const downloadVersion = '0.1.0';
23+
const downloadVersion = '0.1.18204.3';
2424
const downloadFileExtension = '.nupkg';
2525

26-
const DownloadLinks = {
26+
export const DownloadLinks = {
2727
[PlatformName.Windows32Bit]: `${downloadUriPrefix}/${downloadBaseFileName}-${PlatformName.Windows32Bit}.${downloadVersion}${downloadFileExtension}`,
2828
[PlatformName.Windows64Bit]: `${downloadUriPrefix}/${downloadBaseFileName}-${PlatformName.Windows64Bit}.${downloadVersion}${downloadFileExtension}`,
2929
[PlatformName.Linux64Bit]: `${downloadUriPrefix}/${downloadBaseFileName}-${PlatformName.Linux64Bit}.${downloadVersion}${downloadFileExtension}`,

src/client/activation/platformData.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ export enum PlatformName {
1616
Linux64Bit = 'linux-x64'
1717
}
1818

19+
export enum PlatformLSExecutables {
20+
Windows = 'Microsoft.Python.LanguageServer.exe',
21+
MacOS = 'Microsoft.Python.LanguageServer',
22+
Linux = 'Microsoft.Python.LanguageServer'
23+
}
24+
1925
export class PlatformData {
2026
constructor(private platform: IPlatformService, fs: IFileSystem) { }
2127
public async getPlatformName(): Promise<PlatformName> {
@@ -39,9 +45,15 @@ export class PlatformData {
3945
}
4046

4147
public getEngineExecutableName(): string {
42-
return this.platform.isWindows
43-
? 'Microsoft.Python.LanguageServer.exe'
44-
: 'Microsoft.Python.LanguageServer.LanguageServer';
48+
if (this.platform.isWindows) {
49+
return PlatformLSExecutables.Windows;
50+
} else if (this.platform.isLinux) {
51+
return PlatformLSExecutables.Linux;
52+
} else if (this.platform.isMac) {
53+
return PlatformLSExecutables.MacOS;
54+
} else {
55+
return 'unknown-platform';
56+
}
4557
}
4658

4759
public async getExpectedHash(): Promise<string> {

src/client/interpreter/interpreterVersion.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import '../common/extensions';
33
import { IProcessServiceFactory } from '../common/process/types';
44
import { IInterpreterVersionService } from './contracts';
55

6-
export const PIP_VERSION_REGEX = '\\d+\\.\\d+(\\.\\d+)';
6+
export const PIP_VERSION_REGEX = '\\d+\\.\\d+(\\.\\d+)?';
77

88
@injectable()
99
export class InterpreterVersionService implements IInterpreterVersionService {

src/test/activation/downloader.unit.test.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,12 @@
77

88
import * as assert from 'assert';
99
import * as TypeMoq from 'typemoq';
10-
import { LanguageServerDownloader } from '../../client/activation/downloader';
10+
import { DownloadLinks, LanguageServerDownloader } from '../../client/activation/downloader';
11+
import { PlatformName } from '../../client/activation/platformData';
1112
import { IFileSystem, IPlatformService } from '../../client/common/platform/types';
1213
import { IOutputChannel } from '../../client/common/types';
1314
import { IServiceContainer } from '../../client/ioc/types';
1415

15-
const downloadUriPrefix = 'https://pvsc.blob.core.windows.net/python-language-server';
16-
const downloadBaseFileName = 'Python-Language-Server';
17-
const downloadVersion = '0.1.0';
18-
const downloadFileExtension = '.nupkg';
19-
2016
suite('Activation - Downloader', () => {
2117
let languageServerDownloader: LanguageServerDownloader;
2218
let serviceContainer: TypeMoq.IMock<IServiceContainer>;
@@ -48,21 +44,21 @@ suite('Activation - Downloader', () => {
4844
test('Windows 32Bit', async () => {
4945
setupPlatform({ windows: true });
5046
const link = await languageServerDownloader.getDownloadUri();
51-
assert.equal(link, `${downloadUriPrefix}/${downloadBaseFileName}-win-x86.${downloadVersion}${downloadFileExtension}`);
47+
assert.equal(link, DownloadLinks[PlatformName.Windows32Bit]);
5248
});
5349
test('Windows 64Bit', async () => {
5450
setupPlatform({ windows: true, is64Bit: true });
5551
const link = await languageServerDownloader.getDownloadUri();
56-
assert.equal(link, `${downloadUriPrefix}/${downloadBaseFileName}-win-x64.${downloadVersion}${downloadFileExtension}`);
52+
assert.equal(link, DownloadLinks[PlatformName.Windows64Bit]);
5753
});
5854
test('Mac 64Bit', async () => {
5955
setupPlatform({ mac: true, is64Bit: true });
6056
const link = await languageServerDownloader.getDownloadUri();
61-
assert.equal(link, `${downloadUriPrefix}/${downloadBaseFileName}-osx-x64.${downloadVersion}${downloadFileExtension}`);
57+
assert.equal(link, DownloadLinks[PlatformName.Mac64Bit]);
6258
});
6359
test('Linux 64Bit', async () => {
6460
setupPlatform({ linux: true, is64Bit: true });
6561
const link = await languageServerDownloader.getDownloadUri();
66-
assert.equal(link, `${downloadUriPrefix}/${downloadBaseFileName}-linux-x64.${downloadVersion}${downloadFileExtension}`);
62+
assert.equal(link, DownloadLinks[PlatformName.Linux64Bit]);
6763
});
6864
});

src/test/activation/platformData.unit.test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// tslint:disable:no-unused-variable
55
import * as assert from 'assert';
66
import * as TypeMoq from 'typemoq';
7-
import { PlatformData } from '../../client/activation/platformData';
7+
import { PlatformData, PlatformLSExecutables } from '../../client/activation/platformData';
88
import { IFileSystem, IPlatformService } from '../../client/common/platform/types';
99

1010
const testDataWinMac = [
@@ -24,8 +24,9 @@ const testDataLinux = [
2424
];
2525

2626
const testDataModuleName = [
27-
{ isWindows: true, expectedName: 'Microsoft.Python.LanguageServer.exe' },
28-
{ isWindows: false, expectedName: 'Microsoft.Python.LanguageServer.LanguageServer' }
27+
{ isWindows: true, isMac: false, isLinux: false, expectedName: PlatformLSExecutables.Windows },
28+
{ isWindows: false, isMac: true, isLinux: false, expectedName: PlatformLSExecutables.MacOS },
29+
{ isWindows: false, isMac: false, isLinux: true, expectedName: PlatformLSExecutables.Linux }
2930
];
3031

3132
// tslint:disable-next-line:max-func-body-length
@@ -70,6 +71,8 @@ suite('Activation - platform data', () => {
7071
for (const t of testDataModuleName) {
7172
const platformService = TypeMoq.Mock.ofType<IPlatformService>();
7273
platformService.setup(x => x.isWindows).returns(() => t.isWindows);
74+
platformService.setup(x => x.isLinux).returns(() => t.isLinux);
75+
platformService.setup(x => x.isMac).returns(() => t.isMac);
7376

7477
const fs = TypeMoq.Mock.ofType<IFileSystem>();
7578
const pd = new PlatformData(platformService.object, fs.object);

src/test/interpreters/interpreterVersion.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ suite('Interpreters display version', () => {
4343
const pyVersion = await interpreterVersion.getVersion('INVALID_INTERPRETER', 'DEFAULT_TEST_VALUE');
4444
assert.equal(pyVersion, 'DEFAULT_TEST_VALUE', 'Incorrect version');
4545
});
46-
test('Must return the pip Version', async () => {
46+
test('Must return the pip Version.', async () => {
4747
const pythonProcess = await ioc.serviceContainer.get<IProcessServiceFactory>(IProcessServiceFactory).create();
4848
const result = await pythonProcess.exec(PYTHON_PATH, ['-m', 'pip', '--version'], { cwd: __dirname, mergeStdOutErr: true });
4949
const output = result.stdout.splitLines()[0];
@@ -60,7 +60,7 @@ suite('Interpreters display version', () => {
6060
// tslint:disable-next-line:no-non-null-assertion
6161
await expect(pipVersionPromise).to.eventually.equal(matches![0].trim());
6262
});
63-
test('Must throw an exceptionn when pip version cannot be determine', async () => {
63+
test('Must throw an exception when pip version cannot be determined', async () => {
6464
const interpreterVersion = ioc.serviceContainer.get<IInterpreterVersionService>(IInterpreterVersionService);
6565
const pipVersionPromise = interpreterVersion.getPipVersion('INVALID_INTERPRETER');
6666
await expect(pipVersionPromise).to.be.rejectedWith();

0 commit comments

Comments
 (0)