summaryrefslogtreecommitdiff
path: root/src/partest
diff options
context:
space:
mode:
authorHubert Plociniczak <hubert.plociniczak@epfl.ch>2011-10-31 23:41:27 +0000
committerHubert Plociniczak <hubert.plociniczak@epfl.ch>2011-10-31 23:41:27 +0000
commit07c3e9c8c6de0b185ba19e493b5b029645c79333 (patch)
treec57e4b00262a86e9c1c5723f5c3f2eb977d36c0a /src/partest
parent0ba09556cde0ad7758b3cb75c462d53854aeb2f3 (diff)
downloadscala-07c3e9c8c6de0b185ba19e493b5b029645c79333.tar.gz
scala-07c3e9c8c6de0b185ba19e493b5b029645c79333.tar.bz2
scala-07c3e9c8c6de0b185ba19e493b5b029645c79333.zip
Revert r25648 by michelou, it brakes partest
Diffstat (limited to 'src/partest')
-rw-r--r--src/partest/scala/tools/partest/PartestTask.scala134
-rw-r--r--src/partest/scala/tools/partest/nest/CompileManager.scala4
-rw-r--r--src/partest/scala/tools/partest/nest/ConsoleFileManager.scala12
-rw-r--r--src/partest/scala/tools/partest/nest/DirectRunner.scala6
4 files changed, 51 insertions, 105 deletions
diff --git a/src/partest/scala/tools/partest/PartestTask.scala b/src/partest/scala/tools/partest/PartestTask.scala
index 10f5a37a8f..1a75621d4d 100644
--- a/src/partest/scala/tools/partest/PartestTask.scala
+++ b/src/partest/scala/tools/partest/PartestTask.scala
@@ -6,56 +6,24 @@
** |/ **
\* */
+// $Id$
+
package scala.tools
package partest
import scala.actors.Actor._
import scala.util.Properties.setProp
-
-import ant.sabbus.CompilationPathProperty
-import nsc.io.{ Directory, Path => SPath }
+import scala.tools.nsc.io.{ Directory, Path => SPath }
import nsc.util.ClassPath
import util.PathResolver
+import scala.tools.ant.sabbus.CompilationPathProperty
import java.io.File
import java.lang.reflect.Method
-import org.apache.tools.ant.{BuildException, Task}
+import org.apache.tools.ant.Task
import org.apache.tools.ant.types.{Path, Reference, FileSet}
-/** An Ant task to execute the Scala test suite (NSC).
- *
- * This task can take the following parameters as attributes:
- * - `srcdir`,
- * - `classpath`,
- * - `classpathref`,
- * - `showlog`,
- * - `showdiff`,
- * - `erroronfailed`,
- * - `javacmd`,
- * - `javaccmd`,
- * - `scalacopts`,
- * - `timeout`,
- * - `debug`,
- * - `junitreportdir`.
- *
- * It also takes the following parameters as nested elements:
- * - `compilationpath`.
- * - `postests`,
- * - `negtests`,
- * - `runtests`,
- * - `jvmtests`,
- * - `residenttests`,
- * - `buildmanagertests`,
- * - `shootouttests`,
- * - `scalaptests`,
- * - `scalachecktests`,
- * - `specializedtests`,
- * - `presentationtests`,
- * - `scripttests`.
- *
- * @author Philippe Haller
- */
class PartestTask extends Task with CompilationPathProperty {
def addConfiguredPosTests(input: FileSet) {
@@ -106,18 +74,11 @@ class PartestTask extends Task with CompilationPathProperty {
presentationFiles = Some(input)
}
-/*============================================================================*\
-** Properties setters **
-\*============================================================================*/
- /** Sets the `srcdir` attribute. Used by [[http://ant.apache.org Ant]].
- * @param input The value of `srcdir`. */
def setSrcDir(input: String) {
srcDir = Some(input)
}
- /** Sets the `classpath` attribute. Used by [[http://ant.apache.org Ant]].
- * @param input The value of `classpath`. */
def setClasspath(input: Path) {
if (classpath.isEmpty)
classpath = Some(input)
@@ -130,67 +91,46 @@ class PartestTask extends Task with CompilationPathProperty {
classpath.get.createPath()
}
- /** Sets the `classpathref` attribute. Used by [[http://ant.apache.org Ant]].
- * @param input The value of `classpathref`. */
def setClasspathref(input: Reference) {
createClasspath().setRefid(input)
}
- /** Sets the `showlog` attribute. Used by [[http://ant.apache.org Ant]].
- * @param input The value of `showlog`. */
def setShowLog(input: Boolean) {
showLog = input
}
- /** Sets the `showdiff` attribute. Used by [[http://ant.apache.org Ant]].
- * @param input The value of `showdiff`. */
def setShowDiff(input: Boolean) {
showDiff = input
}
- /** Sets the `erroronfailed` attribute. Used by [[http://ant.apache.org Ant]].
- * @param input The value of `erroronfailed`. */
def setErrorOnFailed(input: Boolean) {
errorOnFailed = input
}
- /** Sets the `javacmd` attribute. Used by [[http://ant.apache.org Ant]].
- * @param input The value of `javacmd`. */
def setJavaCmd(input: File) {
javacmd = Some(input)
}
- /** Sets the `javaccmd` attribute. Used by [[http://ant.apache.org Ant]].
- * @param input The value of `javaccmd`. */
def setJavacCmd(input: File) {
javaccmd = Some(input)
}
- /** Sets the `scalacopts` attribute. Used by [[http://ant.apache.org Ant]].
- * @param input The value of `scalacopts`. */
def setScalacOpts(opts: String) {
scalacOpts = Some(opts)
}
- /** Sets the `timeout` attribute. Used by [[http://ant.apache.org Ant]].
- * @param input The value of `timeout`. */
def setTimeout(delay: String) {
timeout = Some(delay)
}
- /** Sets the `debug` attribute. Used by [[http://ant.apache.org Ant]].
- * @param input The value of `debug`. */
def setDebug(input: Boolean) {
debug = input
}
- /** Sets the `junitreportdir` attribute. Used by [[http://ant.apache.org Ant]].
- * @param input The value of `junitreportdir`. */
def setJUnitReportDir(input: File) {
jUnitReportDir = Some(input)
}
- /** The class path to use for this compilation. */
private var classpath: Option[Path] = None
private var srcDir: Option[String] = None
private var javacmd: Option[File] = None
@@ -216,37 +156,43 @@ class PartestTask extends Task with CompilationPathProperty {
private var jUnitReportDir: Option[File] = None
private var debug = false
- private def fileSetToDir(fs: FileSet) = Directory(fs getDir getProject)
+ def fileSetToDir(fs: FileSet) = Directory(fs getDir getProject)
+ def fileSetToArray(fs: FileSet): Array[SPath] = {
+ val root = fileSetToDir(fs)
+ (fs getDirectoryScanner getProject).getIncludedFiles map (root / _)
+ }
private def getFiles(fileSet: Option[FileSet]): Array[File] = fileSet match {
- case None =>
- Array()
- case Some(fs) =>
- val sFiles: Array[SPath] = {
- val root = fileSetToDir(fs)
- (fs getDirectoryScanner getProject).getIncludedFiles map (root / _)
- }
- def shouldExclude(p: SPath) = (p hasExtension "log") || (p.name startsWith ".")
- sFiles filterNot (shouldExclude(_)) map (_.jfile)
+ case None => Array()
+ case Some(fs) => fileSetToArray(fs) filterNot (_ hasExtension "log") map (_.jfile)
}
- private def getDirs(fileSet: Option[FileSet]): Array[File] = fileSet match {
- case None =>
- Array()
+ private def getFilesAndDirs(fileSet: Option[FileSet]): Array[File] = fileSet match {
+ case None => Array()
case Some(fs) =>
- val sDirectories: Array[SPath] = {
- val root = fileSetToDir(fs)
- (fs getDirectoryScanner getProject).getIncludedDirectories map (root / _)
- }
- def shouldExclude(p: SPath) = (p hasExtension "obj") || (p.name startsWith ".")
- sDirectories filterNot (shouldExclude(_)) map (_.jfile)
+ def shouldExclude(name: String) = (name endsWith ".obj") || (name startsWith ".")
+ // println("----> " + fileSet)
+
+ val fileTests = getFiles(Some(fs)) filterNot (x => shouldExclude(x.getName))
+ val dirResult = getDirs(Some(fs)) filterNot (x => shouldExclude(x.getName))
+ // println("dirs: " + dirResult.toList)
+ // println("files: " + fileTests.toList)
+
+ dirResult ++ fileTests
}
- private def getFilesAndDirs(fileSet: Option[FileSet]): Array[File] = fileSet match {
+ private def getDirs(fileSet: Option[FileSet]): Array[File] = fileSet match {
case None => Array()
- case Some(fs) => getFiles(fileSet) ++ getDirs(fileSet)
+ case Some(fs) =>
+ def shouldExclude(name: String) = (name endsWith ".obj") || (name startsWith ".")
+
+ val dirTests: Iterator[SPath] = fileSetToDir(fs).dirs filterNot (x => shouldExclude(x.name))
+ val dirResult = dirTests.toList.toArray map (_.jfile)
+
+ dirResult
}
+
private def getPosFiles = getFilesAndDirs(posFiles)
private def getNegFiles = getFilesAndDirs(negFiles)
private def getRunFiles = getFilesAndDirs(runFiles)
@@ -260,20 +206,12 @@ class PartestTask extends Task with CompilationPathProperty {
private def getSpecializedFiles = getFiles(specializedFiles)
private def getPresentationFiles = getDirs(presentationFiles)
- protected def initialize() {
+ override def execute() {
if (isPartestDebug || debug) {
setProp("partest.debug", "true")
nest.NestUI._verbose = true
}
- // Tests if all mandatory attributes are set and valid.
- //if (srcDir.isEmpty)
- // throw new BuildException("Attribute 'srcdir' is not set.", getLocation)
- }
-
- override def execute() {
- initialize()
-
srcDir foreach (x => setProp("partest.srcdir", x))
val classpath = this.compilationPath getOrElse sys.error("Mandatory attribute 'compilationPath' is not set.")
@@ -327,13 +265,13 @@ class PartestTask extends Task with CompilationPathProperty {
val (succs, fails) = resultsToStatistics(results)
val failed: Iterable[String] = results collect {
- case (path, 1) => path + " [FAILED]"
- case (path, 2) => path + " [TIMOUT]"
+ case (path, 1) => path + " [FAILED]"
+ case (path, 2) => path + " [TIMOUT]"
}
// create JUnit Report xml files if directory was specified
jUnitReportDir foreach { d =>
- d.mkdir()
+ d.mkdir
val report = testReport(name, results, succs, fails)
scala.xml.XML.save(d.getAbsolutePath+"/"+name+".xml", report)
diff --git a/src/partest/scala/tools/partest/nest/CompileManager.scala b/src/partest/scala/tools/partest/nest/CompileManager.scala
index 0e58a42c9b..1b7e5cfff6 100644
--- a/src/partest/scala/tools/partest/nest/CompileManager.scala
+++ b/src/partest/scala/tools/partest/nest/CompileManager.scala
@@ -3,6 +3,8 @@
* @author Philipp Haller
*/
+// $Id$
+
package scala.tools.partest
package nest
@@ -106,7 +108,7 @@ class DirectCompiler(val fileManager: FileManager) extends SimpleCompiler {
val toCompile = files map (_.getPath)
try {
- NestUI.verbose("compiling "+toCompile.mkString(" "))
+ NestUI.verbose("compiling "+toCompile)
try new global.Run compile toCompile
catch {
case FatalError(msg) =>
diff --git a/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala b/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala
index 05ea89bfea..e2e4ba648e 100644
--- a/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala
+++ b/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala
@@ -3,6 +3,8 @@
* @author Philipp Haller
*/
+// $Id$
+
package scala.tools.partest
package nest
@@ -13,10 +15,12 @@ import scala.tools.util.PathResolver
import scala.tools.nsc.{ io, util }
import util.{ ClassPath }
import io.{ Path, Directory }
+import File.pathSeparator
import ClassPath.{ join }
import PathResolver.{ Environment, Defaults }
import RunnerUtils._
+
class ConsoleFileManager extends FileManager {
var testBuild: Option[String] = PartestDefaults.testBuild
def testBuildFile = testBuild map (testParent / _)
@@ -52,6 +56,9 @@ class ConsoleFileManager extends FileManager {
var JAVACMD = PartestDefaults.javaCmd
var JAVAC_CMD = PartestDefaults.javacCmd
+
+ NestUI.verbose("CLASSPATH: "+CLASSPATH)
+
if (!srcDir.isDirectory) {
NestUI.failure("Source directory \"" + srcDir.path + "\" not found")
sys.exit(1)
@@ -61,9 +68,8 @@ class ConsoleFileManager extends FileManager {
val libs = (srcDir / Directory("lib")).files filter (_ hasExtension "jar") map (_.toCanonical.path)
// add all jars in libs
- (CLASSPATH :: libs.toList) mkString File.pathSeparator
+ (CLASSPATH :: libs.toList) mkString pathSeparator
}
- NestUI.verbose("CLASSPATH: "+CLASSPATH)
def findLatest() {
NestUI.verbose("test parent: "+testParent)
@@ -160,8 +166,6 @@ class ConsoleFileManager extends FileManager {
var latestCompFile: File = _
var latestPartestFile: File = _
var latestFjbgFile: File = _
- // NB. Needed by partest when actors library is put in separate jar file.
- def latestActorsFile: File = (latestLibFile.parent / "scala-actors.jar").jfile
def latestScalapFile: File = (latestLibFile.parent / "scalap.jar").jfile
var testClassesDir: Directory = _
// initialize above fields
diff --git a/src/partest/scala/tools/partest/nest/DirectRunner.scala b/src/partest/scala/tools/partest/nest/DirectRunner.scala
index e4a03b71c9..4246fce4c4 100644
--- a/src/partest/scala/tools/partest/nest/DirectRunner.scala
+++ b/src/partest/scala/tools/partest/nest/DirectRunner.scala
@@ -3,6 +3,8 @@
* @author Philipp Haller
*/
+// $Id$
+
package scala.tools.partest
package nest
@@ -52,10 +54,10 @@ trait DirectRunner {
val groupSize = (kindFiles.length / numActors) + 1
val consFM = new ConsoleFileManager
- import consFM.{ latestCompFile, latestLibFile, latestActorsFile, latestPartestFile }
+ import consFM.{ latestCompFile, latestLibFile, latestPartestFile }
val scalacheckURL = PathSettings.scalaCheck.toURL
val scalaCheckParentClassLoader = ScalaClassLoader.fromURLs(
- List(scalacheckURL, latestCompFile.toURI.toURL, latestLibFile.toURI.toURL, latestActorsFile.toURI.toURL, latestPartestFile.toURI.toURL)
+ List(scalacheckURL, latestCompFile.toURI.toURL, latestLibFile.toURI.toURL, latestPartestFile.toURI.toURL)
)
Output.init()