summaryrefslogtreecommitdiff
path: root/src/partest
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2010-04-06 05:18:46 +0000
committerPaul Phillips <paulp@improving.org>2010-04-06 05:18:46 +0000
commit4ca7a22d9e7a60df735aaa25beed6c48d011d161 (patch)
tree3479dd4cbb74ed76f3f3f932b24d266d3b337a34 /src/partest
parent4aa006cecdea7efc79e7aee92c56ad21ee58d154 (diff)
downloadscala-4ca7a22d9e7a60df735aaa25beed6c48d011d161.tar.gz
scala-4ca7a22d9e7a60df735aaa25beed6c48d011d161.tar.bz2
scala-4ca7a22d9e7a60df735aaa25beed6c48d011d161.zip
A couple more bits of partest I discovered were...
A couple more bits of partest I discovered weren't doing their jobs. Some of my classiest messages were going unheard! No review.
Diffstat (limited to 'src/partest')
-rw-r--r--src/partest/scala/tools/partest/Entities.scala6
-rw-r--r--src/partest/scala/tools/partest/Housekeeping.scala36
-rw-r--r--src/partest/scala/tools/partest/Results.scala1
-rw-r--r--src/partest/scala/tools/partest/package.scala18
4 files changed, 33 insertions, 28 deletions
diff --git a/src/partest/scala/tools/partest/Entities.scala b/src/partest/scala/tools/partest/Entities.scala
index aea794d793..ad1a396902 100644
--- a/src/partest/scala/tools/partest/Entities.scala
+++ b/src/partest/scala/tools/partest/Entities.scala
@@ -66,10 +66,8 @@ trait Entities {
def allSteps = testSequence.actions forall (f => f(this))
val outcome = runWrappers(preCheck && allSteps)
- // if outcome is empty, the JVM is trying to shut down, so we clam up
- // to avoid echoing lots of spurious failure messages.
- if (outcome.isEmpty && !isShuttingDown) setShuttingDown()
- else outcome getOrElse false
+ // an empty outcome means we've been interrupted and are shutting down.
+ outcome getOrElse false
}
}
diff --git a/src/partest/scala/tools/partest/Housekeeping.scala b/src/partest/scala/tools/partest/Housekeeping.scala
index 3a092a4782..a624ca8adb 100644
--- a/src/partest/scala/tools/partest/Housekeeping.scala
+++ b/src/partest/scala/tools/partest/Housekeeping.scala
@@ -5,8 +5,10 @@
package scala.tools
package partest
+import scala.util.control.Exception.catching
import util._
import nsc.io._
+import Process.runtime
import Properties._
/** An agglomeration of code which is low on thrills. Hopefully
@@ -17,14 +19,37 @@ trait Housekeeping {
self: Universe =>
/** Orderly shutdown on ctrl-C. */
- private var _shuttingDown = false
+ @volatile private var _shuttingDown = false
protected def setShuttingDown() = {
- warning("Received shutdown signal, partest is cleaning up...\n")
- _shuttingDown = true
- false
+ /** Whatever we want to do as shutdown begins goes here. */
+ if (!_shuttingDown) {
+ warning("Received shutdown signal, partest is cleaning up...\n")
+ _shuttingDown = true
+ }
}
def isShuttingDown = _shuttingDown
+ /** Execute some code with a shutdown hook in place. This is
+ * motivated by the desire not to leave the filesystem full of
+ * junk when someone ctrl-Cs a test run.
+ */
+ def withShutdownHook[T](hook: => Unit)(body: => T): Option[T] =
+ /** Java doesn't like it if you keep adding and removing shutdown
+ * hooks after shutdown has begun, so we trap the failure.
+ */
+ catching(classOf[IllegalStateException]) opt {
+ val t = new Thread() {
+ override def run() = {
+ setShuttingDown()
+ hook
+ }
+ }
+ runtime addShutdownHook t
+
+ try body
+ finally runtime removeShutdownHook t
+ }
+
/** Search for a directory, possibly given only a name, by starting
* at the current dir and walking upward looking for it at each level.
*/
@@ -134,11 +159,12 @@ trait Housekeeping {
outDir createDirectory true
}
def deleteOutDir() = outDir.deleteRecursively()
+ def deleteShutdownHook() = { debug("Shutdown hook deleting " + outDir) ; deleteOutDir() }
protected def runWrappers[T](body: => T): Option[T] = {
prepareForTestRun()
- withShutdownHook({ debug("Shutdown hook deleting " + outDir) ; deleteOutDir }) {
+ withShutdownHook(deleteShutdownHook()) {
loggingOutAndErr {
val result = possiblyTimed { body }
if (!isNoCleanup)
diff --git a/src/partest/scala/tools/partest/Results.scala b/src/partest/scala/tools/partest/Results.scala
index a830652d5f..4e0c446788 100644
--- a/src/partest/scala/tools/partest/Results.scala
+++ b/src/partest/scala/tools/partest/Results.scala
@@ -10,7 +10,6 @@ import scala.collection.immutable
trait Results {
self: Universe =>
-
/** A collection of tests for a Worker.
*/
case class TestsToRun(entities: List[TestEntity])
diff --git a/src/partest/scala/tools/partest/package.scala b/src/partest/scala/tools/partest/package.scala
index abab74de6e..78dd8d569c 100644
--- a/src/partest/scala/tools/partest/package.scala
+++ b/src/partest/scala/tools/partest/package.scala
@@ -4,10 +4,8 @@
package scala.tools
-import scala.util.control.Exception.catching
import nsc.io.{ File, Path, Process, Directory }
import nsc.util.CommandLineSpec
-import Process.runtime
import java.nio.charset.CharacterCodingException
package object partest {
@@ -43,22 +41,6 @@ package object partest {
exit(1)
}
- /** Execute some code with a shutdown hook in place. This is
- * motivated by the desire not to leave the filesystem full of
- * junk when someone ctrl-Cs a test run.
- */
- def withShutdownHook[T](hook: => Unit)(body: => T): Option[T] =
- /** Java doesn't like it if you keep adding and removing shutdown
- * hooks after shutdown has begun, so we trap the failure.
- */
- catching(classOf[IllegalStateException]) opt {
- val t = new Thread() { override def run() = hook }
- runtime addShutdownHook t
-
- try body
- finally runtime removeShutdownHook t
- }
-
/** Apply a function and return the passed value */
def returning[T](x: T)(f: T => Unit): T = { f(x) ; x }
} \ No newline at end of file