Skip to content

Commit

Permalink
Suppress compile errors log during running CompilerSpec
Browse files Browse the repository at this point in the history
  • Loading branch information
tototoshi committed Mar 11, 2022
1 parent 4174fe4 commit e892f83
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion compiler/src/test/scala-3/play/twirl/compiler/test/Helper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import Contexts.Context
import Contexts.ctx
import dotty.tools.dotc.Compiler
import dotty.tools.dotc.Driver
import dotty.tools.dotc.reporting.ConsoleReporter
import dotty.tools.dotc.reporting.Reporter
import dotty.tools.io.PlainDirectory
import dotty.tools.io.Directory
Expand Down Expand Up @@ -94,7 +95,18 @@ object Helper {
def compile(): Reporter = {
val Some((toCompile, rootCtx)) = setup(compilerArgs :+ path.toAbsolutePath.toString, initCtx.fresh)

given Context = rootCtx.fresh.setSetting(rootCtx.settings.outputDir, new PlainDirectory(Directory(outDir)))
val silentReporter = new ConsoleReporter.AbstractConsoleReporter {
def printMessage(msg: String): Unit = {
// We want to suppress compile errors log.
//
// Some of Twirl's tests verify that the template cannot be compiled.
// It would be confusing to the developer if a compile error message were displayed at that time.
}
}

given Context = rootCtx.fresh
.setSetting(rootCtx.settings.outputDir, new PlainDirectory(Directory(outDir)))
.setReporter(silentReporter)

doCompile(newCompiler, toCompile)
}
Expand Down

0 comments on commit e892f83

Please sign in to comment.