summaryrefslogtreecommitdiff
path: root/src/partest
diff options
context:
space:
mode:
authorPhilipp Haller <hallerp@gmail.com>2008-08-01 15:34:19 +0000
committerPhilipp Haller <hallerp@gmail.com>2008-08-01 15:34:19 +0000
commit2389f12ce64f8fd54aedaf94ddd9586bcb1fe377 (patch)
tree6de88a5db1293c940a9a7c9b536d465531f444e2 /src/partest
parent24426432a02c6662c55752fbddbf87166bb4dd2e (diff)
downloadscala-2389f12ce64f8fd54aedaf94ddd9586bcb1fe377.tar.gz
scala-2389f12ce64f8fd54aedaf94ddd9586bcb1fe377.tar.bz2
scala-2389f12ce64f8fd54aedaf94ddd9586bcb1fe377.zip
Added options --buildpath and --classpath.
Diffstat (limited to 'src/partest')
-rw-r--r--src/partest/scala/tools/partest/nest/ConsoleFileManager.scala39
-rw-r--r--src/partest/scala/tools/partest/nest/ConsoleRunner.scala37
-rw-r--r--src/partest/scala/tools/partest/nest/NestUI.scala4
-rw-r--r--src/partest/scala/tools/partest/nest/ReflectiveRunner.scala48
-rw-r--r--src/partest/scala/tools/partest/nest/RunnerUtils.scala35
5 files changed, 126 insertions, 37 deletions
diff --git a/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala b/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala
index ba8bc97915..cb0f87cb88 100644
--- a/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala
+++ b/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala
@@ -13,21 +13,29 @@ import java.net.URI
class ConsoleFileManager extends FileManager {
var testBuild = System.getProperty("scalatest.build")
+ var testClasses: Option[String] = None
val debug: Boolean =
(System.getProperty("partest.debug", "false") equals "true") ||
(System.getProperty("scalatest.debug", "false") equals "true")
- def this(build: String) = {
+ def this(buildPath: String, rawClasses: Boolean) = {
this()
- testBuild = build
+ if (rawClasses)
+ testClasses = Some(buildPath)
+ else
+ testBuild = buildPath
// re-run because initialization of default
// constructor must be updated
findLatest()
}
- def this(build: String, moreOpts: String) = {
- this(build)
+ def this(buildPath: String) = {
+ this(buildPath, false)
+ }
+
+ def this(buildPath: String, rawClasses: Boolean, moreOpts: String) = {
+ this(buildPath, rawClasses)
SCALAC_OPTS = SCALAC_OPTS+" "+moreOpts
}
@@ -85,21 +93,29 @@ else
def accept(dir: File, name: String) = name endsWith ".jar"
}) map {file => file.getCanonicalFile.getAbsolutePath}).mkString(""+File.pathSeparator)
}
- println(CLASSPATH)
def findLatest() {
val testParent = testRootFile.getParentFile
NestUI.verbose("test parent: "+testParent)
- def prefixFileWith(parent: File, relPath: String): File = {
+ def prefixFileWith(parent: File, relPath: String): File =
(new File(parent, relPath)).getCanonicalFile
- }
- def prefixFile(relPath: String): File = {
+ def prefixFile(relPath: String): File =
prefixFileWith(testParent, relPath)
- }
- if (testBuild != null) {
+ if (!testClasses.isEmpty) {
+ testClassesFile = (new File(testClasses.get)).getCanonicalFile
+ NestUI.verbose("Running with classes in "+testClassesFile)
+ latestFile = prefixFileWith(testClassesFile.getParentFile, "bin")
+ latestLibFile = prefixFileWith(testClassesFile, "library")
+ latestActFile = prefixFileWith(testClassesFile, "library")
+ latestCompFile = prefixFileWith(testClassesFile, "compiler")
+ latestPartestFile = prefixFileWith(testClassesFile, "partest")
+ latestFjbgFile = prefixFile("lib/fjbg.jar")
+ }
+ else if (testBuild != null) {
+ testBuildFile = prefixFile(testBuild)
NestUI.verbose("Running on "+testBuild)
latestFile = prefixFile(testBuild+"/bin")
latestLibFile = prefixFile(testBuild+"/lib/scala-library.jar")
@@ -179,6 +195,9 @@ else
var latestActFile: File = _
var latestCompFile: File = _
var latestPartestFile: File = _
+ var latestFjbgFile: File = _
+ var testBuildFile: File = _
+ var testClassesFile: File = _
// initialize above fields
findLatest()
diff --git a/src/partest/scala/tools/partest/nest/ConsoleRunner.scala b/src/partest/scala/tools/partest/nest/ConsoleRunner.scala
index 0be780e5c8..1ffb992661 100644
--- a/src/partest/scala/tools/partest/nest/ConsoleRunner.scala
+++ b/src/partest/scala/tools/partest/nest/ConsoleRunner.scala
@@ -12,7 +12,7 @@ import java.io.{File, PrintStream, FileOutputStream, BufferedReader,
import scala.actors.Actor._
-class ConsoleRunner extends DirectRunner {
+class ConsoleRunner extends DirectRunner with RunnerUtils {
var fileManager: ConsoleFileManager = _
@@ -57,14 +57,22 @@ class ConsoleRunner extends DirectRunner {
if (args.length == 0)
NestUI.usage()
else {
- // create a file manager
+ // find out which build to test
+ val (buildPath, args1) = searchAndRemovePath("--buildpath", args)
+ val (classPath, args2) = searchAndRemovePath("--classpath", args1)
+ args = args2
+
fileManager =
- if (args contains "--pack") {
+ if (!buildPath.isEmpty)
+ new ConsoleFileManager(buildPath.get)
+ else if (!classPath.isEmpty)
+ new ConsoleFileManager(classPath.get, true)
+ else if (args contains "--pack") {
args = args.remove(_ == "--pack") // will create a result file '--pack' otherwise
new ConsoleFileManager("build/pack")
} else if (args contains "--four") {
args = args.remove(_ == "--four")
- new ConsoleFileManager("build/four-pack", "-target:jvm-1.4")
+ new ConsoleFileManager("build/four-pack", false, "-target:jvm-1.4")
} else // auto detection, see ConsoleFileManager.findLatest
new ConsoleFileManager
@@ -111,25 +119,32 @@ class ConsoleRunner extends DirectRunner {
}
}
- NestUI.outline("Source directory is : "+fileManager.srcDir.getAbsolutePath+"\n")
- NestUI.outline("Scala binaries in : "+fileManager.BIN_DIR+"\n")
+ val dir =
+ if (!fileManager.testClasses.isEmpty)
+ fileManager.testClassesFile
+ else if (fileManager.testBuild != null)
+ fileManager.testBuildFile
+ else
+ 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("Scalac options are : "+fileManager.SCALAC_OPTS+"\n")
+ NestUI.outline("Scala version is: "+scalaVersion+"\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 vmOpts = System.getProperty("scalatest.java_options", "?")
- NestUI.outline("Java binaries in : "+vmBin+"\n")
- NestUI.outline("Java runtime is : "+vmName+"\n")
- NestUI.outline("Java options are : "+vmOpts+"\n")
+ NestUI.outline("Java binaries in: "+vmBin+"\n")
+ NestUI.outline("Java runtime is: "+vmName+"\n")
+ NestUI.outline("Java options are: "+vmOpts+"\n")
+ NestUI.outline("Source directory is: "+fileManager.srcDir.getAbsolutePath+"\n")
val start = System.currentTimeMillis
diff --git a/src/partest/scala/tools/partest/nest/NestUI.scala b/src/partest/scala/tools/partest/nest/NestUI.scala
index af57ca18ca..e9c0aeebd6 100644
--- a/src/partest/scala/tools/partest/nest/NestUI.scala
+++ b/src/partest/scala/tools/partest/nest/NestUI.scala
@@ -80,8 +80,8 @@ object NestUI {
println(" --verbose display progress information")
//println(" --version display version information")
println
- println("version Mar13")
- println("Send bugs to <scala@listes.epfl.ch>")
+ println("version 0.9.1")
+ println("maintained by Philipp Haller (EPFL)")
exit(1)
}
diff --git a/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala b/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala
index 982449471e..7d150f72f5 100644
--- a/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala
+++ b/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala
@@ -14,7 +14,7 @@ package scala.tools.partest.nest
* the main NestRunner can be started merely by putting its
* class on the classpath (ideally).
*/
-class ReflectiveRunner {
+class ReflectiveRunner extends RunnerUtils {
// TODO: we might also use fileManager.CLASSPATH
// to use the same classes as used by `scala` that
// was used to start the runner.
@@ -23,19 +23,31 @@ class ReflectiveRunner {
val argList = List.fromArray(args.split("\\s"))
// find out which build to test
+ val buildPath = searchPath("--buildpath", argList)
+ val classPath = searchPath("--classpath", argList)
val fileManager =
- if (argList contains "--pack")
+ if (!buildPath.isEmpty)
+ new ConsoleFileManager(buildPath.get)
+ else if (!classPath.isEmpty)
+ new ConsoleFileManager(classPath.get, true)
+ else if (argList contains "--pack")
new ConsoleFileManager("build/pack")
else if (argList contains "--four")
- new ConsoleFileManager("build/four-pack", "-target:jvm-1.4")
+ new ConsoleFileManager("build/four-pack", false, "-target:jvm-1.4")
else // auto detection
new ConsoleFileManager
import fileManager.{latestCompFile, latestLibFile, latestActFile,
- latestPartestFile}
+ latestPartestFile, latestFjbgFile}
+
+ val sepUrls = if (!classPath.isEmpty)
+ Array(latestCompFile.toURL, latestLibFile.toURL,
+ latestActFile.toURL, latestPartestFile.toURL,
+ latestFjbgFile.toURL)
+ else
+ Array(latestCompFile.toURL, latestLibFile.toURL,
+ latestActFile.toURL, latestPartestFile.toURL)
- val sepUrls = Array(latestCompFile.toURL, latestLibFile.toURL,
- latestActFile.toURL, latestPartestFile.toURL)
val sepLoader = new java.net.URLClassLoader(sepUrls, null)
if (fileManager.debug) {
@@ -43,15 +55,23 @@ class ReflectiveRunner {
sepUrls foreach { url => println(url) }
}
- val sepRunnerClass =
- sepLoader.loadClass("scala.tools.partest.nest.ConsoleRunner")
- val sepRunner = sepRunnerClass.newInstance()
+ try {
+ val sepRunnerClass =
+ sepLoader.loadClass("scala.tools.partest.nest.ConsoleRunner")
+
+ val sepRunner = sepRunnerClass.newInstance()
- val stringClass = Class.forName("java.lang.String")
- val sepMainMethod =
- sepRunnerClass.getMethod("main", Array(stringClass): _*)
+ val stringClass = Class.forName("java.lang.String")
+ val sepMainMethod =
+ sepRunnerClass.getMethod("main", Array(stringClass): _*)
- val cargs: Array[AnyRef] = Array(args)
- sepMainMethod.invoke(sepRunner, cargs: _*)
+ val cargs: Array[AnyRef] = Array(args)
+ sepMainMethod.invoke(sepRunner, cargs: _*)
+ } 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") }
+ }
}
}
diff --git a/src/partest/scala/tools/partest/nest/RunnerUtils.scala b/src/partest/scala/tools/partest/nest/RunnerUtils.scala
new file mode 100644
index 0000000000..2cfee0aaf1
--- /dev/null
+++ b/src/partest/scala/tools/partest/nest/RunnerUtils.scala
@@ -0,0 +1,35 @@
+
+package scala.tools.partest.nest
+
+trait RunnerUtils {
+
+ def searchPath(option: String, as: List[String]): Option[String] = {
+ val Option = option
+ as match {
+ case Option :: r :: rs => Some(r)
+ case other :: rest => searchPath(option, rest)
+ case List() => None
+ }
+ }
+
+ def searchAndRemovePath(option: String, as: List[String]): (Option[String], List[String]) = {
+ val Option = option
+ def search(before: List[String], after: List[String]): (Option[String], List[String]) = after match {
+ case Option :: r :: rs => (Some(r), before ::: rs)
+ case other :: rest => search(before ::: List(other), rest)
+ case List() => (None, before)
+ }
+ search(List(), as)
+ }
+
+ def searchAndRemoveOption(option: String, as: List[String]): (Boolean, List[String]) = {
+ val Option = option
+ def search(before: List[String], after: List[String]): (Boolean, List[String]) = after match {
+ case Option :: rest => (true, before ::: rest)
+ case other :: rest => search(before ::: List(other), rest)
+ case List() => (false, before)
+ }
+ search(List(), as)
+ }
+
+}