Skip to content

Commit 0fdacfb

Browse files
authored
Add command line option to report partial results via StdIOReporter (#887)
1 parent 91843f7 commit 0fdacfb

3 files changed

Lines changed: 29 additions & 4 deletions

File tree

src/main/scala/viper/silver/frontend/SilFrontEndConfig.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,12 @@ abstract class SilFrontendConfig(args: Seq[String], private var projectName: Str
152152
noshort = true
153153
)
154154

155+
val reportPartialResults = opt[Boolean](name = "reportPartialResults",
156+
descr = "Whether to report partial verification success and failure for individual members and branches via the StdIOReporter.",
157+
default = Some(false),
158+
noshort = true
159+
)
160+
155161
validateOpt(file, ignoreFile) {
156162
case (_, Some(true)) => Right(())
157163
case (Some(filepath), _) => validateFileOpt(file.name, filepath)

src/main/scala/viper/silver/frontend/SilFrontend.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,10 @@ trait SilFrontend extends DefaultFrontend {
233233

234234
if (_config != null) {
235235
resetPlugins()
236+
reporter match {
237+
case cf: ConfigurableReporter => cf.setConfig(Some(_config))
238+
case _ =>
239+
}
236240
}
237241
}
238242

src/main/scala/viper/silver/reporter/Reporter.scala

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
package viper.silver.reporter
88

9+
import viper.silver.frontend.SilFrontendConfig
910
import viper.silver.plugin.SilverPluginManager
1011
import viper.silver.verifier.Success
1112

@@ -23,6 +24,14 @@ object NoopReporter extends Reporter {
2324
def report(msg: Message): Unit = ()
2425
}
2526

27+
trait ConfigurableReporter extends Reporter {
28+
protected var config: Option[SilFrontendConfig] = None
29+
30+
def setConfig(c: Option[SilFrontendConfig]): Unit = {
31+
config = c
32+
}
33+
}
34+
2635
trait PluginAwareReporter extends Reporter {
2736

2837
protected var plugins: Option[SilverPluginManager] = None
@@ -115,7 +124,8 @@ case class CSVReporter(name: String = "csv_reporter", path: String = "report.csv
115124
}
116125
}
117126

118-
case class StdIOReporter(name: String = "stdout_reporter", timeInfo: Boolean = true) extends PluginAwareReporter {
127+
case class StdIOReporter(name: String = "stdout_reporter",
128+
timeInfo: Boolean = true) extends PluginAwareReporter with ConfigurableReporter {
119129

120130
var counter = 0
121131

@@ -126,6 +136,8 @@ case class StdIOReporter(name: String = "stdout_reporter", timeInfo: Boolean = t
126136

127137
private def bulletFmt(num_items: Int): String = s"%${num_items.toString.length}d"
128138

139+
private def shouldReportPartial = config.isDefined && config.get.reportPartialResults.getOrElse(false)
140+
129141
def doReport(msg: Message): Unit = {
130142
msg match {
131143
case AstConstructionFailureMessage(t, res) =>
@@ -209,9 +221,12 @@ case class StdIOReporter(name: String = "stdout_reporter", timeInfo: Boolean = t
209221
println( s"encountered missing dependency: $text" )
210222

211223
// These get reported without being transformed by any plugins, it would be an issue if we printed them to STDOUT.
212-
case EntitySuccessMessage(_, _, _, _) => // FIXME Currently, we only print overall verification results to STDOUT.
213-
case EntityFailureMessage(_, _, _, _, _) => // FIXME Currently, we only print overall verification results to STDOUT.
214-
case BranchFailureMessage(_, _, _, _) => // FIXME Currently, we only print overall verification results to STDOUT.
224+
case EntitySuccessMessage(_, _, _, _) =>
225+
if (shouldReportPartial) println(msg)
226+
case EntityFailureMessage(_, _, _, _, _) =>
227+
if (shouldReportPartial) println(msg)
228+
case BranchFailureMessage(_, _, _, _) =>
229+
if (shouldReportPartial) println(msg)
215230
case ConfigurationConfirmation(_) => // TODO use for progress reporting
216231
//println( s"Configuration confirmation: $text" )
217232
case InternalWarningMessage(_) => // TODO use for progress reporting

0 commit comments

Comments
 (0)