diff --git a/build.xml b/build.xml index 8d5492db2..3f4859ee1 100644 --- a/build.xml +++ b/build.xml @@ -655,6 +655,7 @@ BUILD QUICK-TEST LAYER + + + + + + I am SuperSABBUS for Scala core, the fast but simple version of SABBUS. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/compiler/scala/tools/ant/Same.scala b/src/compiler/scala/tools/ant/Same.scala new file mode 100644 index 000000000..78bc9ce5d --- /dev/null +++ b/src/compiler/scala/tools/ant/Same.scala @@ -0,0 +1,170 @@ +/* __ *\ +** ________ ___ / / ___ Scala Ant Tasks ** +** / __/ __// _ | / / / _ | (c) 2005-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id: ScalaTool.scala 11911 2007-06-05 15:57:59Z odersky $ + +package scala.tools.ant + +import java.io.{File, FileInputStream} + +import org.apache.tools.ant.{BuildException, Project} +import org.apache.tools.ant.taskdefs.MatchingTask +import org.apache.tools.ant.util.FileUtils +import org.apache.tools.ant.util.{FileNameMapper, IdentityMapper} + +import org.apache.tools.ant.types.Mapper + +/**

+ * An Ant task that, for a set of files, tests them for byte-to-byte + * equality with one or more other files. + * This task supports the following parameters as attributes: + *

    + *
  • dir
  • + *
  • todir
  • + *
  • resultproperty (a property to be set when all tested files pairs are equal, if not set, the task will fail instead),
  • + *
  • failing (whether to stop if all files are not equal).
+ *

It also support the following nested elements:

    + *
  • mapper (a mapper from original files to test files).
+ *

This task itself defines a fileset that represents the set of original files.

+ * + * @author Gilles Dubochet + * @version 1.0 */ +class Same extends MatchingTask { + + /** The unique Ant file utilities instance to use in this task. */ + private val fileUtils = FileUtils.newFileUtils() + +/*============================================================================*\ +** Ant user-properties ** +\*============================================================================*/ + + private var origin: Option[File] = None + private var destination: Option[File] = None + + private var resultProperty: Option[String] = None + private var failing: Boolean = false + + private var mapperElement: Option[Mapper] = None + +/*============================================================================*\ +** Properties setters ** +\*============================================================================*/ + + def setDir(input: File) = + origin = Some(input) + + def setTodir(input: File) = + destination = Some(input) + + def setResultproperty(input: String) = + resultProperty = Some(input) + + def setFailondifferent(input: Boolean) = + failing = input + + def createMapper(): Mapper = + if (mapperElement.isEmpty) { + val mapper = new Mapper(getProject) + mapperElement = Some(mapper) + mapper + } + else throw new BuildException("Cannot define more than one mapper", getLocation) + + def add(fileNameMapper: FileNameMapper) = + createMapper().add(fileNameMapper) + +/*============================================================================*\ +** Properties getters ** +\*============================================================================*/ + + private def getMapper: FileNameMapper = mapperElement match { + case None => + new IdentityMapper() + case Some(me) => + me.getImplementation + } + +/*============================================================================*\ +** Support methods ** +\*============================================================================*/ + + private var allEqualNow = true + + /** Tests if all mandatory attributes are set and valid. */ + private def validateAttributes = { + if (origin.isEmpty) error("Mandatory attribute 'dir' is not set.") + if (destination.isEmpty) error("Mandatory attribute 'todir' is not set.") + } + + private def reportDiff(f1: File, f2: File) = { + allEqualNow = false + log("File '" + f1 + "' is different from correspondant.") + } + + private def reportMissing(f1: File) = { + allEqualNow = false + log("File '" + f1 + "' has no correspondant.") + } + +/*============================================================================*\ +** The big execute method ** +\*============================================================================*/ + + override def execute() = { + validateAttributes + val mapper = getMapper + allEqualNow = true + val originNames: Array[String] = getDirectoryScanner(origin.get).getIncludedFiles + val bufferSize = 1024 + val originBuffer = new Array[Byte](bufferSize) + val destBuffer = new Array[Byte](bufferSize) + for ( + originName: String <- originNames; + destName: String <- mapper.mapFileName(originName.toString) + ) { + //println("originName="+originName) + //println("destName ="+destName) + var equalNow = true + val originFile = new File(origin.get, originName) + val destFile = new File(destination.get, destName) + if (originFile.canRead && destFile.canRead) { + val originStream = new FileInputStream(originFile) + val destStream = new FileInputStream(destFile) + var originRemaining = originStream.read(originBuffer) + var destRemaining = destStream.read(destBuffer) + while (originRemaining > 0 && equalNow) { + if (originRemaining == destRemaining) + for (idx <- 0 until originRemaining) + equalNow = equalNow && (originBuffer(idx) == destBuffer(idx)) + else + equalNow = false + originRemaining = originStream.read(originBuffer) + destRemaining = destStream.read(destBuffer) + } + if (destRemaining > 0) + equalNow = false + if (!equalNow) + reportDiff(originFile, destFile) + originStream.close + destStream.close + } + else reportMissing(originFile) + } + if (!allEqualNow) + if (failing) + error("There were differences between '" + origin.get + "' and '" + destination.get + "'") + else + log("There were differences between '" + origin.get + "' and '" + destination.get + "'") + else { + if (!resultProperty.isEmpty) + getProject.setProperty(resultProperty.get, "yes") + log("All files in '" + origin.get + "' and '" + destination.get + "' are equal", Project.MSG_VERBOSE) + } + } + +} diff --git a/src/compiler/scala/tools/ant/antlib.xml b/src/compiler/scala/tools/ant/antlib.xml index 2f8565e89..347ad2319 100644 --- a/src/compiler/scala/tools/ant/antlib.xml +++ b/src/compiler/scala/tools/ant/antlib.xml @@ -11,6 +11,10 @@ classname="scala.tools.ant.ScalaBazaar"/> + + diff --git a/src/compiler/scala/tools/ant/sabbus/Break.scala b/src/compiler/scala/tools/ant/sabbus/Break.scala new file mode 100644 index 000000000..7c6695838 --- /dev/null +++ b/src/compiler/scala/tools/ant/sabbus/Break.scala @@ -0,0 +1,26 @@ +/* __ *\ +** ________ ___ / / ___ Scala Ant Tasks ** +** / __/ __// _ | / / / _ | (c) 2005-2008, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +package scala.tools.ant.sabbus + +import org.apache.tools.ant.Task + +class Break extends Task { + + def setId(input: String): Unit = { + id = Some(input) + } + + private var id: Option[String] = None + + override def execute: Unit = { + if (id.isEmpty) error("Attribute 'id' is not set") + Compilers.break(id.get) + } + +} diff --git a/src/compiler/scala/tools/ant/sabbus/CompilationFailure.scala b/src/compiler/scala/tools/ant/sabbus/CompilationFailure.scala new file mode 100644 index 000000000..fc1fa0555 --- /dev/null +++ b/src/compiler/scala/tools/ant/sabbus/CompilationFailure.scala @@ -0,0 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala Ant Tasks ** +** / __/ __// _ | / / / _ | (c) 2005-2008, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +package scala.tools.ant.sabbus + +case class CompilationFailure(message: String, cause: Exception) extends Exception(message, cause) diff --git a/src/compiler/scala/tools/ant/sabbus/Compiler.scala b/src/compiler/scala/tools/ant/sabbus/Compiler.scala new file mode 100644 index 000000000..4a215449c --- /dev/null +++ b/src/compiler/scala/tools/ant/sabbus/Compiler.scala @@ -0,0 +1,46 @@ +/* __ *\ +** ________ ___ / / ___ Scala Ant Tasks ** +** / __/ __// _ | / / / _ | (c) 2005-2008, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +package scala.tools.ant.sabbus + +import java.io.File +import java.net.URL +import java.lang.reflect.InvocationTargetException + +class Compiler(classpath: Array[URL], val settings: CompilerSettings) { + + private lazy val classLoader: ClassLoader = + new java.net.URLClassLoader(classpath, null) + + private lazy val foreignCompilerName: String = + "scala.tools.ant.sabbus.ForeignCompiler" + private lazy val foreignCompiler: AnyRef = + classLoader.loadClass(foreignCompilerName).newInstance.asInstanceOf[AnyRef] + + foreignInvoke("args_$eq", Array(classOf[String]), Array(settings.toArgs)) + + private def foreignInvoke(method: String, types: Array[Class[T] forSome { type T }] , args: Array[AnyRef]) = + try { + foreignCompiler.getClass.getMethod(method, types).invoke(foreignCompiler, args) + } + catch { + case e: InvocationTargetException => throw e.getCause + } + + def compile(files: Array[File]): (Int, Int) = //(errors, warnings) + try { + val result = + foreignInvoke("compile", Array(classOf[Array[File]]), Array(files)).asInstanceOf[Int] + (result >> 16, result & 0x00FF) + } + catch { + case ex: Exception => + throw CompilationFailure(ex.getMessage, ex) + } + +} diff --git a/src/compiler/scala/tools/ant/sabbus/CompilerSettings.scala b/src/compiler/scala/tools/ant/sabbus/CompilerSettings.scala new file mode 100644 index 000000000..75f592d41 --- /dev/null +++ b/src/compiler/scala/tools/ant/sabbus/CompilerSettings.scala @@ -0,0 +1,90 @@ +/* __ *\ +** ________ ___ / / ___ Scala Ant Tasks ** +** / __/ __// _ | / / / _ | (c) 2005-2008, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +package scala.tools.ant.sabbus + +import java.io.File + +import org.apache.tools.ant.types.{Path, Reference} + +class CompilerSettings { + + private var gBf: Option[String] = None + def g = gBf.get + def g_=(s: String): this.type = { gBf = Some(s); this } + + private var uncheckedBf: Boolean = false + def unchecked = uncheckedBf + def unchecked_=(b: Boolean): this.type = { uncheckedBf = b; this } + + private var classpathBf: Option[Path] = None + def classpath = classpathBf.get + def classpath_=(p: Path): this.type = { classpathBf = Some(p); this } + + private var sourcepathBf: Option[Path] = None + def sourcepath = sourcepathBf.get + def sourcepath_=(p: Path): this.type = { sourcepathBf = Some(p); this } + + private var bootclasspathBf: Option[Path] = None + def bootclasspath = bootclasspathBf.get + def bootclasspath_=(p: Path): this.type = { bootclasspathBf = Some(p); this } + + private var extdirsBf: Option[Path] = None + def extdirs = extdirsBf.get + def extdirs_=(p: Path): this.type = { extdirsBf = Some(p); this } + + private var dBf: Option[File] = None + def d = dBf.get + def d_=(f: File): this.type = { dBf = Some(f); this } + + private var encodingBf: Option[String] = None + def encoding = encodingBf.get + def encoding_=(s: String): this.type = { encodingBf = Some(s); this } + + private var targetBf: Option[String] = None + def target = targetBf.get + def target_=(s: String): this.type = { targetBf = Some(s); this } + + private var optimiseBf: Boolean = false + def optimise = optimiseBf + def optimise_=(b: Boolean): Unit = { optimiseBf = b } + + private var moreBf: Option[String] = None + def more = moreBf.get + def more_=(s: String): this.type = { moreBf = Some(s); this } + + def toArgs: String = ("" + + (if (!gBf.isEmpty) "-g:" + g + " " else "") + + (if (uncheckedBf) "-unchecked " else "") + + (if (!classpathBf.isEmpty) "-classpath " + classpath + " " else "") + + (if (!sourcepathBf.isEmpty) "-sourcepath " + sourcepath + " " else "") + + (if (!bootclasspathBf.isEmpty) "-bootclasspath " + bootclasspath + " " else "") + + (if (!extdirsBf.isEmpty) "-extdirs " + extdirs + " " else "") + + (if (!dBf.isEmpty) "-d " + d + " " else "") + + (if (!encodingBf.isEmpty) "-encoding " + encoding + " " else "") + + (if (!targetBf.isEmpty) "-target:" + target + " " else "") + + (if (optimiseBf) "-optimise " else "") + + (if (!moreBf.isEmpty) more else "") + ) + + override def equals(that: Any): Boolean = that match { + case cs: CompilerSettings => + this.gBf == cs.gBf && + this.uncheckedBf == cs.uncheckedBf && + this.classpathBf == cs.classpathBf && + this.sourcepathBf == cs.sourcepathBf && + this.bootclasspathBf == cs.bootclasspathBf && + this.extdirsBf == cs.extdirsBf && + this.dBf == cs.dBf && + this.encodingBf == cs.encodingBf && + this.targetBf == cs.targetBf && + this.optimiseBf == cs.optimiseBf && + this.moreBf == cs.moreBf + } + +} diff --git a/src/compiler/scala/tools/ant/sabbus/CompilerTest.scala b/src/compiler/scala/tools/ant/sabbus/CompilerTest.scala new file mode 100644 index 000000000..5accdafe9 --- /dev/null +++ b/src/compiler/scala/tools/ant/sabbus/CompilerTest.scala @@ -0,0 +1,47 @@ +/* __ *\ +** ________ ___ / / ___ Scala Ant Tasks ** +** / __/ __// _ | / / / _ | (c) 2005-2008, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +package scala.tools.ant.sabbus + +import java.io.File +import java.net.URL + +object CompilerTest { + + def main(args: Array[String]): Unit = { + + implicit def fileToURL(file: File): URL = file.toURL + + val scalalib = new File("/Developer/Scala/latest/lib") + val sabbus = new File("/Users/Dubochet/Documents/Eclipse/FaSabbus") + + val classpath: Array[URL] = Array ( + new File(scalalib, "scala-library.jar"), + new File(scalalib, "scala-compiler.jar"), + new File(sabbus, "bin") + ) + + val settings = new CompilerSettings + settings.d = new File("/Users/Dubochet/Documents/Eclipse/FaSabbus/bin_sabbus") + val compiler = new Compiler(classpath, settings) + + val files: Array[File] = Array ( + new File(sabbus, "src/scala/tools/ant/sabbus/CompilationFailure.scala"), + new File(sabbus, "src/scala/tools/ant/sabbus/Compiler.scala"), + new File(sabbus, "src/scala/tools/ant/sabbus/CompilerTest.scala"), + new File(sabbus, "src/scala/tools/ant/sabbus/ForeignCompiler.scala") + ) + + if (compiler.compile(files)._1 == 0) + println("Everything a-okey, sir!") + else + println("We had some issues, sir!") + + } + +} diff --git a/src/compiler/scala/tools/ant/sabbus/Compilers.scala b/src/compiler/scala/tools/ant/sabbus/Compilers.scala new file mode 100644 index 000000000..b2844c3db --- /dev/null +++ b/src/compiler/scala/tools/ant/sabbus/Compilers.scala @@ -0,0 +1,45 @@ +/* __ *\ +** ________ ___ / / ___ Scala Ant Tasks ** +** / __/ __// _ | / / / _ | (c) 2005-2008, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +package scala.tools.ant.sabbus + +import java.net.URL + +object Compilers extends collection.Map[String, Compiler] { + + val debug = false + + private val container = new collection.mutable.HashMap[String, Compiler] + + def elements = container.elements + + def get(id: String) = container.get(id) + + def size = container.size + + def make(id: String, classpath: Array[URL], settings: CompilerSettings): Compiler = { + val runtime = Runtime.getRuntime + if (debug) println("Making compiler " + id) + if (debug) println(" memory before: " + (runtime.freeMemory/1048576.).formatted("%10.2f") + " MB") + val comp = new Compiler(classpath, settings) + container += Pair(id, comp) + if (debug) println(" memory after: " + (runtime.freeMemory/1048576.).formatted("%10.2f") + " MB") + comp + } + + def break(id: String): Null = { + val runtime = Runtime.getRuntime + if (debug) println("Breaking compiler " + id) + if (debug) println(" memory before: " + (runtime.freeMemory/1048576.).formatted("%10.2f") + " MB") + container -= id + System.gc + if (debug) println(" memory after: " + (runtime.freeMemory/1048576.).formatted("%10.2f") + " MB") + null + } + +} diff --git a/src/compiler/scala/tools/ant/sabbus/ForeignCompiler.scala b/src/compiler/scala/tools/ant/sabbus/ForeignCompiler.scala new file mode 100644 index 000000000..61735eac8 --- /dev/null +++ b/src/compiler/scala/tools/ant/sabbus/ForeignCompiler.scala @@ -0,0 +1,49 @@ +/* __ *\ +** ________ ___ / / ___ Scala Ant Tasks ** +** / __/ __// _ | / / / _ | (c) 2005-2008, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +package scala.tools.ant.sabbus + +import java.io.File + +import scala.tools.nsc._ +import scala.tools.nsc.reporters.ConsoleReporter + +class ForeignCompiler { + + private var argsBuffer: String = null + def args: String = argsBuffer + def args_=(a: String): Unit = { + if (args != null) throw new Error("Argument must be set only once") + argsBuffer = a + nsc + } + + private val error: (String => Nothing) = { msg => throw new Exception(msg) } + + private def settings = new Settings(error) + + private lazy val reporter = new ConsoleReporter(settings) + + private lazy val nsc: Global = { + try { + val command = new CompilerCommand(List.fromString(args, ' '), settings, error, false) + new Global(command.settings, reporter) + } + catch { + case ex @ FatalError(msg) => + throw new Exception(msg, ex) + } + } + + def compile(files: Array[File]): Int = { + val command = new CompilerCommand(files.toList.map(_.toString), settings, error, true) + (new nsc.Run) compile command.files + reporter.ERROR.count << 16 | reporter.WARNING.count + } + +} diff --git a/src/compiler/scala/tools/ant/sabbus/Make.scala b/src/compiler/scala/tools/ant/sabbus/Make.scala new file mode 100644 index 000000000..8639fd18c --- /dev/null +++ b/src/compiler/scala/tools/ant/sabbus/Make.scala @@ -0,0 +1,94 @@ +/* __ *\ +** ________ ___ / / ___ Scala Ant Tasks ** +** / __/ __// _ | / / / _ | (c) 2005-2008, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +package scala.tools.ant.sabbus + +import java.net.URL +import java.io.File +import org.apache.tools.ant.Task +import org.apache.tools.ant.types.{Path, Reference} + +class Make extends Task { + + def setId(input: String): Unit = { + id = Some(input) + } + + def setParams(input: String): Unit = { + params = params match { + case None => Some(input) + case Some(ps) => Some(ps + " " + input) + } + } + + def setCompilationPath(input: Path): Unit = { + if (compilationPath.isEmpty) compilationPath = Some(input) + else compilationPath.get.append(input) + } + + def createCompilationPath: Path = { + if (compilationPath.isEmpty) compilationPath = Some(new Path(getProject())) + compilationPath.get.createPath() + } + + def setCompilationPathRef(input: Reference): Unit = { + createCompilationPath.setRefid(input) + } + + def setSrcPath(input: Path): Unit = { + if (sourcePath.isEmpty) sourcePath = Some(input) + else sourcePath.get.append(input) + } + + def createSrcPath: Path = { + if (sourcePath.isEmpty) sourcePath = Some(new Path(getProject())) + sourcePath.get.createPath() + } + + def setSrcPathRef(input: Reference): Unit = { + createSrcPath.setRefid(input) + } + + def setCompilerPath(input: Path): Unit = { + if (compilerPath.isEmpty) compilerPath = Some(input) + else compilerPath.get.append(input) + } + + def createCompilerPath: Path = { + if (compilerPath.isEmpty) compilerPath = Some(new Path(getProject())) + compilerPath.get.createPath() + } + + def setCompilerPathRef(input: Reference): Unit = { + createCompilerPath.setRefid(input) + } + + def setDestdir(input: File): Unit = { + destinationDir = Some(input) + } + + private var id: Option[String] = None + private var params: Option[String] = None + private var compilationPath: Option[Path] = None + private var sourcePath: Option[Path] = None + private var compilerPath: Option[Path] = None + private var destinationDir: Option[File] = None + + override def execute: Unit = { + if (id.isEmpty) error("Mandatory attribute 'id' is not set.") + if (compilerPath.isEmpty) error("Mandatory attribute 'compilerpath' is not set.") + if (destinationDir.isEmpty) error("Mandatory attribute 'destdir' is not set.") + val settings = new CompilerSettings + if (!destinationDir.isEmpty) settings.d = destinationDir.get + if (!compilationPath.isEmpty) settings.classpath = compilationPath.get + if (!sourcePath.isEmpty) settings.sourcepath = sourcePath.get + if (!params.isEmpty) settings.more = params.get + Compilers.make(id.get, (compilerPath.get.list.map{ path => new File(path).toURL }), settings) + } + +} diff --git a/src/compiler/scala/tools/ant/sabbus/Use.scala b/src/compiler/scala/tools/ant/sabbus/Use.scala new file mode 100644 index 000000000..6daf9b82b --- /dev/null +++ b/src/compiler/scala/tools/ant/sabbus/Use.scala @@ -0,0 +1,69 @@ +/* __ *\ +** ________ ___ / / ___ Scala Ant Tasks ** +** / __/ __// _ | / / / _ | (c) 2005-2008, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +package scala.tools.ant.sabbus + +import java.io.File + +import org.apache.tools.ant.taskdefs.MatchingTask +import org.apache.tools.ant.types.{Path, Reference} +import org.apache.tools.ant.util.{GlobPatternMapper, SourceFileScanner} + +class Use extends MatchingTask { + + def setId(input: String): Unit = { + id = Some(input) + } + + def setSrcdir(input: File) { + sourceDir = Some(input) + } + + def setFailOnError(input: Boolean): Unit = { + failOnError = input + } + + private var id: Option[String] = None + private var sourceDir: Option[File] = None + private var failOnError: Boolean = true + + override def execute(): Unit = { + if (id.isEmpty) error("Mandatory attribute 'id' is not set.") + if (sourceDir.isEmpty) error("Mandatory attribute 'srcdir' is not set.") + val compiler = Compilers(id.get) + val mapper = new GlobPatternMapper() + mapper.setTo("*.class") + mapper.setFrom("*.scala") + val includedFiles: Array[File] = + new SourceFileScanner(this).restrict( + getDirectoryScanner(sourceDir.get).getIncludedFiles, + sourceDir.get, + compiler.settings.d, + mapper + ) map (new File(sourceDir.get, _)) + if (includedFiles.size > 0) + try { + log("Compiling " + includedFiles.size + " file" + (if (includedFiles.size > 1) "s" else "") + " to " + compiler.settings.d.getAbsolutePath) + //for (f <- includedFiles) log(" " + f.getAbsolutePath) + //log("Attributes are " + compiler.settings.toArgs) + val (errors, warnings) = compiler.compile(includedFiles) + if (errors > 0) + error("Compilation failed with " + errors + " error" + (if (errors > 1) "s" else "") + ".") + else if (warnings > 0) + log("Compilation suceeded with " + warnings + " warning" + (if (warnings > 1) "s" else "") + ".") + } + catch { + case CompilationFailure(msg, ex) => + ex.printStackTrace + val errorMsg = + "Compilation failed because of an internal compiler error (" + msg + "); see the error output for details." + if (failOnError) error(errorMsg) else log(errorMsg) + } + } + +} diff --git a/src/compiler/scala/tools/ant/sabbus/antlib.xml b/src/compiler/scala/tools/ant/sabbus/antlib.xml new file mode 100644 index 000000000..3388ee00f --- /dev/null +++ b/src/compiler/scala/tools/ant/sabbus/antlib.xml @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/src/partest/scala/tools/partest/PartestTask.scala b/src/partest/scala/tools/partest/PartestTask.scala new file mode 100644 index 000000000..99f5a6a21 --- /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 000000000..b3b98e853 --- /dev/null +++ b/src/partest/scala/tools/partest/antlib.xml @@ -0,0 +1,4 @@ + + + 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 000000000..c54398937 --- /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 23e9f81fb..daee61c34 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 000000000..3b3784569 --- /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 000000000..2c76d311a --- /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 cdfc81477..a3d7f27be 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()) - } - - 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") +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 - NestUI.failure(failures+" of "+total+" tests failed (elapsed time: "+dispElapsed+")\n") - - if (failures == errors) - System.exit(0) - else - System.exit(1) + worker ! RunTests(kind, toTest) + worker } - } - - 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) - - //val worker = new Worker - //worker.runTests(kind, kindFiles) - } else { - NestUI.failure("test dir empty") - (0, 0) + 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 } - } else (0, 0) + } + logsToDelete.foreach { log => + NestUI.verbose("deleting "+log+"\n") + fileManager.deleteRecursive(log) + } + outdirsToDelete.foreach { outdir => + NestUI.verbose("deleting "+outdir+"\n") + fileManager.deleteRecursive(outdir) + } + + (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 0e7aa43d9..f9f5df43c 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) { @@ -170,7 +18,7 @@ elif [ -d "$PREFIX/bin" ]; then } dir.delete } - + /** * Compares two files using a Java implementation of the GNU diff * available at http://www.bmsi.com/java/#diff. @@ -194,32 +42,15 @@ elif [ -d "$PREFIX/bin" ]; then } res } -} - -class FileManager { - - 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(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 - } - } - - def getFiles(kind: String, doCheck: Boolean): List[File] = - getFiles(kind, doCheck, ".scala") + + + var JAVACMD: String + + var CLASSPATH: String + var LATEST_LIB: String + + var showDiff = false + var showLog = false + var failed = false + } diff --git a/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala b/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala index 228eb7ff6..6892306f2 100644 --- a/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala +++ b/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala @@ -18,8 +18,10 @@ class ReflectiveRunner { // we might also use FileManager.CLASSPATH // to use the same classes as used by `scala` that // was used to start the runner. + + val fileManager = new ConsoleFileManager - import FileManager.{latestCompFile, latestLibFile, latestActFile, + 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 102e23191..7edfa4dab 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 NegTestFile(override val file: File) extends TestFile("neg", file) - -case class RunTestFile(override val file: File) extends TestFile("run", file) { - override def defineSettings(settings: Settings) { - baseSettings(settings) - } -} - -case class JvmTestFile(override val file: File) extends TestFile("jvm", file) { - import FileManager.{CLASSPATH, EXT_CLASSPATH, PATH_SEP} +case class PosTestFile(override val file: File, override val fileManager: FileManager) extends TestFile("pos", 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 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+PATH_SEP+EXT_CLASSPATH + settings.classpath.value = CLASSPATH + //println("settings.classpath.value="+settings.classpath.value) + } +} + +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, override val fileManager: FileManager) extends TestFile("jvm", 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 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 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 bb06a8e3b..5f27f923f 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 @@ -213,7 +210,7 @@ class Worker extends Actor { success = false } else { // -------- run test -------- - + //TODO: detect whether we have to use Runtime.exec val useRuntime = 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)