-
Notifications
You must be signed in to change notification settings - Fork 267
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
Chore: Not generate boogie translation if not verifying #6067
base: master
Are you sure you want to change the base?
Changes from 2 commits
3dbf68f
865aa96
2e5d2c8
61a457f
54e6ec2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
using System.CommandLine; | ||
using System.CommandLine.Builder; | ||
using System.CommandLine.Invocation; | ||
using System.CommandLine.Parsing; | ||
using System.Diagnostics; | ||
using System.IO.Pipelines; | ||
using System.Reactive.Concurrency; | ||
using System.Reflection; | ||
using System.Text; | ||
using Microsoft.Dafny; | ||
using Microsoft.Extensions.Logging.Abstractions; | ||
using OmniSharp.Extensions.JsonRpc; | ||
using OmniSharp.Extensions.JsonRpc.Client; | ||
using OmniSharp.Extensions.JsonRpc.Serialization; | ||
using OmniSharp.Extensions.LanguageServer.Protocol.Client.Capabilities; | ||
using OmniSharp.Extensions.LanguageServer.Protocol.Models; | ||
using XunitAssertMessages; | ||
using Command = System.CommandLine.Command; | ||
|
||
namespace DafnyDriver.Test; | ||
|
||
|
||
public class OptionsTest { | ||
[Fact] | ||
public async Task RunFlagsOverride() { | ||
await TestCliRunArgs([], options => { | ||
Assert.True(options.DafnyVerify); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not a fan of tests for values in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Implementation details can still be tested by unit tests, and this is the meaning of that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But why test like this? You could also test without looking at internals. For example, by using the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did not know about |
||
Assert.True(options.Verify); | ||
return 0; | ||
}); | ||
await TestCliRunArgs(["--no-verify"], options => { | ||
Assert.False(options.DafnyVerify); | ||
Assert.False(options.Verify); | ||
return 0; | ||
}); | ||
await TestCliRunArgs(["--no-verify", "--bprint=-"], options => { | ||
Assert.True(options.DafnyVerify); | ||
Assert.False(options.Verify); | ||
return 0; | ||
}); | ||
} | ||
|
||
private static async Task TestCliRunArgs(string[] cmdArgs, Func<DafnyOptions, int> optionsCallback) { | ||
var fullArgs = new string[] { | ||
"run" | ||
}; | ||
fullArgs = fullArgs.Concat(cmdArgs).Concat(new string[] { "file.dfy" }).ToArray(); | ||
var callbackCalled = false; | ||
var newOptionsCallback = (DafnyOptions options) => { | ||
callbackCalled = true; | ||
return optionsCallback(options); | ||
}; | ||
Command cmd = RunCommand.Create(newOptionsCallback); | ||
var rootCommand = new RootCommand("Test root command"); | ||
rootCommand.AddCommand(cmd); | ||
var builder = new CommandLineBuilder(rootCommand).UseDefaults(); | ||
var parser = builder.Build(); | ||
TextReader inputReader = new StringReader(""); | ||
var outputWriter = new StringWriter(); | ||
var errorWriter = new StringWriter(); | ||
var console = new WritersConsole(inputReader, outputWriter, errorWriter); | ||
var exitCode = await DafnyNewCli.ExecuteForParser(console, fullArgs, parser); | ||
Assert.Equal<object>("", errorWriter.ToString()); | ||
Assert.Equal(0, exitCode); | ||
Assert.True(callbackCalled); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,7 +49,7 @@ static RunCommand() { | |
Concat(DafnyCommands.ConsoleOutputOptions). | ||
Concat(DafnyCommands.ResolverOptions); | ||
|
||
public static Command Create() { | ||
public static Command Create(Func<DafnyOptions, int> continuation = null) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is this for? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's to be able to create a Run command but with a continuation different than the one that launches the regular pipeline, to be able to test the parsing of options only. If you have any other way I could achieve the same result, I'd happily consider it. |
||
var result = new Command("run", "Run the program."); | ||
result.AddArgument(DafnyCommands.FileArgument); | ||
result.AddArgument(UserProgramArguments); | ||
|
@@ -63,7 +63,9 @@ public static Command Create() { | |
options.Compile = true; | ||
options.RunAfterCompile = true; | ||
options.ForceCompile = options.Get(BoogieOptionBag.NoVerify); | ||
|
||
if (continuation != null) { | ||
return continuation(options); | ||
} | ||
return await SynchronousCliCompilation.Run(options); | ||
}); | ||
return result; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2294,6 +2294,8 @@ and what information it produces about the verification process. | |
|
||
* `--no-verify` - turns off verification (for translate, build, run commands) | ||
|
||
* `--do-boogie-translation` - turns on translation to Boogie after resolving or if `--no-verify` is set. Automatically set if `--bprint` is set. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Outdated, please remove |
||
|
||
* `--verify-included-files` (was `-verifyAllModules`) - verify modules that come from include directives. | ||
|
||
By default, Dafny only verifies files explicitly listed on the command | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add
|| options.Get(DeveloperOptionBag.SplitPrint) != null
?