Permalink
Browse files

SI-7349 Partest supports test-interface

Partest uses test-interface API to invoke ScalaCheck.  This obviates
ad hoc output checking for result status.

The context class loader is set to a loader that the scaladoc scalacheck
tests can use.
  • Loading branch information...
1 parent b47ca5b commit bf4466982854ffa8be57068752ea31daf7776eee @som-snytt som-snytt committed with paulp Apr 24, 2013
@@ -48,7 +48,7 @@ class DirectCompiler(val fileManager: FileManager) {
}
def compile(runner: Runner, opts0: List[String], sources: List[File]): TestState = {
- import runner._
+ import runner.{ sources => _, _ }
val testSettings = new TestSettings(ClassPath.join(fileManager.LATEST_LIB, outDir.getPath))
val logWriter = new FileWriter(logFile)
@@ -1,52 +0,0 @@
-/* NEST (New Scala Test)
- * Copyright 2007-2013 LAMP/EPFL
- * @author Philipp Haller
- */
-
-package scala.tools.partest
-package nest
-
-import java.io.File
-import scala.util.Properties.setProp
-import scala.tools.nsc.util.{ ScalaClassLoader, Exceptional }
-import scala.tools.nsc.io.Path
-import scala.collection.{ mutable, immutable }
-import java.util.concurrent._
-
-case class TestRunParams(val scalaCheckParentClassLoader: ScalaClassLoader)
-
-trait DirectRunner {
- def fileManager: FileManager
-
- import PartestDefaults.numThreads
-
- Thread.setDefaultUncaughtExceptionHandler(
- new Thread.UncaughtExceptionHandler {
- def uncaughtException(thread: Thread, t: Throwable) {
- val t1 = Exceptional unwrap t
- System.err.println(s"Uncaught exception on thread $thread: $t1")
- t1.printStackTrace()
- }
- }
- )
- def runTestsForFiles(kindFiles: List[File], kind: String): List[TestState] = {
-
- NestUI.resetTestNumber(kindFiles.size)
-
- val allUrls = PathSettings.scalaCheck.toURL :: fileManager.latestUrls
- val parentClassLoader = ScalaClassLoader fromURLs allUrls
- val pool = Executors newFixedThreadPool numThreads
- val manager = new RunnerManager(kind, fileManager, TestRunParams(parentClassLoader))
- val futures = kindFiles map (f => pool submit callable(manager runTest f))
-
- pool.shutdown()
- try if (!pool.awaitTermination(4, TimeUnit.HOURS))
- NestUI warning "Thread pool timeout elapsed before all tests were complete!"
- catch { case t: InterruptedException =>
- NestUI warning "Thread pool was interrupted"
- t.printStackTrace()
- }
-
- futures map (_.get)
- }
-}
@@ -7,9 +7,9 @@ package nest
import scala.tools.nsc.Properties.{ setProp, propOrEmpty, propOrNone, propOrElse }
import scala.tools.nsc.util.ClassPath
-import scala.tools.nsc.io
+import scala.tools.nsc.io.{ Path, File, Directory }
import scala.util.Properties.{ envOrElse, envOrNone, javaHome, jdkHome }
-import io.{ Path, File, Directory }
+import Path._
object PathSettings {
import PartestDefaults.{ testRootDir, srcDirName }
@@ -19,6 +19,8 @@ object PathSettings {
private def findJar(d: Directory, name: String): Option[File] = findJar(d.files, name)
private def findJar(files: Iterator[File], name: String): Option[File] =
files filter (_ hasExtension "jar") find { _.name startsWith name }
+ private def findJarOrFail(name: String, ds: Directory*): File = findJar(ds flatMap (_.files) iterator, name) getOrElse
+ sys.error(s"'${name}.jar' not found in '${ds map (_.path) mkString ", "}'.")
// Directory <root>/test
lazy val testRoot: Directory = testRootDir getOrElse {
@@ -73,6 +75,8 @@ object PathSettings {
sys.error("No scalacheck jar found in '%s' or '%s'".format(buildPackLibDir, srcLibDir))
}
+ lazy val testInterface: File = findJarOrFail("test-interface", buildPackLibDir, srcLibDir)
+
lazy val diffUtils: File =
findJar(buildPackLibDir.files, "diffutils") getOrElse sys.error(s"No diffutils.jar found in '$buildPackLibDir'.")
@@ -55,7 +55,7 @@ class ReflectiveRunner {
// 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
// it's also used to inject diffutils into the classpath when running partest from the test/partest script
- val srcCodeLibAndDiff = List(PathSettings.srcCodeLib, PathSettings.diffUtils)
+ val srcCodeLibAndDiff = List(PathSettings.srcCodeLib, PathSettings.diffUtils, PathSettings.testInterface)
val sepUrls = srcCodeLibAndDiff.map(_.toURI.toURL) ::: fileManager.latestUrls
// this seems to be the core classloader that determines which classes can be found when running partest from the test/partest script
val sepLoader = new URLClassLoader(sepUrls.toArray, null)
Oops, something went wrong.

0 comments on commit bf44669

Please sign in to comment.