summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-03-29 20:22:40 +0000
committerPaul Phillips <paulp@improving.org>2011-03-29 20:22:40 +0000
commit21432085e182ff01ec339ae63031408d5a0ade81 (patch)
treed51f4966220836c480f9ca6bb51d9903664ae20a /src
parent88fbb71848b56ae5cb2b8ad7833cde21ce3937d9 (diff)
downloadscala-21432085e182ff01ec339ae63031408d5a0ade81.tar.gz
scala-21432085e182ff01ec339ae63031408d5a0ade81.tar.bz2
scala-21432085e182ff01ec339ae63031408d5a0ade81.zip
Fixing the scalap test rig to work like other t...
Fixing the scalap test rig to work like other test types so it doesn't break the distribution build. No review.
Diffstat (limited to 'src')
-rw-r--r--src/partest/scala/tools/partest/PartestTask.scala1
-rw-r--r--src/partest/scala/tools/partest/nest/ConsoleFileManager.scala1
-rw-r--r--src/partest/scala/tools/partest/nest/PathSettings.scala1
-rw-r--r--src/partest/scala/tools/partest/nest/ReflectiveRunner.scala4
-rw-r--r--src/partest/scala/tools/partest/nest/Worker.scala34
5 files changed, 18 insertions, 23 deletions
diff --git a/src/partest/scala/tools/partest/PartestTask.scala b/src/partest/scala/tools/partest/PartestTask.scala
index f1b3ea496d..1a75621d4d 100644
--- a/src/partest/scala/tools/partest/PartestTask.scala
+++ b/src/partest/scala/tools/partest/PartestTask.scala
@@ -19,7 +19,6 @@ import util.PathResolver
import scala.tools.ant.sabbus.CompilationPathProperty
import java.io.File
-import java.net.URLClassLoader
import java.lang.reflect.Method
import org.apache.tools.ant.Task
diff --git a/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala b/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala
index 4182cc78b8..02edf0fc31 100644
--- a/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala
+++ b/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala
@@ -166,6 +166,7 @@ class ConsoleFileManager extends FileManager {
var latestCompFile: File = _
var latestPartestFile: File = _
var latestFjbgFile: File = _
+ def latestScalapFile: File = (latestLibFile.parent / "scalap.jar").jfile
var testClassesDir: Directory = _
// initialize above fields
findLatest()
diff --git a/src/partest/scala/tools/partest/nest/PathSettings.scala b/src/partest/scala/tools/partest/nest/PathSettings.scala
index b02417a50c..7461b45fee 100644
--- a/src/partest/scala/tools/partest/nest/PathSettings.scala
+++ b/src/partest/scala/tools/partest/nest/PathSettings.scala
@@ -10,7 +10,6 @@ import scala.tools.nsc.util.ClassPath
import scala.tools.nsc.io
import io.{ Path, File, Directory }
import RunnerUtils._
-import java.net.URLClassLoader
object PathSettings {
import PartestDefaults.{ testRootDir, srcDirName }
diff --git a/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala b/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala
index b0aa56f9ff..f39debf31d 100644
--- a/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala
+++ b/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala
@@ -48,9 +48,9 @@ class ReflectiveRunner {
new ConsoleFileManager
import fileManager.
- { latestCompFile, latestLibFile, latestPartestFile, latestFjbgFile }
+ { latestCompFile, latestLibFile, latestPartestFile, latestFjbgFile, latestScalapFile }
val files =
- Array(latestCompFile, latestLibFile, latestPartestFile, latestFjbgFile) map (x => io.File(x))
+ Array(latestCompFile, latestLibFile, latestPartestFile, latestFjbgFile, latestScalapFile) map (x => io.File(x))
val sepUrls = files map (_.toURL)
val sepLoader = new URLClassLoader(sepUrls, null)
diff --git a/src/partest/scala/tools/partest/nest/Worker.scala b/src/partest/scala/tools/partest/nest/Worker.scala
index afbdfdba83..2697db475b 100644
--- a/src/partest/scala/tools/partest/nest/Worker.scala
+++ b/src/partest/scala/tools/partest/nest/Worker.scala
@@ -9,7 +9,7 @@ package scala.tools.partest
package nest
import java.io._
-import java.net.{ URLClassLoader, URL }
+import java.net.URL
import java.util.{ Timer, TimerTask }
import scala.util.Properties.{ isWin }
@@ -842,35 +842,31 @@ class Worker(val fileManager: FileManager, params: TestRunParams) extends Actor
case "scalap" =>
runInContext(file, (logFile: File, outDir: File) => {
- val sourceDir = file.getParentFile
- val sourceDirName = sourceDir.getName
+ val sourceDir = Directory(if (file.isFile) file.getParent else file)
+ val sources = sourceDir.files filter (_ hasExtension "scala") map (_.jfile) toList
+ val results = sourceDir.files filter (_.name == "result.test") map (_.jfile) toList
- // 1. Find file with result text
- val results = sourceDir.listFiles(new FilenameFilter {
- def accept(dir: File, name: String) = name == "result.test"
- })
-
- if (results.length != 1) {
- NestUI.verbose("Result file not found in directory " + sourceDirName + " \n")
+ if (sources.length != 1 || results.length != 1) {
+ NestUI.warning("Misconfigured scalap test directory: " + sourceDir + " \n")
false
}
else {
- val resFile = results(0)
+ val resFile = results.head
// 2. Compile source file
- if (!compileMgr.shouldCompile(outDir, List(file), kind, logFile)) {
- NestUI.verbose("compilerMgr failed to compile %s to %s".format(file, outDir))
+ if (!compileMgr.shouldCompile(outDir, sources, kind, logFile)) {
+ NestUI.normal("compilerMgr failed to compile %s to %s".format(sources mkString ", ", outDir))
false
}
else {
// 3. Decompile file and compare results
- val isPackageObject = sourceDir.getName.startsWith("package")
- val className = sourceDirName.capitalize + (if (!isPackageObject) "" else ".package")
- val url = outDir.toURI.toURL
- val loader = new URLClassLoader(Array(url), getClass.getClassLoader)
- val clazz = loader.loadClass(className)
+ val isPackageObject = sourceDir.name startsWith "package"
+ val className = sourceDir.name.capitalize + (if (!isPackageObject) "" else ".package")
+ val url = outDir.toURI.toURL
+ val loader = ScalaClassLoader.fromURLs(List(url), this.getClass.getClassLoader)
+ val clazz = loader.loadClass(className)
val byteCode = ByteCode.forClass(clazz)
- val result = scala.tools.scalap.Main.decompileScala(byteCode.bytes, isPackageObject)
+ val result = scala.tools.scalap.Main.decompileScala(byteCode.bytes, isPackageObject)
SFile(logFile) writeAll result
diffCheck(compareFiles(logFile, resFile))