Skip to content

Commit fca17f3

Browse files
committed
Wait for workspace to be updated in Reanalyze tests
1 parent 824755d commit fca17f3

File tree

4 files changed

+25
-18
lines changed

4 files changed

+25
-18
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/integrationTests/reAnalyze.integration.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@ suite(`ReAnalyze: ${testAssetWorkspace.description}`, function () {
4444
this.skip();
4545
}
4646

47-
eventStream = (await activateCSharpExtension()).eventStream;
48-
await testAssetWorkspace.restore();
47+
const activation = await activateCSharpExtension();
48+
await testAssetWorkspace.restoreAndWait(activation);
49+
50+
eventStream = activation.eventStream;
4951

5052
let projectDirectory = testAssetWorkspace.projects[0].projectDirectoryPath;
5153
interfaceUri = vscode.Uri.file(path.join(projectDirectory, 'ISomeInterface.cs'));

test/integrationTests/semanticTokensProvider.test.ts

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import * as path from 'path';
99
import { should, assert } from 'chai';
1010
import { activateCSharpExtension, isRazorWorkspace } from './integrationHelpers';
1111
import testAssetWorkspace from './testAssets/testAssetWorkspace';
12-
import { EventType } from '../../src/omnisharp/EventType';
13-
import { poll } from './poll';
1412

1513
const chai = require('chai');
1614
chai.use(require('chai-arrays'));
@@ -60,19 +58,7 @@ suite(`SemanticTokensProvider: ${testAssetWorkspace.description}`, function () {
6058
}
6159

6260
const activation = await activateCSharpExtension();
63-
await testAssetWorkspace.restore();
64-
65-
// Wait for workspace information to be returned
66-
let isWorkspaceLoaded = false;
67-
68-
const subscription = activation.eventStream.subscribe(event => {
69-
if (event.type === EventType.WorkspaceInformationUpdated) {
70-
isWorkspaceLoaded = true;
71-
subscription.unsubscribe();
72-
}
73-
});
74-
75-
await poll(() => isWorkspaceLoaded, 25000, 500);
61+
await testAssetWorkspace.restoreAndWait(activation);
7662

7763
const fileName = 'semantictokens.cs';
7864
const projectDirectory = testAssetWorkspace.projects[0].projectDirectoryPath;

test/integrationTests/testAssets/testAssets.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
import * as fs from 'async-file';
77
import * as path from 'path';
88
import * as vscode from 'vscode';
9+
import { EventType } from '../../../src/omnisharp/EventType';
10+
import { ActivationResult } from '../integrationHelpers';
11+
import { poll } from '../poll';
912
import spawnGit from './spawnGit';
1013

1114
export class TestAssetProject {
@@ -41,6 +44,22 @@ export class TestAssetWorkspace {
4144
await vscode.commands.executeCommand("dotnet.restore.all");
4245
}
4346

47+
async restoreAndWait(activation: ActivationResult): Promise<void> {
48+
await this.restore();
49+
50+
// Wait for workspace information to be returned
51+
let isWorkspaceLoaded = false;
52+
53+
const subscription = activation.eventStream.subscribe(event => {
54+
if (event.type === EventType.WorkspaceInformationUpdated) {
55+
isWorkspaceLoaded = true;
56+
subscription.unsubscribe();
57+
}
58+
});
59+
60+
await poll(() => isWorkspaceLoaded, 25000, 500);
61+
}
62+
4463
get vsCodeDirectoryPath(): string {
4564
return path.join(vscode.workspace.workspaceFolders[0].uri.fsPath, ".vscode");
4665
}

0 commit comments

Comments
 (0)