summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/partest/scala/tools/partest/nest/DirectCompiler.scala2
-rw-r--r--src/partest/scala/tools/partest/nest/DirectRunner.scala52
-rw-r--r--src/partest/scala/tools/partest/nest/PathSettings.scala8
-rw-r--r--src/partest/scala/tools/partest/nest/ReflectiveRunner.scala2
-rw-r--r--src/partest/scala/tools/partest/nest/Runner.scala246
-rw-r--r--src/partest/scala/tools/partest/nest/RunnerManager.scala97
-rw-r--r--src/partest/scala/tools/partest/package.scala14
-rw-r--r--test/files/scalacheck/HashTrieSplit.scala47
-rw-r--r--test/files/scalacheck/parallel-collections/pc.scala14
-rwxr-xr-xtest/partest1
-rw-r--r--test/scaladoc/scalacheck/CommentFactoryTest.scala2
-rw-r--r--test/scaladoc/scalacheck/HtmlFactoryTest.scala17
-rw-r--r--test/scaladoc/scalacheck/IndexScriptTest.scala14
-rw-r--r--test/scaladoc/scalacheck/IndexTest.scala12
14 files changed, 263 insertions, 265 deletions
diff --git a/src/partest/scala/tools/partest/nest/DirectCompiler.scala b/src/partest/scala/tools/partest/nest/DirectCompiler.scala
index 650b6c35c8..8e5ff2abc4 100644
--- a/src/partest/scala/tools/partest/nest/DirectCompiler.scala
+++ b/src/partest/scala/tools/partest/nest/DirectCompiler.scala
@@ -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)
diff --git a/src/partest/scala/tools/partest/nest/DirectRunner.scala b/src/partest/scala/tools/partest/nest/DirectRunner.scala
deleted file mode 100644
index d38bdd62c8..0000000000
--- a/src/partest/scala/tools/partest/nest/DirectRunner.scala
+++ /dev/null
@@ -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)
- }
-}
diff --git a/src/partest/scala/tools/partest/nest/PathSettings.scala b/src/partest/scala/tools/partest/nest/PathSettings.scala
index bae6bf819d..8e454d8de8 100644
--- a/src/partest/scala/tools/partest/nest/PathSettings.scala
+++ b/src/partest/scala/tools/partest/nest/PathSettings.scala
@@ -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'.")
diff --git a/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala b/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala
index 9780e82cd9..734affa153 100644
--- a/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala
+++ b/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala
@@ -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)
diff --git a/src/partest/scala/tools/partest/nest/Runner.scala b/src/partest/scala/tools/partest/nest/Runner.scala
index 34676a8c89..e823c6b09f 100644
--- a/src/partest/scala/tools/partest/nest/Runner.scala
+++ b/src/partest/scala/tools/partest/nest/Runner.scala
@@ -7,19 +7,20 @@ package nest
import java.io.{ Console => _, _ }
import java.net.URL
-import scala.tools.nsc.Properties.{ jdkHome, javaHome, propOrElse, propOrEmpty }
-import scala.util.Properties.{ envOrElse, isWin }
+import java.nio.charset.{ Charset, CharsetDecoder, CharsetEncoder, CharacterCodingException, CodingErrorAction => Action }
+import java.util.concurrent.{ Executors, TimeUnit }
+import scala.collection.mutable.ListBuffer
+import scala.io.Codec
+import scala.sys.process.Process
+import scala.tools.nsc.Properties.{ envOrElse, isWin, jdkHome, javaHome, propOrElse, propOrEmpty, setProp }
import scala.tools.nsc.{ Settings, CompilerCommand, Global }
-import scala.tools.nsc.io.{ AbstractFile, PlainFile, Path, Directory, File => SFile }
+import scala.tools.nsc.io.{ AbstractFile, PlainFile }
import scala.tools.nsc.reporters.ConsoleReporter
-import scala.tools.nsc.util.{ ClassPath, FakePos, ScalaClassLoader, stackTraceString }
-import ClassPath.{ join, split }
+import scala.tools.nsc.util.{ Exceptional, ScalaClassLoader, stackTraceString }
+import scala.tools.scalap.Main.decompileScala
import scala.tools.scalap.scalax.rules.scalasig.ByteCode
-import scala.collection.{ mutable, immutable }
-import scala.sys.process.Process
-import java.util.concurrent.{ Executors, TimeUnit, TimeoutException }
+import ClassPath.{ join, split }
import PartestDefaults.{ javaCmd, javacCmd }
-import scala.tools.scalap.Main.decompileScala
trait PartestRunSettings {
def gitPath: Path
@@ -35,7 +36,7 @@ trait PartestRunSettings {
class TestTranscript {
import NestUI.color._
- private val buf = mutable.ListBuffer[String]()
+ private val buf = ListBuffer[String]()
private def pass(s: String) = bold(green("% ")) + s
private def fail(s: String) = bold(red("% ")) + s
@@ -49,7 +50,8 @@ class TestTranscript {
}
}
-class Runner(val testFile: File, fileManager: FileManager) {
+/** Run a single test. Rubber meets road. */
+class Runner(val testFile: File, fileManager: FileManager, val testRunParams: TestRunParams) {
import fileManager._
// Override to true to have the outcome of this test displayed
@@ -57,8 +59,6 @@ class Runner(val testFile: File, fileManager: FileManager) {
// except for a . per passing test to show progress.
def isEnumeratedTest = false
- def testRunParams: TestRunParams = ???
-
private var _lastState: TestState = null
private var _transcript = new TestTranscript
@@ -227,6 +227,7 @@ class Runner(val testFile: File, fileManager: FileManager) {
override def toString = s"""Test($testIdent, lastState = $lastState)"""
+ // result is unused
def newTestWriters() = {
val swr = new StringWriter
val wr = new PrintWriter(swr, true)
@@ -348,6 +349,7 @@ class Runner(val testFile: File, fileManager: FileManager) {
/** 1. Creates log file and output directory.
* 2. Runs script function, providing log file and output directory as arguments.
+ * 2b. or, just run the script without context and return a new context
*/
def runInContext(body: => Boolean): (Boolean, LogContext) = {
val (swr, wr) = newTestWriters()
@@ -356,11 +358,16 @@ class Runner(val testFile: File, fileManager: FileManager) {
}
/** Grouped files in group order, and lex order within each group. */
- def groupedFiles(dir: File): List[List[File]] = {
- val testFiles = dir.listFiles.toList filter (_.isJavaOrScala)
- val grouped = testFiles groupBy (_.group)
- grouped.keys.toList.sorted map (k => grouped(k) sortBy (_.getName))
- }
+ def groupedFiles(files: List[File]): List[List[File]] = (
+ if (files.tail.nonEmpty) {
+ val grouped = files filter (_.isJavaOrScala) groupBy (_.group)
+ grouped.keys.toList.sorted map (k => grouped(k) sortBy (_.getName))
+ }
+ else List(files)
+ )
+
+ /** Source files for the given test file. */
+ def sources(file: File): List[File] = if (file.isDirectory) file.listFiles.toList else List(file)
def newCompiler = new DirectCompiler(fileManager)
@@ -411,11 +418,9 @@ class Runner(val testFile: File, fileManager: FileManager) {
lazy val result = { pushTranscript(description) ; attemptCompile(fs) }
}
- def compilationRounds(file: File): List[CompileRound] = {
- val grouped = if (file.isDirectory) groupedFiles(file) else List(List(file))
-
- (grouped map mixedCompileGroup).flatten
- }
+ def compilationRounds(file: File): List[CompileRound] = (
+ (groupedFiles(sources(file)) map mixedCompileGroup).flatten
+ )
def mixedCompileGroup(allFiles: List[File]): List[CompileRound] = {
val (scalaFiles, javaFiles) = allFiles partition (_.isScala)
val isMixed = javaFiles.nonEmpty && scalaFiles.nonEmpty
@@ -495,28 +500,68 @@ class Runner(val testFile: File, fileManager: FileManager) {
}
def runScalacheckTest() = runTestCommon {
- def runScalacheckTest0() = {
- NestUI.verbose("compilation of "+testFile+" succeeded\n")
-
- val outURL = outDir.getAbsoluteFile.toURI.toURL
- val logWriter = new PrintStream(new FileOutputStream(logFile), true)
+ NestUI verbose f"compilation of $testFile succeeded%n"
- try Output.withRedirected(logWriter) {
- // this classloader is test specific: its parent contains library classes and others
- ScalaClassLoader.fromURLs(List(outURL), testRunParams.scalaCheckParentClassLoader).run("Test", Nil)
- } finally logWriter.close()
- true // succeeds trivially
+ // this classloader is test specific: its parent contains library classes and others
+ val loader = {
+ import PathSettings.scalaCheck
+ val locations = List(outDir, scalaCheck.jfile) map (_.getAbsoluteFile.toURI.toURL)
+ ScalaClassLoader.fromURLs(locations, getClass.getClassLoader)
}
- def checkScalacheckLog = {
- NestUI.verbose(file2String(logFile))
- // obviously this must be improved upon
- val lines = SFile(logFile).lines map (_.trim) filterNot (_ == "") toBuffer;
- lines.forall(x => !x.startsWith("!")) || {
- _transcript append logFile.fileContents
- false
+ val logWriter = new PrintStream(new FileOutputStream(logFile), true)
+
+ def toolArgs(tool: String): List[String] = {
+ def argsplitter(s: String) = words(s) filter (_.nonEmpty)
+ def argsFor(f: File): List[String] = {
+ import scala.util.matching.Regex
+ val p = new Regex(s"(?:.*\\s)?${tool}:(.*)?", "args")
+ val max = 10
+ val src = Path(f).toFile.chars(codec)
+ val args = try {
+ src.getLines take max collectFirst {
+ case s if (p findFirstIn s).nonEmpty => for (m <- p findFirstMatchIn s) yield m group "args"
+ }
+ } finally src.close()
+ args.flatten map argsplitter getOrElse Nil
+ }
+ sources(testFile) flatMap argsFor
+ }
+ def runInFramework(): Boolean = {
+ import org.scalatools.testing._
+ val f: Framework = loader.instantiate[Framework]("org.scalacheck.ScalaCheckFramework")
+ val logger = new Logger {
+ def ansiCodesSupported = false //params.env.isSet("colors")
+ def error(msg: String) = logWriter println msg
+ def warn(msg: String) = logWriter println msg
+ def info(msg: String) = logWriter println msg
+ def debug(msg: String) = logWriter println msg
+ def trace(t: Throwable) = t printStackTrace logWriter
+ }
+ var bad = 0
+ val handler = new EventHandler {
+ // testName, description, result, error
+ // Result = Success, Failure, Error, Skipped
+ def handle(event: Event): Unit = event.result match {
+ case Result.Success =>
+ //case Result.Skipped => // an exhausted test is skipped, therefore bad
+ case _ => bad += 1
+ }
+ }
+ val loggers = Array(logger)
+ val r = f.testRunner(loader, loggers).asInstanceOf[Runner2] // why?
+ val claas = "Test"
+ val fingerprint = f.tests collectFirst { case x: SubclassFingerprint if x.isModule => x }
+ val args = toolArgs("scalacheck")
+ vlog(s"Run $testFile with args $args")
+ // set the context class loader for scaladoc/scalacheck tests (FIX ME)
+ ScalaClassLoader(testRunParams.scalaCheckParentClassLoader).asContext {
+ r.run(claas, fingerprint.get, handler, args.toArray) // synchronous?
}
+ val ok = (bad == 0)
+ if (!ok) _transcript append logFile.fileContents
+ ok
}
- (runScalacheckTest0() && nextTestActionExpectTrue("ScalaCheck test failed", checkScalacheckLog))
+ try nextTestActionExpectTrue("ScalaCheck test failed", runInFramework()) finally logWriter.close()
}
def runResidentTest() = {
@@ -630,3 +675,122 @@ class Runner(val testFile: File, fileManager: FileManager) {
Directory(outDir).deleteRecursively()
}
}
+
+case class TestRunParams(val scalaCheckParentClassLoader: ScalaClassLoader)
+
+/** Extended by Ant- and ConsoleRunner for running a set of tests. */
+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)
+
+ // this special class loader is for the benefit of scaladoc tests, which need a class path
+ import PathSettings.{ testInterface, scalaCheck }
+ val allUrls = scalaCheck.toURL :: testInterface.toURL :: fileManager.latestUrls
+ val parentClassLoader = ScalaClassLoader fromURLs allUrls
+ // add scalacheck.jar to a special classloader, but use our loader as parent with test-interface
+ //val parentClassLoader = ScalaClassLoader fromURLs (List(scalaCheck.toURL), getClass().getClassLoader)
+ 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)
+ }
+}
+
+class LogContext(val file: File, val writers: Option[(StringWriter, PrintWriter)])
+
+object LogContext {
+ def apply(file: File, swr: StringWriter, wr: PrintWriter): LogContext = {
+ require (file != null)
+ new LogContext(file, Some((swr, wr)))
+ }
+ def apply(file: File): LogContext = new LogContext(file, None)
+}
+
+object Output {
+ object outRedirect extends Redirecter(out)
+ object errRedirect extends Redirecter(err)
+
+ System.setOut(outRedirect)
+ System.setErr(errRedirect)
+
+ import scala.util.DynamicVariable
+ private def out = java.lang.System.out
+ private def err = java.lang.System.err
+ private val redirVar = new DynamicVariable[Option[PrintStream]](None)
+
+ class Redirecter(stream: PrintStream) extends PrintStream(new OutputStream {
+ def write(b: Int) = withStream(_ write b)
+
+ private def withStream(f: PrintStream => Unit) = f(redirVar.value getOrElse stream)
+
+ override def write(b: Array[Byte]) = withStream(_ write b)
+ override def write(b: Array[Byte], off: Int, len: Int) = withStream(_.write(b, off, len))
+ override def flush = withStream(_.flush)
+ override def close = withStream(_.close)
+ })
+
+ // this supports thread-safe nested output redirects
+ def withRedirected[T](newstream: PrintStream)(func: => T): T = {
+ // note down old redirect destination
+ // this may be None in which case outRedirect and errRedirect print to stdout and stderr
+ val saved = redirVar.value
+ // set new redirecter
+ // this one will redirect both out and err to newstream
+ redirVar.value = Some(newstream)
+
+ try func
+ finally {
+ newstream.flush()
+ redirVar.value = saved
+ }
+ }
+}
+
+/** Use a Runner to run a test. */
+class RunnerManager(kind: String, fileManager: FileManager, params: TestRunParams) {
+ import fileManager._
+ fileManager.CLASSPATH += File.pathSeparator + PathSettings.scalaCheck
+ fileManager.CLASSPATH += File.pathSeparator + PathSettings.diffUtils // needed to put diffutils on test/partest's classpath
+
+ def runTest(testFile: File): TestState = {
+ val runner = new Runner(testFile, fileManager, params)
+
+ // when option "--failed" is provided execute test only if log
+ // is present (which means it failed before)
+ if (fileManager.failed && !runner.logFile.canRead)
+ runner.genPass()
+ else {
+ val (state, elapsed) =
+ try timed(runner.run())
+ catch {
+ case t: Throwable => throw new RuntimeException(s"Error running $testFile", t)
+ }
+ NestUI.reportTest(state)
+ runner.cleanup()
+ state
+ }
+ }
+}
diff --git a/src/partest/scala/tools/partest/nest/RunnerManager.scala b/src/partest/scala/tools/partest/nest/RunnerManager.scala
deleted file mode 100644
index fa2b5ea74b..0000000000
--- a/src/partest/scala/tools/partest/nest/RunnerManager.scala
+++ /dev/null
@@ -1,97 +0,0 @@
-/* NEST (New Scala Test)
- * Copyright 2007-2013 LAMP/EPFL
- * @author Philipp Haller
- */
-
-package scala.tools.partest
-package nest
-
-import java.io._
-import java.net.URL
-import scala.tools.nsc.Properties.{ jdkHome, javaHome, propOrElse }
-import scala.util.Properties.{ envOrElse, isWin }
-import scala.tools.nsc.{ Settings, CompilerCommand, Global }
-import scala.tools.nsc.io.{ AbstractFile, PlainFile, Path, Directory, File => SFile }
-import scala.tools.nsc.reporters.ConsoleReporter
-import scala.tools.nsc.util.{ ClassPath, FakePos, ScalaClassLoader, stackTraceString }
-import ClassPath.{ join, split }
-import scala.tools.scalap.scalax.rules.scalasig.ByteCode
-import scala.collection.{ mutable, immutable }
-import scala.sys.process._
-import java.util.concurrent.{ Executors, TimeUnit, TimeoutException }
-import PartestDefaults.{ javaCmd, javacCmd }
-import scala.tools.scalap.Main.decompileScala
-
-class LogContext(val file: File, val writers: Option[(StringWriter, PrintWriter)])
-
-object LogContext {
- def apply(file: File, swr: StringWriter, wr: PrintWriter): LogContext = {
- require (file != null)
- new LogContext(file, Some((swr, wr)))
- }
- def apply(file: File): LogContext = new LogContext(file, None)
-}
-
-object Output {
- object outRedirect extends Redirecter(out)
- object errRedirect extends Redirecter(err)
-
- System.setOut(outRedirect)
- System.setErr(errRedirect)
-
- import scala.util.DynamicVariable
- private def out = java.lang.System.out
- private def err = java.lang.System.err
- private val redirVar = new DynamicVariable[Option[PrintStream]](None)
-
- class Redirecter(stream: PrintStream) extends PrintStream(new OutputStream {
- def write(b: Int) = withStream(_ write b)
-
- private def withStream(f: PrintStream => Unit) = f(redirVar.value getOrElse stream)
-
- override def write(b: Array[Byte]) = withStream(_ write b)
- override def write(b: Array[Byte], off: Int, len: Int) = withStream(_.write(b, off, len))
- override def flush = withStream(_.flush)
- override def close = withStream(_.close)
- })
-
- // this supports thread-safe nested output redirects
- def withRedirected[T](newstream: PrintStream)(func: => T): T = {
- // note down old redirect destination
- // this may be None in which case outRedirect and errRedirect print to stdout and stderr
- val saved = redirVar.value
- // set new redirecter
- // this one will redirect both out and err to newstream
- redirVar.value = Some(newstream)
-
- try func
- finally {
- newstream.flush()
- redirVar.value = saved
- }
- }
-}
-
-class RunnerManager(kind: String, val fileManager: FileManager, params: TestRunParams) {
- import fileManager._
-
- fileManager.CLASSPATH += File.pathSeparator + PathSettings.scalaCheck
- fileManager.CLASSPATH += File.pathSeparator + PathSettings.diffUtils // needed to put diffutils on test/partest's classpath
- PathSettings.platformTools foreach (fileManager.CLASSPATH += File.pathSeparator + _)
-
- def runTest(testFile: File): TestState = {
- val runner = new Runner(testFile, fileManager) {
- override def testRunParams = params
- }
- // when option "--failed" is provided execute test only if log
- // is present (which means it failed before)
- if (fileManager.failed && !runner.logFile.canRead)
- runner.genPass()
- else {
- val (state, elapsed) = timed(runner.run())
- NestUI.reportTest(state)
- runner.cleanup()
- state
- }
- }
-}
diff --git a/src/partest/scala/tools/partest/package.scala b/src/partest/scala/tools/partest/package.scala
index 9e21b0f6ba..0b169c767a 100644
--- a/src/partest/scala/tools/partest/package.scala
+++ b/src/partest/scala/tools/partest/package.scala
@@ -31,6 +31,8 @@ package object partest {
def ojoin(xs: String*): String = oempty(xs: _*) mkString space
def nljoin(xs: String*): String = oempty(xs: _*) mkString EOL
+ implicit val codec = scala.io.Codec.UTF8
+
def setUncaughtHandler() = {
Thread.setDefaultUncaughtExceptionHandler(
new Thread.UncaughtExceptionHandler {
@@ -85,6 +87,18 @@ package object partest {
def copyTo(dest: Path): Unit = dest.toFile writeAll f.slurp(scala.io.Codec.UTF8)
}
+ implicit class LoaderOps(val loader: ClassLoader) extends AnyVal {
+ import scala.util.control.Exception.catching
+ /** Like ScalaClassLoader.create for the case where the result type is
+ * available to the current class loader, implying that the current
+ * loader is a parent of `loader`.
+ */
+ def instantiate[A >: Null](name: String): A = (
+ catching(classOf[ClassNotFoundException], classOf[SecurityException]) opt
+ (loader loadClass name).newInstance.asInstanceOf[A] orNull
+ )
+ }
+
implicit def temporaryPath2File(x: Path): File = x.jfile
implicit def stringPathToJavaFile(path: String): File = new File(path)
diff --git a/test/files/scalacheck/HashTrieSplit.scala b/test/files/scalacheck/HashTrieSplit.scala
deleted file mode 100644
index 908c878f54..0000000000
--- a/test/files/scalacheck/HashTrieSplit.scala
+++ /dev/null
@@ -1,47 +0,0 @@
-
-
-
-
-
-import collection._
-
-
-
-
-// checks whether hash tries split their iterators correctly
-// even after some elements have been traversed
-object Test {
- def main(args: Array[String]) {
- doesSplitOk
- }
-
- def doesSplitOk = {
- val sz = 2000
- var ht = new parallel.immutable.ParHashMap[Int, Int]
- // println("creating trie")
- for (i <- 0 until sz) ht += ((i + sz, i))
- // println("created trie")
- for (n <- 0 until (sz - 1)) {
- // println("---------> n = " + n)
- val pit = ht.splitter
- val pit2 = ht.splitter
- var i = 0
- while (i < n) {
- pit.next
- pit2.next
- i += 1
- }
- // println("splitting")
- val pits = pit.split
- val fst = pits(0).toSet
- val snd = pits(1).toSet
- val orig = pit2.toSet
- if (orig.size != (fst.size + snd.size) || orig != (fst ++ snd)) {
- println("Original: " + orig)
- println("First: " + fst)
- println("Second: " + snd)
- assert(false)
- }
- }
- }
-}
diff --git a/test/files/scalacheck/parallel-collections/pc.scala b/test/files/scalacheck/parallel-collections/pc.scala
index 0a91977da0..e6b6b4856d 100644
--- a/test/files/scalacheck/parallel-collections/pc.scala
+++ b/test/files/scalacheck/parallel-collections/pc.scala
@@ -1,12 +1,11 @@
-
-
-
+/*
+ * scalac: -deprecation
+ * scalacheck: -workers 1 -minSize 0 -maxSize 4000 -minSuccessfulTests 5
+ */
import org.scalacheck._
-
import scala.collection.parallel._
-
class ParCollProperties extends Properties("Parallel collections") {
/* Collections */
@@ -35,8 +34,8 @@ class ParCollProperties extends Properties("Parallel collections") {
include(immutable.IntParallelVectorCheck)
}
-
-object Test {
+object Test extends ParCollProperties {
+ /*
def main(args: Array[String]) {
val pc = new ParCollProperties
org.scalacheck.Test.checkProperties(
@@ -51,4 +50,5 @@ object Test {
pc
)
}
+ */
}
diff --git a/test/partest b/test/partest
index e3270f8eaa..99a731a49b 100755
--- a/test/partest
+++ b/test/partest
@@ -129,6 +129,7 @@ fi
$JAVA_OPTS -cp "$EXT_CLASSPATH" \
${partestDebugStr} \
"$color_opts" \
+ -Dfile.encoding=UTF-8 \
-Dscala.home="${SCALA_HOME}" \
-Dpartest.javacmd="${JAVACMD}" \
-Dpartest.java_opts="${JAVA_OPTS}" \
diff --git a/test/scaladoc/scalacheck/CommentFactoryTest.scala b/test/scaladoc/scalacheck/CommentFactoryTest.scala
index 96174d29d1..28043e5a06 100644
--- a/test/scaladoc/scalacheck/CommentFactoryTest.scala
+++ b/test/scaladoc/scalacheck/CommentFactoryTest.scala
@@ -45,7 +45,7 @@ object Test extends Properties("CommentFactory") {
with MemberLookup)
}
- def parse(src: String, dst: Inline) = {
+ def parse(src: String, dst: Inline): Boolean = {
factory.parseComment(src) match {
case Some(inline) =>
inline == dst
diff --git a/test/scaladoc/scalacheck/HtmlFactoryTest.scala b/test/scaladoc/scalacheck/HtmlFactoryTest.scala
index d7b5e48288..03348b81d2 100644
--- a/test/scaladoc/scalacheck/HtmlFactoryTest.scala
+++ b/test/scaladoc/scalacheck/HtmlFactoryTest.scala
@@ -2,6 +2,8 @@ import org.scalacheck._
import org.scalacheck.Prop._
import java.net.{URLClassLoader, URLDecoder}
+import scala.collection.mutable
+import scala.xml.NodeSeq
object XMLUtil {
import scala.xml._
@@ -34,21 +36,24 @@ object Test extends Properties("HtmlFactory") {
// this test previously relied on the assumption that the current thread's classloader is an url classloader and contains all the classpaths
// does partest actually guarantee this? to quote Leonard Nimoy: The answer, of course, is no.
// this test _will_ fail again some time in the future.
- val paths = Thread.currentThread.getContextClassLoader.asInstanceOf[URLClassLoader].getURLs.map(u => URLDecoder.decode(u.getPath))
- val morepaths = Thread.currentThread.getContextClassLoader.getParent.asInstanceOf[URLClassLoader].getURLs.map(u => URLDecoder.decode(u.getPath))
- (paths ++ morepaths).mkString(java.io.File.pathSeparator)
+ // Footnote: java.lang.ClassCastException: org.apache.tools.ant.loader.AntClassLoader5 cannot be cast to java.net.URLClassLoader
+ val loader = Thread.currentThread.getContextClassLoader.asInstanceOf[URLClassLoader]
+ val paths = loader.getURLs.map(u => URLDecoder.decode(u.getPath))
+ paths mkString java.io.File.pathSeparator
}
def createFactory = {
val settings = new Settings({Console.err.println(_)})
+ settings.scaladocQuietRun = true
+ settings.nowarn.value = true
settings.classpath.value = getClasspath
val reporter = new scala.tools.nsc.reporters.ConsoleReporter(settings)
new DocFactory(reporter, settings)
}
- def createTemplates(basename: String) = {
- val result = scala.collection.mutable.Map[String, scala.xml.NodeSeq]()
+ def createTemplates(basename: String): collection.Map[String, NodeSeq] = {
+ val result = mutable.Map[String, NodeSeq]()
createFactory.makeUniverse(Left(List(RESOURCES+basename))) match {
case Some(universe) => {
@@ -57,7 +62,7 @@ object Test extends Properties("HtmlFactory") {
result += (page.absoluteLinkTo(page.path) -> page.body)
})
}
- case _ => ;
+ case _ =>
}
result
diff --git a/test/scaladoc/scalacheck/IndexScriptTest.scala b/test/scaladoc/scalacheck/IndexScriptTest.scala
index 37f6947aaa..b8b9f92965 100644
--- a/test/scaladoc/scalacheck/IndexScriptTest.scala
+++ b/test/scaladoc/scalacheck/IndexScriptTest.scala
@@ -8,14 +8,20 @@ import java.net.{URLClassLoader, URLDecoder}
object Test extends Properties("IndexScript") {
def getClasspath = {
- val loader = Thread.currentThread.getContextClassLoader
- val paths = loader.asInstanceOf[URLClassLoader].getURLs
- val morepaths = loader.getParent.asInstanceOf[URLClassLoader].getURLs
- (paths ++ morepaths).map(u => URLDecoder.decode(u.getPath)).mkString(java.io.File.pathSeparator)
+ // these things can be tricky
+ // this test previously relied on the assumption that the current thread's classloader is an url classloader and contains all the classpaths
+ // does partest actually guarantee this? to quote Leonard Nimoy: The answer, of course, is no.
+ // this test _will_ fail again some time in the future.
+ // Footnote: java.lang.ClassCastException: org.apache.tools.ant.loader.AntClassLoader5 cannot be cast to java.net.URLClassLoader
+ val loader = Thread.currentThread.getContextClassLoader.asInstanceOf[URLClassLoader]
+ val paths = loader.getURLs.map(u => URLDecoder.decode(u.getPath))
+ paths mkString java.io.File.pathSeparator
}
val docFactory = {
val settings = new doc.Settings({Console.err.println(_)})
+ settings.scaladocQuietRun = true
+ settings.nowarn.value = true
settings.classpath.value = getClasspath
val reporter = new scala.tools.nsc.reporters.ConsoleReporter(settings)
new doc.DocFactory(reporter, settings)
diff --git a/test/scaladoc/scalacheck/IndexTest.scala b/test/scaladoc/scalacheck/IndexTest.scala
index dc4ab126d4..abc0e5da01 100644
--- a/test/scaladoc/scalacheck/IndexTest.scala
+++ b/test/scaladoc/scalacheck/IndexTest.scala
@@ -12,19 +12,19 @@ object Test extends Properties("Index") {
// this test previously relied on the assumption that the current thread's classloader is an url classloader and contains all the classpaths
// does partest actually guarantee this? to quote Leonard Nimoy: The answer, of course, is no.
// this test _will_ fail again some time in the future.
- val paths = Thread.currentThread.getContextClassLoader.asInstanceOf[URLClassLoader].getURLs.map(u => URLDecoder.decode(u.getPath))
- val morepaths = Thread.currentThread.getContextClassLoader.getParent.asInstanceOf[URLClassLoader].getURLs.map(u => URLDecoder.decode(u.getPath))
- (paths ++ morepaths).mkString(java.io.File.pathSeparator)
+ // Footnote: java.lang.ClassCastException: org.apache.tools.ant.loader.AntClassLoader5 cannot be cast to java.net.URLClassLoader
+ val loader = Thread.currentThread.getContextClassLoader.asInstanceOf[URLClassLoader]
+ val paths = loader.getURLs.map(u => URLDecoder.decode(u.getPath))
+ paths mkString java.io.File.pathSeparator
}
val docFactory = {
val settings = new doc.Settings({Console.err.println(_)})
-
+ settings.scaladocQuietRun = true
+ settings.nowarn.value = true
settings.classpath.value = getClasspath
- println(settings.classpath.value)
val reporter = new scala.tools.nsc.reporters.ConsoleReporter(settings)
-
new doc.DocFactory(reporter, settings)
}