summaryrefslogtreecommitdiff
path: root/src/partest
diff options
context:
space:
mode:
authorGilles Dubochet <gilles.dubochet@epfl.ch>2008-02-29 14:31:10 +0000
committerGilles Dubochet <gilles.dubochet@epfl.ch>2008-02-29 14:31:10 +0000
commit941b8cc5604b2cbc15c8de55fa84fc62146408a4 (patch)
treedac4d1014ce460f23b1ad108357399868984f6ae /src/partest
parent50d638aa63b1c7ec8c1b9fad4cd62880f87cd781 (diff)
downloadscala-941b8cc5604b2cbc15c8de55fa84fc62146408a4.tar.gz
scala-941b8cc5604b2cbc15c8de55fa84fc62146408a4.tar.bz2
scala-941b8cc5604b2cbc15c8de55fa84fc62146408a4.zip
First step towards a faster commit build.
1. Added new Ant tasks to build the compiler in a memory-efficient way. 2. Modified Partest to make it more extensible and added an Ant task to run it. 3. Created a SuperSABBUS build file (beta) using these new tasks.
Diffstat (limited to 'src/partest')
-rw-r--r--src/partest/scala/tools/partest/PartestTask.scala169
-rw-r--r--src/partest/scala/tools/partest/antlib.xml4
-rw-r--r--src/partest/scala/tools/partest/nest/AntRunner.scala35
-rw-r--r--src/partest/scala/tools/partest/nest/CompileManager.scala36
-rw-r--r--src/partest/scala/tools/partest/nest/ConsoleFileManager.scala164
-rw-r--r--src/partest/scala/tools/partest/nest/ConsoleRunner.scala199
-rw-r--r--src/partest/scala/tools/partest/nest/DirectRunner.scala249
-rw-r--r--src/partest/scala/tools/partest/nest/FileManager.scala185
-rw-r--r--src/partest/scala/tools/partest/nest/ReflectiveRunner.scala6
-rw-r--r--src/partest/scala/tools/partest/nest/TestFile.scala43
-rw-r--r--src/partest/scala/tools/partest/nest/Worker.scala37
11 files changed, 687 insertions, 440 deletions
diff --git a/src/partest/scala/tools/partest/PartestTask.scala b/src/partest/scala/tools/partest/PartestTask.scala
new file mode 100644
index 0000000000..75c2472df3
--- /dev/null
+++ b/src/partest/scala/tools/partest/PartestTask.scala
@@ -0,0 +1,169 @@
+/* __ *\
+** ________ ___ / / ___ Scala Parallel Testing **
+** / __/ __// _ | / / / _ | (c) 2007-2008, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+
+package scala.tools.partest
+
+import scala.actors.Actor._
+
+import java.io.File
+import java.net.URLClassLoader
+
+import org.apache.tools.ant.Task
+import org.apache.tools.ant.types.{Path, Reference, FileSet}
+
+class PartestTask extends Task {
+
+ def addConfiguredPosTests(input: FileSet): Unit =
+ posFiles = Some(input)
+
+ def addConfiguredNegTests(input: FileSet): Unit =
+ negFiles = Some(input)
+
+ def addConfiguredRunTests(input: FileSet): Unit =
+ runFiles = Some(input)
+
+ def setClasspath(input: Path): Unit =
+ if (classpath.isEmpty)
+ classpath = Some(input)
+ else
+ classpath.get.append(input)
+
+ def createClasspath(): Path = {
+ if (classpath.isEmpty) classpath = Some(new Path(getProject()))
+ classpath.get.createPath()
+ }
+
+ def setClasspathref(input: Reference): Unit =
+ createClasspath().setRefid(input)
+
+ def setShowLog(input: Boolean): Unit =
+ showLog = input
+
+ def setShowDiff(input: Boolean): Unit =
+ showDiff = input
+
+ private var classpath: Option[Path] = None
+ private var javacmd: Option[File] = None
+ private var showDiff: Boolean = false
+ private var showLog: Boolean = false
+ private var runFailed: Boolean = false
+ private var posFiles: Option[FileSet] = None
+ private var negFiles: Option[FileSet] = None
+ private var runFiles: Option[FileSet] = None
+
+ private def getPosFiles: Array[File] =
+ if (!posFiles.isEmpty) {
+ val files = posFiles.get
+ (files.getDirectoryScanner(getProject).getIncludedFiles map { fs => new File(files.getDir(getProject), fs) })
+ }
+ else
+ Array()
+
+ private def getNegFiles: Array[File] =
+ if (!negFiles.isEmpty) {
+ val files = negFiles.get
+ (files.getDirectoryScanner(getProject).getIncludedFiles map { fs => new File(files.getDir(getProject), fs) })
+ }
+ else
+ Array()
+
+ private def getRunFiles: Array[File] =
+ if (!runFiles.isEmpty) {
+ val files = runFiles.get
+ (files.getDirectoryScanner(getProject).getIncludedFiles map { fs => new File(files.getDir(getProject), fs) })
+ }
+ else
+ Array()
+
+
+ override def execute(): Unit = {
+
+ if (classpath.isEmpty)
+ error("Mandatory attribute 'classpath' is not set.")
+
+ val scalaLibrary =
+ (classpath.get.list map { fs => new File(fs) }) find { f =>
+ f.getName match {
+ case "scala-library.jar" => true
+ case "lib" if (f.getParentFile.getName == "library") => true
+ case _ => false
+ }
+ }
+
+ if (scalaLibrary.isEmpty)
+ error("Provided classpath does not contain a Scala library.")
+
+ val classloader = this.getClass.getClassLoader
+
+ val antRunner: AnyRef =
+ classloader.loadClass("scala.tools.partest.nest.AntRunner").newInstance().asInstanceOf[AnyRef]
+ val antFileManager: AnyRef =
+ antRunner.getClass.getMethod("fileManager", Array()).invoke(antRunner, Array())
+
+ val runMethod =
+ antRunner.getClass.getMethod("reflectiveRunTestsForFiles", Array(classOf[Array[File]], classOf[String]))
+
+ def runTestsForFiles(kindFiles: Array[File], kind: String): (Int, Int) = {
+ val result = runMethod.invoke(antRunner, Array(kindFiles, kind)).asInstanceOf[Int]
+ (result >> 16, result & 0x00FF)
+ }
+
+ def setFileManagerBooleanProperty(name: String, value: Boolean) = {
+ val setMethod =
+ antFileManager.getClass.getMethod(name+"_$eq", Array(classOf[Boolean]))
+ setMethod.invoke(antFileManager, Array(new java.lang.Boolean(value)))
+ }
+
+ def setFileManagerStringProperty(name: String, value: String) = {
+ val setMethod =
+ antFileManager.getClass.getMethod(name+"_$eq", Array(classOf[String]))
+ setMethod.invoke(antFileManager, Array(value))
+ }
+
+ setFileManagerBooleanProperty("showDiff", showDiff)
+ setFileManagerBooleanProperty("showLog", showLog)
+ setFileManagerBooleanProperty("failed", runFailed)
+ if (!javacmd.isEmpty)
+ setFileManagerStringProperty("JAVACMD", javacmd.get.getAbsolutePath)
+ setFileManagerStringProperty("CLASSPATH", classpath.get.list.mkString(File.pathSeparator))
+ setFileManagerStringProperty("LATEST_LIB", scalaLibrary.get.getAbsolutePath)
+
+ var allSucesses: int = 0
+ var allFailures: int = 0
+
+ if (getPosFiles.size > 0) {
+ log("Compiling files that are expected to build")
+ val (successes, failures) = runTestsForFiles(getPosFiles, "pos")
+ allSucesses += successes
+ allFailures += failures
+ }
+
+ if (getNegFiles.size > 0) {
+ log("Compiling files that are expected to fail")
+ val (successes, failures) = runTestsForFiles(getNegFiles, "neg")
+ allSucesses += successes
+ allFailures += failures
+ }
+
+ if (getRunFiles.size > 0) {
+ log("Compiling and running files")
+ val (successes, failures) = runTestsForFiles(getRunFiles, "run")
+ allSucesses += successes
+ allFailures += failures
+ }
+
+ if ((getPosFiles.size + getNegFiles.size + getRunFiles.size) == 0)
+ log("There where no tests to run.")
+ else if (allFailures == 0)
+ log("Test suite finished with no failures.")
+ else
+ log("Test suite finished with " + allFailures + " case" + (if (allFailures > 0) "s" else "") + " failing.")
+
+ }
+
+}
diff --git a/src/partest/scala/tools/partest/antlib.xml b/src/partest/scala/tools/partest/antlib.xml
new file mode 100644
index 0000000000..b3b98e853f
--- /dev/null
+++ b/src/partest/scala/tools/partest/antlib.xml
@@ -0,0 +1,4 @@
+<antlib>
+ <taskdef name="partest"
+ classname="scala.tools.partest.PartestTask"/>
+</antlib>
diff --git a/src/partest/scala/tools/partest/nest/AntRunner.scala b/src/partest/scala/tools/partest/nest/AntRunner.scala
new file mode 100644
index 0000000000..0285e5a17f
--- /dev/null
+++ b/src/partest/scala/tools/partest/nest/AntRunner.scala
@@ -0,0 +1,35 @@
+/* __ *\
+** ________ ___ / / ___ Scala Parallel Testing **
+** / __/ __// _ | / / / _ | (c) 2007-2008, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+
+package scala.tools.partest.nest
+
+import scala.actors.Actor._
+
+import java.io.File
+import java.net.URLClassLoader
+
+import org.apache.tools.ant.Task
+import org.apache.tools.ant.types.{Path, Reference, FileSet}
+
+class AntRunner extends DirectRunner {
+
+ val fileManager = new FileManager {
+
+ var JAVACMD: String = "java"
+
+ var CLASSPATH: String = _
+ var LATEST_LIB: String = _
+
+ }
+
+ def reflectiveRunTestsForFiles(kindFiles: Array[File], kind: String): Int = {
+ val (succs, fails) = runTestsForFiles(kindFiles.toList, kind)
+ succs << 16 | fails
+ }
+
+}
diff --git a/src/partest/scala/tools/partest/nest/CompileManager.scala b/src/partest/scala/tools/partest/nest/CompileManager.scala
index 23e9f81fbd..daee61c345 100644
--- a/src/partest/scala/tools/partest/nest/CompileManager.scala
+++ b/src/partest/scala/tools/partest/nest/CompileManager.scala
@@ -24,7 +24,7 @@ abstract class SimpleCompiler {
def compile(file: File, kind: String, log: File): Boolean
}
-class DirectCompiler extends SimpleCompiler {
+class DirectCompiler(val fileManager: FileManager) extends SimpleCompiler {
def newGlobal(settings: Settings, reporter: Reporter): Global =
new Global(settings, reporter)
@@ -54,12 +54,12 @@ class DirectCompiler extends SimpleCompiler {
val testRep: ExtConsoleReporter = global.reporter.asInstanceOf[ExtConsoleReporter]
val test: TestFile = kind match {
- case "pos" => PosTestFile(file)
- case "neg" => NegTestFile(file)
- case "run" => RunTestFile(file)
- case "jvm" => JvmTestFile(file)
- case "jvm5" => Jvm5TestFile(file)
- case "shootout" => ShootoutTestFile(file)
+ case "pos" => PosTestFile(file, fileManager)
+ case "neg" => NegTestFile(file, fileManager)
+ case "run" => RunTestFile(file, fileManager)
+ case "jvm" => JvmTestFile(file, fileManager)
+ case "jvm5" => Jvm5TestFile(file, fileManager)
+ case "shootout" => ShootoutTestFile(file, fileManager)
}
test.defineSettings(testSettings)
@@ -83,12 +83,12 @@ class DirectCompiler extends SimpleCompiler {
val global = newGlobal(testSettings, testRep)
val test: TestFile = kind match {
- case "pos" => PosTestFile(file)
- case "neg" => NegTestFile(file)
- case "run" => RunTestFile(file)
- case "jvm" => JvmTestFile(file)
- case "jvm5" => Jvm5TestFile(file)
- case "shootout" => ShootoutTestFile(file)
+ case "pos" => PosTestFile(file, fileManager)
+ case "neg" => NegTestFile(file, fileManager)
+ case "run" => RunTestFile(file, fileManager)
+ case "jvm" => JvmTestFile(file, fileManager)
+ case "jvm5" => Jvm5TestFile(file, fileManager)
+ case "shootout" => ShootoutTestFile(file, fileManager)
}
test.defineSettings(testSettings)
@@ -107,8 +107,8 @@ class DirectCompiler extends SimpleCompiler {
}
}
-class ReflectiveCompiler extends SimpleCompiler {
- import FileManager.{latestCompFile, latestPartestFile, latestFjbgFile}
+class ReflectiveCompiler(val fileManager: ConsoleFileManager) extends SimpleCompiler {
+ import fileManager.{latestCompFile, latestPartestFile, latestFjbgFile}
val sepUrls = Array(latestCompFile.toURL, latestPartestFile.toURL,
latestFjbgFile.toURL)
@@ -151,13 +151,13 @@ class ReflectiveCompiler extends SimpleCompiler {
}
}
-class CompileManager {
- var compiler: SimpleCompiler = new /*ReflectiveCompiler*/ DirectCompiler
+class CompileManager(val fileManager: FileManager) {
+ var compiler: SimpleCompiler = new /*ReflectiveCompiler*/ DirectCompiler(fileManager)
var numSeparateCompilers = 1
def createSeparateCompiler() = {
numSeparateCompilers += 1
- compiler = new /*ReflectiveCompiler*/ DirectCompiler
+ compiler = new /*ReflectiveCompiler*/ DirectCompiler(fileManager)
}
/* This method returns true iff compilation succeeds.
diff --git a/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala b/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala
new file mode 100644
index 0000000000..a0052d92ff
--- /dev/null
+++ b/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala
@@ -0,0 +1,164 @@
+/* NEST (New Scala Test)
+ * Copyright 2007-2008 LAMP/EPFL
+ * @author Philipp Haller
+ */
+
+// $Id: FileManager.scala 14161 2008-02-27 19:45:27Z phaller $
+
+package scala.tools.partest.nest
+
+import java.io.{File, FilenameFilter, IOException, StringWriter}
+import java.net.URI
+
+class ConsoleFileManager extends FileManager {
+
+ var CLASSPATH = System.getProperty("java.class.path", ".")
+ NestUI.verbose("CLASSPATH: "+CLASSPATH)
+ val SCALAHOME = System.getProperty("scala.home", ".")
+ NestUI.verbose("SCALAHOME: "+SCALAHOME)
+ var JAVACMD = System.getProperty("scalatest.javacmd", "java")
+ val PREFIX = (new File(SCALAHOME)).getAbsolutePath
+
+/*
+if [ -d "$PREFIX/test" ]; then
+ TESTROOT="$PREFIX/test";
+elif [ -d "$PREFIX/misc/scala-test" ]; then
+ TESTROOT="$PREFIX/misc/scala-test";
+else
+ abort "Test directory not found";
+*/
+ val TESTROOT = {
+ val test = new File(SCALAHOME, "test")
+ val scala_test = new File(SCALAHOME, "misc/scala-test")
+ val testroot =
+ if (test.isDirectory)
+ test
+ else if (scala_test.isDirectory)
+ scala_test
+ else
+ error("Test directory not found")
+ testroot.getAbsolutePath
+ }
+
+ CLASSPATH += File.pathSeparator + {
+ val libs = new File(TESTROOT, "files/lib")
+ // add all jars in libs to EXT_CLASSPATH
+ (libs.listFiles(new FilenameFilter {
+ def accept(dir: File, name: String) = name endsWith ".jar"
+ }) map {file => file.getCanonicalFile.getAbsolutePath}).mkString(""+File.pathSeparator)
+ }
+ def findLatest() {
+ def prefixFile(relPath: String): File =
+ (new File(PREFIX, relPath)).getCanonicalFile
+
+ NestUI.verbose("PREFIX: "+PREFIX)
+ val dists = new File(PREFIX, "dists")
+ val build = new File(PREFIX, "build")
+ val bin = new File(PREFIX, "bin")
+
+ if (dists.isDirectory) {
+ latestFile = prefixFile("dists/latest/bin")
+ latestLibFile = prefixFile("dists/latest/lib/scala-library.jar")
+ latestActFile = prefixFile("dists/latest/lib/scala-library.jar")
+ latestCompFile = prefixFile("dists/latest/lib/scala-compiler.jar")
+ latestPartestFile = prefixFile("dists/latest/lib/scala-partest.jar")
+ latestFjbgFile = prefixFile("lib/fjbg.jar") // starr
+ }
+ else if (build.isDirectory) {
+ latestFile = prefixFile("build/quick/bin")
+ latestLibFile = prefixFile("build/quick/lib/library")
+ latestActFile = prefixFile("build/quick/lib/actors")
+ latestCompFile = prefixFile("build/quick/lib/compiler")
+ latestPartestFile = prefixFile("build/quick/lib/partest")
+ latestFjbgFile = prefixFile("lib/fjbg.jar") // starr
+ }
+ else if (bin.isDirectory) {
+ latestFile = prefixFile("bin")
+ latestLibFile = prefixFile("lib/scala-library.jar")
+ latestActFile = prefixFile("lib/scala-library.jar")
+ latestCompFile = prefixFile("lib/scala-compiler.jar")
+ latestPartestFile = prefixFile("lib/scala-partest.jar")
+ }
+ else
+ error("Scala binaries could not be found")
+
+ println("latestPartestFile="+latestPartestFile)
+
+ BIN_DIR = latestFile.getAbsolutePath
+ LATEST_LIB = latestLibFile.getAbsolutePath
+ LATEST_COMP = latestCompFile.getAbsolutePath
+ LATEST_PARTEST = latestPartestFile.getAbsolutePath
+
+ // detect whether we are running on Windows
+ val osName = System.getProperty("os.name")
+ NestUI.verbose("OS: "+osName)
+
+ val scalaCommand = if (osName startsWith "Windows")
+ "scala.bat" else "scala"
+ val scalacCommand = if (osName startsWith "Windows")
+ "scalac.bat" else "scalac"
+
+ SCALA = (new File(latestFile, scalaCommand)).getAbsolutePath
+ SCALAC_CMD = (new File(latestFile, scalacCommand)).getAbsolutePath
+ }
+
+ var BIN_DIR: String = ""
+ var LATEST_LIB: String = ""
+ var LATEST_COMP: String = ""
+ var LATEST_PARTEST: String = ""
+ var SCALA: String = ""
+ var SCALAC_CMD: String = ""
+
+ val SCALAC_OPTS = System.getProperty("scalatest.scalac_opts", "-deprecation")
+
+ var latestFile: File = _
+ var latestLibFile: File = _
+ var latestActFile: File = _
+ var latestCompFile: File = _
+ var latestPartestFile: File = _
+ var latestFjbgFile: File = _
+ // initialize above fields
+ findLatest()
+
+ val srcDir: File = {
+ val src = new File(TESTROOT, "files")
+ if (src.isDirectory)
+ src
+ else {
+ val path = TESTROOT + File.separator + "files"
+ NestUI.failure("Source directory \"" + path + "\" not found")
+ exit(1)
+ }
+ }
+
+ private def basename(name: String): String = {
+ val inx = name.lastIndexOf(".")
+ if (inx < 0) name else name.substring(0, inx)
+ }
+
+ var testFiles: List[File] = List()
+
+ def getFiles(kind: String, doCheck: Boolean, ending: String): List[File] = {
+ val filter = new FilenameFilter {
+ def accept(dir: File, name: String): Boolean = name endsWith ending
+ }
+ val dir = new File(srcDir, kind)
+ NestUI.verbose("look in "+dir+" for tests")
+ if (dir.isDirectory) {
+ if (!testFiles.isEmpty) {
+ val dirpath = dir.getAbsolutePath
+ testFiles filter { _.getParentFile.getAbsolutePath == dirpath }
+ } else if (doCheck)
+ dir.listFiles(filter).toList
+ else // skip
+ Nil
+ } else {
+ NestUI.failure("Directory \"" + dir.getPath + "\" not found")
+ Nil
+ }
+ }
+
+ def getFiles(kind: String, doCheck: Boolean): List[File] =
+ getFiles(kind, doCheck, ".scala")
+
+}
diff --git a/src/partest/scala/tools/partest/nest/ConsoleRunner.scala b/src/partest/scala/tools/partest/nest/ConsoleRunner.scala
new file mode 100644
index 0000000000..294d62b8a1
--- /dev/null
+++ b/src/partest/scala/tools/partest/nest/ConsoleRunner.scala
@@ -0,0 +1,199 @@
+/* NEST (New Scala Test)
+ * Copyright 2007-2008 LAMP/EPFL
+ * @author Philipp Haller
+ */
+
+// $Id: $
+
+package scala.tools.partest.nest
+
+import java.io.{File, PrintStream, FileOutputStream, BufferedReader,
+ InputStreamReader, StringWriter, PrintWriter}
+import java.util.StringTokenizer
+
+import scala.actors.Actor._
+
+class ConsoleRunner extends DirectRunner {
+
+ val fileManager: ConsoleFileManager = new ConsoleFileManager
+
+ private val version = System.getProperty("java.version", "")
+ private val isJava5 = version matches "1.[5|6|7].*"
+
+ private var posCheck = false
+ private var negCheck = false
+ private var runCheck = false
+ private var jvmCheck = false
+ private var jvm5Check = false
+ private var resCheck = false
+ private var runAll = false
+
+ private var testFiles: List[File] = List()
+ private val con = new PrintStream(Console.out)
+ private var out = con
+
+ private val errors =
+ Integer.parseInt(System.getProperty("scalatest.errors", "0"))
+
+ def denotesTestSet(arg: String) =
+ arg match {
+ case "--pos" => true
+ case "--neg" => true
+ case "--run" => true
+ case "--jvm" => true
+ case "--jvm5" => true
+ case "--res" => true
+ case _ => false
+ }
+
+ def main(argstr: String) {
+ // tokenize args
+ var args: List[String] = List()
+ val st = new StringTokenizer(argstr)
+ while (st.hasMoreTokens) {
+ args = args ::: List(st.nextToken())
+ }
+
+ if (args.length == 0)
+ NestUI.usage()
+ else {
+ if (!args.exists(denotesTestSet(_))) runAll = true
+ for (arg <- args) {
+ arg match {
+ case "--pos" => posCheck = true
+ case "--neg" => negCheck = true
+ case "--run" => runCheck = true
+ case "--jvm" => jvmCheck = true
+ case "--jvm5" => jvm5Check = true
+ case "--res" => resCheck = true
+ case "--verbose" => NestUI._verbose = true
+ case "--show-diff" => fileManager.showDiff = true
+ case "--show-log" => fileManager.showLog = true
+ case "--failed" => fileManager.failed = true
+ case "--version" => //todo: printVersion
+ case "--ansi" => NestUI.initialize(NestUI.MANY)
+ case _ =>
+ if (arg endsWith ".scala") {
+ val file = new File(arg)
+ if (file.isFile) {
+ NestUI.verbose("adding test file "+file)
+ testFiles = file :: testFiles
+ } else {
+ NestUI.failure("File \"" + arg + "\" not found")
+ System.exit(1)
+ }
+ } else if (out eq con) {
+ val file = new File(arg)
+ if (file.isFile || file.createNewFile)
+ out = new PrintStream(new FileOutputStream(file))
+ else {
+ NestUI.failure("Result file \"" + arg + "\" not found")
+ System.exit(1)
+ }
+ } else
+ NestUI.usage()
+ }
+ }
+
+ NestUI.outline("Source directory is : "+fileManager.srcDir.getAbsolutePath+"\n")
+ NestUI.outline("Scala binaries in : "+fileManager.BIN_DIR+"\n")
+
+ // obtain scalac version
+ val cmd = fileManager.SCALAC_CMD+" -version"
+ NestUI.verbose("running "+cmd)
+ val proc = Runtime.getRuntime.exec(cmd)
+ val in = proc.getInputStream
+ val err = proc.getErrorStream
+ val exitCode = proc.waitFor()
+ NestUI.verbose("exit code: "+exitCode)
+ val scalaVersion = StreamAppender.appendToString(in, err)
+
+ NestUI.outline("Scala version is : "+scalaVersion)
+ 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")
+
+ val start = System.currentTimeMillis
+
+ val (successes, failures) = testCheckAll()
+
+ val end = System.currentTimeMillis
+ val total = successes + failures
+
+ val elapsedSecs = (end - start)/1000
+ val elapsedMins = elapsedSecs/60
+ val elapsedHrs = elapsedMins/60
+ val dispMins = elapsedMins - elapsedHrs * 60
+ val dispSecs = elapsedSecs - elapsedMins * 60
+ val dispElapsed = {
+ def form(num: Long) = if (num < 10) "0"+num else ""+num
+ form(elapsedHrs)+":"+form(dispMins)+":"+form(dispSecs)
+ }
+
+ println
+ if (failures == 0)
+ NestUI.success("All of "+total+" tests were successful (elapsed time: "+dispElapsed+")\n")
+ else
+ NestUI.failure(failures+" of "+total+" tests failed (elapsed time: "+dispElapsed+")\n")
+
+ if (failures == errors)
+ System.exit(0)
+ else
+ System.exit(1)
+ }
+ }
+
+ def runTests(kind: String, check: Boolean, msg: String): (Int, Int) = {
+ if (check) {
+ val kindFiles =
+ if (!testFiles.isEmpty) {
+ NestUI.verbose("testing "+testFiles)
+ testFiles
+ }
+ else if (kind == "res") //TODO: is there a nicer way?
+ fileManager.getFiles(kind, check, ".res")
+ else
+ fileManager.getFiles(kind, check)
+ if (!kindFiles.isEmpty) {
+ NestUI.outline("\n"+msg+"\n")
+
+ runTestsForFiles(kindFiles, kind)
+
+ //val worker = new Worker
+ //worker.runTests(kind, kindFiles)
+ } else {
+ NestUI.failure("test dir empty")
+ (0, 0)
+ }
+ } else (0, 0)
+ }
+
+ /**
+ * @return (success count, failure count)
+ */
+ def testCheckAll(): (Int, Int) = {
+ if (runAll) { // run all tests
+ posCheck = true
+ negCheck = true
+ runCheck = true
+ jvmCheck = true
+ jvm5Check = true
+ //resCheck = true
+ }
+ val results = List(runTests("pos", posCheck, "Testing compiler (on files whose compilation should succeed)"),
+ runTests("neg", negCheck, "Testing compiler (on files whose compilation should fail)"),
+ runTests("run", runCheck, "Testing JVM backend"),
+ runTests("jvm", jvmCheck, "Testing JVM backend"),
+ runTests("jvm5", jvm5Check, "Testing JVM backend"),
+ runTests("res", resCheck, "Testing resident compiler"))
+ results reduceLeft { (p: (Int, Int), q: (Int, Int)) =>
+ (p._1+q._1, p._2+q._2) }
+ }
+}
diff --git a/src/partest/scala/tools/partest/nest/DirectRunner.scala b/src/partest/scala/tools/partest/nest/DirectRunner.scala
index cdfc814773..d82b82b072 100644
--- a/src/partest/scala/tools/partest/nest/DirectRunner.scala
+++ b/src/partest/scala/tools/partest/nest/DirectRunner.scala
@@ -13,221 +13,48 @@ import java.util.StringTokenizer
import scala.actors.Actor._
-class DirectRunner {
- private val version = System.getProperty("java.version", "")
- private val isJava5 = version matches "1.[5|6|7].*"
-
- private val numActors = Integer.parseInt(System.getProperty("scalatest.actors", "8"))
-
- private var posCheck = false
- private var negCheck = false
- private var runCheck = false
- private var jvmCheck = false
- private var jvm5Check = false
- private var resCheck = false
- private var runAll = false
-
- private var testFiles: List[File] = List()
- private val con = new PrintStream(Console.out)
- private var out = con
-
- private val errors =
- Integer.parseInt(System.getProperty("scalatest.errors", "0"))
-
- def denotesTestSet(arg: String) =
- arg match {
- case "--pos" => true
- case "--neg" => true
- case "--run" => true
- case "--jvm" => true
- case "--jvm5" => true
- case "--res" => true
- case _ => false
- }
-
- def main(argstr: String) {
- // tokenize args
- var args: List[String] = List()
- val st = new StringTokenizer(argstr)
- while (st.hasMoreTokens) {
- args = args ::: List(st.nextToken())
+trait DirectRunner {
+
+ def fileManager: FileManager
+
+ protected val numActors = Integer.parseInt(System.getProperty("scalatest.actors", "8"))
+
+ def runTestsForFiles(kindFiles: List[File], kind: String): (Int, Int) = {
+ val len = kindFiles.length
+ val (testsEach, lastFrag) = (len/numActors, len%numActors)
+ val last = numActors-1
+ val workers = for (i <- List.range(0, numActors)) yield {
+ val toTest = kindFiles.slice(i*testsEach, (i+1)*testsEach)
+ val worker = new Worker(fileManager)
+ worker.start()
+ if (i == last)
+ worker ! RunTests(kind, (kindFiles splitAt (last*testsEach))._2)
+ else
+ worker ! RunTests(kind, toTest)
+ worker
}
-
- if (args.length == 0)
- NestUI.usage()
- else {
- if (!args.exists(denotesTestSet(_))) runAll = true
- for (arg <- args) {
- arg match {
- case "--pos" => posCheck = true
- case "--neg" => negCheck = true
- case "--run" => runCheck = true
- case "--jvm" => jvmCheck = true
- case "--jvm5" => jvm5Check = true
- case "--res" => resCheck = true
- case "--verbose" => NestUI._verbose = true
- case "--show-diff" => FileManager.showDiff = true
- case "--show-log" => FileManager.showLog = true
- case "--failed" => FileManager.failed = true
- case "--version" => //todo: printVersion
- case "--ansi" => NestUI.initialize(NestUI.MANY)
- case _ =>
- if (arg endsWith ".scala") {
- val file = new File(arg)
- if (file.isFile) {
- NestUI.verbose("adding test file "+file)
- testFiles = file :: testFiles
- } else {
- NestUI.failure("File \"" + arg + "\" not found")
- System.exit(1)
- }
- } else if (out eq con) {
- val file = new File(arg)
- if (file.isFile || file.createNewFile)
- out = new PrintStream(new FileOutputStream(file))
- else {
- NestUI.failure("Result file \"" + arg + "\" not found")
- System.exit(1)
- }
- } else
- NestUI.usage()
- }
+ var succs = 0; var fails = 0
+ var logsToDelete: List[File] = List()
+ var outdirsToDelete: List[File] = List()
+ workers foreach { w =>
+ receive {
+ case Results(s, f, logs, outdirs) =>
+ logsToDelete = logsToDelete ::: logs.filter(_.toDelete)
+ outdirsToDelete = outdirsToDelete ::: outdirs
+ succs += s
+ fails += f
}
-
- NestUI.outline("Source directory is : "+FileManager.srcDir.getAbsolutePath+"\n")
- NestUI.outline("Scala binaries in : "+FileManager.BIN_DIR+"\n")
-
- // obtain scalac version
- val cmd = FileManager.SCALAC_CMD+" -version"
- NestUI.verbose("running "+cmd)
- val proc = Runtime.getRuntime.exec(cmd)
- val in = proc.getInputStream
- val err = proc.getErrorStream
- val exitCode = proc.waitFor()
- NestUI.verbose("exit code: "+exitCode)
- val scalaVersion = StreamAppender.appendToString(in, err)
-
- NestUI.outline("Scala version is : "+scalaVersion)
- 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")
-
- val start = System.currentTimeMillis
-
- val (successes, failures) = testCheckAll()
-
- val end = System.currentTimeMillis
- val total = successes + failures
-
- val elapsedSecs = (end - start)/1000
- val elapsedMins = elapsedSecs/60
- val elapsedHrs = elapsedMins/60
- val dispMins = elapsedMins - elapsedHrs * 60
- val dispSecs = elapsedSecs - elapsedMins * 60
- val dispElapsed = {
- def form(num: Long) = if (num < 10) "0"+num else ""+num
- form(elapsedHrs)+":"+form(dispMins)+":"+form(dispSecs)
- }
-
- println
- if (failures == 0)
- NestUI.success("All of "+total+" tests were successful (elapsed time: "+dispElapsed+")\n")
- else
- NestUI.failure(failures+" of "+total+" tests failed (elapsed time: "+dispElapsed+")\n")
-
- if (failures == errors)
- System.exit(0)
- else
- System.exit(1)
}
- }
-
- def runTests(kind: String, check: Boolean, msg: String): (Int, Int) = {
- if (check) {
- val fileMgr = new FileManager
- val kindFiles =
- if (!testFiles.isEmpty) {
- NestUI.verbose("testing "+testFiles)
- testFiles
- }
- else if (kind == "res") //TODO: is there a nicer way?
- fileMgr.getFiles(kind, check, ".res")
- else
- fileMgr.getFiles(kind, check)
- if (!kindFiles.isEmpty) {
- NestUI.outline("\n"+msg+"\n")
-
- val len = kindFiles.length
- val (testsEach, lastFrag) = (len/numActors, len%numActors)
- val last = numActors-1
- val workers = for (i <- List.range(0, numActors)) yield {
- val toTest = kindFiles.slice(i*testsEach, (i+1)*testsEach)
- val worker = new Worker
- worker.start()
- if (i == last)
- worker ! RunTests(kind, (kindFiles splitAt (last*testsEach))._2)
- else
- worker ! RunTests(kind, toTest)
- worker
- }
- var succs = 0; var fails = 0
- var logsToDelete: List[File] = List()
- var outdirsToDelete: List[File] = List()
- workers foreach { w =>
- receive {
- case Results(s, f, logs, outdirs) =>
- logsToDelete = logsToDelete ::: logs.filter(_.toDelete)
- outdirsToDelete = outdirsToDelete ::: outdirs
- succs += s
- fails += f
- }
- }
- logsToDelete.foreach { log =>
- NestUI.verbose("deleting "+log+"\n")
- FileManager.deleteRecursive(log)
- }
- outdirsToDelete.foreach { outdir =>
- NestUI.verbose("deleting "+outdir+"\n")
- FileManager.deleteRecursive(outdir)
- }
-
- (succs, fails)
+ logsToDelete.foreach { log =>
+ NestUI.verbose("deleting "+log+"\n")
+ fileManager.deleteRecursive(log)
+ }
+ outdirsToDelete.foreach { outdir =>
+ NestUI.verbose("deleting "+outdir+"\n")
+ fileManager.deleteRecursive(outdir)
+ }
- //val worker = new Worker
- //worker.runTests(kind, kindFiles)
- } else {
- NestUI.failure("test dir empty")
- (0, 0)
- }
- } else (0, 0)
+ (succs, fails)
}
- /**
- * @return (success count, failure count)
- */
- def testCheckAll(): (Int, Int) = {
- if (runAll) { // run all tests
- posCheck = true
- negCheck = true
- runCheck = true
- jvmCheck = true
- jvm5Check = true
- //resCheck = true
- }
- val results = List(runTests("pos", posCheck, "Testing compiler (on files whose compilation should succeed)"),
- runTests("neg", negCheck, "Testing compiler (on files whose compilation should fail)"),
- runTests("run", runCheck, "Testing JVM backend"),
- runTests("jvm", jvmCheck, "Testing JVM backend"),
- runTests("jvm5", jvm5Check, "Testing JVM backend"),
- runTests("res", resCheck, "Testing resident compiler"))
- results reduceLeft { (p: (Int, Int), q: (Int, Int)) =>
- (p._1+q._1, p._2+q._2) }
- }
}
diff --git a/src/partest/scala/tools/partest/nest/FileManager.scala b/src/partest/scala/tools/partest/nest/FileManager.scala
index bb9a3f4842..f83882d078 100644
--- a/src/partest/scala/tools/partest/nest/FileManager.scala
+++ b/src/partest/scala/tools/partest/nest/FileManager.scala
@@ -10,159 +10,7 @@ package scala.tools.partest.nest
import java.io.{File, FilenameFilter, IOException, StringWriter}
import java.net.URI
-object FileManager {
-
- val PATH_SEP = File.pathSeparatorChar
- val CLASSPATH = System.getProperty("java.class.path", ".")
- NestUI.verbose("CLASSPATH: "+CLASSPATH)
- val SCALAHOME = System.getProperty("scala.home", ".")
- NestUI.verbose("SCALAHOME: "+SCALAHOME)
- val JAVACMD = System.getProperty("scalatest.javacmd", "java")
- val PREFIX = (new File(SCALAHOME)).getAbsolutePath
-
-/*
-if [ -d "$PREFIX/test" ]; then
- TESTROOT="$PREFIX/test";
-elif [ -d "$PREFIX/misc/scala-test" ]; then
- TESTROOT="$PREFIX/misc/scala-test";
-else
- abort "Test directory not found";
-*/
- val TESTROOT = {
- val test = new File(SCALAHOME, "test")
- val scala_test = new File(SCALAHOME, "misc/scala-test")
- val testroot =
- if (test.isDirectory)
- test
- else if (scala_test.isDirectory)
- scala_test
- else
- error("Test directory not found")
- testroot.getAbsolutePath
- }
-
- val EXT_CLASSPATH = {
- val libs = new File(TESTROOT, "files/lib")
- // add all jars in libs to EXT_CLASSPATH
- (libs.listFiles(new FilenameFilter {
- def accept(dir: File, name: String) = name endsWith ".jar"
- }) map {file => file.getCanonicalFile.getAbsolutePath}).mkString(""+PATH_SEP)
- }
-
-/*
-if [ -d "$PREFIX/dists" ]; then
- LATEST="$PREFIX/dists/latest/bin";
- LATEST_LIB="$PREFIX/dists/latest/lib/scala-library.jar";
- LATEST_COMP="$PREFIX/dists/latest/lib/scala-compiler.jar";
- LATEST_PREDEF="$PREFIX/dists/latest/lib/predef.dll";
- LATEST_CLDC=$QUICK_CLDC;
- LATEST_CLDCAPI=$QUICK_CLDCAPI;
-elif [ -d "$PREFIX/build" ]; then
- LATEST="$QUICK";
- LATEST_LIB=$QUICK_LIB;
- LATEST_COMP=$QUICK_COMP;
- LATEST_ACT=$QUICK_ACT;
- LATEST_PREDEF=$QUICK_PREDEF;
- LATEST_CLDC=$QUICK_CLDC;
- LATEST_CLDCAPI=$QUICK_CLDCAPI;
-elif [ -d "$PREFIX/bin" ]; then
- LATEST="$PREFIX/bin";
- LATEST_LIB="$PREFIX/lib/scala-library.jar";
- LATEST_COMP="$PREFIX/lib/scala-compiler.jar";
- LATEST_PREDEF="$PREFIX/lib/predef.dll";
- LATEST_CLDC="$PREFIX/lib/scalaapi10-unverified.jar";
- LATEST_CLDCAPI="$PREFIX/lib/scalaapi10.jar";
-*/
- def findLatest() {
- def prefixFile(relPath: String): File =
- (new File(PREFIX, relPath)).getCanonicalFile
-
- NestUI.verbose("PREFIX: "+PREFIX)
- val dists = new File(PREFIX, "dists")
- val build = new File(PREFIX, "build")
- val bin = new File(PREFIX, "bin")
-
- if (dists.isDirectory) {
- latestFile = prefixFile("dists/latest/bin")
- latestLibFile = prefixFile("dists/latest/lib/scala-library.jar")
- latestActFile = prefixFile("dists/latest/lib/scala-library.jar")
- latestCompFile = prefixFile("dists/latest/lib/scala-compiler.jar")
- latestPartestFile = prefixFile("dists/latest/lib/scala-partest.jar")
- latestFjbgFile = prefixFile("lib/fjbg.jar") // starr
- }
- else if (build.isDirectory) {
- latestFile = prefixFile("build/quick/bin")
- latestLibFile = prefixFile("build/quick/lib/library")
- latestActFile = prefixFile("build/quick/lib/actors")
- latestCompFile = prefixFile("build/quick/lib/compiler")
- latestPartestFile = prefixFile("build/quick/lib/partest")
- latestFjbgFile = prefixFile("lib/fjbg.jar") // starr
- }
- else if (bin.isDirectory) {
- latestFile = prefixFile("bin")
- latestLibFile = prefixFile("lib/scala-library.jar")
- latestActFile = prefixFile("lib/scala-library.jar")
- latestCompFile = prefixFile("lib/scala-compiler.jar")
- latestPartestFile = prefixFile("lib/scala-partest.jar")
- }
- else
- error("Scala binaries could not be found")
-
- BIN_DIR = latestFile.getAbsolutePath
- LATEST_LIB = latestLibFile.getAbsolutePath
- LATEST_COMP = latestCompFile.getAbsolutePath
- LATEST_PARTEST = latestPartestFile.getAbsolutePath
-
- // detect whether we are running on Windows
- val osName = System.getProperty("os.name")
- NestUI.verbose("OS: "+osName)
-
- val scalaCommand = if (osName startsWith "Windows")
- "scala.bat" else "scala"
- val scalacCommand = if (osName startsWith "Windows")
- "scalac.bat" else "scalac"
-
- SCALA = (new File(latestFile, scalaCommand)).getAbsolutePath
- SCALAC_CMD = (new File(latestFile, scalacCommand)).getAbsolutePath
- }
-
- var BIN_DIR: String = ""
- var LATEST_LIB: String = ""
- var LATEST_COMP: String = ""
- var LATEST_PARTEST: String = ""
- var SCALA: String = ""
- var SCALAC_CMD: String = ""
-
- val SCALAC_OPTS = System.getProperty("scalatest.scalac_opts", "-deprecation")
-
- var latestFile: File = _
- var latestLibFile: File = _
- var latestActFile: File = _
- var latestCompFile: File = _
- var latestPartestFile: File = _
- var latestFjbgFile: File = _
- // initialize above fields
- findLatest()
-
- val srcDir: File = {
- val src = new File(TESTROOT, "files")
- if (src.isDirectory)
- src
- else {
- val path = TESTROOT + File.separator + "files"
- NestUI.failure("Source directory \"" + path + "\" not found")
- exit(1)
- }
- }
-
- var showDiff = false
- var showLog = false
- var failed = false
-
- private def basename(name: String): String = {
- val inx = name.lastIndexOf(".")
- if (inx < 0) name else name.substring(0, inx)
- }
+trait FileManager {
def deleteRecursive(dir: File) {
if (dir.isDirectory) {
@@ -194,32 +42,15 @@ elif [ -d "$PREFIX/bin" ]; then
}
res
}
-}
-class FileManager {
- var testFiles: List[File] = List()
+ var JAVACMD: String
- def getFiles(kind: String, doCheck: Boolean, ending: String): List[File] = {
- val filter = new FilenameFilter {
- def accept(dir: File, name: String): Boolean = name endsWith ending
- }
- val dir = new File(FileManager.srcDir, kind)
- NestUI.verbose("look in "+dir+" for tests")
- if (dir.isDirectory) {
- if (!testFiles.isEmpty) {
- val dirpath = dir.getAbsolutePath
- testFiles filter { _.getParentFile.getAbsolutePath == dirpath }
- } else if (doCheck)
- dir.listFiles(filter).toList
- else // skip
- Nil
- } else {
- NestUI.failure("Directory \"" + dir.getPath + "\" not found")
- Nil
- }
- }
+ var CLASSPATH: String
+ var LATEST_LIB: String
+
+ var showDiff = false
+ var showLog = false
+ var failed = false
- def getFiles(kind: String, doCheck: Boolean): List[File] =
- getFiles(kind, doCheck, ".scala")
}
diff --git a/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala b/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala
index 228eb7ff6c..ba04267609 100644
--- a/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala
+++ b/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala
@@ -19,7 +19,9 @@ class ReflectiveRunner {
// to use the same classes as used by `scala` that
// was used to start the runner.
- import FileManager.{latestCompFile, latestLibFile, latestActFile,
+ val fileManager = new ConsoleFileManager
+
+ import fileManager.{latestCompFile, latestLibFile, latestActFile,
latestPartestFile, latestFjbgFile}
val sepUrls = Array(latestCompFile.toURL, latestLibFile.toURL,
@@ -28,7 +30,7 @@ class ReflectiveRunner {
val sepLoader = new java.net.URLClassLoader(sepUrls, null)
val sepRunnerClass =
- sepLoader.loadClass("scala.tools.partest.nest.DirectRunner")
+ sepLoader.loadClass("scala.tools.partest.nest.ConsoleRunner")
val sepRunner = sepRunnerClass.newInstance()
val stringClass = Class.forName("java.lang.String")
diff --git a/src/partest/scala/tools/partest/nest/TestFile.scala b/src/partest/scala/tools/partest/nest/TestFile.scala
index 102e231910..7edfa4dabc 100644
--- a/src/partest/scala/tools/partest/nest/TestFile.scala
+++ b/src/partest/scala/tools/partest/nest/TestFile.scala
@@ -10,7 +10,7 @@ package scala.tools.partest.nest
import java.io.File
import scala.tools.nsc.Settings
-class TestFile(kind: String, val file: File) {
+class TestFile(kind: String, val file: File, val fileManager: FileManager) {
val dir = file.getParentFile
val dirpath = dir.getAbsolutePath
@@ -48,41 +48,60 @@ class TestFile(kind: String, val file: File) {
override def toString(): String = kind+" "+file
}
-case class PosTestFile(override val file: File) extends TestFile("pos", file)
+case class PosTestFile(override val file: File, override val fileManager: FileManager) extends TestFile("pos", file, fileManager) {
+ import fileManager.CLASSPATH
-case class NegTestFile(override val file: File) extends TestFile("neg", file)
+ override def defineSettings(settings: Settings) {
+ baseSettings(settings)
+ settings.classpath.value = CLASSPATH
+ //println("settings.classpath.value="+settings.classpath.value)
+ }
+}
+
+case class NegTestFile(override val file: File, override val fileManager: FileManager) extends TestFile("neg", file, fileManager) {
+ import fileManager.CLASSPATH
+
+ override def defineSettings(settings: Settings) {
+ baseSettings(settings)
+ settings.classpath.value = CLASSPATH
+ //println("settings.classpath.value="+settings.classpath.value)
+ }
+}
-case class RunTestFile(override val file: File) extends TestFile("run", file) {
+case class RunTestFile(override val file: File, override val fileManager: FileManager) extends TestFile("run", file, fileManager) {
+ import fileManager.CLASSPATH
override def defineSettings(settings: Settings) {
baseSettings(settings)
+ settings.classpath.value = CLASSPATH
}
}
-case class JvmTestFile(override val file: File) extends TestFile("jvm", file) {
- import FileManager.{CLASSPATH, EXT_CLASSPATH, PATH_SEP}
+case class JvmTestFile(override val file: File, override val fileManager: FileManager) extends TestFile("jvm", file, fileManager) {
+ import fileManager.CLASSPATH
override def defineSettings(settings: Settings) {
baseSettings(settings)
- settings.classpath.value = CLASSPATH+PATH_SEP+EXT_CLASSPATH
+ settings.classpath.value = CLASSPATH
//println("settings.classpath.value="+settings.classpath.value)
}
}
-case class Jvm5TestFile(override val file: File) extends TestFile("jvm5", file) {
- import FileManager.{CLASSPATH, EXT_CLASSPATH, PATH_SEP}
+case class Jvm5TestFile(override val file: File, override val fileManager: FileManager) extends TestFile("jvm5", file, fileManager) {
+ import fileManager.CLASSPATH
override def defineSettings(settings: Settings) {
baseSettings(settings)
- settings.classpath.value = CLASSPATH+PATH_SEP+EXT_CLASSPATH
+ settings.classpath.value = CLASSPATH
settings.target.value = "jvm-1.5"
//println("settings.classpath.value="+settings.classpath.value)
}
}
-case class ShootoutTestFile(override val file: File) extends TestFile("shootout", file) {
+case class ShootoutTestFile(override val file: File, override val fileManager: FileManager) extends TestFile("shootout", file, fileManager) {
+ import fileManager.CLASSPATH
override def defineSettings(settings: Settings) {
baseSettings(settings)
- settings.classpath.value = System.getProperty("EXT_CLASSPATH")
+ settings.classpath.value = CLASSPATH
//println("CLASSPATH="+settings.classpath.value)
}
}
diff --git a/src/partest/scala/tools/partest/nest/Worker.scala b/src/partest/scala/tools/partest/nest/Worker.scala
index f4594c1348..1faa21f0eb 100644
--- a/src/partest/scala/tools/partest/nest/Worker.scala
+++ b/src/partest/scala/tools/partest/nest/Worker.scala
@@ -15,8 +15,6 @@ import scala.tools.nsc.ObjectRunner
import scala.actors.Actor
import scala.actors.Actor._
-import FileManager._
-
case class RunTests(kind: String, files: List[File])
case class Results(succ: Int, fail: Int, logs: List[LogFile], outdirs: List[File])
@@ -24,7 +22,8 @@ class LogFile(parent: File, child: String) extends File(parent, child) {
var toDelete = false
}
-class Worker extends Actor {
+class Worker(val fileManager: FileManager) extends Actor {
+ import fileManager._
def act() {
react {
case RunTests(kind, files) =>
@@ -93,9 +92,7 @@ class Worker extends Actor {
val classpath: List[URL] =
outDir.toURL ::
List(file.getParentFile.toURL) :::
- (List.fromString(CLASSPATH, PATH_SEP) map { x =>
- (new File(x)).toURL }) :::
- (List.fromString(EXT_CLASSPATH, PATH_SEP) map { x =>
+ (List.fromString(CLASSPATH, File.pathSeparatorChar) map { x =>
(new File(x)).toURL })
try {
NestUI.verbose("classpath: "+classpath)
@@ -114,7 +111,7 @@ class Worker extends Actor {
def execTest(outDir: File, logFile: File) {
val cmd =
JAVACMD+
- " -classpath "+outDir+PATH_SEP+CLASSPATH+PATH_SEP+EXT_CLASSPATH+
+ " -classpath "+outDir+File.pathSeparatorChar+CLASSPATH+
" -Djava.library.path="+logFile.getParentFile.getAbsolutePath+
" -Dscalatest.output="+outDir.getAbsolutePath+
" -Dscalatest.lib="+LATEST_LIB+
@@ -159,7 +156,7 @@ class Worker extends Actor {
err.close
out.close*/
- if (FileManager.showLog) {
+ if (fileManager.showLog) {
// produce log as string in `log`
val reader = new BufferedReader(new FileReader(logFile))
val swriter = new StringWriter
@@ -180,12 +177,12 @@ class Worker extends Actor {
new File(dir, fileBase + "-" + kind + ".check")
}
if (!checkFile.exists || !checkFile.canRead) ""
- else FileManager.compareFiles(logFile, checkFile)
+ else fileManager.compareFiles(logFile, checkFile)
}
def runJvmTests(kind: String, files: List[File]): (Int, Int) = {
NestUI.verbose("testing "+files)
- val compileMgr = new CompileManager
+ val compileMgr = new CompileManager(fileManager)
var errors = 0
var success = true
var diff = ""
@@ -199,7 +196,7 @@ class Worker extends Actor {
// when option "--failed" is provided
// execute test only if log file is present
// (which means it failed before)
- if (!FileManager.failed || (logFile.exists && logFile.canRead)) {
+ if (!fileManager.failed || (logFile.exists && logFile.canRead)) {
val swr = new StringWriter
val wr = new PrintWriter(swr)
success = true
@@ -247,8 +244,8 @@ class Worker extends Actor {
wr.flush()
swr.flush()
NestUI.normal(swr.toString)
- if (!success && FileManager.showDiff) NestUI.normal(diff)
- if (!success && FileManager.showLog) NestUI.normal(log)
+ if (!success && fileManager.showDiff) NestUI.normal(diff)
+ if (!success && fileManager.showLog) NestUI.normal(log)
}
} // for each file
NestUI.verbose("finished testing "+kind+" with "+errors+" errors")
@@ -271,7 +268,7 @@ class Worker extends Actor {
* @param files The list of test files
*/
def runTests(kind: String, files: List[File]): (Int, Int) = {
- val compileMgr = new CompileManager
+ val compileMgr = new CompileManager(fileManager)
var errors = 0
var succeeded = true
var diff = ""
@@ -327,7 +324,7 @@ class Worker extends Actor {
// execute test only if log file is present
// (which means it failed before)
val logFile = createLogFile(file, kind)
- if (!FileManager.failed || (logFile.exists && logFile.canRead)) {
+ if (!fileManager.failed || (logFile.exists && logFile.canRead)) {
val swr = new StringWriter
val wr = new PrintWriter(swr)
succeeded = true; diff = ""; log = ""
@@ -366,8 +363,8 @@ class Worker extends Actor {
swr.flush()
NestUI.normal(swr.toString)
- if (!succeeded && FileManager.showDiff) NestUI.normal(diff)
- if (!succeeded && FileManager.showLog) {
+ if (!succeeded && fileManager.showDiff) NestUI.normal(diff)
+ if (!succeeded && fileManager.showLog) {
// output log file
val logReader = new BufferedReader(new FileReader(logFile))
val logWriter = new PrintWriter(new StringWriter, true)
@@ -410,7 +407,7 @@ class Worker extends Actor {
// $SCALAC -d "$os_dstbase".obj -Xresident -sourcepath . "$@"
val cmd =
JAVACMD+
- " -classpath "+outDir+PATH_SEP+CLASSPATH+PATH_SEP+EXT_CLASSPATH+
+ " -classpath "+outDir+File.pathSeparator+CLASSPATH+
" -Djavacmd="+JAVACMD+
" scala.tools.nsc.Main"+
" -d "+outDir.getCanonicalFile.getAbsolutePath+
@@ -457,8 +454,8 @@ class Worker extends Actor {
errors += 1
}
- if (!succeeded && FileManager.showDiff) NestUI.normal(diff)
- if (!succeeded && FileManager.showLog) {
+ if (!succeeded && fileManager.showDiff) NestUI.normal(diff)
+ if (!succeeded && fileManager.showLog) {
// output log file
val logReader = new BufferedReader(new FileReader(logFile))
val logWriter = new PrintWriter(new StringWriter, true)