diff options
author | Paul Phillips <paulp@improving.org> | 2013-03-06 08:16:52 -0800 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2013-03-09 11:59:11 -0800 |
commit | 1dd88d9291b82f5fe2b46357aa0446cb87027c6e (patch) | |
tree | 07a704357c3af72d756eeaf660ef0c0a09ba4145 /src | |
parent | e83defaa29bf8d7ed742a611c301ee8b04e971b8 (diff) | |
download | scala-1dd88d9291b82f5fe2b46357aa0446cb87027c6e.tar.gz scala-1dd88d9291b82f5fe2b46357aa0446cb87027c6e.tar.bz2 scala-1dd88d9291b82f5fe2b46357aa0446cb87027c6e.zip |
Teach partest the magic of abstraction.
Some new partest abilities which were necessary to deal with
additional standard jars. These new abilities aren't yet put
to the test because scaladoc and interactive are still going
into the compiler jar.
No longer need each jar or classes directory be named
directly for partest to find them.
Diffstat (limited to 'src')
3 files changed, 26 insertions, 34 deletions
diff --git a/src/partest/scala/tools/partest/nest/DirectRunner.scala b/src/partest/scala/tools/partest/nest/DirectRunner.scala index 3aaf784cad..7e4c3b842c 100644 --- a/src/partest/scala/tools/partest/nest/DirectRunner.scala +++ b/src/partest/scala/tools/partest/nest/DirectRunner.scala @@ -38,27 +38,15 @@ trait DirectRunner { def runTestsForFiles(_kindFiles: List[File], kind: String): immutable.Map[String, TestState] = { System.setProperty("line.separator", "\n") - // @partest maintainer: we cannot create a fresh file manager here - // since the FM must respect --buildpath and --classpath from the command line - // for example, see how it's done in ReflectiveRunner - //val consFM = new ConsoleFileManager - //import consFM.{ latestCompFile, latestLibFile, latestPartestFile } - val latestCompFile = new File(fileManager.LATEST_COMP) - val latestReflectFile = new File(fileManager.LATEST_REFLECT) - val latestLibFile = new File(fileManager.LATEST_LIB) - val latestPartestFile = new File(fileManager.LATEST_PARTEST) - val latestActorsFile = new File(fileManager.LATEST_ACTORS) - val scalacheckURL = PathSettings.scalaCheck.toURL - val scalaCheckParentClassLoader = ScalaClassLoader.fromURLs( - scalacheckURL :: (List(latestCompFile, latestReflectFile, latestLibFile, latestActorsFile, latestPartestFile).map(_.toURI.toURL)) - ) - - val kindFiles = onlyValidTestPaths(_kindFiles) - val pool = Executors.newFixedThreadPool(numThreads) - val manager = new RunnerManager(kind, fileManager, TestRunParams(scalaCheckParentClassLoader)) - val futures = kindFiles map (f => (f, pool submit callable(manager runTest f))) toMap + val allUrls = PathSettings.scalaCheck.toURL :: fileManager.latestUrls + val scalaCheckParentClassLoader = ScalaClassLoader.fromURLs(allUrls) + val kindFiles = onlyValidTestPaths(_kindFiles) + val pool = Executors.newFixedThreadPool(numThreads) + val manager = new RunnerManager(kind, fileManager, TestRunParams(scalaCheckParentClassLoader)) + val futures = kindFiles map (f => (f, pool submit callable(manager runTest f))) toMap pool.shutdown() + try if (!pool.awaitTermination(4, TimeUnit.HOURS)) NestUI.warning("Thread pool timeout elapsed before all tests were complete!") catch { case t: InterruptedException => diff --git a/src/partest/scala/tools/partest/nest/FileManager.scala b/src/partest/scala/tools/partest/nest/FileManager.scala index a4c4e7e6a6..a32c56e973 100644 --- a/src/partest/scala/tools/partest/nest/FileManager.scala +++ b/src/partest/scala/tools/partest/nest/FileManager.scala @@ -64,6 +64,20 @@ trait FileManager extends FileUtil { var LATEST_PARTEST: String var LATEST_ACTORS: String + protected def relativeToLibrary(what: String): String = { + if (LATEST_LIB endsWith ".jar") { + (SFile(LATEST_LIB).parent / s"scala-$what.jar").toAbsolute.path + } + else { + (SFile(LATEST_LIB).parent.parent / "classes" / what).toAbsolute.path + } + } + def latestScaladoc = relativeToLibrary("scaladoc") + def latestInteractive = relativeToLibrary("interactive") + def latestPaths = List(LATEST_LIB, LATEST_REFLECT, LATEST_COMP, LATEST_PARTEST, LATEST_ACTORS, latestScaladoc, latestInteractive) + def latestFiles = latestPaths map (p => new java.io.File(p)) + def latestUrls = latestFiles map (_.toURI.toURL) + var showDiff = false var updateCheck = false var showLog = false diff --git a/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala b/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala index 3446dd0f72..05cae7b238 100644 --- a/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala +++ b/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala @@ -50,22 +50,15 @@ class ReflectiveRunner { else // auto detection new ConsoleFileManager - import fileManager. - { latestCompFile, latestReflectFile, latestLibFile, latestPartestFile, latestScalapFile, latestActorsFile } - val files = - Array(latestCompFile, latestReflectFile, latestLibFile, latestPartestFile, latestScalapFile, latestActorsFile) map (x => io.File(x)) - - val sepUrls = files map (_.toURL) - var sepLoader = new URLClassLoader(sepUrls, null) - // this is a workaround for https://issues.scala-lang.org/browse/SI-5433 - // when that bug is fixed, this paragraph of code can be safely removed + // when that bug is fixed, the addition of PathSettings.srcCodeLib can be removed // we hack into the classloader that will become parent classloader for scalac // this way we ensure that reflective macro lookup will pick correct Code.lift - sepLoader = new URLClassLoader((PathSettings.srcCodeLib +: files) map (_.toURL), null) + val sepUrls = PathSettings.srcCodeLib.toURI.toURL :: fileManager.latestUrls + val sepLoader = new URLClassLoader(sepUrls.toArray, null) if (isPartestDebug) - println("Loading classes from:\n" + sepUrls.mkString("\n")) + println("Loading classes from:\n " + fileManager.latestUrls.mkString("\n ")) // @partest maintainer: it seems to me that commented lines are incorrect // if classPath is not empty, then it has been provided by the --classpath option @@ -76,11 +69,8 @@ class ReflectiveRunner { // case Some(cp) => Nil // case _ => files.toList map (_.path) //} - val paths = files.toList map (_.path) - - val newClasspath = ClassPath.join(paths: _*) - setProp("java.class.path", newClasspath) + setProp("java.class.path", ClassPath.join(fileManager.latestPaths: _*)) // don't let partest find pluginsdir; in ant build, standard plugin has dedicated test suite //setProp("scala.home", latestLibFile.parent.parent.path) |