-
Notifications
You must be signed in to change notification settings - Fork 261
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
366f00c
commit 48e3482
Showing
6 changed files
with
168 additions
and
84 deletions.
There are no files selected for viewing
74 changes: 74 additions & 0 deletions
74
Source/DafnyLanguageServer.Test/Diagnostics/ConcurrentLinearVerificationDiagnosticTester.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,74 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text.RegularExpressions; | ||
using System.Threading.Tasks; | ||
using Microsoft.Dafny.LanguageServer.IntegrationTest.Extensions; | ||
using Microsoft.Dafny.LanguageServer.IntegrationTest.Util; | ||
using Microsoft.Dafny.LanguageServer.Workspace.Notifications; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using OmniSharp.Extensions.JsonRpc; | ||
using OmniSharp.Extensions.LanguageServer.Protocol.Document; | ||
using OmniSharp.Extensions.LanguageServer.Protocol.Models; | ||
using Range = OmniSharp.Extensions.LanguageServer.Protocol.Models.Range; | ||
|
||
namespace Microsoft.Dafny.LanguageServer.IntegrationTest.Diagnostics; | ||
|
||
[TestClass] | ||
public class ConcurrentLinearVerificationDiagnosticTester : LinearVerificationDiagnosticTester { | ||
private const int MaxSimultaneousVerificationTasks = 3; | ||
|
||
protected DiagnosticsReceiver[] diagnosticsReceivers = new DiagnosticsReceiver[MaxSimultaneousVerificationTasks]; | ||
protected TestNotificationReceiver<VerificationStatusGutter>[] verificationDiagnosticsReceivers = | ||
new TestNotificationReceiver<VerificationStatusGutter>[MaxSimultaneousVerificationTasks]; | ||
|
||
private void NotifyAllDiagnosticsReceivers(PublishDiagnosticsParams request) { | ||
foreach (var receiver in diagnosticsReceivers) { | ||
receiver.NotificationReceived(request); | ||
} | ||
} | ||
|
||
private void NotifyAllVerificationDiagnosticsReceivers(VerificationStatusGutter request) { | ||
foreach (var receiver in verificationDiagnosticsReceivers) { | ||
receiver.NotificationReceived(request); | ||
} | ||
} | ||
|
||
[TestInitialize] | ||
public override async Task SetUp() { | ||
for (var i = 0; i < diagnosticsReceivers.Length; i++) { | ||
diagnosticsReceivers[i] = new(); | ||
verificationDiagnosticsReceivers[i] = new(); | ||
} | ||
verificationDiagnosticsReceiver = new(); | ||
client = await InitializeClient(options => | ||
options | ||
.OnPublishDiagnostics(NotifyAllDiagnosticsReceivers) | ||
.AddHandler(DafnyRequestNames.VerificationStatusGutter, | ||
NotificationHandler.For<VerificationStatusGutter>(NotifyAllVerificationDiagnosticsReceivers)) | ||
); | ||
} | ||
|
||
[TestMethod/*, Timeout(MaxTestExecutionTimeMs)*/] | ||
public async Task EnsuresManyDocumentsCanBeVerifiedAtOnce() { | ||
var result = new List<Task>(); | ||
for (var i = 0; i < MaxSimultaneousVerificationTasks; i++) { | ||
result.Add(VerifyTrace(@" | ||
. | | | I | | :predicate F(i: int) { | ||
. | | | I | | : false // Should not be highlighted in gutter. | ||
. | | | I | | :} | ||
| | | I | | : | ||
. S [S][ ][I][S][ ]:method H() | ||
. S [=][=][-][~][O]: ensures F(1) | ||
. S [=][=][-][~][=]:{//Next: { assert false; | ||
. S [S][ ][I][S][ ]:}", $"testfile{i}.dfy", diagnosticsReceivers[i], verificationDiagnosticsReceivers[i])); | ||
} | ||
|
||
for (var i = 0; i < MaxSimultaneousVerificationTasks; i++) { | ||
await result[i]; | ||
} | ||
|
||
//await Task.WhenAll(result.ToArray()); | ||
} | ||
|
||
} |
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
Oops, something went wrong.