-
Notifications
You must be signed in to change notification settings - Fork 260
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: "Stuck on Verifying..." (#1771)
- Loading branch information
1 parent
93cbefc
commit c5a096c
Showing
3 changed files
with
73 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
Source/DafnyLanguageServer.Test/Various/CancelVerification.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
using Microsoft.Dafny.LanguageServer.IntegrationTest.Extensions; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using OmniSharp.Extensions.LanguageServer.Protocol.Client; | ||
using System.IO; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using OmniSharp.Extensions.LanguageServer.Protocol.Document; | ||
using OmniSharp.Extensions.LanguageServer.Protocol.Models; | ||
|
||
namespace Microsoft.Dafny.LanguageServer.IntegrationTest.Various { | ||
[TestClass] | ||
public class CancelVerificationTest : DafnyLanguageServerTestBase { | ||
private ILanguageClient client; | ||
|
||
[TestInitialize] | ||
public async Task SetUp() { | ||
client = await InitializeClient(); | ||
} | ||
|
||
// https://github.com/dafny-lang/language-server-csharp/issues/40 | ||
[TestMethod] | ||
public async Task CancelingVerificationStopsTheProver() { | ||
var source = @" | ||
function method {:unroll 100} Ack(m: nat, n: nat): nat | ||
decreases m, n | ||
{ | ||
if m == 0 then | ||
n + 1 | ||
else if n == 0 then | ||
Ack(m - 1, 1) | ||
else | ||
Ack(m - 1, Ack(m, n - 1)) | ||
} | ||
method test() { | ||
assert Ack(5, 5) == 0; | ||
}".TrimStart(); | ||
var documentItem = CreateTestDocument(source); | ||
client.OpenDocument(documentItem); | ||
await Task.Delay(5_000); | ||
// This cancels the previous request. | ||
client.DidChangeTextDocument(new DidChangeTextDocumentParams { | ||
TextDocument = new OptionalVersionedTextDocumentIdentifier { | ||
Uri = documentItem.Uri, | ||
Version = documentItem.Version + 1 | ||
}, | ||
ContentChanges = new[] {new TextDocumentContentChangeEvent { | ||
Range = new Range((12, 9), (12, 23)), | ||
Text = "true" | ||
}} | ||
}); | ||
await client.WaitForNotificationCompletionAsync(documentItem.Uri, CancellationToken); | ||
var document = await Documents.GetDocumentAsync(documentItem.Uri); | ||
Assert.IsNotNull(document); | ||
Assert.IsTrue(!document.Errors.HasErrors); | ||
client.DidChangeTextDocument(new DidChangeTextDocumentParams { | ||
TextDocument = new OptionalVersionedTextDocumentIdentifier { | ||
Uri = documentItem.Uri, | ||
Version = documentItem.Version + 2 | ||
}, | ||
ContentChanges = new[] {new TextDocumentContentChangeEvent { | ||
Range = new Range((12, 9), (12, 13)), | ||
Text = "/" // A parse error | ||
}} | ||
}); | ||
await client.WaitForNotificationCompletionAsync(documentItem.Uri, CancellationToken); | ||
document = await Documents.GetDocumentAsync(documentItem.Uri); | ||
Assert.IsNotNull(document); | ||
Assert.IsTrue(document.Errors.HasErrors); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters