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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/client/activation/downloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`,
Expand Down
18 changes: 15 additions & 3 deletions src/client/activation/platformData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<PlatformName> {
Expand All @@ -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<string> {
Expand Down
2 changes: 1 addition & 1 deletion src/client/interpreter/interpreterVersion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
16 changes: 6 additions & 10 deletions src/test/activation/downloader.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<IServiceContainer>;
Expand Down Expand Up @@ -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]);
});
});
9 changes: 6 additions & 3 deletions src/test/activation/platformData.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand All @@ -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
Expand Down Expand Up @@ -70,6 +71,8 @@ suite('Activation - platform data', () => {
for (const t of testDataModuleName) {
const platformService = TypeMoq.Mock.ofType<IPlatformService>();
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<IFileSystem>();
const pd = new PlatformData(platformService.object, fs.object);
Expand Down
4 changes: 2 additions & 2 deletions src/test/interpreters/interpreterVersion.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>(IProcessServiceFactory).create();
const result = await pythonProcess.exec(PYTHON_PATH, ['-m', 'pip', '--version'], { cwd: __dirname, mergeStdOutErr: true });
const output = result.stdout.splitLines()[0];
Expand All @@ -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>(IInterpreterVersionService);
const pipVersionPromise = interpreterVersion.getPipVersion('INVALID_INTERPRETER');
await expect(pipVersionPromise).to.be.rejectedWith();
Expand Down