Skip to content

Commit d528e09

Browse files
authored
Merge pull request #6655 from dibarbet/test_integration_errors
Attempt to stabilize some of the O# integration test failures
2 parents 8ec02bb + f26d525 commit d528e09

File tree

3 files changed

+11
-23
lines changed

3 files changed

+11
-23
lines changed

omnisharptest/omnisharpIntegrationTests/diagnostics.integration.test.ts

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { describe, expect, test, beforeAll, afterAll } from '@jest/globals';
77
import * as vscode from 'vscode';
88
import * as path from 'path';
99
import {
10+
ActivationResult,
1011
activateCSharpExtension,
1112
describeIfNotGenerator,
1213
describeIfNotRazorOrGenerator,
@@ -39,8 +40,10 @@ describeIfNotGenerator(`DiagnosticProvider: ${testAssetWorkspace.description}`,
3940
let razorFileUri: vscode.Uri;
4041
let virtualRazorFileUri: vscode.Uri;
4142

43+
let activation: ActivationResult;
44+
4245
beforeAll(async function () {
43-
const activation = await activateCSharpExtension();
46+
activation = await activateCSharpExtension();
4447
await testAssetWorkspace.restoreAndWait(activation);
4548

4649
const fileName = 'diagnostics.cs';
@@ -53,10 +56,12 @@ describeIfNotGenerator(`DiagnosticProvider: ${testAssetWorkspace.description}`,
5356
virtualRazorFileUri = vscode.Uri.file(razorFileUri.fsPath + '__virtual.cs');
5457
});
5558

59+
afterAll(async () => {
60+
await testAssetWorkspace.cleanupWorkspace();
61+
});
62+
5663
describeIfRazor('razor workspace', () => {
5764
beforeAll(async function () {
58-
const activation = await activateCSharpExtension();
59-
await testAssetWorkspace.restore();
6065
await vscode.commands.executeCommand('vscode.open', razorFileUri);
6166
await testAssetWorkspace.waitForIdle(activation.eventStream);
6267
});
@@ -82,18 +87,11 @@ describeIfNotGenerator(`DiagnosticProvider: ${testAssetWorkspace.description}`,
8287
}
8388
);
8489
});
85-
86-
afterAll(async () => {
87-
await testAssetWorkspace.cleanupWorkspace();
88-
});
8990
});
9091

9192
describeIfNotRazorOrGenerator('small workspace (based on maxProjectFileCountForDiagnosticAnalysis setting)', () => {
9293
beforeAll(async function () {
93-
const activation = await activateCSharpExtension();
94-
await testAssetWorkspace.restore();
9594
await vscode.commands.executeCommand('vscode.open', fileUri);
96-
9795
await testAssetWorkspace.waitForIdle(activation.eventStream);
9896
});
9997

@@ -162,10 +160,6 @@ describeIfNotGenerator(`DiagnosticProvider: ${testAssetWorkspace.description}`,
162160
(res) => expect(res.length).toBeGreaterThan(0)
163161
);
164162
});
165-
166-
afterAll(async () => {
167-
await testAssetWorkspace.cleanupWorkspace();
168-
});
169163
});
170164

171165
const describeCondition =
@@ -179,8 +173,6 @@ describeIfNotGenerator(`DiagnosticProvider: ${testAssetWorkspace.description}`,
179173
describeCondition('large workspace (based on maxProjectFileCountForDiagnosticAnalysis setting)', () => {
180174
beforeAll(async function () {
181175
await setDiagnosticWorkspaceLimit(1);
182-
const activation = await activateCSharpExtension();
183-
await testAssetWorkspace.restore();
184176
await restartOmniSharpServer();
185177
await testAssetWorkspace.waitForIdle(activation.eventStream);
186178
});
@@ -208,9 +200,5 @@ describeIfNotGenerator(`DiagnosticProvider: ${testAssetWorkspace.description}`,
208200
(secondaryDiag) => expect(secondaryDiag.length).toEqual(0)
209201
);
210202
});
211-
212-
afterAll(async () => {
213-
await testAssetWorkspace.cleanupWorkspace();
214-
});
215203
});
216204
});

src/features/commands.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,13 +198,13 @@ async function dotnetRestoreAllProjects(server: OmniSharpServer, eventStream: Ev
198198

199199
async function getProjectDescriptors(server: OmniSharpServer): Promise<protocol.ProjectDescriptor[]> {
200200
if (!server.isRunning()) {
201-
return Promise.reject('OmniSharp server is not running.');
201+
throw new Error('OmniSharp server is not running.');
202202
}
203203

204204
const info = await serverUtils.requestWorkspaceInformation(server);
205205
const descriptors = protocol.getDotNetCoreProjectDescriptors(info);
206206
if (descriptors.length === 0) {
207-
return Promise.reject('No .NET Core projects found');
207+
throw new Error('No .NET Core projects found');
208208
}
209209

210210
return descriptors;

src/omnisharp/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ export class OmniSharpServer {
741741

742742
public async makeRequest<TResponse>(command: string, data?: any, token?: CancellationToken): Promise<TResponse> {
743743
if (this._state.status !== ServerState.Started) {
744-
return Promise.reject<TResponse>('OmniSharp server is not running.');
744+
throw new Error('OmniSharp server is not running.');
745745
}
746746

747747
const { engine } = this._state;

0 commit comments

Comments
 (0)