diff options
author | Paul Phillips <paulp@improving.org> | 2010-04-12 16:11:36 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-04-12 16:11:36 +0000 |
commit | 6dd325002065e385bf4bb368542fb7b85509ed19 (patch) | |
tree | 8f0e09b76d5032f1d25b59f72e7f86ecbfd59d0f | |
parent | 7693ab0dec5e46a591db284ef148b3cff469163f (diff) | |
download | scala-6dd325002065e385bf4bb368542fb7b85509ed19.tar.gz scala-6dd325002065e385bf4bb368542fb7b85509ed19.tar.bz2 scala-6dd325002065e385bf4bb368542fb7b85509ed19.zip |
Some modifications to partest to improve output.
-rw-r--r-- | src/partest/scala/tools/partest/Actions.scala | 2 | ||||
-rw-r--r-- | src/partest/scala/tools/partest/Dispatcher.scala | 19 | ||||
-rw-r--r-- | src/partest/scala/tools/partest/Results.scala | 20 | ||||
-rw-r--r-- | src/partest/scala/tools/partest/io/Logging.scala | 5 |
4 files changed, 28 insertions, 18 deletions
diff --git a/src/partest/scala/tools/partest/Actions.scala b/src/partest/scala/tools/partest/Actions.scala index 48b80cface..15351db2a7 100644 --- a/src/partest/scala/tools/partest/Actions.scala +++ b/src/partest/scala/tools/partest/Actions.scala @@ -54,7 +54,7 @@ trait Actions { proc = Process.exec(toArgs(cmd), execEnv, execCwd.orNull, true) proc.slurp() } - proc.waitFor() == 0 + proc != null && (proc.waitFor() == 0) } result getOrElse { warning("Process never terminated: '%s'" format cmd) diff --git a/src/partest/scala/tools/partest/Dispatcher.scala b/src/partest/scala/tools/partest/Dispatcher.scala index 2c7d9d6a2f..2a9d99ab60 100644 --- a/src/partest/scala/tools/partest/Dispatcher.scala +++ b/src/partest/scala/tools/partest/Dispatcher.scala @@ -31,14 +31,14 @@ trait Dispatcher { val groups = selected groupBy (_.category) val count = selected.size - if (count == 0) return CombinedTestResults(0, 0, 0) + if (count == 0) return CombinedTestResults(0, 0, 0, Nil) else if (count == allTests.size) verbose("Running all %d tests." format count) else verbose("Running %d/%d tests: %s".format(count, allTests.size, toStringTrunc(selected map (_.label) mkString ", "))) allCategories collect { case x if groups contains x => runCategory(x, groups(x)) } reduceLeft (_ ++ _) } - private def parallelizeTests(tests: List[TestEntity]): immutable.Map[TestEntity, Int] = { + private def parallelizeTests(tests: List[TestEntity]): immutable.Map[TestEntity, TestResult] = { // propagate verbosity if (isDebug) scala.actors.Debug.level = 3 @@ -63,9 +63,9 @@ trait Dispatcher { case ResultsOfRun(resultMap) => resultMap case TIMEOUT => warning("Worker %d timed out." format w.workerNum) - immutable.Map[TestEntity, Int]() // mark all the worker's tests as having timed out - should be hard to miss - groups(w.workerNum) map (_ -> 2) toMap + // immutable.Map[TestEntity, TestResult]() + groups(w.workerNum) map (x => (x -> new Timeout(x))) toMap } }) reduceLeft (_ ++ _) } @@ -75,9 +75,10 @@ trait Dispatcher { normal("%s (%s tests in %s)\n".format(category.startMessage, tests.size, category)) val (milliSeconds, resultMap) = timed2(parallelizeTests(tests)) - val (passed, failed) = resultsToStatistics(resultMap) + val (passed, failed) = resultsToStatistics(resultMap mapValues (_.state)) + val failures = resultMap.values filterNot (_.passed) toList - CombinedTestResults(passed, failed, milliSeconds) + CombinedTestResults(passed, failed, milliSeconds, failures) } /** A Worker is given a bundle of tests and runs them all sequentially. @@ -92,8 +93,8 @@ trait Dispatcher { /** Runs the tests. Passes the result Map to onCompletion when done. */ - private def runTests(tests: List[TestEntity])(onCompletion: immutable.Map[TestEntity, Int] => Unit) { - var results = new immutable.HashMap[TestEntity, Int] // maps tests to results + private def runTests(tests: List[TestEntity])(onCompletion: immutable.Map[TestEntity, TestResult] => Unit) { + var results = new immutable.HashMap[TestEntity, TestResult] // maps tests to results val numberOfTests = tests.size val testIterator = tests.iterator def processed = results.size @@ -122,7 +123,7 @@ trait Dispatcher { return warning("Received duplicate result for %s: was %s, now %s".format(test, results(test), state)) // increment the counter for this result state - results += (test -> state) + results += (test -> result) // show on screen if (isDryRun) normal("\n") // blank line between dry run traces diff --git a/src/partest/scala/tools/partest/Results.scala b/src/partest/scala/tools/partest/Results.scala index 4e0c446788..8078e7bf85 100644 --- a/src/partest/scala/tools/partest/Results.scala +++ b/src/partest/scala/tools/partest/Results.scala @@ -16,7 +16,7 @@ trait Results { /** The response from a Worker who has been given TestsToRun. */ - case class ResultsOfRun(results: immutable.Map[TestEntity, Int]) + case class ResultsOfRun(results: immutable.Map[TestEntity, TestResult]) /** The result of a single test. (0: OK, 1: FAILED, 2: TIMEOUT) */ @@ -39,7 +39,7 @@ trait Results { case _ => false } override def hashCode = entity.hashCode - override def toString = "%s (%s)".format(entity, if (passed) "passed" else "failed") + override def toString = "%s [%s]".format(entity, description) } class Success(val entity: TestEntity) extends TestResult(0, " OK ") { @@ -58,6 +58,7 @@ trait Results { if (isShowLog || isTrace) normal(toStringTrunc(entity.failureMessage(), 1600)) } + override def toString = List(super.toString, toStringTrunc(entity.failureMessage(), 400)) mkString "\n" } class Timeout(val entity: TestEntity) extends TestResult(2, "TIME OUT") { def colorize(s: String) = markFailure(s) @@ -84,7 +85,8 @@ trait Results { case class CombinedTestResults( passed: Int, failed: Int, - elapsedMilliseconds: Long + elapsedMilliseconds: Long, + failures: List[TestResult] ) { // housekeeping val elapsedSecs = elapsedMilliseconds / 1000 @@ -100,14 +102,20 @@ trait Results { def ++(x: CombinedTestResults) = CombinedTestResults( passed + x.passed, failed + x.failed, - elapsedMilliseconds + x.elapsedMilliseconds + elapsedMilliseconds + x.elapsedMilliseconds, + failures ::: x.failures ) - def elapsedString = "%02d:%02d:%02d".format(elapsedHrs, dispMins, dispSecs) + def elapsedString = "%02d:%02d:%02d".format(elapsedHrs, dispMins, dispSecs) + def failuresString = { + if (failures.isEmpty) "" + else "Summary of failures:" :: failures mkString ("\n", "\n", "") + } + override def toString = if (total == 0) "There were no tests to run." else if (isDryRun) "%d tests would be run." format total - else if (hasFailures) "%d of %d tests failed (elapsed time: %s)".format(failed, total, elapsedString) + else if (hasFailures) "%d of %d tests failed (elapsed time: %s)".format(failed, total, elapsedString) + failuresString else "All %d tests were successful (elapsed time: %s)".format(total, elapsedString) } }
\ No newline at end of file diff --git a/src/partest/scala/tools/partest/io/Logging.scala b/src/partest/scala/tools/partest/io/Logging.scala index 3d1b0fa0b4..3667faaf3d 100644 --- a/src/partest/scala/tools/partest/io/Logging.scala +++ b/src/partest/scala/tools/partest/io/Logging.scala @@ -75,8 +75,9 @@ trait Logging { def loggingResult(body: => String) = try returning(true)(_ => logFile writeAll body) catch { - case x: ControlThrowable => throw x - case x: Throwable => logException(x) + case x: ControlThrowable => throw x + case x: InterruptedException => normal(this + " received interrupt, failing.\n") ; false + case x: Throwable => logException(x) } def throwableToString(x: Throwable): String = { |