diff options
author | Paul Phillips <paulp@improving.org> | 2013-04-19 14:01:25 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2013-04-19 14:01:25 -0700 |
commit | 857dfa64d3d4fcd154789e213b86b2643769d779 (patch) | |
tree | 9c3c98a293edca806cbdb10cbd828de1e0cf8a5f /src | |
parent | 86651c1205de9d901a9f0a0214888ac7c4724b81 (diff) | |
parent | 01edd0436c19314ea581f86362b1d547a4b7fdb8 (diff) | |
download | scala-857dfa64d3d4fcd154789e213b86b2643769d779.tar.gz scala-857dfa64d3d4fcd154789e213b86b2643769d779.tar.bz2 scala-857dfa64d3d4fcd154789e213b86b2643769d779.zip |
Merge pull request #2338 from som-snytt/issue/7314-test-tools-jar
SI-7314 Partest locates tools.jar and javac
Diffstat (limited to 'src')
-rw-r--r-- | src/partest/scala/tools/partest/nest/PathSettings.scala | 30 | ||||
-rw-r--r-- | src/partest/scala/tools/partest/nest/RunnerManager.scala | 2 |
2 files changed, 32 insertions, 0 deletions
diff --git a/src/partest/scala/tools/partest/nest/PathSettings.scala b/src/partest/scala/tools/partest/nest/PathSettings.scala index 7c005b4f61..b1f868c9d2 100644 --- a/src/partest/scala/tools/partest/nest/PathSettings.scala +++ b/src/partest/scala/tools/partest/nest/PathSettings.scala @@ -8,6 +8,7 @@ package nest import scala.tools.nsc.Properties.{ setProp, propOrEmpty, propOrNone, propOrElse } import scala.tools.nsc.util.ClassPath import scala.tools.nsc.io +import scala.util.Properties.{ envOrElse, envOrNone, javaHome, jdkHome } import io.{ Path, File, Directory } object PathSettings { @@ -74,6 +75,35 @@ object PathSettings { lazy val diffUtils: File = findJar(buildPackLibDir.files, "diffutils") getOrElse sys.error(s"No diffutils.jar found in '$buildPackLibDir'.") + + /** The platform-specific support jar. + * Usually this is tools.jar in the jdk/lib directory of the platform distribution. + * The file location is determined by probing the lib directory under JDK_HOME or JAVA_HOME, + * if one of those environment variables is set, then the lib directory under java.home, + * and finally the lib directory under the parent of java.home. Or, as a last resort, + * search deeply under those locations (except for the parent of java.home, on the notion + * that if this is not a canonical installation, then that search would have litte + * chance of succeeding). + */ + lazy val platformTools: Option[File] = { + val jarName = "tools.jar" + def jarPath(path: Path) = (path / "lib" / jarName).toFile + def jarAt(path: Path) = { + val f = jarPath(path) + if (f.isFile) Some(f) else None + } + val jdkDir = { + val d = Directory(jdkHome) + if (d.isDirectory) Some(d) else None + } + def deeply(dir: Directory) = dir.deepFiles find (_.name == jarName) + + val home = envOrNone("JDK_HOME") orElse envOrNone("JAVA_HOME") map (p => Path(p)) + val install = Some(Path(javaHome)) + + (home flatMap jarAt) orElse (install flatMap jarAt) orElse (install map (_.parent) flatMap jarAt) orElse + (jdkDir flatMap deeply) + } } class PathSettings() { diff --git a/src/partest/scala/tools/partest/nest/RunnerManager.scala b/src/partest/scala/tools/partest/nest/RunnerManager.scala index 1c689714c7..fa2b5ea74b 100644 --- a/src/partest/scala/tools/partest/nest/RunnerManager.scala +++ b/src/partest/scala/tools/partest/nest/RunnerManager.scala @@ -74,8 +74,10 @@ object Output { class RunnerManager(kind: String, val fileManager: FileManager, params: TestRunParams) { import fileManager._ + fileManager.CLASSPATH += File.pathSeparator + PathSettings.scalaCheck fileManager.CLASSPATH += File.pathSeparator + PathSettings.diffUtils // needed to put diffutils on test/partest's classpath + PathSettings.platformTools foreach (fileManager.CLASSPATH += File.pathSeparator + _) def runTest(testFile: File): TestState = { val runner = new Runner(testFile, fileManager) { |