diff options
author | Paul Phillips <paulp@improving.org> | 2009-03-16 13:03:02 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2009-03-16 13:03:02 +0000 |
commit | 00d196adeeb3aa88f2afedcb5d7eb51f0fc19896 (patch) | |
tree | 856ab3879e450c929c04907551acd6898fa51ede /src/partest | |
parent | ff9887891f8f865617c60351a3afc8daced2db0e (diff) | |
download | scala-00d196adeeb3aa88f2afedcb5d7eb51f0fc19896.tar.gz scala-00d196adeeb3aa88f2afedcb5d7eb51f0fc19896.tar.bz2 scala-00d196adeeb3aa88f2afedcb5d7eb51f0fc19896.zip |
Various cleanups and redundancy-removal related...
Various cleanups and redundancy-removal related to properties.
Diffstat (limited to 'src/partest')
3 files changed, 38 insertions, 59 deletions
diff --git a/src/partest/scala/tools/partest/nest/ConsoleRunner.scala b/src/partest/scala/tools/partest/nest/ConsoleRunner.scala index 065d04f332..67053ce732 100644 --- a/src/partest/scala/tools/partest/nest/ConsoleRunner.scala +++ b/src/partest/scala/tools/partest/nest/ConsoleRunner.scala @@ -9,6 +9,7 @@ package scala.tools.partest.nest import java.io.{File, PrintStream, FileOutputStream, BufferedReader, InputStreamReader, StringWriter, PrintWriter} +import utils.Properties._ class ConsoleRunner extends DirectRunner with RunnerUtils { @@ -38,8 +39,7 @@ class ConsoleRunner extends DirectRunner with RunnerUtils { var fileManager: ConsoleFileManager = _ - private val version = System.getProperty("java.version", "") - private val isJava5 = version matches "1.[5|6|7].*" + private val isJava5 = javaVersion matches "1.[5|6|7].*" private var runAll = false private var testFiles: List[File] = List() private val errors = @@ -54,13 +54,7 @@ class ConsoleRunner extends DirectRunner with RunnerUtils { def denotesTestDir(arg: String) = (new File(arg)).isDirectory - private def printVersion { - val versionMsg = "Scala partest "+ - utils.Properties.versionString+ - " -- "+ - scala.tools.nsc.Properties.copyrightString - NestUI.outline(versionMsg+"\n") - } + private def printVersion { NestUI outline (versionMsg + "\n") } def main(argstr: String) { // tokenize args. filter: "".split("\\s") yields Array("") @@ -143,19 +137,13 @@ class ConsoleRunner extends DirectRunner with RunnerUtils { fileManager.latestCompFile.getParentFile.getParentFile.getCanonicalFile NestUI.outline("Scala compiler classes in: "+dir+"\n") - val scalaVersion = "Scala compiler "+ - scala.tools.nsc.Properties.versionString+ - " -- "+ - scala.tools.nsc.Properties.copyrightString - - NestUI.outline("Scala version is: "+scalaVersion+"\n") + NestUI.outline("Scala version is: "+nsc.Properties.versionMsg+"\n") NestUI.outline("Scalac options are: "+fileManager.SCALAC_OPTS+"\n") - val vmBin = System.getProperty("java.home", "")+File.separator+"bin" - val vmName = System.getProperty("java.vm.name", "")+" (build "+ - System.getProperty("java.vm.version", "")+", "+ - System.getProperty("java.vm.info", "")+")" + val vmBin = javaHome + File.separator + "bin" + val vmName = "%s (build %s, %s)".format(javaVmName, javaVmVersion, javaVmInfo) val vmOpts = fileManager.JAVA_OPTS + NestUI.outline("Java binaries in: "+vmBin+"\n") NestUI.outline("Java runtime is: "+vmName+"\n") NestUI.outline("Java options are: "+vmOpts+"\n") diff --git a/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala b/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala index 3cb48dfd9d..c655494d4d 100644 --- a/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala +++ b/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala @@ -19,6 +19,12 @@ class ReflectiveRunner extends RunnerUtils { // to use the same classes as used by `scala` that // was used to start the runner. + import java.net.URLClassLoader + import java.io.File.pathSeparator + import utils.Properties.{ sysprop, syspropset } + + val sepRunnerClassName = "scala.tools.partest.nest.ConsoleRunner" + def main(args: String) { val argList = List.fromArray(args.split("\\s")) @@ -37,55 +43,40 @@ class ReflectiveRunner extends RunnerUtils { else // auto detection new ConsoleFileManager - import fileManager.{latestCompFile, latestLibFile, latestActFile, - latestPartestFile, latestFjbgFile} - - val sepUrls = Array(latestCompFile.toURL, latestLibFile.toURL, - latestActFile.toURL, latestPartestFile.toURL, - latestFjbgFile.toURL) - - val sepLoader = new java.net.URLClassLoader(sepUrls, null) + import fileManager. + { latestCompFile, latestLibFile, latestActFile, latestPartestFile, latestFjbgFile } + val files = + Array(latestCompFile, latestLibFile, latestActFile, latestPartestFile, latestFjbgFile) - if (fileManager.debug) { - println("Loading classes from:") - sepUrls foreach { url => println(url) } - } + val sepUrls = files map { _.toURL } + val sepLoader = new URLClassLoader(sepUrls, null) - try { - val paths = if (!classPath.isEmpty) - Array(latestCompFile.getPath, latestLibFile.getPath, - latestActFile.getPath, latestPartestFile.getPath, - latestFjbgFile.getPath) - else - Array(latestCompFile.getPath, latestLibFile.getPath, - latestActFile.getPath, latestPartestFile.getPath) - val newClasspath = paths.mkString(java.io.File.pathSeparator) - System.setProperty("java.class.path", newClasspath) - System.setProperty("env.classpath", newClasspath) - System.setProperty("scala.home", "") - if (fileManager.debug) { - println("java.class.path: "+System.getProperty("java.class.path")) - println("env.classpath: "+System.getProperty("env.classpath")) - println("sun.boot.class.path: "+System.getProperty("sun.boot.class.path")) - println("java.ext.dirs: "+System.getProperty("java.ext.dirs")) - } + if (fileManager.debug) + println("Loading classes from:\n" + sepUrls.mkString("\n")) - val sepRunnerClass = - sepLoader.loadClass("scala.tools.partest.nest.ConsoleRunner") + val paths = (if (classPath.isEmpty) files.slice(0, 4) else files) map { _.getPath } + val newClasspath = paths mkString pathSeparator - val sepRunner = sepRunnerClass.newInstance() + syspropset("java.class.path", newClasspath) + syspropset("env.classpath", newClasspath) + syspropset("scala.home", "") - val stringClass = Class.forName("java.lang.String") - val sepMainMethod = - sepRunnerClass.getMethod("main", Array(stringClass): _*) + if (fileManager.debug) + for (prop <- List("java.class.path", "env.classpath", "sun.boot.class.path", "java.ext.dirs")) + println(prop + ": " + sysprop(prop)) + try { + val sepRunnerClass = sepLoader loadClass sepRunnerClassName + val sepRunner = sepRunnerClass.newInstance() + val sepMainMethod = sepRunnerClass.getMethod("main", Array(classOf[String]): _*) val cargs: Array[AnyRef] = Array(args) sepMainMethod.invoke(sepRunner, cargs: _*) - } catch { + } + catch { case cnfe: ClassNotFoundException => cnfe.printStackTrace() - NestUI.failure("scala.tools.partest.nest.ConsoleRunner could not be loaded from: \n") - sepUrls foreach { url => NestUI.failure(url+"\n") } + NestUI.failure(sepRunnerClassName +" could not be loaded from:\n") + sepUrls foreach (x => NestUI.failure(x + "\n")) } } } diff --git a/src/partest/scala/tools/partest/utils/Properties.scala b/src/partest/scala/tools/partest/utils/Properties.scala index 8c96083306..1ab1d47020 100644 --- a/src/partest/scala/tools/partest/utils/Properties.scala +++ b/src/partest/scala/tools/partest/utils/Properties.scala @@ -17,4 +17,4 @@ object Properties extends scala.util.PropertiesTrait { // XXX unlikely it's intentional that only partest uses ISO-8859-1 override val encodingString = prop("file.encoding", "ISO-8859-1") -} +}
\ No newline at end of file |