diff options
author | Paul Phillips <paulp@improving.org> | 2012-11-13 00:14:40 -0800 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-11-19 11:55:06 -0800 |
commit | d5e3f85946af966111f88af90a666a709df0ba6f (patch) | |
tree | edb2d3cfae76679bc0311f3c22d01779a2f32ef3 /src/partest | |
parent | 645c2676dd6699ac24a57dfe750386bbdb827ee8 (diff) | |
download | scala-d5e3f85946af966111f88af90a666a709df0ba6f.tar.gz scala-d5e3f85946af966111f88af90a666a709df0ba6f.tar.bz2 scala-d5e3f85946af966111f88af90a666a709df0ba6f.zip |
Revert "Commenting out unused members."
This reverts commit 951fc3a486.
Diffstat (limited to 'src/partest')
13 files changed, 132 insertions, 133 deletions
diff --git a/src/partest/scala/tools/partest/CompilerTest.scala b/src/partest/scala/tools/partest/CompilerTest.scala index bb0732dcc6..d73d99bc89 100644 --- a/src/partest/scala/tools/partest/CompilerTest.scala +++ b/src/partest/scala/tools/partest/CompilerTest.scala @@ -21,7 +21,7 @@ abstract class CompilerTest extends DirectTest { lazy val global: Global = newCompiler() lazy val units = compilationUnits(global)(sources: _ *) import global._ - import definitions.{ compilerTypeFromTag } + import definitions._ override def extraSettings = "-usejavacp -d " + testOutput.path @@ -32,6 +32,7 @@ abstract class CompilerTest extends DirectTest { def sources: List[String] = List(code) // Utility functions + class MkType(sym: Symbol) { def apply[M](implicit t: ru.TypeTag[M]): Type = if (sym eq NoSymbol) NoType diff --git a/src/partest/scala/tools/partest/SecurityTest.scala b/src/partest/scala/tools/partest/SecurityTest.scala index 8d57e7e38d..2d6f61d0b1 100644 --- a/src/partest/scala/tools/partest/SecurityTest.scala +++ b/src/partest/scala/tools/partest/SecurityTest.scala @@ -11,8 +11,8 @@ import java.util._ abstract class SecurityTest extends App { def throwIt(x: Any) = throw new AccessControlException("" + x) - // def readPerm(p: PropertyPermission) = p.getActions contains "read" - // def writePerm(p: PropertyPermission) = p.getActions contains "write" + def readPerm(p: PropertyPermission) = p.getActions contains "read" + def writePerm(p: PropertyPermission) = p.getActions contains "write" def propertyCheck(p: PropertyPermission): Unit = throwIt(p) def check(perm: Permission): Unit = perm match { @@ -20,13 +20,13 @@ abstract class SecurityTest extends App { case _ => () } - // lazy val sm = new SecurityManager { - // // these two are the choke points for all permissions checks - // override def checkPermission(perm: Permission): Unit = check(perm) - // override def checkPermission(perm: Permission, context: Object): Unit = check(perm) - // } - // def securityOn(): Boolean = { - // try { System.setSecurityManager(sm) ; true } - // catch { case _: SecurityException => false } - // } + lazy val sm = new SecurityManager { + // these two are the choke points for all permissions checks + override def checkPermission(perm: Permission): Unit = check(perm) + override def checkPermission(perm: Permission, context: Object): Unit = check(perm) + } + def securityOn(): Boolean = { + try { System.setSecurityManager(sm) ; true } + catch { case _: SecurityException => false } + } } diff --git a/src/partest/scala/tools/partest/TestUtil.scala b/src/partest/scala/tools/partest/TestUtil.scala index bd5dc39498..9bfd444180 100644 --- a/src/partest/scala/tools/partest/TestUtil.scala +++ b/src/partest/scala/tools/partest/TestUtil.scala @@ -24,13 +24,13 @@ trait TestUtil { } def nanos(body: => Unit): Long = alsoNanos(body)._1 - // def verifySpeed(body1: => Unit, body2: => Unit, acceptableMultiple: Double) = { - // val t1 = nanos(body1).toDouble - // val t2 = nanos(body2).toDouble - // val mult = if (t1 > t2) t1 / t2 else t2 / t1 + def verifySpeed(body1: => Unit, body2: => Unit, acceptableMultiple: Double) = { + val t1 = nanos(body1).toDouble + val t2 = nanos(body2).toDouble + val mult = if (t1 > t2) t1 / t2 else t2 / t1 - // assert(mult <= acceptableMultiple, "Performance difference too great: multiple = " + mult) - // } + assert(mult <= acceptableMultiple, "Performance difference too great: multiple = " + mult) + } def intercept[T <: Exception : ClassTag](code: => Unit): Unit = try { @@ -41,6 +41,6 @@ trait TestUtil { } } -// Used in tests. object TestUtil extends TestUtil { + } diff --git a/src/partest/scala/tools/partest/instrumented/Instrumentation.scala b/src/partest/scala/tools/partest/instrumented/Instrumentation.scala index 18dd740208..8a284b313b 100644 --- a/src/partest/scala/tools/partest/instrumented/Instrumentation.scala +++ b/src/partest/scala/tools/partest/instrumented/Instrumentation.scala @@ -78,7 +78,6 @@ object Instrumentation { !t.className.startsWith("scala/util/DynamicVariable") } - // Used in tests. def printStatistics(stats: Statistics = getStatistics, filter: MethodCallTrace => Boolean = standardFilter): Unit = { val stats = getStatistics println("Method call statistics:") diff --git a/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala b/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala index d8ae4b2403..75aed449a8 100644 --- a/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala +++ b/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala @@ -79,7 +79,7 @@ class ConsoleFileManager extends FileManager { testClassesDir = Path(testClasses.get).toCanonical.toDirectory NestUI.verbose("Running with classes in "+testClassesDir) - // latestFile = testClassesDir.parent / "bin" + latestFile = testClassesDir.parent / "bin" latestLibFile = testClassesDir / "library" latestActorsFile = testClassesDir / "library" / "actors" latestReflectFile = testClassesDir / "reflect" @@ -90,7 +90,7 @@ class ConsoleFileManager extends FileManager { else if (testBuild.isDefined) { val dir = Path(testBuild.get) NestUI.verbose("Running on "+dir) - // latestFile = dir / "bin" + latestFile = dir / "bin" latestLibFile = dir / "lib/scala-library.jar" latestActorsFile = dir / "lib/scala-actors.jar" latestReflectFile = dir / "lib/scala-reflect.jar" @@ -101,7 +101,7 @@ class ConsoleFileManager extends FileManager { else { def setupQuick() { NestUI.verbose("Running build/quick") - // latestFile = prefixFile("build/quick/bin") + latestFile = prefixFile("build/quick/bin") latestLibFile = prefixFile("build/quick/classes/library") latestActorsFile = prefixFile("build/quick/classes/library/actors") latestReflectFile = prefixFile("build/quick/classes/reflect") @@ -112,7 +112,7 @@ class ConsoleFileManager extends FileManager { def setupInst() { NestUI.verbose("Running dist (installed)") val p = testParent.getParentFile - // latestFile = prefixFileWith(p, "bin") + latestFile = prefixFileWith(p, "bin") latestLibFile = prefixFileWith(p, "lib/scala-library.jar") latestActorsFile = prefixFileWith(p, "lib/scala-actors.jar") latestReflectFile = prefixFileWith(p, "lib/scala-reflect.jar") @@ -122,7 +122,7 @@ class ConsoleFileManager extends FileManager { def setupDist() { NestUI.verbose("Running dists/latest") - // latestFile = prefixFile("dists/latest/bin") + latestFile = prefixFile("dists/latest/bin") latestLibFile = prefixFile("dists/latest/lib/scala-library.jar") latestActorsFile = prefixFile("dists/latest/lib/scala-actors.jar") latestReflectFile = prefixFile("dists/latest/lib/scala-reflect.jar") @@ -132,7 +132,7 @@ class ConsoleFileManager extends FileManager { def setupPack() { NestUI.verbose("Running build/pack") - // latestFile = prefixFile("build/pack/bin") + latestFile = prefixFile("build/pack/bin") latestLibFile = prefixFile("build/pack/lib/scala-library.jar") latestActorsFile = prefixFile("build/pack/lib/scala-actors.jar") latestReflectFile = prefixFile("build/pack/lib/scala-reflect.jar") @@ -175,7 +175,7 @@ class ConsoleFileManager extends FileManager { var LATEST_PARTEST: String = "" var LATEST_ACTORS: String = "" - // var latestFile: File = _ + var latestFile: File = _ var latestLibFile: File = _ var latestActorsFile: File = _ var latestReflectFile: File = _ @@ -187,7 +187,7 @@ class ConsoleFileManager extends FileManager { // initialize above fields findLatest() - // var testFiles: List[io.Path] = Nil + var testFiles: List[io.Path] = Nil def getFiles(kind: String, cond: Path => Boolean): List[File] = { def ignoreDir(p: Path) = List("svn", "obj") exists (p hasExtension _) @@ -197,7 +197,9 @@ class ConsoleFileManager extends FileManager { if (dir.isDirectory) NestUI.verbose("look in %s for tests" format dir) else NestUI.failure("Directory '%s' not found" format dir) - val files = dir.list filterNot ignoreDir filter cond toList + val files = + if (testFiles.nonEmpty) testFiles filter (_.parent isSame dir) + else dir.list filterNot ignoreDir filter cond toList ( if (failed) files filter (x => logFileExists(x, kind)) else files ) map (_.jfile) } diff --git a/src/partest/scala/tools/partest/nest/ConsoleRunner.scala b/src/partest/scala/tools/partest/nest/ConsoleRunner.scala index 35bce01684..d23ee81e4d 100644 --- a/src/partest/scala/tools/partest/nest/ConsoleRunner.scala +++ b/src/partest/scala/tools/partest/nest/ConsoleRunner.scala @@ -51,7 +51,7 @@ class ConsoleRunner extends DirectRunner { private val testSetArgs = testSets map ("--" + _.kind) private val testSetArgMap = testSetArgs zip testSets toMap - // def denotesTestSet(arg: String) = testSetArgs contains arg + def denotesTestSet(arg: String) = testSetArgs contains arg private def printVersion() { NestUI outline (versionMsg + "\n") } diff --git a/src/partest/scala/tools/partest/nest/FileManager.scala b/src/partest/scala/tools/partest/nest/FileManager.scala index 9e2a34a34e..21fd314552 100644 --- a/src/partest/scala/tools/partest/nest/FileManager.scala +++ b/src/partest/scala/tools/partest/nest/FileManager.scala @@ -74,15 +74,15 @@ trait FileManager extends FileUtil { var timeout = PartestDefaults.timeout // how can 15 minutes not be enough? What are you doing, run/lisp.scala? // You complete in 11 seconds on my machine. - // var oneTestTimeout = 60 * 60 * 1000 + var oneTestTimeout = 60 * 60 * 1000 /** Only when --debug is given. */ lazy val testTimings = new mutable.HashMap[String, Long] def recordTestTiming(name: String, milliseconds: Long) = synchronized { testTimings(name) = milliseconds } - // def showTestTimings() { - // testTimings.toList sortBy (-_._2) foreach { case (k, v) => println("%s: %s".format(k, v)) } - // } + def showTestTimings() { + testTimings.toList sortBy (-_._2) foreach { case (k, v) => println("%s: %s".format(k, v)) } + } def getLogFile(dir: File, fileBase: String, kind: String): File = new File(dir, fileBase + "-" + kind + ".log") diff --git a/src/partest/scala/tools/partest/nest/NestUI.scala b/src/partest/scala/tools/partest/nest/NestUI.scala index 00aa27bd34..70db6d0ed1 100644 --- a/src/partest/scala/tools/partest/nest/NestUI.scala +++ b/src/partest/scala/tools/partest/nest/NestUI.scala @@ -54,9 +54,9 @@ object NestUI { } def warning(msg: String) = print(_warning + msg + _default) - // def warning(msg: String, wr: PrintWriter) = synchronized { - // wr.print(_warning + msg + _default) - // } + def warning(msg: String, wr: PrintWriter) = synchronized { + wr.print(_warning + msg + _default) + } def normal(msg: String) = print(_default + msg) def normal(msg: String, wr: PrintWriter) = synchronized { @@ -104,7 +104,7 @@ object NestUI { } var _verbose = false - // var _debug = false + var _debug = false def verbose(msg: String) { if (_verbose) { @@ -112,10 +112,10 @@ object NestUI { println(msg) } } - // def debug(msg: String) { - // if (isPartestDebug) { - // outline("debug: ") - // println(msg) - // } - // } + def debug(msg: String) { + if (isPartestDebug) { + outline("debug: ") + println(msg) + } + } } diff --git a/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala b/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala index 4b0ed1f82a..5cb8589d66 100644 --- a/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala +++ b/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala @@ -3,6 +3,8 @@ * @author Philipp Haller */ +// $Id$ + package scala.tools.partest package nest @@ -10,6 +12,7 @@ import scala.tools.nsc.Properties.{ setProp, propOrEmpty } import scala.tools.nsc.util.ClassPath import scala.tools.nsc.io import io.Path +import RunnerUtils._ import java.net.URLClassLoader /* This class is used to load an instance of DirectRunner using @@ -25,12 +28,6 @@ class ReflectiveRunner { // was used to start the runner. val sepRunnerClassName = "scala.tools.partest.nest.ConsoleRunner" - private def searchPath(option: String, as: List[String]): Option[String] = as match { - case `option` :: r :: _ => Some(r) - case _ :: rest => searchPath(option, rest) - case Nil => None - } - def main(args: String) { val argList = (args.split("\\s")).toList diff --git a/src/partest/scala/tools/partest/nest/RunnerManager.scala b/src/partest/scala/tools/partest/nest/RunnerManager.scala index 2651088018..548c5abbd9 100644 --- a/src/partest/scala/tools/partest/nest/RunnerManager.scala +++ b/src/partest/scala/tools/partest/nest/RunnerManager.scala @@ -291,10 +291,10 @@ class RunnerManager(kind: String, val fileManager: FileManager, params: TestRunP ((swr, wr)) } - // def fail(what: Any) = { - // NestUI.verbose("scalac: compilation of "+what+" failed\n") - // false - // } + def fail(what: Any) = { + NestUI.verbose("scalac: compilation of "+what+" failed\n") + false + } def diffCheck(testFile: File, diff: String) = { testDiff = diff testDiff == "" diff --git a/src/partest/scala/tools/partest/nest/RunnerUtils.scala b/src/partest/scala/tools/partest/nest/RunnerUtils.scala index 8a47989b7c..6707a9338a 100644 --- a/src/partest/scala/tools/partest/nest/RunnerUtils.scala +++ b/src/partest/scala/tools/partest/nest/RunnerUtils.scala @@ -1,29 +1,29 @@ -// /* NEST (New Scala Test) -// * Copyright 2007-2013 LAMP/EPFL -// * @author Philipp Haller -// */ +/* NEST (New Scala Test) + * Copyright 2007-2013 LAMP/EPFL + * @author Philipp Haller + */ -// // $Id$ +// $Id$ -// package scala.tools.partest -// package nest +package scala.tools.partest +package nest -// object RunnerUtils { -// def splitArgs(str: String) = str split "\\s" filterNot (_ == "") toList +object RunnerUtils { + def splitArgs(str: String) = str split "\\s" filterNot (_ == "") toList -// def searchPath(option: String, as: List[String]): Option[String] = as match { -// case `option` :: r :: _ => Some(r) -// case _ :: rest => searchPath(option, rest) -// case Nil => None -// } + def searchPath(option: String, as: List[String]): Option[String] = as match { + case `option` :: r :: _ => Some(r) + case _ :: rest => searchPath(option, rest) + case Nil => None + } -// def searchAndRemovePath(option: String, as: List[String]) = (as indexOf option) match { -// case -1 => (None, as) -// case idx => (Some(as(idx + 1)), (as take idx) ::: (as drop (idx + 2))) -// } + def searchAndRemovePath(option: String, as: List[String]) = (as indexOf option) match { + case -1 => (None, as) + case idx => (Some(as(idx + 1)), (as take idx) ::: (as drop (idx + 2))) + } -// def searchAndRemoveOption(option: String, as: List[String]) = (as indexOf option) match { -// case -1 => (false, as) -// case idx => (true, (as take idx) ::: (as drop (idx + 1))) -// } -// } + def searchAndRemoveOption(option: String, as: List[String]) = (as indexOf option) match { + case -1 => (false, as) + case idx => (true, (as take idx) ::: (as drop (idx + 1))) + } +} diff --git a/src/partest/scala/tools/partest/package.scala b/src/partest/scala/tools/partest/package.scala index fa0c88a2b2..58cc7d5b0b 100644 --- a/src/partest/scala/tools/partest/package.scala +++ b/src/partest/scala/tools/partest/package.scala @@ -13,9 +13,9 @@ import java.util.concurrent.Callable package partest { class TestState { - // def isOk = this eq TestState.Ok - // def isFail = this eq TestState.Fail - // def isTimeout = this eq TestState.Timeout + def isOk = this eq TestState.Ok + def isFail = this eq TestState.Fail + def isTimeout = this eq TestState.Timeout } object TestState { val Ok = new TestState @@ -43,7 +43,7 @@ package object partest { def callable[T](body: => T): Callable[T] = new Callable[T] { override def call() = body } - // def path2String(path: String) = file2String(new JFile(path)) + def path2String(path: String) = file2String(new JFile(path)) def file2String(f: JFile) = try SFile(f).slurp(scala.io.Codec.UTF8) catch { case _: FileNotFoundException => "" } diff --git a/src/partest/scala/tools/partest/utils/PrintMgr.scala b/src/partest/scala/tools/partest/utils/PrintMgr.scala index 56fdcda2ea..d25be87c1e 100644 --- a/src/partest/scala/tools/partest/utils/PrintMgr.scala +++ b/src/partest/scala/tools/partest/utils/PrintMgr.scala @@ -1,52 +1,52 @@ -// /* __ *\ -// ** ________ ___ / / ___ Scala Parallel Testing ** -// ** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** -// ** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -// ** /____/\___/_/ |_/____/_/ | | ** -// ** |/ ** -// \* */ - -// // $Id$ - -// package scala.tools.partest -// package utils - -// /** -// * @author Thomas Hofer -// */ -// object PrintMgr { - -// val NONE = 0 -// val SOME = 1 -// val MANY = 2 - -// var outline = "" -// var success = "" -// var failure = "" -// var warning = "" -// var default = "" - -// def initialization(number: Int) = number match { -// case MANY => -// outline = Console.BOLD + Console.BLACK -// success = Console.BOLD + Console.GREEN -// failure = Console.BOLD + Console.RED -// warning = Console.BOLD + Console.YELLOW -// default = Console.RESET -// case SOME => -// outline = Console.BOLD + Console.BLACK -// success = Console.RESET -// failure = Console.BOLD + Console.BLACK -// warning = Console.BOLD + Console.BLACK -// default = Console.RESET -// case _ => -// } - -// def printOutline(msg: String) = print(outline + msg + default) - -// def printSuccess(msg: String) = print(success + msg + default) - -// def printFailure(msg: String) = print(failure + msg + default) - -// def printWarning(msg: String) = print(warning + msg + default) -// } +/* __ *\ +** ________ ___ / / ___ Scala Parallel Testing ** +** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id$ + +package scala.tools.partest +package utils + +/** + * @author Thomas Hofer + */ +object PrintMgr { + + val NONE = 0 + val SOME = 1 + val MANY = 2 + + var outline = "" + var success = "" + var failure = "" + var warning = "" + var default = "" + + def initialization(number: Int) = number match { + case MANY => + outline = Console.BOLD + Console.BLACK + success = Console.BOLD + Console.GREEN + failure = Console.BOLD + Console.RED + warning = Console.BOLD + Console.YELLOW + default = Console.RESET + case SOME => + outline = Console.BOLD + Console.BLACK + success = Console.RESET + failure = Console.BOLD + Console.BLACK + warning = Console.BOLD + Console.BLACK + default = Console.RESET + case _ => + } + + def printOutline(msg: String) = print(outline + msg + default) + + def printSuccess(msg: String) = print(success + msg + default) + + def printFailure(msg: String) = print(failure + msg + default) + + def printWarning(msg: String) = print(warning + msg + default) +} |