зеркало из https://github.com/dotnet/razor.git
Fix integration tests to validate the change
This commit is contained in:
Родитель
a05f9e64c0
Коммит
744e9e3242
|
@ -17,13 +17,15 @@ public class BreakpointSpanTests(ITestOutputHelper testOutputHelper) : AbstractR
|
|||
|
||||
// Wait for classifications to indicate Razor LSP is up and running
|
||||
await TestServices.Editor.WaitForComponentClassificationAsync(ControlledHangMitigatingCancellationToken);
|
||||
await TestServices.Editor.SetTextAsync("<p>@{ var abc = 123; }</p>", ControlledHangMitigatingCancellationToken);
|
||||
|
||||
// Act
|
||||
await TestServices.Debugger.SetBreakpointAsync(RazorProjectConstants.CounterRazorFile, line: 1, character: 1, ControlledHangMitigatingCancellationToken);
|
||||
await TestServices.RazorProjectSystem.WaitForCSharpVirtualDocumentUpdateAsync(RazorProjectConstants.BlazorProjectName, RazorProjectConstants.CounterRazorFile, async () =>
|
||||
{
|
||||
await TestServices.Editor.SetTextAsync("<p>@{ var abc = 123; }</p>", ControlledHangMitigatingCancellationToken);
|
||||
}, ControlledHangMitigatingCancellationToken);
|
||||
|
||||
// Assert
|
||||
await TestServices.Debugger.VerifyBreakpointAsync(RazorProjectConstants.CounterRazorFile, line: 1, character: 7, ControlledHangMitigatingCancellationToken);
|
||||
Assert.True(await TestServices.Debugger.SetBreakpointAsync(RazorProjectConstants.CounterRazorFile, line: 1, character: 1, ControlledHangMitigatingCancellationToken));
|
||||
|
||||
Assert.True(await TestServices.Debugger.VerifyBreakpointAsync(RazorProjectConstants.CounterRazorFile, line: 1, character: 7, ControlledHangMitigatingCancellationToken));
|
||||
}
|
||||
|
||||
[IdeFact]
|
||||
|
@ -34,15 +36,17 @@ public class BreakpointSpanTests(ITestOutputHelper testOutputHelper) : AbstractR
|
|||
|
||||
// Wait for classifications to indicate Razor LSP is up and running
|
||||
await TestServices.Editor.WaitForComponentClassificationAsync(ControlledHangMitigatingCancellationToken);
|
||||
await TestServices.Editor.SetTextAsync(@"<p>@{
|
||||
var abc = 123;
|
||||
}</p>", ControlledHangMitigatingCancellationToken);
|
||||
|
||||
// Act
|
||||
var result = await TestServices.Debugger.SetBreakpointAsync(RazorProjectConstants.CounterRazorFile, line: 1, character: 1, ControlledHangMitigatingCancellationToken);
|
||||
await TestServices.RazorProjectSystem.WaitForCSharpVirtualDocumentUpdateAsync(RazorProjectConstants.BlazorProjectName, RazorProjectConstants.CounterRazorFile, async () =>
|
||||
{
|
||||
await TestServices.Editor.SetTextAsync("""
|
||||
<p>@{
|
||||
var abc = 123;
|
||||
}</p>
|
||||
""", ControlledHangMitigatingCancellationToken);
|
||||
}, ControlledHangMitigatingCancellationToken);
|
||||
|
||||
// Assert
|
||||
Assert.False(result);
|
||||
Assert.False(await TestServices.Debugger.SetBreakpointAsync(RazorProjectConstants.CounterRazorFile, line: 1, character: 1, ControlledHangMitigatingCancellationToken));
|
||||
}
|
||||
|
||||
[IdeFact]
|
||||
|
@ -53,14 +57,18 @@ public class BreakpointSpanTests(ITestOutputHelper testOutputHelper) : AbstractR
|
|||
|
||||
// Wait for classifications to indicate Razor LSP is up and running
|
||||
await TestServices.Editor.WaitForComponentClassificationAsync(ControlledHangMitigatingCancellationToken);
|
||||
await TestServices.Editor.SetTextAsync(@"<p>@{
|
||||
var abc = 123;
|
||||
}</p>", ControlledHangMitigatingCancellationToken);
|
||||
|
||||
// Act
|
||||
await TestServices.Debugger.SetBreakpointAsync(RazorProjectConstants.CounterRazorFile, line: 2, character: 1, ControlledHangMitigatingCancellationToken);
|
||||
await TestServices.RazorProjectSystem.WaitForCSharpVirtualDocumentUpdateAsync(RazorProjectConstants.BlazorProjectName, RazorProjectConstants.CounterRazorFile, async () =>
|
||||
{
|
||||
await TestServices.Editor.SetTextAsync("""
|
||||
<p>@{
|
||||
var abc = 123;
|
||||
}</p>
|
||||
""", ControlledHangMitigatingCancellationToken);
|
||||
}, ControlledHangMitigatingCancellationToken);
|
||||
|
||||
// Assert
|
||||
await TestServices.Debugger.VerifyBreakpointAsync(RazorProjectConstants.CounterRazorFile, line: 2, character: 4, ControlledHangMitigatingCancellationToken);
|
||||
Assert.True(await TestServices.Debugger.SetBreakpointAsync(RazorProjectConstants.CounterRazorFile, line: 2, character: 1, ControlledHangMitigatingCancellationToken));
|
||||
|
||||
Assert.True(await TestServices.Debugger.VerifyBreakpointAsync(RazorProjectConstants.CounterRazorFile, line: 2, character: 5, ControlledHangMitigatingCancellationToken));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ internal partial class DebuggerInProcess
|
|||
|
||||
foreach (EnvDTE.Breakpoint breakpoint in debugger.Breakpoints)
|
||||
{
|
||||
if (breakpoint.File == fileName &&
|
||||
if (breakpoint.File.EndsWith(fileName) &&
|
||||
breakpoint.FileLine == line &&
|
||||
breakpoint.FileColumn == character)
|
||||
{
|
||||
|
|
|
@ -127,4 +127,43 @@ internal partial class RazorProjectSystemInProcess
|
|||
|
||||
}, TimeSpan.FromMilliseconds(100), cancellationToken);
|
||||
}
|
||||
|
||||
public async Task WaitForCSharpVirtualDocumentUpdateAsync(string projectName, string relativeFilePath, Func<Task> updater, CancellationToken cancellationToken)
|
||||
{
|
||||
var filePath = await TestServices.SolutionExplorer.GetAbsolutePathForProjectRelativeFilePathAsync(projectName, relativeFilePath, cancellationToken);
|
||||
|
||||
var documentManager = await TestServices.Shell.GetComponentModelServiceAsync<LSPDocumentManager>(cancellationToken);
|
||||
|
||||
var uri = new Uri(filePath, UriKind.Absolute);
|
||||
|
||||
long? desiredVersion = null;
|
||||
|
||||
await Helper.RetryAsync(async ct =>
|
||||
{
|
||||
if (documentManager.TryGetDocument(uri, out var snapshot))
|
||||
{
|
||||
if (snapshot.TryGetVirtualDocument<CSharpVirtualDocumentSnapshot>(out var virtualDocument))
|
||||
{
|
||||
if (!virtualDocument.ProjectKey.IsUnknown &&
|
||||
virtualDocument.Snapshot.Length > 0)
|
||||
{
|
||||
if (desiredVersion is null)
|
||||
{
|
||||
desiredVersion = virtualDocument.HostDocumentSyncVersion + 1;
|
||||
await updater();
|
||||
}
|
||||
else if (virtualDocument.HostDocumentSyncVersion == desiredVersion)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}, TimeSpan.FromMilliseconds(100), cancellationToken);
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче