-
Notifications
You must be signed in to change notification settings - Fork 271
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Chore: Support for
--do-boogie-translation
And not activated by default if `--no-verify` is set. This option emulates the `/dafnyVerify` command in the previous CLI Added tests
- Loading branch information
1 parent
c9cffc3
commit 3dbf68f
Showing
7 changed files
with
96 additions
and
7 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
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
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 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); | ||
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", "--do-boogie-translation"], options => { | ||
Assert.True(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); | ||
} | ||
} |
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
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
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
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