From 21432085e182ff01ec339ae63031408d5a0ade81 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Tue, 29 Mar 2011 20:22:40 +0000 Subject: 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. --- src/partest/scala/tools/partest/PartestTask.scala | 1 - .../tools/partest/nest/ConsoleFileManager.scala | 1 + .../scala/tools/partest/nest/PathSettings.scala | 1 - .../tools/partest/nest/ReflectiveRunner.scala | 4 +-- src/partest/scala/tools/partest/nest/Worker.scala | 34 ++++++++++------------ 5 files changed, 18 insertions(+), 23 deletions(-) (limited to 'src') 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)) -- cgit v1.2.3