diff options
author | Guillaume Martres <smarter@ubuntu.com> | 2016-07-27 23:26:58 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-27 23:26:58 -0700 |
commit | 79e0fe02708a115140f53678499c423c773123c4 (patch) | |
tree | 4388cd4c3d03bd48058466cf9b4a41abf048ecf7 /test | |
parent | 48d6460865f4b83e6df42551ce55319805ad7342 (diff) | |
parent | 04e6d5e5ad39d046a977de1bfd4563287e5b0f41 (diff) | |
download | dotty-79e0fe02708a115140f53678499c423c773123c4.tar.gz dotty-79e0fe02708a115140f53678499c423c773123c4.tar.bz2 dotty-79e0fe02708a115140f53678499c423c773123c4.zip |
Merge pull request #1289 from dotty-staging/fix/partest-separate
partest: Enable separate compilation
Diffstat (limited to 'test')
-rw-r--r-- | test/dotty/partest/DPConsoleRunner.scala | 82 | ||||
-rw-r--r-- | test/test/CompilerTest.scala | 3 |
2 files changed, 58 insertions, 27 deletions
diff --git a/test/dotty/partest/DPConsoleRunner.scala b/test/dotty/partest/DPConsoleRunner.scala index baa62579c..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) @@ -245,32 +301,6 @@ class DPTestRunner(testFile: File, suiteRunner: DPSuiteRunner) extends nest.Runn } getOrElse true } - // override because Dotty currently doesn't handle separate compilation well, - // so we ignore groups (tests suffixed with _1 and _2) - override def groupedFiles(sources: List[File]): List[List[File]] = { - val grouped = sources groupBy (_.group) - val flatGroup = List(grouped.keys.toList.sorted.map({ k => grouped(k) sortBy (_.getName) }).flatten) - try { // try/catch because of bug in partest that throws exception - if (flatGroup != super.groupedFiles(sources)) - throw new java.lang.UnsupportedOperationException() - } catch { - case e: java.lang.UnsupportedOperationException => - val genlogFWriter = new FileWriter(DPConfig.genLog.jfile, true) - val genlogWriter = new PrintWriter(genlogFWriter, true) - genlogWriter.println("Warning: Overriding compilation groups for tests: " + sources) - genlogWriter.close - genlogFWriter.close - } - flatGroup - } - - // override to avoid separate compilation of scala and java sources - override def mixedCompileGroup(allFiles: List[File]): List[CompileRound] = List(OnlyDotty(allFiles)) - case class OnlyDotty(fs: List[File]) extends CompileRound { - def description = s"dotc $fsString" - lazy val result = { pushTranscript(description) ; attemptCompile(fs) } - } - // override to add dotty and scala jars to classpath override def extraClasspath = suiteRunner.fileManager.asInstanceOf[DottyFileManager].extraJarList ::: super.extraClasspath diff --git a/test/test/CompilerTest.scala b/test/test/CompilerTest.scala index 1d8fb9bf5..56b9e1099 100644 --- a/test/test/CompilerTest.scala +++ b/test/test/CompilerTest.scala @@ -410,7 +410,8 @@ abstract class CompilerTest { nr: Int = 0, oldOutput: String = defaultOutputDir): Unit = { val partestOutput = dest.jfile.getParentFile + JFile.separator + dest.stripExtension + "-" + kind + ".obj" - val flags = oldFlags.map(f => if (f == oldOutput) partestOutput else f) + val flags = oldFlags.map(f => if (f == oldOutput) partestOutput else f) ++ + List(s"-classpath $partestOutput") // Required for separate compilation tests getExisting(dest).isDifferent(source, flags, nerr) match { case NotExists => copyFiles(source, dest, partestOutput, flags, nerr, kind) |