aboutsummaryrefslogtreecommitdiff
path: root/test/test/CompilerTest.scala
diff options
context:
space:
mode:
authorNicolas Stucki <nicolas.stucki@gmail.com>2016-07-04 16:54:12 +0200
committerNicolas Stucki <nicolas.stucki@gmail.com>2016-07-07 11:39:11 +0200
commit1b4511be11338f56feb79eb0fcd28fa6e642f775 (patch)
treef121f06f6c44ea686c3a5753238b4875f72da819 /test/test/CompilerTest.scala
parent07fd8a357ed660ef15163efb2788928fec290fdd (diff)
downloaddotty-1b4511be11338f56feb79eb0fcd28fa6e642f775.tar.gz
dotty-1b4511be11338f56feb79eb0fcd28fa6e642f775.tar.bz2
dotty-1b4511be11338f56feb79eb0fcd28fa6e642f775.zip
Fix #1336: Discard reporter output for tests that succeed.
Diffstat (limited to 'test/test/CompilerTest.scala')
-rw-r--r--test/test/CompilerTest.scala25
1 files changed, 20 insertions, 5 deletions
diff --git a/test/test/CompilerTest.scala b/test/test/CompilerTest.scala
index 1977d21e0..3ee5597e6 100644
--- a/test/test/CompilerTest.scala
+++ b/test/test/CompilerTest.scala
@@ -1,8 +1,10 @@
package test
+import dotty.tools.dotc.core.Contexts._
import dotty.partest.DPConfig
import dotty.tools.dotc.{Main, Bench, Driver}
-import dotty.tools.dotc.reporting.Reporter
+import dotty.tools.dotc.interfaces.Diagnostic.ERROR
+import dotty.tools.dotc.reporting._
import dotty.tools.dotc.util.SourcePosition
import dotty.tools.dotc.config.CompilerCommand
import dotty.tools.io.PlainFile
@@ -12,8 +14,6 @@ import scala.tools.partest.nest.{ FileManager, NestUI }
import scala.annotation.tailrec
import java.io.{ RandomAccessFile, File => JFile }
-import org.junit.Test
-
/** This class has two modes: it can directly run compiler tests, or it can
* generate the necessary file structure for partest in the directory
@@ -234,7 +234,22 @@ abstract class CompilerTest {
(implicit defaultOptions: List[String]): Unit = {
val allArgs = args ++ defaultOptions
val processor = if (allArgs.exists(_.startsWith("#"))) Bench else Main
- val reporter = processor.process(allArgs)
+ val storeReporter = new Reporter with UniqueMessagePositions with HideNonSensicalMessages {
+ private val consoleReporter = new ConsoleReporter()
+ private var innerStoreReporter = new StoreReporter(consoleReporter)
+ def doReport(d: Diagnostic)(implicit ctx: Context): Unit = {
+ if (innerStoreReporter == null) {
+ consoleReporter.report(d)
+ } else {
+ innerStoreReporter.report(d)
+ if (d.level == ERROR) {
+ innerStoreReporter.flush()
+ innerStoreReporter = null
+ }
+ }
+ }
+ }
+ val reporter = processor.process(allArgs, storeReporter)
val nerrors = reporter.errorCount
val xerrors = (expectedErrorsPerFile map {_.totalErrors}).sum
@@ -244,7 +259,7 @@ abstract class CompilerTest {
}
assert(nerrors == xerrors,
s"""Wrong # of errors. Expected: $xerrors, found: $nerrors
- |Files with expected errors: $expectedErrorFiles%, %
+ |Files with expected errors: $expectedErrorFiles
""".stripMargin)
// NEG TEST
if (xerrors > 0) {