aboutsummaryrefslogtreecommitdiff
path: root/compiler/test/dotty
diff options
context:
space:
mode:
authorFelix Mulder <felix.mulder@gmail.com>2017-03-09 16:45:23 +0100
committerFelix Mulder <felix.mulder@gmail.com>2017-03-29 10:33:21 +0200
commit5ce54c68f9130dea5b4d31b3b47bb78d76a57952 (patch)
tree6741281428ebd4aec1c0772ebf671bd2fabe8d2d /compiler/test/dotty
parent9ba9b147fb8d7894761e2f2fb18b08601981db20 (diff)
downloaddotty-5ce54c68f9130dea5b4d31b3b47bb78d76a57952.tar.gz
dotty-5ce54c68f9130dea5b4d31b3b47bb78d76a57952.tar.bz2
dotty-5ce54c68f9130dea5b4d31b3b47bb78d76a57952.zip
Add initial compilation functionality to ParallelTesting trait
Diffstat (limited to 'compiler/test/dotty')
-rw-r--r--compiler/test/dotty/tools/dotc/ParallelTesting.scala41
1 files changed, 41 insertions, 0 deletions
diff --git a/compiler/test/dotty/tools/dotc/ParallelTesting.scala b/compiler/test/dotty/tools/dotc/ParallelTesting.scala
new file mode 100644
index 000000000..5df9e2e3d
--- /dev/null
+++ b/compiler/test/dotty/tools/dotc/ParallelTesting.scala
@@ -0,0 +1,41 @@
+package dotty
+package tools
+package dotc
+
+import java.io.{ File => JFile }
+import scala.io.Source
+
+import core.Contexts._
+import reporting.{ Reporter, UniqueMessagePositions, HideNonSensicalMessages, MessageRendering }
+import reporting.diagnostic.MessageContainer
+import interfaces.Diagnostic.ERROR
+import java.nio.file.StandardCopyOption.REPLACE_EXISTING
+import java.nio.file.{ Files, Path, Paths }
+
+trait ParallelTesting {
+
+ private val driver = new Driver {
+ override def newCompiler(implicit ctx: Context) = new Compiler
+ }
+
+ private class DaftReporter(suppress: Boolean)
+ extends Reporter with UniqueMessagePositions with HideNonSensicalMessages
+ with MessageRendering {
+ private var _errors: List[MessageContainer] = Nil
+ def errors = _errors
+
+ override def doReport(m: MessageContainer)(implicit ctx: Context) = {
+ if (!suppress && m.level == ERROR) {
+ _errors = m :: _errors
+ System.err.println(messageAndPos(m.contained, m.pos, diagnosticLevel(m)))
+ }
+ }
+ }
+
+ private def compile(files: Array[JFile], flags: Array[String]): (Array[JFile], List[MessageContainer]) = {
+ val reporter = new DaftReporter(suppress = false)
+ driver.process(flags ++ files.map(_.getAbsolutePath), reporter = reporter)
+ files -> reporter.errors
+ }
+
+}