Skip to content

Commit

Permalink
Merge branch 'master' into tweak-useMono-option
Browse files Browse the repository at this point in the history
  • Loading branch information
DustinCampbell authored May 1, 2018
2 parents e9df1e9 + 83b52ff commit da04dcd
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 40 deletions.
13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
"keywords": [
"multi-root ready"
],
"defaults":{
"omniSharp" : "1.29.1"
},
"main": "./out/src/main",
"scripts": {
"vscode:prepublish": "tsc -p ./",
Expand Down Expand Up @@ -143,7 +146,7 @@
"description": "OmniSharp for Windows (.NET 4.6 / x86)",
"url": "https://download.visualstudio.microsoft.com/download/pr/11655913/afaf4c0f0bee0304c8b1c55dfc190a9f/omnisharp-win-x86-1.29.1.zip",
"fallbackUrl": "https://omnisharpdownload.blob.core.windows.net/ext/omnisharp-win-x86-1.29.1.zip",
"installPath": ".omnisharp",
"installPath": ".omnisharp/1.29.1",
"platforms": [
"win32"
],
Expand All @@ -157,7 +160,7 @@
"description": "OmniSharp for Windows (.NET 4.6 / x64)",
"url": "https://download.visualstudio.microsoft.com/download/pr/11655914/fc5dedbd95030e4015ffc24e48177255/omnisharp-win-x64-1.29.1.zip",
"fallbackUrl": "https://omnisharpdownload.blob.core.windows.net/ext/omnisharp-win-x64-1.29.1.zip",
"installPath": ".omnisharp",
"installPath": ".omnisharp/1.29.1",
"platforms": [
"win32"
],
Expand All @@ -171,7 +174,7 @@
"description": "OmniSharp for OSX",
"url": "https://download.visualstudio.microsoft.com/download/pr/11655911/eee9835195b397df4c80ca16c51e1a58/omnisharp-osx-1.29.1.zip",
"fallbackUrl": "https://omnisharpdownload.blob.core.windows.net/ext/omnisharp-osx-1.29.1.zip",
"installPath": ".omnisharp",
"installPath": ".omnisharp/1.29.1",
"platforms": [
"darwin"
],
Expand All @@ -186,7 +189,7 @@
"description": "OmniSharp for Linux (x86)",
"url": "https://download.visualstudio.microsoft.com/download/pr/11655910/48d2fd69a5061fee074219c8a9b37232/omnisharp-linux-x86-1.29.1.zip",
"fallbackUrl": "https://omnisharpdownload.blob.core.windows.net/ext/omnisharp-linux-x86-1.29.1.zip",
"installPath": ".omnisharp",
"installPath": ".omnisharp/1.29.1",
"platforms": [
"linux"
],
Expand All @@ -205,7 +208,7 @@
"description": "OmniSharp for Linux (x64)",
"url": "https://download.visualstudio.microsoft.com/download/pr/11655912/d0b11407c8b6a61cc0cf8071b2a07c87/omnisharp-linux-x64-1.29.1.zip",
"fallbackUrl": "https://omnisharpdownload.blob.core.windows.net/ext/omnisharp-linux-x64-1.29.1.zip",
"installPath": ".omnisharp",
"installPath": ".omnisharp/1.29.1",
"platforms": [
"linux"
],
Expand Down
4 changes: 2 additions & 2 deletions src/omnisharp/OmnisharpManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ export class OmnisharpManager {
private platformInfo: PlatformInformation) {
}

public async GetOmniSharpLaunchInfo(omnisharpPath: string, serverUrl: string, latestVersionFileServerPath: string, installPath: string, extensionPath: string): Promise<LaunchInfo> {
public async GetOmniSharpLaunchInfo(defaultOmnisharpVersion: string, omnisharpPath: string, serverUrl: string, latestVersionFileServerPath: string, installPath: string, extensionPath: string): Promise<LaunchInfo> {
if (!omnisharpPath) {
// If omnisharpPath was not specified, return the default path.
let basePath = path.resolve(extensionPath, '.omnisharp');
let basePath = path.resolve(extensionPath, '.omnisharp', defaultOmnisharpVersion);
return this.GetLaunchInfo(this.platformInfo, basePath);
}

Expand Down
8 changes: 4 additions & 4 deletions src/omnisharp/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ module Events {

const TelemetryReportingDelay = 2 * 60 * 1000; // two minutes
const serverUrl = "https://roslynomnisharp.blob.core.windows.net";
const installPath = ".omnisharp/experimental";
const installPath = ".omnisharp";
const latestVersionFileServerPath = 'releases/versioninfo.txt';

export class OmniSharpServer {
Expand All @@ -91,9 +91,9 @@ export class OmniSharpServer {
private updateProjectDebouncer = new Subject<ObservableEvents.ProjectModified>();
private firstUpdateProject: boolean;

constructor(private vscode: vscode, networkSettingsProvider: NetworkSettingsProvider, private eventStream: EventStream, packageJSON: any, private platformInfo: PlatformInformation) {
constructor(private vscode: vscode, networkSettingsProvider: NetworkSettingsProvider, private eventStream: EventStream, private packageJSON: any, private platformInfo: PlatformInformation) {
this._requestQueue = new RequestQueueCollection(this.eventStream, 8, request => this._makeRequest(request));
let downloader = new OmnisharpDownloader(networkSettingsProvider, this.eventStream, packageJSON, platformInfo);
let downloader = new OmnisharpDownloader(networkSettingsProvider, this.eventStream, this.packageJSON, platformInfo);
this._omnisharpManager = new OmnisharpManager(downloader, platformInfo);
this.updateProjectDebouncer.debounceTime(1500).subscribe((event) => { this.updateProjectInfo(); });
this.firstUpdateProject = true;
Expand Down Expand Up @@ -310,7 +310,7 @@ export class OmniSharpServer {
let launchInfo: LaunchInfo;
try {
let extensionPath = utils.getExtensionPath();
launchInfo = await this._omnisharpManager.GetOmniSharpLaunchInfo(this._options.path, serverUrl, latestVersionFileServerPath, installPath, extensionPath);
launchInfo = await this._omnisharpManager.GetOmniSharpLaunchInfo(this.packageJSON.defaults.omniSharp, this._options.path, serverUrl, latestVersionFileServerPath, installPath, extensionPath);
}
catch (error) {
this.eventStream.post(new ObservableEvents.OmnisharpFailure(`Error occured in loading omnisharp from omnisharp.path\nCould not start the server due to ${error.toString()}`, error));
Expand Down
9 changes: 6 additions & 3 deletions tasks/commandLineArguments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@
import * as minimist from 'minimist';
import * as path from 'path';

let argv = minimist(process.argv.slice(2));
let argv = minimist(process.argv.slice(2), {
boolean: ['retainVsix']
});

export const commandLineOptions ={
outputFolder: makePathAbsolute(argv['o']),
export const commandLineOptions = {
retainVsix: !!argv['retainVsix'],
outputFolder: makePathAbsolute(argv['o']),
codeExtensionPath: makePathAbsolute(argv['codeExtensionPath'])
};

Expand Down
10 changes: 9 additions & 1 deletion tasks/offlinePackagingTasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { PlatformInformation } from '../src/platform';
import { DownloadAndInstallPackages } from '../src/packageManager/PackageManager';
import NetworkSettings from '../src/NetworkSettings';
import { GetRunTimeDependenciesPackages } from '../src/CSharpExtDownloader';
import { commandLineOptions } from '../tasks/commandLineArguments';

gulp.task('vsix:offline:package', async () => {
del.sync(vscodeignorePath);
Expand All @@ -37,7 +38,14 @@ gulp.task('vsix:offline:package', async () => {
});

async function doPackageOffline() {
cleanSync(true);
if (commandLineOptions.retainVsix) {
//if user doesnot want to clean up the existing vsix packages
cleanSync(false);
}
else {
cleanSync(true);
}

util.setExtensionPath(codeExtensionPath);
const packageJSON = getPackageJSON();
const name = packageJSON.name;
Expand Down
6 changes: 3 additions & 3 deletions test-plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ The easist way to verify that a project was successfully loaded is to open a .cs

#### omnisharp.path
Setting this path to any of the values as listed below, should start the OmniSharp server and display the correct OmniSharp path in the `OmniSharp Log`(View --> Output--> OmniSharp Log).
* undefined - OmniSharp server must start using the copy of omnisharp shipped with the extension, that is, the OmniSharp path must be the extension path, followed by .omnisharp followed by the platform-specific executable.
* undefined - OmniSharp server must start using the copy of omnisharp shipped with the extension, that is, the OmniSharp path must be the extension path, followed by .omnisharp followed by the default omnisharp version as present in the package.json and the platform-specific executable.
* Some absolute path - OmniSharp server must start using the local copy of OmniSharp pointed to by the path and the same must be displayed as the Omnisharp path. Example:C:\omnisharp-roslyn\artifacts\publish\OmniSharp.Stdio\win7-x64\OmniSharp.exe.
* "<version>" - The specified version must be downloaded and installed (The status of download/install can be seen in the `C#` log). If the installation is successful, the server must start and the OmniSharp path must include the .omnisharp/experimental folder followed by the version name and the executable. Eg: If the version is `1.29.2-beta.60`, the path displayed on Windows should be `.omnisharp/experimental/1.29.2-beta.60/OmniSharp.exe`.
* "latest" - The file containing the information about the latest CI build (https://roslynomnisharp.blob.core.windows.net/releases/versioninfo.txt), must be downloaded and accordingly the latest CI build from the "master" branch of omnisharp-roslyn should be downloaded and installed. If the installation is successful, the server must start and the OmniSharp path must include the .omnisharp/experimental folder followed by the version name and the executable. Eg: If the latest version is `1.29.2-beta.62`, the path displayed on Windows should be `.omnisharp/experimental/1.29.2-beta.62/OmniSharp.exe`.
* "<version>" - The specified version must be downloaded and installed (The status of download/install can be seen in the `C#` log). If the installation is successful, the server must start and the OmniSharp path must include the .omnisharp folder followed by the version name and the executable. Eg: If the version is `1.29.2-beta.60`, the path displayed on Windows should be `.omnisharp/1.29.2-beta.60/OmniSharp.exe`.
* "latest" - The file containing the information about the latest CI build (https://roslynomnisharp.blob.core.windows.net/releases/versioninfo.txt), must be downloaded and accordingly the latest CI build from the "master" branch of omnisharp-roslyn should be downloaded and installed. If the installation is successful, the server must start and the OmniSharp path must include the .omnisharp folder followed by the version name and the executable. Eg: If the latest version is `1.29.2-beta.62`, the path displayed on Windows should be `.omnisharp/1.29.2-beta.62/OmniSharp.exe`.
* All the above configurations should work, with and without setting the useMono option on Linux
* The above behavior should be exhibited when a new vscode window is opened, as well as if the setting is modified and a "Restart OmniSharp"(Ctrl+Shift+P --> OmniSharp: Restart OmniSharp) is performed.

Expand Down
2 changes: 1 addition & 1 deletion test/featureTests/OmnisharpDownloader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ suite("DownloadAndInstallExperimentalVersion : Gets the version packages, downlo
const eventStream = new EventStream();
const downloader = GetTestOmnisharpDownloader(eventStream, platformInfo);
const serverUrl = "https://roslynomnisharp.blob.core.windows.net";
const installPath = ".omnisharp/experimental/";
const installPath = "somePath";

setup(() => {
tmpDir = tmp.dirSync();
Expand Down
43 changes: 22 additions & 21 deletions test/featureTests/OmnisharpManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ const tmp = require('tmp');
suite('GetExperimentalOmnisharpPath : Returns Omnisharp experiment path depending on the path and useMono option', () => {
const platformInfo = new PlatformInformation("win32", "x86");
const serverUrl = "https://roslynomnisharp.blob.core.windows.net";
const installPath = ".omnisharp/experimental";
const installPath = "somePath";
const versionFilepathInServer = "releases/testVersionInfo.txt";
const eventStream = new EventStream();
const manager = GetTestOmnisharpManager(eventStream, platformInfo);
const defaultVersion = "0.1.2";
let extensionPath: string;
let tmpDir: any;
let tmpFile: any;
Expand All @@ -37,68 +38,68 @@ suite('GetExperimentalOmnisharpPath : Returns Omnisharp experiment path dependin
});

test('Throws error if the path is neither an absolute path nor a valid semver, nor the string "latest"', async () => {
expect(manager.GetOmniSharpLaunchInfo("Some incorrect path", serverUrl, versionFilepathInServer, installPath, extensionPath)).to.be.rejectedWith(Error);
expect(manager.GetOmniSharpLaunchInfo(defaultVersion, "Some incorrect path", serverUrl, versionFilepathInServer, installPath, extensionPath)).to.be.rejectedWith(Error);
});

test('Throws error when the specified path is null', async () => {
expect(manager.GetOmniSharpLaunchInfo(null, serverUrl, versionFilepathInServer, installPath, extensionPath)).to.be.rejectedWith(Error);
expect(manager.GetOmniSharpLaunchInfo(defaultVersion, null, serverUrl, versionFilepathInServer, installPath, extensionPath)).to.be.rejectedWith(Error);
});

test('Throws error when the specified path is empty', async () => {
expect(manager.GetOmniSharpLaunchInfo("", serverUrl, versionFilepathInServer, installPath, extensionPath)).to.be.rejectedWith(Error);
expect(manager.GetOmniSharpLaunchInfo(defaultVersion, "", serverUrl, versionFilepathInServer, installPath, extensionPath)).to.be.rejectedWith(Error);
});

test('Throws error when the specified path is an invalid semver', async () => {
expect(manager.GetOmniSharpLaunchInfo("a.b.c", serverUrl, versionFilepathInServer, installPath, extensionPath)).to.be.rejectedWith(Error);
expect(manager.GetOmniSharpLaunchInfo(defaultVersion, "a.b.c", serverUrl, versionFilepathInServer, installPath, extensionPath)).to.be.rejectedWith(Error);
});

test('Returns default paths if no path is specified', async () => {
let launchInfo = await manager.GetOmniSharpLaunchInfo(undefined, serverUrl, versionFilepathInServer, installPath, extensionPath);
launchInfo.LaunchPath.should.equal(path.resolve(extensionPath, '.omnisharp/OmniSharp.exe'));
let launchInfo = await manager.GetOmniSharpLaunchInfo(defaultVersion, undefined, serverUrl, versionFilepathInServer, installPath, extensionPath);
launchInfo.LaunchPath.should.equal(path.resolve(extensionPath, `.omnisharp/${defaultVersion}/OmniSharp.exe`));
expect(launchInfo.MonoLaunchPath).to.be.undefined;
});

test('Returns default paths if no path is specified - Linux ', async () => {
let manager = GetTestOmnisharpManager(eventStream, new PlatformInformation("linux", "x64"));
let launchInfo = await manager.GetOmniSharpLaunchInfo(undefined, serverUrl, versionFilepathInServer, installPath, extensionPath);
launchInfo.LaunchPath.should.equal(path.resolve(extensionPath, '.omnisharp/run'));
launchInfo.MonoLaunchPath.should.equal(path.resolve(extensionPath, '.omnisharp/omnisharp/OmniSharp.exe'));
let launchInfo = await manager.GetOmniSharpLaunchInfo(defaultVersion, undefined, serverUrl, versionFilepathInServer, installPath, extensionPath);
launchInfo.LaunchPath.should.equal(path.resolve(extensionPath, `.omnisharp/${defaultVersion}/run`));
launchInfo.MonoLaunchPath.should.equal(path.resolve(extensionPath, `.omnisharp/${defaultVersion}/omnisharp/OmniSharp.exe`));
});

test('Returns the same path if absolute path to an existing file is passed', async () => {
tmpFile = tmp.fileSync();
let launchInfo = await manager.GetOmniSharpLaunchInfo(tmpFile.name, serverUrl, versionFilepathInServer, installPath, extensionPath);
let launchInfo = await manager.GetOmniSharpLaunchInfo(defaultVersion, tmpFile.name, serverUrl, versionFilepathInServer, installPath, extensionPath);
launchInfo.LaunchPath.should.equal(tmpFile.name);
});

test('Installs the latest version and returns the launch path based on the version and platform', async () => {
let launchInfo = await manager.GetOmniSharpLaunchInfo("latest", serverUrl, versionFilepathInServer, installPath, extensionPath);
launchInfo.LaunchPath.should.equal(path.resolve(extensionPath, `.omnisharp/experimental/1.2.3/OmniSharp.exe`));
let launchInfo = await manager.GetOmniSharpLaunchInfo(defaultVersion, "latest", serverUrl, versionFilepathInServer, installPath, extensionPath);
launchInfo.LaunchPath.should.equal(path.resolve(extensionPath, `somePath/1.2.3/OmniSharp.exe`));
expect(launchInfo.MonoLaunchPath).to.be.undefined;
});

test('Installs the test version and returns the launch path based on the version and platform', async () => {
let launchInfo = await manager.GetOmniSharpLaunchInfo("1.2.3", serverUrl, versionFilepathInServer, installPath, extensionPath);
launchInfo.LaunchPath.should.equal(path.resolve(extensionPath, `.omnisharp/experimental/1.2.3/OmniSharp.exe`));
let launchInfo = await manager.GetOmniSharpLaunchInfo(defaultVersion, "1.2.3", serverUrl, versionFilepathInServer, installPath, extensionPath);
launchInfo.LaunchPath.should.equal(path.resolve(extensionPath, `somePath/1.2.3/OmniSharp.exe`));
expect(launchInfo.MonoLaunchPath).to.be.undefined;
});

test('Downloads package from given url and installs them at the specified path', async () => {
await manager.GetOmniSharpLaunchInfo("1.2.3", serverUrl, versionFilepathInServer, installPath, extensionPath);
let exists = await util.fileExists(path.resolve(extensionPath, `.omnisharp/experimental/1.2.3/install_check_1.2.3.txt`));
await manager.GetOmniSharpLaunchInfo(defaultVersion, "1.2.3", serverUrl, versionFilepathInServer, installPath, extensionPath);
let exists = await util.fileExists(path.resolve(extensionPath, `somePath/1.2.3/install_check_1.2.3.txt`));
exists.should.equal(true);
});

test('Downloads package and returns launch path based on platform - on Linux ', async () => {
let manager = GetTestOmnisharpManager(eventStream, new PlatformInformation("linux", "x64"));
let launchInfo = await manager.GetOmniSharpLaunchInfo("1.2.3", serverUrl, versionFilepathInServer, installPath, extensionPath);
launchInfo.LaunchPath.should.equal(path.resolve(extensionPath, '.omnisharp/experimental/1.2.3/run'));
launchInfo.MonoLaunchPath.should.equal(path.resolve(extensionPath, '.omnisharp/experimental/1.2.3/omnisharp/OmniSharp.exe'));
let launchInfo = await manager.GetOmniSharpLaunchInfo(defaultVersion, "1.2.3", serverUrl, versionFilepathInServer, installPath, extensionPath);
launchInfo.LaunchPath.should.equal(path.resolve(extensionPath, 'somePath/1.2.3/run'));
launchInfo.MonoLaunchPath.should.equal(path.resolve(extensionPath, 'somePath/1.2.3/omnisharp/OmniSharp.exe'));
});

test('Downloads package and returns launch path based on install path ', async () => {
let manager = GetTestOmnisharpManager(eventStream, platformInfo);
let launchInfo = await manager.GetOmniSharpLaunchInfo("1.2.3", serverUrl, versionFilepathInServer, "installHere", extensionPath);
let launchInfo = await manager.GetOmniSharpLaunchInfo(defaultVersion, "1.2.3", serverUrl, versionFilepathInServer, "installHere", extensionPath);
launchInfo.LaunchPath.should.equal(path.resolve(extensionPath, 'installHere/1.2.3/OmniSharp.exe'));
expect(launchInfo.MonoLaunchPath).to.be.undefined;
});
Expand Down
1 change: 1 addition & 0 deletions test/releaseTests/offlinePackage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ suite("Offline packaging of VSIX", function () {
let args: string[] = [];
args.push(path.join("node_modules", "gulp", "bin", "gulp.js"));
args.push("package:offline");
args.push("--retainVsix");// do not delete the existing vsix in the repo
args.push(`-o`);
args.push(tmpDir.name);
invokeNode(args);
Expand Down

0 comments on commit da04dcd

Please sign in to comment.