summaryrefslogtreecommitdiff
path: root/src/partest
diff options
context:
space:
mode:
authorPhilipp Haller <hallerp@gmail.com>2008-03-13 11:21:21 +0000
committerPhilipp Haller <hallerp@gmail.com>2008-03-13 11:21:21 +0000
commit10b30e9d2246dd9e2c3664c72438f234443bf8a4 (patch)
tree5d0b678180da2917131041622f587c79cdc5f8b9 /src/partest
parent44c4ab87bddbb9e1f093ab2e28868de8f31ebf75 (diff)
downloadscala-10b30e9d2246dd9e2c3664c72438f234443bf8a4.tar.gz
scala-10b30e9d2246dd9e2c3664c72438f234443bf8a4.tar.bz2
scala-10b30e9d2246dd9e2c3664c72438f234443bf8a4.zip
Test root can be overridden and look-up is smar...
Test root can be overridden and look-up is smarter. Removed dependency on SCALA_HOME. Deleted obsolete files.
Diffstat (limited to 'src/partest')
-rw-r--r--src/partest/scala/tools/partest/MasterActor.scala155
-rw-r--r--src/partest/scala/tools/partest/NestRunner.scala (renamed from src/partest/scala/tools/partest/nest/NestRunner.scala)0
-rw-r--r--src/partest/scala/tools/partest/ReflectiveRunner.scala (renamed from src/partest/scala/tools/partest/nest/ReflectiveRunner.scala)2
-rw-r--r--src/partest/scala/tools/partest/TestRunner.scala283
-rw-r--r--src/partest/scala/tools/partest/WorkerActor.scala330
-rw-r--r--src/partest/scala/tools/partest/nest/ConsoleFileManager.scala65
-rw-r--r--src/partest/scala/tools/partest/nest/NestUI.scala2
7 files changed, 44 insertions, 793 deletions
diff --git a/src/partest/scala/tools/partest/MasterActor.scala b/src/partest/scala/tools/partest/MasterActor.scala
deleted file mode 100644
index 600d1dad4f..0000000000
--- a/src/partest/scala/tools/partest/MasterActor.scala
+++ /dev/null
@@ -1,155 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala Parallel Testing **
-** / __/ __// _ | / / / _ | (c) 2007-2008, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id$
-
-package scala.tools.partest
-
-import java.awt.event.{ActionEvent, ActionListener}
-import java.io.{File, FileOutputStream, PrintStream}
-import javax.swing.Timer
-
-import scala.actors.Actor
-import scala.collection.mutable.SynchronizedQueue
-import scala.tools.nsc.Settings
-
-import utils.PrintMgr._
-
-/**
- * @author Adriaan Moors, Thomas Hofer
- * @version 1.0
- */
-class MasterActor(testDir: File, out: PrintStream) extends Actor {
- import scala.actors.Actor._
-
- private final val testPathLen = testDir.getAbsolutePath.length
-
- private final val WIDTH = 56
- private final val TIMEOUT = 1360000
-
- private var counter = 0
- private var failed = 0
-
- private var conservative = false
-
- private val globalSettings = new Settings(x => ())
-
- //private var numOfActors = Math.min(4, Math.max(Integer.parseInt(System.getProperty("actors.maxPoolSize")),
- private val numOfActors = 4
-
- private var workers = (for (i <- 0 until numOfActors) yield (new WorkerActor(this, new Settings(x => ()), new ExtConsoleReporter(globalSettings)), i)).toList
-
- private var workingOn: List[(Int, Test)] = List()
-
- private var timers = (for (i <- 0 until numOfActors) yield createTimer(workers(i)._1)).toList
-
- private var testsToRun = new SynchronizedQueue[Test]
-
- private var failedTests: List[Test] = List()
-
- private def createTimer(worker: WorkerActor): Timer = {
- val action: ActionListener = new ActionListener {
- def actionPerformed(event: ActionEvent) {
- val workerID = workers.find((_)._1 == worker) match {
- case Some(x) => x
- case None => (null, -1)
- }
- val test = workingOn.find((_)._1 == workerID._2) match {
- case Some(x) => x._2
- case None => null
- }
- println("Actor " + workerID._1 + " failed, while testing " + test.file.getPath)
- failedTests.find(_ == test) match {
- case Some(x) => //...
- case None => testFailed(workerID, test)
- }
-
- }
- }
-
- new Timer(TIMEOUT, action)
- }
-
- private def testFailed(actor: (WorkerActor, Int), test: Test) = {
- failedTests = test :: failedTests
- var newWorker = new WorkerActor(this, new Settings(x => ()), new ExtConsoleReporter(globalSettings))
- timers(actor._2).stop
- timers = timers.take(actor._2 - 1) ::: List(createTimer(newWorker)) ::: timers.drop(actor._2)
- newWorker.start
- //println("Started actor " + newWorker)
- workers = (newWorker, actor._2) :: workers.remove(_ == actor)
-
- timers(actor._2).start
- newWorker ! (test, true, conservative)
- }
-
- def act() {
- loop {
- react {
- case test: Test =>
- testsToRun += test
-
- case ("start", conservative: Boolean) =>
- this.conservative = conservative
- workers foreach (x => {
- if (!testsToRun.isEmpty) {
- x._1.start
- val test = testsToRun.dequeue
- // TODO Change here should be x._1 ! (test, false, conservative)
- x._1 ! (test, false, conservative)
- timers(x._2).start
- workingOn = (x._2, test) :: workingOn
- }
- })
-
- case (kind: String, succeeded: Boolean, file: File) =>
- val workerID = workers.find((_)._1 == sender) match {
- case Some(x) => x
- case None => (null, -1)
- }
- if (workerID._2 != -1) {
- workingOn = workingOn.remove((_)._1 == workerID._2)
- if (!testsToRun.isEmpty) {
- val test = testsToRun.dequeue
- // TODO Change here should be x._1 ! (test, false, conservative)
- sender ! (test, false, conservative)
- timers(workerID._2).restart
- workingOn = (workerID._2, test) :: workingOn
- } else {
- sender ! false
- timers(workerID._2).stop
- }
- } else {
- //Houston, we got a problem...
- }
- counter += 1
- printOutline("testing: ")
- val name = file.getAbsolutePath.substring(testPathLen)
- print("[...]" + name + List.toString(List.make(WIDTH - name.length, ' ')) + "[")
- if (succeeded) {
- printSuccess(" OK ")
- } else {
- failed += 1
- printFailure("FAILED")
- }
- println("]")
- if (workingOn.isEmpty) {
- out.println(failed)
- out.println(counter - failed)
- out.close
- println
- exit
- }
-
- case msg =>
- println(msg)
- }
- }
- }
-
-}
diff --git a/src/partest/scala/tools/partest/nest/NestRunner.scala b/src/partest/scala/tools/partest/NestRunner.scala
index e2974e4183..e2974e4183 100644
--- a/src/partest/scala/tools/partest/nest/NestRunner.scala
+++ b/src/partest/scala/tools/partest/NestRunner.scala
diff --git a/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala b/src/partest/scala/tools/partest/ReflectiveRunner.scala
index 6b0bd9d457..af5d4d10ed 100644
--- a/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala
+++ b/src/partest/scala/tools/partest/ReflectiveRunner.scala
@@ -15,7 +15,7 @@ package scala.tools.partest.nest
* class on the classpath (ideally).
*/
class ReflectiveRunner {
- // we might also use FileManager.CLASSPATH
+ // TODO: we might also use fileManager.CLASSPATH
// to use the same classes as used by `scala` that
// was used to start the runner.
diff --git a/src/partest/scala/tools/partest/TestRunner.scala b/src/partest/scala/tools/partest/TestRunner.scala
deleted file mode 100644
index b1cfc4cdb5..0000000000
--- a/src/partest/scala/tools/partest/TestRunner.scala
+++ /dev/null
@@ -1,283 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala Parallel Testing **
-** / __/ __// _ | / / / _ | (c) 2007-2008, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id$
-
-package scala.tools.partest
-
-import java.awt.event.{ActionEvent, ActionListener}
-import java.io.{File, FilenameFilter, FileInputStream, FileOutputStream,
- PrintStream}
-import java.net.URI
-
-import scala.tools.nsc.Settings
-
-import utils.PrintMgr
-import utils.PrintMgr._
-
-/**
- * @author Adriaan Moors, Thomas Hofer
- * @version 1.0
- */
-class Test(val kind: String, val file: File) {
- val dir = file.getParentFile
- val dirpath = dir.getAbsolutePath
- protected def baseSettings(settings: Settings) {
- settings.classpath.value = dirpath
- settings.outdir.value = {
- var outDir = new File(dir, fileBase + "-" + kind + ".obj")
- outDir.mkdir
- outDir.toString
- }
- settings.deprecation.value = true
- settings.nowarnings.value = false
- settings.encoding.value = "iso-8859-1"
- }
- def defineSettings(settings: Settings) {
- baseSettings(settings)
- }
- private def basename(name: String): String = {
- val inx = name.lastIndexOf(".")
- if (inx < 0) name else name.substring(0, inx)
- }
- val fileBase: String = basename(file.getName)
- val logFile: File = new File(dir, fileBase + "-" + kind + ".log")
- val checkFile: File = {
- var chkFile = new File(dir, fileBase + ".check")
- if (chkFile.isFile) {
- chkFile
- } else {
- new File(dir, fileBase + "-" + kind + ".check")
- }
- }
-}
-
-case class PosTest(override val file: File) extends Test("pos", file)
-case class NegTest(override val file: File) extends Test("neg", file)
-case class JVMTest(override val file: File) extends Test("jvm", file) {
- override def defineSettings(settings: Settings) {
- baseSettings(settings)
- settings.target.value =
- if (dirpath endsWith "jvm5") "jvm-1.5" else "jvm-1.4"
- settings.classpath.value = System.getProperty("EXT_CLASSPATH")
- TestRunner.printVerbose("CLASSPATH="+settings.classpath.value)
- }
-}
-case class ShootoutTest(override val file: File) extends Test("shootout", file) {
- override def defineSettings(settings: Settings) {
- baseSettings(settings)
- settings.classpath.value = System.getProperty("EXT_CLASSPATH")
- TestRunner.printVerbose("CLASSPATH="+settings.classpath.value)
- }
-}
-
-/**
- * @author Stephane Micheloud
- * @version 1.0
- */
-object TestRunner {
- private final val version = System.getProperty("java.version", "")
- private final val isJava5 = version matches "1.[5|6|7].*"
-
- private var posCheck = false
- private var negCheck = false
- private var jvmCheck = false
- private var runCheck = false
- private var shootoutCheck = false
-
- private var conservative = false
- private var verbose = false
-
- private val srcDir = {
- val dirname = System.getProperty("scalatest.cwd", "")
- val dir = if (dirname.isEmpty) { // guess
- val libDir = new File(new URI(classOf[Test].getResource("/").toString))
- val path = libDir.getAbsolutePath
- val parent = libDir.getParentFile
- val rootDir =
- if (path contains "quick") parent.getParentFile.getParentFile.getParentFile
- else if (path contains "dists") parent.getParentFile.getParentFile
- else parent
- new File(rootDir, "test" + File.separator + "files")
- } else
- new File(dirname)
- dir
- }
- private val testDir = srcDir.getParentFile
-
- private var testFiles = new collection.mutable.ListBuffer[File]
- private val con = new PrintStream(Console.out)
- private var out = con
-
- private def createTestFile(file: File, suffix: String): File = {
- def getBaseName(f: File): String = {
- val name = f.getName
- val inx = name lastIndexOf '.'
- if (inx < 0) name else name.substring(0, inx)
- }
- def concat(outputFile: File, inputFiles: File*) {
- val out = new FileOutputStream(outputFile)
- for (f <- inputFiles) {
- val in = new FileInputStream(f)
- val buf = new Array[Byte](1024)
- var len = 0
- while (len != -1) {
- out.write(buf, 0, len)
- len = in.read(buf)
- }
- in.close
- }
- out.close
- }
- try {
- val parent = file.getParentFile
- val outDir = new File(parent, getBaseName(file) + "-" + suffix + ".obj")
- outDir.mkdir
- val testfile = new File(outDir, "test.scala")
- val runnerfile = new File(parent, file.getName + ".runner")
- concat(testfile, file, runnerfile)
- testfile
- }
- catch {
- case e: Exception =>
- println("Couldn't create test file for \"" + file.getPath + "\"")
- file
- }
- }
-
- private def go {
- val master = new MasterActor(testDir, out)
- val filter = new FilenameFilter {
- def accept(dir: File, name: String): Boolean = name endsWith ".scala"
- }
- def getFiles(kind: String, doCheck: Boolean): List[File] = {
- val dir = new File(srcDir, kind)
- if (dir.isDirectory) {
- if (! testFiles.isEmpty) {
- val dirpath = dir.getAbsolutePath
- val files = testFiles filter { _.getParentFile.getAbsolutePath == dirpath }
- files.toList
- } else if (doCheck)
- dir.listFiles(filter).toList
- else // skip
- Nil
- } else {
- println("Directory \"" + dir.getPath + "\" not found")
- Nil
- }
- }
-
- master.start
-
- val posFiles = getFiles("pos", posCheck)
- if (! posFiles.isEmpty) {
- printOutline("\nTesting compiler (on files whose compilation should succeed)\n")
- for (file <- posFiles) master ! PosTest(file)
- }
- val negFiles = getFiles("neg", negCheck)
- if (! negFiles.isEmpty) {
- printOutline("\nTesting compiler (on files whose compilation should fail)\n")
- for (file <- negFiles) master ! NegTest(file)
- }
- val jvmFiles = getFiles("jvm", jvmCheck) ::: getFiles("run", jvmCheck) :::
- getFiles("jvm5", jvmCheck && isJava5)
- if (! jvmFiles.isEmpty) {
- printOutline("\nTesting JVM backend\n")
- for (file <- jvmFiles) master ! JVMTest(file)
- } else {
- val runFiles = getFiles("run", runCheck)
- if (! runFiles.isEmpty) {
- printOutline("\nTesting JVM backend\n")
- for (file <- runFiles) master ! JVMTest(file)
- }
- }
- val shootFiles = getFiles("shootout", shootoutCheck)
- if (! shootFiles.isEmpty) {
- printOutline("\nTesting shootout benchmarks\n")
- for (file <- shootFiles) master! ShootoutTest(createTestFile(file, "shootout"))
- }
-
- master ! ("start", conservative)
- }
-
- private def printUsage {
- println("Usage: TestRunner [<options>] [<testfile> ..] [<resfile>]")
- println(" --pos next files test a compilation success")
- println(" --neg next files test a compilation failure")
- println(" --jvm next files test the JVM backend")
- println(" --run next files test the interpreter and all backends")
- println(" --shootout ...")
- println(" --conservative ...")
- println(" --verbose display progress information")
- println(" --version output version information and exit")
- println
- println("Send bugs to <scala@listes.epfl.ch>")
- exit(1)
- }
-
- private def printVersion {
- println(utils.Properties.versionMsg)
- exit(0)
- }
-
- final def printVerbose(msg: String) {
- if (verbose) {
- printOutline("debug : ")
- println(msg)
- }
- }
-
- def main(args: Array[String]) {
- if (!srcDir.isDirectory) {
- println("Test directory \"" + srcDir.getAbsolutePath + "\" not found")
- exit(1)
- }
- printVerbose(srcDir.getAbsolutePath)
- if (args.length == 0)
- printUsage
- else {
- for (arg <- args) {
- arg match {
- case "--pos" => posCheck = true
- case "--neg" => negCheck = true
- case "--jvm" => jvmCheck = true
- case "--run" => runCheck = true
- case "--shootout" => shootoutCheck = true
- case "--conservative" => conservative = true
- case "--verbose" => verbose = true
- case "--version" => printVersion
- case _ =>
- if (arg endsWith ".scala") {
- val file = new File(arg)
- if (file.isFile)
- testFiles += file
- else {
- println("File \"" + arg + "\" not found")
- exit(1)
- }
- } else if (out eq con) {
- val file = new File(arg)
- if (file.isFile || file.createNewFile)
- out = new PrintStream(new FileOutputStream(file))
- else {
- println("Result file \"" + arg + "\" not found")
- exit(1)
- }
- } else
- printUsage
- }
- }
- if (!(posCheck | negCheck | jvmCheck | runCheck | shootoutCheck)) {
- posCheck = true
- negCheck = true
- }
- initialization(PrintMgr.MANY)
- go
- }
- }
-}
diff --git a/src/partest/scala/tools/partest/WorkerActor.scala b/src/partest/scala/tools/partest/WorkerActor.scala
deleted file mode 100644
index 557d048515..0000000000
--- a/src/partest/scala/tools/partest/WorkerActor.scala
+++ /dev/null
@@ -1,330 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala Parallel Testing **
-** / __/ __// _ | / / / _ | (c) 2007-2008, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id$
-
-package scala.tools.partest
-
-import java.io.{BufferedInputStream, BufferedReader, File, FileReader, FileWriter,
- FileInputStream, FileOutputStream, InputStreamReader,
- PrintStream, PrintWriter}
-import java.net.URL
-
-import scala.actors.Actor
-import scala.tools.nsc.{Global, ObjectRunner, Settings}
-import scala.tools.nsc.reporters.{Reporter, AbstractReporter, ConsoleReporter}
-
-
-class ExtConsoleReporter(override val settings: Settings, reader: BufferedReader, var writer: PrintWriter) extends ConsoleReporter(settings, reader, writer) {
- def this(settings: Settings) = {
- this(settings, Console.in, new PrintWriter(new FileWriter("/dev/null")))
- }
- def hasWarnings: Boolean = WARNING.count != 0
-}
-
-class ExtGlobal(settings: Settings, reporter: Reporter) extends Global(settings, reporter) {
- override def inform(msg: String) {}
-}
-
-/**
- * @author Adriaan Moors, Thomas Hofer
- * @version 1.0
- */
-class WorkerActor(val master: MasterActor, val settings: Settings, var reporter: ExtConsoleReporter) extends Actor {
- import scala.actors.Actor._
-
- def newGlobal: ExtGlobal = new ExtGlobal(settings, reporter)
-
- def newGlobal(log: File): ExtGlobal = {
- reporter = new ExtConsoleReporter(new Settings(x => ()), Console.in, new PrintWriter(new FileWriter(log)))
- reporter.shortname = true
- newGlobal
- }
-
- private def dirDelete(dir: File) {
- if (dir.isDirectory) {
- for (file <- dir.list) dirDelete(new File(dir, file))
- }
- dir.delete
- }
-
- private val PATH_SEP = java.io.File.pathSeparatorChar
- private val CLASSPATH = System.getProperty("CLASSPATH", "")
- private val EXT_CLASSPATH = System.getProperty("EXT_CLASSPATH", "")
-
- private val GREP_COMMAND = "grep"
- private val GREP_PATTERNS =
- List("Console.read", "Scheduler.impl",
- "System.exit", "System.out").foldLeft("")((x, y) => x + " -e " + y)
-
- def act() {
- var compiler = newGlobal
- val bufferSize = 1024
- val originBuffer = new Array[Byte](bufferSize)
- val destBuffer = new Array[Byte](bufferSize)
- loop {
- react {
- case (test: Test, bypass: Boolean, conservative: Boolean) => {
- var bypassObjectRunner = bypass
- if (!bypassObjectRunner) {
- // TODO check the shootout source files for "dangerous" patterns, such as: Console.read, Scheduler.impl,
- val grepCmd = GREP_COMMAND + " " + test.file.getPath + " " + GREP_PATTERNS
- TestRunner.printVerbose(grepCmd)
-
- val grep = Runtime.getRuntime.exec(grepCmd)
-
- val in = new BufferedReader(new InputStreamReader(grep.getInputStream))
-
- val line = in.readLine
- bypassObjectRunner = (line != null)
-
- in.close
-
- //println(bypassObjectRunner)
- }
-
- var start = System.currentTimeMillis
- //println("Starting..." + test.kind + " " + test.test)
-
- var toCompile = List(test.file.getPath)
-
- var outDir: File = new File(test.dir, test.fileBase + "-" + test.kind + ".obj")
- if (! outDir.exists) {
- outDir.mkdir
- //println(this.toString + " " + "Created " + outDir)
- } else {
- //println(this.toString + " " + "Didn't need to create " + outDir)
- }
- test match {
- case NegTest(_) =>
- compiler = newGlobal(test.logFile)
-
- case JVMTest(_) =>
- TestRunner.printVerbose(test.file.getPath + ": " + test.checkFile.exists + " / " + test.logFile.exists)
- if (test.checkFile.exists) {
- var checkReader = new BufferedReader(new FileReader(test.checkFile))
- var firstLine = checkReader.readLine
- if (firstLine != null && firstLine.startsWith("warning")) {
- //reporter = new ExtConsoleReporter(new Settings(x => ()), Console.in, new PrintWriter(logFile))
- //reporter.shortname = true
- compiler = newGlobal(test.logFile)
- }
- } else if (conservative) compiler = newGlobal
-
- case ShootoutTest(_) =>
- var testFile = new File(outDir, "Test.scala")
- if (testFile.exists) {
- toCompile = List(testFile.toString)
- //println(this.toString + " ready to compile :" + toCompile)
- } else {
- // BASH script couldn't create test file...
- }
- if (test.checkFile.exists) {
- var checkReader = new BufferedReader(new FileReader(test.checkFile))
- var firstLine = checkReader.readLine
- if (firstLine.startsWith("warning")) {
- //reporter = new ExtConsoleReporter(new Settings(x => ()), Console.in, new PrintWriter(logFile))
- //reporter.shortname = true
- compiler = newGlobal(test.logFile)
- }
- } else if (conservative) compiler = newGlobal
-
- case _ =>
- }
-
- val c = compiler
-
- //println("about to define compilation settings...")
-
- test.defineSettings(settings)
- try {
- //println(this.toString + " " + "Launching compiler on " + toCompile)
- (new c.Run) compile toCompile
- reporter.printSummary
- reporter.writer.flush
- reporter.writer.close
- //println(this.toString + " " + "Finished compiling " + test.fileBase)
- } catch {
- case e => {
- e.printStackTrace
- reporter.error(null, "IO/Error")
- }
- }
- (reporter.hasErrors, test) match {
- case (_, NegTest(_)) =>
- case (true, _) =>
- compiler = newGlobal
- val c = compiler
- try {
- (new c.Run) compile toCompile
- } catch {
- case e => reporter.error(null, "IO/Error")
- }
- case _ =>
- }
-
- var success = test match {
- case NegTest(_) => reporter.hasErrors
- case _ => !reporter.hasErrors
- }
- (bypassObjectRunner, success, test) match {
- case (_, _, PosTest(_)) =>
- case (_, _, NegTest(_)) =>
- case (false, true, _) =>
- /*
- System.setProperty("scalatest.output", outDir.toString)
- test match {
- case ShootoutTest(_) => System.setProperty("scalatest.cwd", test.dir)
- case _ => {}
- }
- */
- var classpath: List[URL] =
- outDir.toURL ::
- List(test.dir.toURL) :::
- (List.fromString(CLASSPATH, PATH_SEP) map { x => (new File(x)).toURL }) :::
- (List.fromString(EXT_CLASSPATH, PATH_SEP) map { x => (new File(x)).toURL })
-
- try {
- //println(this.toString + " " + "Launching test " + test.fileBase)
- var out = new FileOutputStream(test.logFile, true)
- Console.withOut(new PrintStream(out)) {
- ObjectRunner.run(classpath, "Test", List("jvm"))
- }
- out.flush
- out.close
- //println(this.toString + " " + "Finished running " + test.fileBase)
- } catch {
- case e =>
- println(e + " (" + test.file.getPath + ")")
- }
-
- case _ =>
- }
- (!bypassObjectRunner && success, test.checkFile.exists, test) match {
- case (_, _, PosTest(_)) =>
- case (true, true, _) =>
- /*var cmd: String = "diff " + test.logFile + " " + test.checkFile
- //println(this.toString + " Comparing files " + test.fileBase)
- var proc: Process = Runtime.getRuntime.exec(cmd)
- proc.waitFor
- success = (proc.exitValue == 0)*/
- var equalNow = true
- if (test.checkFile.canRead) {
- val originStream = new FileInputStream(test.logFile)
- val destStream = new FileInputStream(test.checkFile)
- var originSize = originStream.read(originBuffer)
- while (originSize >= 0) {
- if (originSize == destStream.read(destBuffer)) {
- for (idx <- 0 until originSize)
- equalNow = equalNow && (originBuffer(idx) == destBuffer(idx))
- if (!equalNow) {
- success = false
- //println("Diff1: diffs found")
- }
- }
- else {
- success = false
- //println("Diff1: diffs found")
- }
- originSize = originStream.read(originBuffer)
- }
- if (destStream.read(destBuffer) >= 0) success = false
- }
-
- case _ =>
- //println("Not testing diff... " + test.test)
- }
-
- (bypassObjectRunner || !success, test) match {
- case (_, PosTest(_)) =>
- case (_, NegTest(_)) =>
- case (true, _) =>
- success = true
- //var javaoptsFile = new File(test.dir, test.fileBase + ".javaopts")
- //var javaNewOpts = (new BufferedFileReader(javaoptsFile)).readLine
- //if (javaoptsFile.exists && javaNewOpts != null) {}
- //Use Runtime.exec to execute the compiled file and pipe the standard system
- //out and the console out to the logfile
- val cmd =
- "env JAVACMD=java JAVA_OPTS=-Djava.library.path=\"" + test.dirpath + "\" " +
- System.getProperty("SCALA")+
- " -Dscalatest.lib=\"" + System.getProperty("scalatest.lib") + "\" " +
- "-Dscalatest.cwd=\"" + test.dirpath + "\" " +
- "-Dscalatest.output=" + outDir +
- " -classpath " + outDir + PATH_SEP + CLASSPATH + PATH_SEP + EXT_CLASSPATH +
- " Test jvm"
-
- TestRunner.printVerbose(cmd)
-
- var execution = Runtime.getRuntime.exec(cmd)
-
- var in = execution.getInputStream
- var out = new FileOutputStream(test.logFile)
-
- var c = in.read
- while (c != -1) {
- out.write(c)
- c = in.read
- }
-
- in.close
- out.close
-
- //println("Running diff")
-
- /*var diff = Runtime.getRuntime.exec("diff " + test.logFile + " " + test.checkFile)
- diff.waitFor
-
- success = (diff.exitValue == 0)*/
- var equalNow = true
- if (test.checkFile.canRead) {
- val originStream = new FileInputStream(test.logFile)
- val destStream = new FileInputStream(test.checkFile)
- var originSize = originStream.read(originBuffer)
- while (originSize >= 0) {
- if (originSize == destStream.read(destBuffer)) {
- for (idx <- 0 until originSize)
- equalNow = equalNow && (originBuffer(idx) == destBuffer(idx))
- if (!equalNow) {
- success = false
- //println("Differences found between the log and check files..")
- }
- }
- else {
- success = false
- //println("Differences found between the log and check files..")
- }
-
- originSize = originStream.read(originBuffer)
- }
- if (destStream.read(destBuffer) >= 0) success = false
- }
- //else reportMissing(originFile)
-
- case _ =>
- //println("Not Using runtime... " + test.test)
- }
- if (success) test.logFile.delete
-
- var end = System.currentTimeMillis
-
- //println(test.test + ": " + (end - start))
-
- //println(this.toString + ": "+ success)
- master ! (test.kind, success, test.file)
- if (success) dirDelete(outDir)
- }
- case false =>
- exit
-
- case msg =>
- println("Unknown message : " + msg)
- }
- }
- }
-}
diff --git a/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala b/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala
index f4b960751b..abd9819138 100644
--- a/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala
+++ b/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala
@@ -14,12 +14,20 @@ 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
+ val prefixFile = {
+ val cwd = System.getProperty("user.dir")
+ if (cwd != null)
+ (new File(cwd)).getCanonicalFile
+ else
+ error("user.dir property not set")
+ }
+ val PREFIX = prefixFile.getAbsolutePath
- val debug: Boolean = System.getProperty("partest.debug", "false") equals "true"
+ val debug: Boolean =
+ (System.getProperty("partest.debug", "false") equals "true") ||
+ (System.getProperty("scalatest.debug", "false") equals "true")
/*
if [ -d "$PREFIX/test" ]; then
@@ -29,18 +37,31 @@ elif [ -d "$PREFIX/misc/scala-test" ]; then
else
abort "Test directory not found";
*/
- val TESTROOT = {
- val test = new File(SCALAHOME, "test")
- val scala_test = new File(SCALAHOME, "misc/scala-test")
+
+ val testRootFile = {
+ val testRootProp = System.getProperty("scalatest.root")
val testroot =
- if (test.isDirectory)
- test
- else if (scala_test.isDirectory)
- scala_test
- else
- error("Test directory not found")
- testroot.getAbsolutePath
+ if (testRootProp != null)
+ new File(testRootProp)
+ else {
+ // case 1: cwd is `test`
+ if (prefixFile.getName == "test" && (new File(prefixFile, "files")).exists)
+ prefixFile
+ else {
+ // case 2: cwd is `test/..`
+ val test = new File(prefixFile, "test")
+ val scalaTest = new File(new File(prefixFile, "misc"), "scala-test")
+ if (test.isDirectory)
+ test
+ else if (scalaTest.isDirectory)
+ scalaTest
+ else
+ error("Test directory not found")
+ }
+ }
+ testroot.getCanonicalFile
}
+ val TESTROOT = testRootFile.getAbsolutePath
CLASSPATH = CLASSPATH + File.pathSeparator + {
val libs = new File(TESTROOT, "files/lib")
@@ -49,19 +70,17 @@ else
def accept(dir: File, name: String) = name endsWith ".jar"
}) map {file => file.getCanonicalFile.getAbsolutePath}).mkString(""+File.pathSeparator)
}
- if (debug) {
- println("CLASSPATH (" + this + "):")
- println(CLASSPATH)
- }
def findLatest() {
+ val testParent = testRootFile.getParentFile
+
def prefixFile(relPath: String): File =
- (new File(PREFIX, relPath)).getCanonicalFile
+ (new File(testParent, relPath)).getCanonicalFile
- NestUI.verbose("PREFIX: "+PREFIX)
- val dists = new File(PREFIX, "dists")
- val build = new File(PREFIX, "build")
- val bin = new File(PREFIX, "bin")
+ NestUI.verbose("test parent: "+testParent)
+ val dists = new File(testParent, "dists")
+ val build = new File(testParent, "build")
+ val bin = new File(testParent, "bin")
if (dists.isDirectory) {
NestUI.verbose("Running on DISTRIBUTION")
diff --git a/src/partest/scala/tools/partest/nest/NestUI.scala b/src/partest/scala/tools/partest/nest/NestUI.scala
index 9204ac1112..fa235ed543 100644
--- a/src/partest/scala/tools/partest/nest/NestUI.scala
+++ b/src/partest/scala/tools/partest/nest/NestUI.scala
@@ -61,7 +61,7 @@ object NestUI {
def usage() {
println("Usage: NestRunner [<options>] [<testfile> ..] [<resfile>]")
- println("version Mar4")
+ println("version Mar13")
println(" --all run all tests")
println(" --pos next files test a compilation success")
println(" --neg next files test a compilation failure")