diff options
author | vsalvis <salvisbergvera@gmail.com> | 2015-04-15 14:34:53 +0200 |
---|---|---|
committer | vsalvis <salvisbergvera@gmail.com> | 2015-04-17 18:13:44 +0200 |
commit | 8d08915765848d1370542742c8b7482bd1bf86d0 (patch) | |
tree | f8a794ba285e0eff28930cffe21cf7956aa9371b /test/dotty/partest/DPDirectCompiler.scala | |
parent | 85b48de299fcdba17397c59c9bcaa0a69da93350 (diff) | |
download | dotty-8d08915765848d1370542742c8b7482bd1bf86d0.tar.gz dotty-8d08915765848d1370542742c8b7482bd1bf86d0.tar.bz2 dotty-8d08915765848d1370542742c8b7482bd1bf86d0.zip |
Partest for Dotty with pos tests and neg tests with error count
Diffstat (limited to 'test/dotty/partest/DPDirectCompiler.scala')
-rw-r--r-- | test/dotty/partest/DPDirectCompiler.scala | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/test/dotty/partest/DPDirectCompiler.scala b/test/dotty/partest/DPDirectCompiler.scala new file mode 100644 index 000000000..86e766505 --- /dev/null +++ b/test/dotty/partest/DPDirectCompiler.scala @@ -0,0 +1,34 @@ +package dotty.partest + +import scala.tools.partest.{ TestState, nest } +import java.io.File + + +/* NOTE: Adapted from partest.DirectCompiler and DottyTest */ +class DPDirectCompiler(runner: nest.Runner) extends nest.DirectCompiler(runner) { + + override def compile(opts0: List[String], sources: List[File]): TestState = { + println("\ncompiling " + sources.mkString(" ") + "\noptions: " + opts0.mkString(" ")) + + implicit var ctx: dotty.tools.dotc.core.Contexts.Context = { + val base = new dotty.tools.dotc.core.Contexts.ContextBase + import base.settings._ + val ctx = base.initialCtx.fresh.setSetting(printtypes, true) + .setSetting(pageWidth, 90).setSetting(log, List("<some")) + base.definitions.init(ctx) + ctx + } + + try { + val processor = if (opts0.exists(_.startsWith("#"))) dotty.tools.dotc.Bench else dotty.tools.dotc.Main + val reporter = processor.process((sources.map(_.toString) ::: opts0).toArray, ctx) + if (!reporter.hasErrors) runner.genPass() + else { + reporter.printSummary(ctx) + runner.genFail(s"compilation failed with ${reporter.errorCount} errors") + } + } catch { + case t: Throwable => runner.genCrash(t) + } + } +} |