Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Low-hanging nullable fruit #5186

Merged
merged 19 commits into from
Apr 25, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Test for empty omnisharp.path
  • Loading branch information
50Wliu committed Apr 25, 2022
commit f6655825bef32fdb1c8c04d393d128df91747912
2 changes: 1 addition & 1 deletion src/omnisharp/OmnisharpManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class OmnisharpManager {
}

public async GetOmniSharpLaunchInfo(defaultOmnisharpVersion: string, omnisharpPath: string | undefined, useFramework: boolean, serverUrl: string, latestVersionFileServerPath: string, installPath: string, extensionPath: string): Promise<LaunchInfo> {
if (omnisharpPath === undefined) {
if (omnisharpPath === undefined || omnisharpPath.length === 0) {
// If omnisharpPath was not specified, return the default path.
const basePath = path.resolve(extensionPath, '.omnisharp', defaultOmnisharpVersion + (useFramework ? '' : `-net${modernNetVersion}`));
return this.GetLaunchInfo(this.platformInfo, useFramework, basePath);
Expand Down
18 changes: 18 additions & 0 deletions test/unitTests/OmnisharpManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,24 @@ suite(OmnisharpManager.name, () => {
}
});

test('Returns the default path if the omnisharp path is empty', async () => {
const launchInfo = await manager.GetOmniSharpLaunchInfo(defaultVersion, "", useFramework, server.baseUrl, latestfilePath, installPath, extensionPath);
if (useFramework) {
expect(launchInfo.LaunchPath).to.be.equal(path.join(extensionPath, ".omnisharp", defaultVersion + suffix, elem.executable));
if (elem.platformInfo.isWindows()) {
expect(launchInfo.MonoLaunchPath).to.be.undefined;
}
else {
expect(launchInfo.MonoLaunchPath).to.be.equal(path.join(extensionPath, ".omnisharp", defaultVersion, "omnisharp", "OmniSharp.exe"));
}
}
else {
expect(launchInfo.LaunchPath).to.be.undefined;
expect(launchInfo.MonoLaunchPath).to.be.undefined;
expect(launchInfo.DotnetLaunchPath).to.be.equal(path.join(extensionPath, ".omnisharp", defaultVersion + suffix, elem.executable));
}
});

test('Installs the latest version and returns the launch path ', async () => {
let launchInfo = await manager.GetOmniSharpLaunchInfo(defaultVersion, "latest", useFramework, server.baseUrl, latestfilePath, installPath, extensionPath);
if (useFramework) {
Expand Down