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

Add two options, /quiet and /silent #694

Merged
merged 4 commits into from
Feb 20, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 10 additions & 0 deletions Source/Core/CoreOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ public enum Inlining

public bool Trace { get; }

public enum VerbosityLevel
{
Silent,
Quiet,
Normal,
Trace
}

public VerbosityLevel Verbosity { get; }

public bool TraceVerify { get; }

public int VerifySnapshots { get; }
Expand Down
15 changes: 9 additions & 6 deletions Source/ExecutionEngine/CommandLineOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -431,10 +431,9 @@ public bool PrintWithUniqueASTIds {
[Peer] public XmlSink XmlSink { get; set; }
public bool Wait { get; set; }

public bool Trace {
get => trace;
set => trace = value;
}
public bool Trace => Verbosity == CoreOptions.VerbosityLevel.Trace;

public CoreOptions.VerbosityLevel Verbosity => verbosity;

public bool NormalizeNames
{
Expand Down Expand Up @@ -816,7 +815,6 @@ void ObjectInvariant5()
private bool trustNoninterference = false;
private bool trustRefinement = false;
private bool trustInductiveSequentialization = false;
private bool trace = false;
private int enhancedErrorMessages = 0;
private int stagedHoudiniThreads = 1;
private uint timeLimitPerAssertionInPercent = 10;
Expand All @@ -829,6 +827,7 @@ void ObjectInvariant5()
private bool emitDebugInformation = true;
private bool normalizeNames;
private bool normalizeDeclarationOrder = true;
private CoreOptions.VerbosityLevel verbosity = CoreOptions.VerbosityLevel.Normal;

public List<CoreOptions.ConcurrentHoudiniOptions> Cho { get; set; } = new();

Expand Down Expand Up @@ -1535,7 +1534,9 @@ protected override bool ParseOption(string name, CommandLineParseState ps)
ps.CheckBooleanFlag("printInstrumented", x => printInstrumented = x) ||
ps.CheckBooleanFlag("printWithUniqueIds", x => printWithUniqueAstIds = x) ||
ps.CheckBooleanFlag("wait", x => Wait = x) ||
ps.CheckBooleanFlag("trace", x => trace = x) ||
ps.CheckBooleanFlag("trace", x => verbosity = CoreOptions.VerbosityLevel.Trace) ||
ps.CheckBooleanFlag("quiet", x => verbosity = CoreOptions.VerbosityLevel.Quiet) ||
ps.CheckBooleanFlag("silent", x => verbosity = CoreOptions.VerbosityLevel.Silent) ||
ps.CheckBooleanFlag("traceTimes", x => TraceTimes = x) ||
ps.CheckBooleanFlag("tracePOs", x => TraceProofObligations = x) ||
ps.CheckBooleanFlag("noResolve", x => NoResolve = x) ||
Expand Down Expand Up @@ -2088,6 +2089,8 @@ print Boogie program after it has been instrumented with

---- Debugging and general tracing options ---------------------------------

/silent print nothing at all
/quiet print nothing but warnings and errors
/trace blurt out various debug trace information
/traceTimes output timing information at certain points in the pipeline
/tracePOs output information about the number of proof obligations
Expand Down
24 changes: 24 additions & 0 deletions Source/ExecutionEngine/ConsolePrinter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ public class ConsolePrinter : OutputPrinter
public virtual void ErrorWriteLine(TextWriter tw, string s)
{
Contract.Requires(s != null);
if (Options.Verbosity == CoreOptions.VerbosityLevel.Silent) {
return;
}

if (!s.Contains("Error: ") && !s.Contains("Error BP"))
{
tw.WriteLine(s);
Expand Down Expand Up @@ -48,6 +52,10 @@ public virtual void ErrorWriteLine(TextWriter tw, string s)
public virtual void ErrorWriteLine(TextWriter tw, string format, params object[] args)
{
Contract.Requires(format != null);
if (Options.Verbosity == CoreOptions.VerbosityLevel.Silent) {
return;
}

string s = string.Format(format, args);
ErrorWriteLine(tw, s);
}
Expand All @@ -56,6 +64,10 @@ public virtual void ErrorWriteLine(TextWriter tw, string format, params object[]
public virtual void AdvisoryWriteLine(TextWriter output, string format, params object[] args)
{
Contract.Requires(format != null);
if (Options.Verbosity == CoreOptions.VerbosityLevel.Silent) {
return;
}

ConsoleColor col = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine(format, args);
Expand All @@ -82,6 +94,10 @@ public virtual void WriteTrailer(TextWriter textWriter, PipelineStatistics stats
Contract.Requires(0 <= stats.VerifiedCount && 0 <= stats.ErrorCount && 0 <= stats.InconclusiveCount &&
0 <= stats.TimeoutCount && 0 <= stats.OutOfMemoryCount);

if (Options.Verbosity <= CoreOptions.VerbosityLevel.Quiet) {
return;
}

textWriter.WriteLine();
if (Options.ShowVerifiedProcedureCount)
{
Expand Down Expand Up @@ -128,6 +144,10 @@ public virtual void WriteErrorInformation(ErrorInformation errorInfo, TextWriter
{
Contract.Requires(errorInfo != null);

if (Options.Verbosity == CoreOptions.VerbosityLevel.Silent) {
return;
}

ReportBplError(errorInfo.Tok, errorInfo.FullMsg, true, tw);

foreach (var e in errorInfo.Aux)
Expand All @@ -148,6 +168,10 @@ public virtual void ReportBplError(IToken tok, string message, bool error, TextW
{
Contract.Requires(message != null);

if (Options.Verbosity == CoreOptions.VerbosityLevel.Silent) {
return;
}

if (category != null)
{
message = string.Format("{0}: {1}", category, message);
Expand Down
7 changes: 7 additions & 0 deletions Test/commandline/quiet.bpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// RUN: %parallel-boogie -quiet "%s" > "%t"
// RUN: %diff "%s.expect" "%t"

procedure BadAssert()
{
assert 1 == 2;
}
3 changes: 3 additions & 0 deletions Test/commandline/quiet.bpl.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
quiet.bpl(6,3): Error: this assertion could not be proved
Execution trace:
quiet.bpl(6,3): anon0
7 changes: 7 additions & 0 deletions Test/commandline/silent.bpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// RUN: %parallel-boogie -silent "%s" > "%t"

Choose a reason for hiding this comment

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

Does boogie have an exit code to test?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I thought it did, but apparently not! So -silent is not super useful for Boogie alone. The internal option it controls is useful for clients of Boogie as a library, like Dafny, however.

Choose a reason for hiding this comment

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

How does dafny know whether boogie is successful or not? I presume it makes some API call rather than spawning a command-line invocation.

I suggest you add an issue for boogie to return a proper exit code (though it is not an issue for me) like all good citizens should

Copy link
Contributor

Choose a reason for hiding this comment

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

Is the exit code typically spit out on the console along with other output?

It would be great if we could add the standard story for exit code to Boogie also.

Choose a reason for hiding this comment

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

In dafny testing, we write things like %exits-with 1 %parallel-boogie ...
to check the output exit code

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Dafny uses Boogie as a library, so it inspects the verification results directly. I added #695 to make Boogie emit a non-zero exit code when verification fails, like Dafny does.

// RUN: %diff "%s.expect" "%t"

procedure BadAssert()
{
assert 1 == 2;
}
Empty file.