From 4cc2d6cce8a03edc1e9230e75fbf7c186b70add8 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedchin Date: Thu, 3 Aug 2023 16:57:08 -0700 Subject: [PATCH 1/3] Deprecate support for old CLI --- Source/DafnyCore/DafnyOptions.cs | 6 +- Source/DafnyCore/TestGenerationOptions.cs | 68 +------------------ Source/DafnyTestGeneration/DeadCodeCommand.cs | 16 ++--- .../GenerateTestsCommand.cs | 34 ++++++---- .../ProgramModification.cs | 2 +- docs/DafnyRef/Options.txt | 20 +----- docs/dev/news/4384.fix | 1 + 7 files changed, 31 insertions(+), 116 deletions(-) create mode 100644 docs/dev/news/4384.fix diff --git a/Source/DafnyCore/DafnyOptions.cs b/Source/DafnyCore/DafnyOptions.cs index 8bcbf9476d3..6eb521625e7 100644 --- a/Source/DafnyCore/DafnyOptions.cs +++ b/Source/DafnyCore/DafnyOptions.cs @@ -792,8 +792,8 @@ protected bool ParseDafnySpecificOption(string name, Bpl.CommandLineParseState p return true; } - // Unless this is an option for test generation, defer to superclass - return TestGenOptions.ParseOption(name, ps) || base.ParseOption(name, ps); + // Defer to superclass + return base.ParseOption(name, ps); } private static string[] ParseInnerArguments(string argumentsString) { @@ -1462,8 +1462,6 @@ focal predicate P to P#[_k-1]. /proverOpt:O:model.compact=false (for z3 version >= 4.8.7), and /proverOpt:O:model.completion=true. ----- Test generation options ----------------------------------------------- -{TestGenOptions.Help} ---- Compilation options --------------------------------------------------- /compile: diff --git a/Source/DafnyCore/TestGenerationOptions.cs b/Source/DafnyCore/TestGenerationOptions.cs index 72110edbb33..02a40421821 100644 --- a/Source/DafnyCore/TestGenerationOptions.cs +++ b/Source/DafnyCore/TestGenerationOptions.cs @@ -5,76 +5,14 @@ namespace Microsoft.Dafny { public class TestGenerationOptions { - - public static readonly string TestInlineAttribute = "testInline"; - public static readonly string TestEntryAttribute = "testEntry"; + public const string TestInlineAttribute = "testInline"; + public const string TestEntryAttribute = "testEntry"; public bool WarnDeadCode = false; public enum Modes { None, Block, Path }; public Modes Mode = Modes.None; public uint SeqLengthLimit = 0; [CanBeNull] public string PrintBpl = null; - public bool DisablePrune = false; + public bool ForcePrune = false; public const uint DefaultTimeLimit = 10; - - public bool ParseOption(string name, Bpl.CommandLineParseState ps) { - var args = ps.args; - - switch (name) { - - case "warnDeadCode": - WarnDeadCode = true; - Mode = Modes.Block; - return true; - - case "generateTestMode": - if (ps.ConfirmArgumentCount(1)) { - Mode = args[ps.i] switch { - "None" => Modes.None, - "Block" => Modes.Block, - "Path" => Modes.Path, - _ => throw new Exception("Invalid value for generateTestMode") - }; - } - return true; - - case "generateTestSeqLengthLimit": - var limit = 0; - if (ps.GetIntArgument(ref limit)) { - SeqLengthLimit = (uint)limit; - } - return true; - - case "generateTestPrintBpl": - if (ps.ConfirmArgumentCount(1)) { - PrintBpl = args[ps.i]; - } - return true; - - case "generateTestNoPrune": - DisablePrune = true; - return true; - } - - return false; - } - - public string Help => @" -/warnDeadCode - Use counterexample generation to warn about potential dead code. -/generateTestMode: - None (default) - Has no effect. - Block - Prints block-coverage tests for the given program. - Path - Prints path-coverage tests for the given program. - Using /definiteAssignment:3, /generateTestNoPrune, - /generateTestSeqLengthLimit, and /loopUnroll is highly recommended - when generating tests. -/generateTestSeqLengthLimit: - Add an axiom that sets the length of all sequences to be no greater - than . 0 (default) indicates no limit. -/generateTestPrintBpl: - Print the Boogie code used during test generation. -/generateTestNoPrune - Disable axiom pruning that Dafny uses to speed up verification."; - } } diff --git a/Source/DafnyTestGeneration/DeadCodeCommand.cs b/Source/DafnyTestGeneration/DeadCodeCommand.cs index c985b469028..95764d0a2e5 100644 --- a/Source/DafnyTestGeneration/DeadCodeCommand.cs +++ b/Source/DafnyTestGeneration/DeadCodeCommand.cs @@ -6,16 +6,17 @@ using System.CommandLine; using System.CommandLine.Invocation; using System.Linq; +using Microsoft.Boogie; namespace Microsoft.Dafny; public class DeadCodeCommand : ICommandSpec { public IEnumerable