summaryrefslogtreecommitdiff
path: root/test/files/run/repl-trim-stack-trace.scala
diff options
context:
space:
mode:
authorSom Snytt <som.snytt@gmail.com>2013-08-24 04:20:44 -0700
committerSom Snytt <som.snytt@gmail.com>2013-09-02 18:59:15 -0700
commit2fc528e0887b46a8dea403c1f8620ca8967c4b42 (patch)
tree578b50bc3cb03aeeae6d1359074f3d26b4af44cf /test/files/run/repl-trim-stack-trace.scala
parenta8c05274f738943ae58ecefda4b012b9daf5d8dc (diff)
downloadscala-2fc528e0887b46a8dea403c1f8620ca8967c4b42.tar.gz
scala-2fc528e0887b46a8dea403c1f8620ca8967c4b42.tar.bz2
scala-2fc528e0887b46a8dea403c1f8620ca8967c4b42.zip
SI-7781 REPL stack trunc shows cause
The handy stack trace truncation in REPL doesn't show cause like a regular trace. This commit fixes that and also adds the usual indicator for truncation, viz, "... 33 more". The example from the ticket produces: ``` scala> rewrapperer java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: Point of failure at .rewrapper(<console>:9) at .rewrapperer(<console>:10) ... 32 elided Caused by: java.lang.RuntimeException: java.lang.RuntimeException: Point of failure at .wrapper(<console>:8) ... 34 more Caused by: java.lang.RuntimeException: Point of failure at .sample(<console>:7) ... 35 more ``` Suppressed exceptions on Java 7 are handled reflectively. ``` java.lang.RuntimeException: My problem at scala.tools.nsc.util.StackTraceTest.repressed(StackTraceTest.scala:56) ... 27 elided Suppressed: java.lang.RuntimeException: Point of failure at scala.tools.nsc.util.StackTraceTest.sample(StackTraceTest.scala:29) at scala.tools.nsc.util.StackTraceTest.repressed(StackTraceTest.scala:54) ... 27 more ```
Diffstat (limited to 'test/files/run/repl-trim-stack-trace.scala')
-rw-r--r--test/files/run/repl-trim-stack-trace.scala8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/files/run/repl-trim-stack-trace.scala b/test/files/run/repl-trim-stack-trace.scala
index bbf46f2f19..db42b37fdd 100644
--- a/test/files/run/repl-trim-stack-trace.scala
+++ b/test/files/run/repl-trim-stack-trace.scala
@@ -13,6 +13,7 @@ f: Nothing
scala> f
java.lang.Exception: Uh-oh
at .f(<console>:7)
+ ... 69 elided
scala> def f = throw new Exception("")
f: Nothing
@@ -20,6 +21,7 @@ f: Nothing
scala> f
java.lang.Exception:
at .f(<console>:7)
+ ... 69 elided
scala> def f = throw new Exception
f: Nothing
@@ -27,7 +29,13 @@ f: Nothing
scala> f
java.lang.Exception
at .f(<console>:7)
+ ... 69 elided
scala> """
+ // remove the "elided" lines because the frame count is variable
+ lazy val elided = """\s+\.{3} (?:\d+) elided""".r
+ def filtered(lines: Seq[String]) = lines filter { case elided() => false ; case _ => true }
+ override def eval() = filtered(super.eval().toSeq).iterator
+ override def expected = filtered(super.expected).toList
}