diff options
author | Guillaume Martres <smarter@ubuntu.com> | 2016-06-02 23:58:42 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-07-27 19:28:36 +0200 |
commit | 8c35854f9167a7cedd85e4601cadb9f422a83a5e (patch) | |
tree | fcc87ee712f9fe2a3f6b175bc012dd3bff434ad1 /test/dotty | |
parent | 1fa136f3be21dce9eae2d09d7cee959ede48e177 (diff) | |
download | dotty-8c35854f9167a7cedd85e4601cadb9f422a83a5e.tar.gz dotty-8c35854f9167a7cedd85e4601cadb9f422a83a5e.tar.bz2 dotty-8c35854f9167a7cedd85e4601cadb9f422a83a5e.zip |
partest: put more stuff on javac classpath
Some java tests require the scala-library to be present on the
classpath, this fixes tests/pos/java-interop/{t1186, t1235, t1254,
t1642}.
Also correctly redirect the output of javac so that it will be displayed
by partest --verbose
Diffstat (limited to 'test/dotty')
-rw-r--r-- | test/dotty/partest/DPConsoleRunner.scala | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/test/dotty/partest/DPConsoleRunner.scala b/test/dotty/partest/DPConsoleRunner.scala index c939e6704..d445722c9 100644 --- a/test/dotty/partest/DPConsoleRunner.scala +++ b/test/dotty/partest/DPConsoleRunner.scala @@ -134,6 +134,62 @@ class DPTestRunner(testFile: File, suiteRunner: DPSuiteRunner) extends nest.Runn // override to provide DottyCompiler override def newCompiler = new dotty.partest.DPDirectCompiler(this) + // Adapted from nest.Runner#javac because: + // - Our classpath handling is different and we need to pass extraClassPath + // to java to get the scala-library which is required for some java tests + // - The compiler output should be redirected to cLogFile, like the output of + // dotty itself + override def javac(files: List[File]): TestState = { + import fileManager._ + import suiteRunner._ + import FileManager.joinPaths + // compile using command-line javac compiler + val args = Seq( + javacCmdPath, + "-d", + outDir.getAbsolutePath, + "-classpath", + joinPaths(outDir :: extraClasspath ++ testClassPath) + ) ++ files.map(_.getAbsolutePath) + + pushTranscript(args mkString " ") + + val captured = StreamCapture(runCommand(args, cLogFile)) + if (captured.result) genPass() else { + cLogFile appendAll captured.stderr + cLogFile appendAll captured.stdout + genFail("java compilation failed") + } + } + + // FIXME: This is copy-pasted from nest.Runner where it is private + // Remove this once https://github.com/scala/scala-partest/pull/61 is merged + /** Runs command redirecting standard out and + * error out to output file. + */ + def runCommand(args: Seq[String], outFile: File): Boolean = { + import scala.sys.process.{ Process, ProcessLogger } + //(Process(args) #> outFile !) == 0 or (Process(args) ! pl) == 0 + val pl = ProcessLogger(outFile) + val nonzero = 17 // rounding down from 17.3 + def run: Int = { + val p = Process(args) run pl + try p.exitValue + catch { + case e: InterruptedException => + NestUI verbose s"Interrupted waiting for command to finish (${args mkString " "})" + p.destroy + nonzero + case t: Throwable => + NestUI verbose s"Exception waiting for command to finish: $t (${args mkString " "})" + p.destroy + throw t + } + finally pl.close() + } + (pl buffer run) == 0 + } + // override to provide default dotty flags from file in directory override def flagsForCompilation(sources: List[File]): List[String] = { val specificFlags = super.flagsForCompilation(sources) |