Skip to content
This repository was archived by the owner on Sep 8, 2022. It is now read-only.

SI-7786 Partest finds javac #62

Merged
merged 2 commits into from
Jun 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/main/scala/scala/tools/partest/PartestDefaults.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ package partest

import scala.concurrent.duration.Duration
import scala.tools.nsc.Properties.{ propOrNone => prop }
import scala.util.Properties.jdkHome
import java.lang.Runtime.{ getRuntime => runtime }

object PartestDefaults {
def sourcePath = prop("partest.srcdir") getOrElse "files"
def javaCmd = prop("partest.javacmd") getOrElse "java"
def javacCmd = prop("partest.javac_cmd") getOrElse "javac"
def javaCmd = prop("partest.javacmd") orElse jdkexec("java") getOrElse "java"
def javacCmd = prop("partest.javac_cmd") orElse jdkexec("javac") getOrElse "javac"
def javaOpts = prop("partest.java_opts") getOrElse "" // opts when running java during tests
def scalacOpts = prop("partest.scalac_opts") getOrElse ""

Expand All @@ -18,4 +19,13 @@ object PartestDefaults {
def waitTime = Duration(prop("partest.timeout") getOrElse "4 hours")

//def timeout = "1200000" // per-test timeout

// probe for the named executable
private def jdkexec(name: String): Option[String] = {
import scala.reflect.io.Path, Path._
Some(Path(jdkHome) / "bin") filter (_.isDirectory) flatMap { p =>
val candidates = (p walkFilter { e => (e.name == name || e.name.startsWith(s"$name.")) && e.jfile.canExecute }).toList
(candidates find (_.name == name) orElse candidates.headOption) map (_.path)
}
}
}
13 changes: 10 additions & 3 deletions src/main/scala/scala/tools/partest/nest/Runner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ class Runner(val testFile: File, val suiteRunner: SuiteRunner) {
joinPaths(outDir :: testClassPath),
"-J-Duser.language=en",
"-J-Duser.country=US"
) ++ files.map(_.getAbsolutePath)
) ++ (toolArgsFor(files)("javac")
) ++ (files.map(_.getAbsolutePath)
)

pushTranscript(args mkString " ")
val captured = StreamCapture(runCommand(args, logFile))
Expand Down Expand Up @@ -439,7 +441,12 @@ class Runner(val testFile: File, val suiteRunner: SuiteRunner) {
perTest ++ perGroup
}

def toolArgs(tool: String, split: Boolean = true): List[String] = {
// inspect sources for tool args
def toolArgs(tool: String, split: Boolean = true): List[String] =
toolArgsFor(sources(testFile))(tool, split)

// inspect given files for tool args
def toolArgsFor(files: List[File])(tool: String, split: Boolean = true): List[String] = {
def argsplitter(s: String) = if (split) words(s) filter (_.nonEmpty) else List(s)
def argsFor(f: File): List[String] = {
import scala.util.matching.Regex
Expand All @@ -453,7 +460,7 @@ class Runner(val testFile: File, val suiteRunner: SuiteRunner) {
} finally src.close()
args.flatten map argsplitter getOrElse Nil
}
sources(testFile) flatMap argsFor
files flatMap argsFor
}

abstract class CompileRound {
Expand Down