Skip to content

Commit

Permalink
tests that gobra messages are printable
Browse files Browse the repository at this point in the history
  • Loading branch information
ArquintL committed Dec 4, 2023
1 parent 9f38d64 commit 625426f
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/test/scala/viper/gobra/GobraTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import viper.gobra.frontend.Source.FromFileSource
import viper.gobra.frontend.info.Info
import viper.gobra.frontend.{Config, PackageResolver, Parser, Source}
import viper.gobra.reporting.VerifierResult.{Failure, Success}
import viper.gobra.reporting.{NoopReporter, VerifierError}
import viper.gobra.reporting.{GobraMessage, GobraReporter, VerifierError}
import viper.silver.testing.{AbstractOutput, AnnotatedTestInput, ProjectInfo, SystemUnderTest}
import viper.silver.utility.TimingUtils
import viper.gobra.util.{DefaultGobraExecutionContext, GobraExecutionContext}
Expand Down Expand Up @@ -51,7 +51,7 @@ class GobraTests extends AbstractGobraTests with BeforeAndAfterAll {
private def getConfig(source: Source): Config =
Config(
logLevel = Level.INFO,
reporter = NoopReporter,
reporter = StringifyReporter,
packageInfoInputMap = Map(Source.getPackageInfo(source, Path.of("")) -> Vector(source)),
checkConsistency = true,
cacheParserAndTypeChecker = cacheParserAndTypeChecker,
Expand Down Expand Up @@ -120,4 +120,13 @@ class GobraTests extends AbstractGobraTests with BeforeAndAfterAll {
/** A short and unique identifier for this output. */
override def fullId: String = error.id
}

case object StringifyReporter extends GobraReporter {
override val name: String = "StringifyReporter"

override def report(msg: GobraMessage): Unit = {
// by invoking `toString`, we check that messages are printable, which includes pretty-printing AST nodes:
msg.toString
}
}
}

0 comments on commit 625426f

Please sign in to comment.