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

Allow the :test attribute when using run and build #3275

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Source/DafnyCore/Compilers/Compiler-Csharp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3390,7 +3390,7 @@ public override bool RunTargetProgram(string dafnyProgramName, string targetProg
}

private void AddTestCheckerIfNeeded(string name, Declaration decl, ConcreteSyntaxTree wr) {
if (DafnyOptions.O.RunAllTests || !Attributes.Contains(decl.Attributes, "test")) {
if (DafnyOptions.O.Compile || DafnyOptions.O.RunAllTests || !Attributes.Contains(decl.Attributes, "test")) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just checking that the intended behavior is that methods marked {:test} are only compiled when testing

Copy link
Member Author

@keyboardDrummer keyboardDrummer Dec 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They're always compiled when compiling, but the C# XUnit.Fact attribute is only added when using dafny translate.

return;
}

Expand Down
9 changes: 8 additions & 1 deletion Source/DafnyCore/Options/DeveloperOptionBag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@ namespace Microsoft.Dafny;

public class DeveloperOptionBag {

public static readonly Option<bool> SpillTranslation = new("--spill-translation",
@"In case the Dafny source code is translated to another language, emit that translation.") {
IsHidden = true
};

public static readonly Option<bool> UseBaseFileName = new("--useBaseNameForFileName",
"When parsing use basename of file for tokens instead of the path supplied on the command line") {
IsHidden = true
};

public static readonly Option<string> BoogiePrint = new("--bprint",
@"
@"
Print Boogie program translated from Dafny
(use - as <file> to print to console)".TrimStart()) {
IsHidden = true,
Expand All @@ -33,6 +38,8 @@ Print Dafny program after resolving it.
};

static DeveloperOptionBag() {
DafnyOptions.RegisterLegacyBinding(SpillTranslation, (o, f) => o.SpillTargetCode = f ? 1U : 0U);

DafnyOptions.RegisterLegacyBinding(ResolvedPrint, (options, value) => {
options.DafnyPrintResolvedFile = value;
options.ExpandFilename(options.DafnyPrintResolvedFile, x => options.DafnyPrintResolvedFile = x, options.LogPrefix,
Expand Down
3 changes: 2 additions & 1 deletion Source/DafnyCore/Options/ICommandSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ static ICommandSpec() {
}.Concat(VerificationOptions).ToList();

public static IReadOnlyList<Option> ExecutionOptions = new Option[] {
CommonOptionBag.Target
CommonOptionBag.Target,
DeveloperOptionBag.SpillTranslation
}.Concat(TranslationOptions).ToList();

public static IReadOnlyList<Option> ConsoleOutputOptions = new List<Option>(new Option[] {
Expand Down