Skip to content

Commit ae20c81

Browse files
authored
Unblock integration tests from even starting if cohosting is on (#11904)
This doesn't necessarily make them all pass, but they at least get to the point of running the test. I did a quick check of a FAR test and it passes locally with these changes.
2 parents 7ce1f4b + 9f82d6f commit ae20c81

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

src/Razor/test/Microsoft.VisualStudio.Razor.IntegrationTests/AbstractRazorEditorTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ private async Task EnsureTextViewRolesAsync(CancellationToken cancellationToken)
169169

170170
private async Task EnsureExtensionInstalledAsync(CancellationToken cancellationToken)
171171
{
172-
const string AssemblyName = "Microsoft.AspNetCore.Razor.LanguageServer";
172+
const string AssemblyName = "Microsoft.CodeAnalysis.Razor.Workspaces";
173173
using var semaphore = new SemaphoreSlim(1);
174174
await semaphore.WaitAsync(cancellationToken);
175175

src/Razor/test/Microsoft.VisualStudio.Razor.IntegrationTests/InProcess/RazorProjectSystemInProcess.cs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ namespace Microsoft.VisualStudio.Extensibility.Testing;
1919
[TestService]
2020
internal partial class RazorProjectSystemInProcess
2121
{
22+
public async Task<bool> IsCohostingActiveAsync(CancellationToken cancellationToken)
23+
{
24+
var options = await TestServices.Shell.GetComponentModelServiceAsync<LanguageServerFeatureOptions>(cancellationToken);
25+
Assert.NotNull(options);
26+
return options.UseRazorCohostServer;
27+
}
28+
2229
public async Task WaitForLSPServerActivatedAsync(CancellationToken cancellationToken)
2330
{
2431
await WaitForLSPServerActivationStatusAsync(active: true, cancellationToken);
@@ -31,6 +38,11 @@ public async Task WaitForLSPServerDeactivatedAsync(CancellationToken cancellatio
3138

3239
private async Task WaitForLSPServerActivationStatusAsync(bool active, CancellationToken cancellationToken)
3340
{
41+
if (await IsCohostingActiveAsync(cancellationToken))
42+
{
43+
return;
44+
}
45+
3446
var tracker = await TestServices.Shell.GetComponentModelServiceAsync<ILspServerActivationTracker>(cancellationToken);
3547
await Helper.RetryAsync(ct =>
3648
{
@@ -40,6 +52,11 @@ await Helper.RetryAsync(ct =>
4052

4153
public async Task WaitForProjectFileAsync(string projectFilePath, CancellationToken cancellationToken)
4254
{
55+
if (await IsCohostingActiveAsync(cancellationToken))
56+
{
57+
return;
58+
}
59+
4360
var projectManager = await TestServices.Shell.GetComponentModelServiceAsync<ProjectSnapshotManager>(cancellationToken);
4461
Assert.NotNull(projectManager);
4562
await Helper.RetryAsync(ct =>
@@ -54,6 +71,11 @@ await Helper.RetryAsync(ct =>
5471

5572
public async Task WaitForComponentTagNameAsync(string projectName, string componentName, CancellationToken cancellationToken)
5673
{
74+
if (await IsCohostingActiveAsync(cancellationToken))
75+
{
76+
return;
77+
}
78+
5779
var projectFilePath = await TestServices.SolutionExplorer.GetProjectFileNameAsync(projectName, cancellationToken);
5880
var projectManager = await TestServices.Shell.GetComponentModelServiceAsync<ProjectSnapshotManager>(cancellationToken);
5981
Assert.NotNull(projectManager);
@@ -73,6 +95,11 @@ await Helper.RetryAsync(async ct =>
7395

7496
public async Task WaitForRazorFileInProjectAsync(string projectFilePath, string filePath, CancellationToken cancellationToken)
7597
{
98+
if (await IsCohostingActiveAsync(cancellationToken))
99+
{
100+
return;
101+
}
102+
76103
var projectManager = await TestServices.Shell.GetComponentModelServiceAsync<ProjectSnapshotManager>(cancellationToken);
77104
Assert.NotNull(projectManager);
78105

@@ -88,6 +115,11 @@ await Helper.RetryAsync(ct =>
88115

89116
public async Task<ImmutableArray<string>> GetProjectKeyIdsForProjectAsync(string projectFilePath, CancellationToken cancellationToken)
90117
{
118+
if (await IsCohostingActiveAsync(cancellationToken))
119+
{
120+
throw new InvalidOperationException("This method makes no sense in cohosting, as there are no project keys.");
121+
}
122+
91123
var projectManager = await TestServices.Shell.GetComponentModelServiceAsync<ProjectSnapshotManager>(cancellationToken);
92124
Assert.NotNull(projectManager);
93125

@@ -96,6 +128,11 @@ public async Task<ImmutableArray<string>> GetProjectKeyIdsForProjectAsync(string
96128

97129
public async Task WaitForCSharpVirtualDocumentAsync(string razorFilePath, CancellationToken cancellationToken)
98130
{
131+
if (await IsCohostingActiveAsync(cancellationToken))
132+
{
133+
return;
134+
}
135+
99136
var documentManager = await TestServices.Shell.GetComponentModelServiceAsync<LSPDocumentManager>(cancellationToken);
100137

101138
var uri = new Uri(razorFilePath, UriKind.Absolute);
@@ -118,6 +155,11 @@ await Helper.RetryAsync(ct =>
118155

119156
public async Task WaitForCSharpVirtualDocumentUpdateAsync(string projectName, string relativeFilePath, Func<Task> updater, CancellationToken cancellationToken)
120157
{
158+
if (await IsCohostingActiveAsync(cancellationToken))
159+
{
160+
return;
161+
}
162+
121163
var filePath = await TestServices.SolutionExplorer.GetAbsolutePathForProjectRelativeFilePathAsync(projectName, relativeFilePath, cancellationToken);
122164

123165
var documentManager = await TestServices.Shell.GetComponentModelServiceAsync<LSPDocumentManager>(cancellationToken);

0 commit comments

Comments
 (0)