Skip to content

Commit abf258e

Browse files
committed
Fix 1336: Discard reporter output for tests that succeed.
1 parent 07fd8a3 commit abf258e

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

test/test/CompilerTest.scala

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package test
22

3+
import dotty.tools.dotc.core.Contexts._
34
import dotty.partest.DPConfig
45
import dotty.tools.dotc.{Main, Bench, Driver}
5-
import dotty.tools.dotc.reporting.Reporter
6+
import dotty.tools.dotc.interfaces.Diagnostic.ERROR
7+
import dotty.tools.dotc.reporting._
68
import dotty.tools.dotc.util.SourcePosition
79
import dotty.tools.dotc.config.CompilerCommand
810
import dotty.tools.io.PlainFile
@@ -12,8 +14,6 @@ import scala.tools.partest.nest.{ FileManager, NestUI }
1214
import scala.annotation.tailrec
1315
import java.io.{ RandomAccessFile, File => JFile }
1416

15-
import org.junit.Test
16-
1717

1818
/** This class has two modes: it can directly run compiler tests, or it can
1919
* generate the necessary file structure for partest in the directory
@@ -234,7 +234,22 @@ abstract class CompilerTest {
234234
(implicit defaultOptions: List[String]): Unit = {
235235
val allArgs = args ++ defaultOptions
236236
val processor = if (allArgs.exists(_.startsWith("#"))) Bench else Main
237-
val reporter = processor.process(allArgs)
237+
val storeReporter = new Reporter with UniqueMessagePositions with HideNonSensicalMessages {
238+
private val consoleReporter = new ConsoleReporter()
239+
private var innerStoreReporter = new StoreReporter(consoleReporter)
240+
def doReport(d: Diagnostic)(implicit ctx: Context): Unit = {
241+
if (innerStoreReporter == null) {
242+
consoleReporter.report(d)
243+
} else {
244+
innerStoreReporter.report(d)
245+
if (d.level == ERROR) {
246+
innerStoreReporter.flush()
247+
innerStoreReporter = null
248+
}
249+
}
250+
}
251+
}
252+
val reporter = processor.process(allArgs, storeReporter)
238253

239254
val nerrors = reporter.errorCount
240255
val xerrors = (expectedErrorsPerFile map {_.totalErrors}).sum
@@ -244,7 +259,7 @@ abstract class CompilerTest {
244259
}
245260
assert(nerrors == xerrors,
246261
s"""Wrong # of errors. Expected: $xerrors, found: $nerrors
247-
|Files with expected errors: $expectedErrorFiles%, %
262+
|Files with expected errors: $expectedErrorFiles
248263
""".stripMargin)
249264
// NEG TEST
250265
if (xerrors > 0) {

0 commit comments

Comments
 (0)