diff options
author | Paul Phillips <paulp@improving.org> | 2010-12-30 03:13:38 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-12-30 03:13:38 +0000 |
commit | 3ec0583fb6724416d5ebda8a927bbdecc23ebef5 (patch) | |
tree | 6ff6cdd93812393dc145bb36b4644775a842fde0 /src/partest | |
parent | cf49fb332626621f3443f15cb9e4cc5339a7a748 (diff) | |
download | scala-3ec0583fb6724416d5ebda8a927bbdecc23ebef5.tar.gz scala-3ec0583fb6724416d5ebda8a927bbdecc23ebef5.tar.bz2 scala-3ec0583fb6724416d5ebda8a927bbdecc23ebef5.zip |
It's all partest freeze debugging. No review.
Diffstat (limited to 'src/partest')
-rw-r--r-- | src/partest/scala/tools/partest/nest/DirectRunner.scala | 7 | ||||
-rw-r--r-- | src/partest/scala/tools/partest/nest/FileManager.scala | 1 | ||||
-rw-r--r-- | src/partest/scala/tools/partest/nest/Worker.scala | 61 |
3 files changed, 53 insertions, 16 deletions
diff --git a/src/partest/scala/tools/partest/nest/DirectRunner.scala b/src/partest/scala/tools/partest/nest/DirectRunner.scala index d15f851ffc..ce35a830cb 100644 --- a/src/partest/scala/tools/partest/nest/DirectRunner.scala +++ b/src/partest/scala/tools/partest/nest/DirectRunner.scala @@ -51,6 +51,13 @@ trait DirectRunner { println("Dumping partest internals.") println("results.size = " + results.size + ", " + workers.size + " workers.") workers foreach println + workers filter (_.currentFileElapsed > 60) foreach { w => + val elapsed = w.currentFileElapsed + println("A worker requires euthanasia! At least so it seems, since I received") + println("a signal and this one has been in la-la land for " + elapsed + " seconds.") + println("Attempting to force test timeout.") + w.forceTimeout() + } } def runTestsForFiles(_kindFiles: List[File], kind: String): immutable.Map[String, Int] = { diff --git a/src/partest/scala/tools/partest/nest/FileManager.scala b/src/partest/scala/tools/partest/nest/FileManager.scala index 35f4494f65..13afc5b34b 100644 --- a/src/partest/scala/tools/partest/nest/FileManager.scala +++ b/src/partest/scala/tools/partest/nest/FileManager.scala @@ -50,6 +50,7 @@ trait FileManager { var SCALAC_OPTS = PartestDefaults.scalacOpts var JAVA_OPTS = PartestDefaults.javaOpts var timeout = PartestDefaults.timeout + var oneTestTimeout = 5 * 60 * 1000 // if one test takes over 5 minutes it must go /** Only when --debug is given. */ lazy val testTimings = new HashMap[String, Long] diff --git a/src/partest/scala/tools/partest/nest/Worker.scala b/src/partest/scala/tools/partest/nest/Worker.scala index 734404bf1c..ef0a1e910c 100644 --- a/src/partest/scala/tools/partest/nest/Worker.scala +++ b/src/partest/scala/tools/partest/nest/Worker.scala @@ -116,15 +116,54 @@ class Worker(val fileManager: FileManager, params: TestRunParams) extends Actor else fileManager.JAVAC_CMD + private var currentTimerTask: KickableTimerTask = _ + + def cancelTimerTask() = if (currentTimerTask != null) currentTimerTask.cancel() + def updateTimerTask(body: => Unit) = { + cancelTimerTask() + currentTimerTask = new KickableTimerTask(body) + timer.schedule(currentTimerTask, fileManager.oneTestTimeout) + } + + class KickableTimerTask(body: => Unit) extends TimerTask { + def run() = body + def kick() = { + cancel() + body + } + } + /** Formerly deeper inside, these next few things are now promoted outside so * I can see what they're doing when the world comes to a premature stop. */ private val filesRemaining = new mutable.HashSet[File] private def addFilesRemaining(xs: Traversable[File]) = filesRemaining ++= xs private var currentTestFile: File = _ + private var currentFileStart: Long = System.currentTimeMillis + + def currentFileElapsed = (System.currentTimeMillis - currentFileStart) / 1000 + def forceTimeout() = { + println("Let's see what them threads are doing before I kill that test.") + system.allThreads foreach { t => + println(t) + t.getStackTrace foreach println + println("") + } + currentTimerTask.kick() + } + + private def currentFileString = { + "Current test file is: %s\n Started: %s (%s seconds ago)\n Current time: %s".format( + currentTestFile, + new java.util.Date(currentFileStart), + currentFileElapsed, + new java.util.Date() + ) + } private def getNextFile() = synchronized { currentTestFile = filesRemaining.head filesRemaining -= currentTestFile + currentFileStart = System.currentTimeMillis currentTestFile } // maps canonical file names to the test result (0: OK, 1: FAILED, 2: TIMOUT) @@ -133,8 +172,8 @@ class Worker(val fileManager: FileManager, params: TestRunParams) extends Actor status(key) = num } override def toString = ( - ">> Partest Worker:\n" + - "Current test file is: " + currentTestFile + "\n" + + ">> Partest Worker in state " + getState + ":\n" + + currentFileString + "There are " + filesRemaining.size + " files remaining:\n" + filesRemaining.toList.sortBy(_.toString).map(" " + _ + "\n").mkString("") + "\nstatus hashmap contains " + status.size + " entries:\n" + @@ -485,15 +524,6 @@ class Worker(val fileManager: FileManager, params: TestRunParams) extends Actor runTestCommon(file, kind, expectFailure = false)((logFile, outDir) => { val fileBase = basename(file.getName) val dir = file.getParentFile - - //TODO: detect whether we have to use Runtime.exec - // val useRuntime = true - // - // if (useRuntime) - // execTest(outDir, logFile, fileBase) - // else - // execTestObjectRunner(file, outDir, logFile) - // // NestUI.verbose(this+" finished running "+fileBase) execTest(outDir, logFile, fileBase) diffCheck(compareOutput(dir, fileBase, kind, logFile)) @@ -1022,10 +1052,7 @@ class Worker(val fileManager: FileManager, params: TestRunParams) extends Actor actor { val testFile = getNextFile() - val ontimeout = new TimerTask { - def run() = parent ! Timeout(testFile) - } - timer.schedule(ontimeout, fileManager.timeout.toLong) + updateTimerTask(parent ! Timeout(testFile)) val context = try processSingleFile(testFile) @@ -1060,8 +1087,10 @@ class Worker(val fileManager: FileManager, params: TestRunParams) extends Actor if (logs != null) Some(logs.file) else None, if (logs != null) logs.writers else None) } - if (filesRemaining.isEmpty) + if (filesRemaining.isEmpty) { + cancelTimerTask() reportAll(status.toMap, topcont) + } } } } |