diff options
author | Paul Phillips <paulp@improving.org> | 2010-03-08 18:46:35 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-03-08 18:46:35 +0000 |
commit | fa34ce4700548a8d913d8aef71e8c86f668e498f (patch) | |
tree | a55cce5f90f35d6eda60498e3f0a9f28cadeb14f | |
parent | 5f7ddb20ab2e3729f30f6b1ee432a078a1a09899 (diff) | |
download | scala-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.
-rw-r--r-- | build.xml | 12 | ||||
-rw-r--r-- | src/compiler/scala/tools/ant/sabbus/TaskArgs.scala | 38 | ||||
-rw-r--r-- | src/partest/scala/tools/partest/PartestTask.scala | 58 |
3 files changed, 43 insertions, 65 deletions
@@ -1397,10 +1397,10 @@ BOOTRAPING TEST AND TEST SUITE <partest showlog="yes" erroronfailed="yes" javacmd="${java.home}/bin/java" timeout="1200000" javaccmd="${javac.cmd}" scalacopts="${scalac.args.optimise}"> - <classpath> + <compilationpath> <path refid="pack.classpath"/> - <fileset dir="${partest.dir}/files/lib" includes="*.jar"/> - </classpath> + <fileset dir="${partest.dir}/files/lib" includes="*.jar" /> + </compilationpath> <runtests dir="${partest.dir}/files"> <include name="run/**/*.scala"/> <include name="jvm/**/*.scala"/> @@ -1412,10 +1412,10 @@ BOOTRAPING TEST AND TEST SUITE <partest showlog="yes" erroronfailed="yes" javacmd="${java.home}/bin/java" timeout="2400000" javaccmd="${javac.cmd}" scalacopts="${scalac.args.optimise}"> - <classpath> + <compilationpath> <path refid="pack.classpath"/> - <fileset dir="${partest.dir}/files/lib" includes="*.jar"/> - </classpath> + <fileset dir="${partest.dir}/files/lib" includes="*.jar" /> + </compilationpath> <postests dir="${partest.dir}/files/pos" includes="*.scala"/> <negtests dir="${partest.dir}/files/neg" includes="*.scala"/> <runtests dir="${partest.dir}/files"> diff --git a/src/compiler/scala/tools/ant/sabbus/TaskArgs.scala b/src/compiler/scala/tools/ant/sabbus/TaskArgs.scala index 6526f67254..20a6791648 100644 --- a/src/compiler/scala/tools/ant/sabbus/TaskArgs.scala +++ b/src/compiler/scala/tools/ant/sabbus/TaskArgs.scala @@ -14,22 +14,10 @@ import java.io.File import org.apache.tools.ant.Task import org.apache.tools.ant.types.{Path, Reference} -trait TaskArgs { this: Task => +trait CompilationPathProperty { + this: Task => - def setId(input: String) { - id = Some(input) - } - - def setParams(input: String) { - params = params match { - case None => Some(input) - case Some(ps) => Some(ps + " " + input) - } - } - - def setTarget(input: String) { - compTarget = Some(input) - } + protected var compilationPath: Option[Path] = None def setCompilationPath(input: Path) { if (compilationPath.isEmpty) compilationPath = Some(input) @@ -44,6 +32,25 @@ trait TaskArgs { this: Task => def setCompilationPathRef(input: Reference) { createCompilationPath.setRefid(input) } +} + +trait TaskArgs extends CompilationPathProperty { + this: Task => + + def setId(input: String) { + id = Some(input) + } + + def setParams(input: String) { + params = params match { + case None => Some(input) + case Some(ps) => Some(ps + " " + input) + } + } + + def setTarget(input: String) { + compTarget = Some(input) + } def setSrcPath(input: Path) { if (sourcePath.isEmpty) sourcePath = Some(input) @@ -80,7 +87,6 @@ trait TaskArgs { this: Task => protected var id: Option[String] = None protected var params: Option[String] = None protected var compTarget: Option[String] = None - protected var compilationPath: Option[Path] = None protected var sourcePath: Option[Path] = None protected var compilerPath: Option[Path] = None protected var destinationDir: Option[File] = None 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 { |