diff options
author | Felix Mulder <felix.mulder@gmail.com> | 2017-03-09 16:47:39 +0100 |
---|---|---|
committer | Felix Mulder <felix.mulder@gmail.com> | 2017-03-29 10:33:21 +0200 |
commit | 58e1c659c406705e84322f96b500eecc754f99cd (patch) | |
tree | 29b5921bc486d7400c8490e19274ed0e43f72bfc | |
parent | 531c7226d9a765aa1530f4437633365e3e140f0f (diff) | |
download | dotty-58e1c659c406705e84322f96b500eecc754f99cd.tar.gz dotty-58e1c659c406705e84322f96b500eecc754f99cd.tar.bz2 dotty-58e1c659c406705e84322f96b500eecc754f99cd.zip |
Add java compilation to `ParallelTesting`
-rw-r--r-- | compiler/test/dotty/tools/dotc/ParallelTesting.scala | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/compiler/test/dotty/tools/dotc/ParallelTesting.scala b/compiler/test/dotty/tools/dotc/ParallelTesting.scala index 4061517e6..eada2c763 100644 --- a/compiler/test/dotty/tools/dotc/ParallelTesting.scala +++ b/compiler/test/dotty/tools/dotc/ParallelTesting.scala @@ -33,6 +33,29 @@ trait ParallelTesting { } private def compile(files: Array[JFile], flags: Array[String]): (Array[JFile], List[MessageContainer]) = { + + def findJarFromRuntime(partialName: String) = { + val urls = ClassLoader.getSystemClassLoader.asInstanceOf[java.net.URLClassLoader].getURLs.map(_.getFile.toString) + urls.find(_.contains(partialName)).getOrElse { + throw new java.io.FileNotFoundException( + s"""Unable to locate $partialName on classpath:\n${urls.toList.mkString("\n")}""" + ) + } + } + + def compileWithJavac(fs: Array[String]) = if (fs.nonEmpty) { + val scalaLib = findJarFromRuntime("scala-library") + val fullArgs = Array( + "javac", + "-classpath", + s".:$scalaLib" + ) ++ flags.takeRight(2) ++ fs + + assert(Runtime.getRuntime.exec(fullArgs).waitFor() == 0, s"java compilation failed for ${fs.mkString(", ")}") + } + + compileWithJavac(files.filter(_.getName.endsWith(".java")).map(_.getAbsolutePath)) + val reporter = new DaftReporter(suppress = false) driver.process(flags ++ files.map(_.getAbsolutePath), reporter = reporter) files -> reporter.errors |