Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge functionality to filter out tests #9

Open
wants to merge 14 commits into
base: Latest
Choose a base branch
from
11 changes: 11 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,14 @@ All other pull requests and issues can be submitted here.
## Code of Conduct

See [`CODE_OF_CONDUCT.md`](./CODE_OF_CONDUCT.md).

## FAQ

### What to do if the nightly build failed but because of a "download failure"?

If the test in a PR named `Build and Test / check-deep-tests / check-deep-tests` failed, clicking on its "details" reveals a view (view 1) in which you can see a failed run with the failure being something like "Error: Last run of deep-tests.yml did not succeed (some URL in parentheses).

Clicking on this URL will reveal the deep tests that were run (view 2). If one of this test is just a "download failure", then one simply needs to re-run it (button on the top right).
Once it succeeds, one has to go back to (view 1) and re-run the failed jobs, so that it will retrieve the latest successful deep tests.

After doing these steps once, for other PRs, one only needs to re-run deep checks in (view 1)
2 changes: 2 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Upcoming

- fix: Hovering over variables and methods inside cases of nested match statements work again (https://github.com/dafny-lang/dafny/pull/2334)
- fix: Fix bug in translation of two-state predicates with heap labels. (https://github.com/dafny-lang/dafny/pull/2300)
- fix: Check that arguments of 'unchanged' satisfy enclosing reads clause. (https://github.com/dafny-lang/dafny/pull/2302)
- fix: Caching in the language server does not prevent gutter icons from being updated correctly. (https://github.com/dafny-lang/dafny/pull/2312)
- fix: Correctly infer type of numeric arguments, where the type is a subset type of a newtype. (https://github.com/dafny-lang/dafny/pull/2314)

# 3.7.1
Expand Down
2 changes: 1 addition & 1 deletion Source/Dafny/Resolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11964,7 +11964,7 @@ private class RBranchStmt : RBranch {
}

public RBranchStmt(int branchid, NestedMatchCaseStmt x, Attributes attrs = null) : base(x.Tok, branchid, new List<ExtendedPattern>()) {
this.Body = x.Body.ConvertAll((new Cloner()).CloneStmt);
this.Body = new List<Statement>(x.Body); // Resolving the body will insert new elements.
this.Attributes = attrs;
this.Patterns.Add(x.Pat);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
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.Language;
using Microsoft.Dafny.LanguageServer.Workspace;
using Microsoft.Dafny.LanguageServer.Workspace.Notifications;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
using Range = OmniSharp.Extensions.LanguageServer.Protocol.Models.Range;

namespace Microsoft.Dafny.LanguageServer.IntegrationTest.Diagnostics;

[TestClass]
public class CachedLinearVerificationGutterStatusTester : LinearVerificationGutterStatusTester {
private const int MaxTestExecutionTimeMs = 10000;



// To add a new test, just call VerifyTrace on a given program,
// the test will fail and give the correct output that can be use for the test
// Add '//Next<n>:' to edit a line multiple times

[TestMethod, Timeout(MaxTestExecutionTimeMs)]
public async Task EnsureCachingDoesNotMakeSquigglyLinesToRemain() {
await SetUp(new Dictionary<string, string>() {
{ $"{VerifierOptions.Section}:{nameof(VerifierOptions.VerifySnapshots)}", "1" }
});
await VerifyTrace(@"
. S S | I $ | :method test() {
. S | | I $ | : assert true;
. S S | I $ | : //Next:
. S S | I $ | :}");
}

[TestMethod, Timeout(MaxTestExecutionTimeMs)]
public async Task EnsureCachingDoesNotHideErrors() {
await SetUp(new Dictionary<string, string>() {
{ $"{VerifierOptions.Section}:{nameof(VerifierOptions.VerifySnapshots)}", "1" }
});
await VerifyTrace(@"
. S [S][ ][I][S][S][ ]:method test() {
. S [O][O][o][Q][O][O]: assert true;
. S [=][=][-][~][=][=]: assert false;
. S [S][ ][I][S][S][ ]: //Next:
. S [S][ ][I][S][S][ ]:}");
}
}
11 changes: 11 additions & 0 deletions Source/DafnyLanguageServer.Test/Lookup/HoverTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -427,5 +427,16 @@ function ToRelativeIndependent(): (p: Position)
}
");
}

[TestMethod]
public async Task HoveringVariablesInsideNestedMatchStmtWorks() {
await AssertHover(@"
lemma dummy(e: int) {
match e {
case _ => var xx := 1;
^[```dafny\nghost xx: int\n```]
}
}");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class AssertionBatchCompletedObserver : OutputPrinter {

public void ReportSplitResult(Split split, VCResult vcResult) {
if (reportVerificationDiagnostics) {
completedBatches.OnNext(new AssertionBatchResult(split, vcResult));
completedBatches.OnNext(new AssertionBatchResult(split.Implementation, vcResult));
}
}

Expand Down
2 changes: 1 addition & 1 deletion Source/DafnyLanguageServer/Language/IProgramVerifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using VC;

namespace Microsoft.Dafny.LanguageServer.Language {
public record AssertionBatchResult(Split Split, VCResult Result);
public record AssertionBatchResult(Implementation Implementation, VCResult Result);

public record ProgramVerificationTasks(IReadOnlyList<IImplementationTask> Tasks);

Expand Down
8 changes: 7 additions & 1 deletion Source/DafnyLanguageServer/Workspace/TextDocumentLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ VerifierOptions verifierOptions
}
var implementations = verificationTasks.Select(t => t.Implementation).ToHashSet();
var subscription = verifier.BatchCompletions.Where(c =>
implementations.Contains(c.Split.Implementation)).Subscribe(progressReporter.ReportAssertionBatchResult);
implementations.Contains(c.Implementation)).Subscribe(progressReporter.ReportAssertionBatchResult);
cancellationToken.Register(() => subscription.Dispose());
result.GutterProgressReporter = progressReporter;
return result;
Expand Down Expand Up @@ -245,6 +245,12 @@ bool loadCanceled

var statusUpdates = implementationTask.TryRun();
if (statusUpdates == null) {
if (VerifierOptions.GutterStatus && implementationTask.CacheStatus is Completed completedCache) {
foreach (var result in completedCache.Result.VCResults) {
dafnyDocument.GutterProgressReporter!.ReportAssertionBatchResult(new AssertionBatchResult(implementationTask.Implementation, result));
}
dafnyDocument.GutterProgressReporter!.ReportEndVerifyImplementation(implementationTask.Implementation, completedCache.Result);
}
return Observable.Empty<DafnyDocument>();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,8 @@ INotificationPublisher notificationPublisher
return;
}
lock (LockProcessing) {
var split = batchResult.Split;
var implementation = batchResult.Implementation;
var result = batchResult.Result;
var implementation = split.Implementation;
// While there is no error, just add successful nodes.
var targetMethodNode = GetTargetMethodTree(implementation, out var implementationNode);
if (targetMethodNode == null) {
Expand Down
5 changes: 0 additions & 5 deletions docs/OnlineTutorial/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@

# Getting Started with Dafny: A Guide

Be sure to follow along with the code examples by clicking the "load
in editor" link in the
corner. See what the tool says, try to fix programs on your own, and
experiment!

## Introduction

Dafny is a language that is designed to make it easy to
Expand Down