summaryrefslogtreecommitdiff
path: root/src/partest
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2010-03-08 18:46:35 +0000
committerPaul Phillips <paulp@improving.org>2010-03-08 18:46:35 +0000
commitfa34ce4700548a8d913d8aef71e8c86f668e498f (patch)
treea55cce5f90f35d6eda60498e3f0a9f28cadeb14f /src/partest
parent5f7ddb20ab2e3729f30f6b1ee432a078a1a09899 (diff)
downloadscala-fa34ce4700548a8d913d8aef71e8c86f668e498f.tar.gz
scala-fa34ce4700548a8d913d8aef71e8c86f668e498f.tar.bz2
scala-fa34ce4700548a8d913d8aef71e8c86f668e498f.zip
Changed partest ant task not to use reflection,...
Changed partest ant task not to use reflection, instead using the path with which scala was invoked. No review.
Diffstat (limited to 'src/partest')
-rw-r--r--src/partest/scala/tools/partest/PartestTask.scala58
1 files changed, 15 insertions, 43 deletions
diff --git a/src/partest/scala/tools/partest/PartestTask.scala b/src/partest/scala/tools/partest/PartestTask.scala
index 757a53813d..4546b58541 100644
--- a/src/partest/scala/tools/partest/PartestTask.scala
+++ b/src/partest/scala/tools/partest/PartestTask.scala
@@ -18,6 +18,7 @@ import io.{ Directory }
import nsc.Settings
import nsc.util.ClassPath
import util.PathResolver
+import scala.tools.ant.sabbus.CompilationPathProperty
import java.io.File
import java.net.URLClassLoader
@@ -26,7 +27,7 @@ import java.lang.reflect.Method
import org.apache.tools.ant.Task
import org.apache.tools.ant.types.{Path, Reference, FileSet}
-class PartestTask extends Task {
+class PartestTask extends Task with CompilationPathProperty {
def addConfiguredPosTests(input: FileSet) {
posFiles = Some(input)
@@ -174,23 +175,11 @@ class PartestTask extends Task {
private def getShootoutFiles = getFiles(shootoutFiles)
private def getScalapFiles = getFiles(scalapFiles)
- private def findMethod(target: AnyRef, name: String, types: Class[_]*): Method =
- target.getClass.getMethod(name, Array(types: _*): _*)
-
- private def invokeMethod[T](target: AnyRef, m: Method, args: AnyRef*): T =
- m.invoke(target, args: _*).asInstanceOf[T]
-
- private def invoke[T](target: AnyRef, name: String, args: Any*): T = {
- val boxed = args map (_.asInstanceOf[AnyRef])
- val m = findMethod(target, name, boxed map (_.getClass): _*)
- invokeMethod[T](target, m, boxed: _*)
- }
-
override def execute() {
if (isPartestDebug)
setProp("partest.debug", "true")
- val classpath = this.classpath getOrElse error("Mandatory attribute 'classpath' is not set.")
+ val classpath = this.compilationPath getOrElse error("Mandatory attribute 'compilationPath' is not set.")
val scalaLibrary = {
(classpath.list map { fs => new File(fs) }) find { f =>
@@ -202,36 +191,19 @@ class PartestTask extends Task {
}
} getOrElse error("Provided classpath does not contain a Scala library.")
- val classloader = this.getClass.getClassLoader
- def load(name: String) = classloader.loadClass(name).newInstance().asInstanceOf[AnyRef]
-
- val antRunner = load("scala.tools.partest.nest.AntRunner")
- val antFileManager = invoke[AnyRef](antRunner, "fileManager")
- val runMethod = findMethod(antRunner, "reflectiveRunTestsForFiles", classOf[Array[File]], classOf[String])
-
- def runTestsForFiles(kindFiles: Array[File], kind: String) =
- invokeMethod[Map[String, Int]](antRunner, runMethod, kindFiles, kind)
-
- def setFileManagerBooleanProperty(name: String, value: Boolean) {
- val setMethod = findMethod(antFileManager, name + "_$eq", classOf[Boolean])
- invokeMethod[Unit](antFileManager, setMethod, Boolean.box(value))
- }
-
- def setFileManagerStringProperty(name: String, value: String) {
- val setMethod = findMethod(antFileManager, name + "_$eq", classOf[String])
- invokeMethod[Unit](antFileManager, setMethod, value)
- }
+ val antRunner = new scala.tools.partest.nest.AntRunner
+ val antFileManager = antRunner.fileManager
- setFileManagerBooleanProperty("showDiff", showDiff)
- setFileManagerBooleanProperty("showLog", showLog)
- setFileManagerBooleanProperty("failed", runFailed)
- setFileManagerStringProperty("CLASSPATH", ClassPath.join(classpath.list: _*))
- setFileManagerStringProperty("LATEST_LIB", scalaLibrary.getAbsolutePath)
+ antFileManager.showDiff = showDiff
+ antFileManager.showLog = showLog
+ antFileManager.failed = runFailed
+ antFileManager.CLASSPATH = ClassPath.join(classpath.list: _*)
+ antFileManager.LATEST_LIB = scalaLibrary.getAbsolutePath
- javacmd foreach (x => setFileManagerStringProperty("JAVACMD", x.getAbsolutePath))
- javaccmd foreach (x => setFileManagerStringProperty("JAVAC_CMD", x.getAbsolutePath))
- scalacOpts foreach (x => setFileManagerStringProperty("SCALAC_OPTS", x))
- timeout foreach (x => setFileManagerStringProperty("timeout", x))
+ javacmd foreach (x => antFileManager.JAVACMD = x.getAbsolutePath)
+ javaccmd foreach (x => antFileManager.JAVAC_CMD = x.getAbsolutePath)
+ scalacOpts foreach (antFileManager.SCALAC_OPTS = _)
+ timeout foreach (antFileManager.timeout = _)
type TFSet = (Array[File], String, String)
val testFileSets = List(
@@ -252,7 +224,7 @@ class PartestTask extends Task {
if (files.isEmpty) (0, 0, List())
else {
log(msg)
- val results: Iterable[(String, Int)] = runTestsForFiles(files, name)
+ val results: Iterable[(String, Int)] = antRunner.reflectiveRunTestsForFiles(files, name)
val (succs, fails) = resultsToStatistics(results)
val failed: Iterable[String] = results partialMap {