From 8dc162cf28a3e2dfa6923730c3304467b12c5b78 Mon Sep 17 00:00:00 2001 From: Felix Mulder Date: Tue, 28 Mar 2017 16:34:23 +0200 Subject: Preserve stack trace when invoking main in run tests --- compiler/test/dotty/tools/dotc/ParallelTesting.scala | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'compiler/test/dotty/tools/dotc') diff --git a/compiler/test/dotty/tools/dotc/ParallelTesting.scala b/compiler/test/dotty/tools/dotc/ParallelTesting.scala index 6fedfe379..c01c444b2 100644 --- a/compiler/test/dotty/tools/dotc/ParallelTesting.scala +++ b/compiler/test/dotty/tools/dotc/ParallelTesting.scala @@ -406,8 +406,12 @@ trait ParallelTesting { private final class RunTest(testSources: List[TestSource], times: Int, threadLimit: Option[Int], suppressAllOutput: Boolean) extends Test(testSources, times, threadLimit, suppressAllOutput) { - private def runMain(dir: JFile, testSource: TestSource): Array[String] = { + def renderStackTrace(ex: Throwable): String = + ex.getStackTrace + .takeWhile(_.getMethodName != "invoke0") + .mkString(" ", "\n ", "") + import java.io.ByteArrayOutputStream import java.net.{ URL, URLClassLoader } @@ -424,15 +428,15 @@ trait ParallelTesting { } catch { case ex: NoSuchMethodException => - echo(s"test in '$dir' did not contain method: ${ex.getMessage} ") + echo(s"test in '$dir' did not contain method: ${ex.getMessage}\n${renderStackTrace(ex.getCause)}") failTestSource(testSource) case ex: ClassNotFoundException => - echo(s"test in '$dir' did not contain class: ${ex.getMessage} ") + echo(s"test in '$dir' did not contain class: ${ex.getMessage}\n${renderStackTrace(ex.getCause)}") failTestSource(testSource) case ex: InvocationTargetException => - echo(s"An exception ocurred when running main: ${ex.getCause} ") + echo(s"An exception ocurred when running main: ${ex.getCause}\n${renderStackTrace(ex.getCause)}") failTestSource(testSource) } printStream.toString("utf-8").lines.toArray -- cgit v1.2.3