Skip to content

Commit 8dc162c

Browse files
committed
Preserve stack trace when invoking main in run tests
1 parent c8321d6 commit 8dc162c

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

compiler/test/dotty/tools/dotc/ParallelTesting.scala

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -406,8 +406,12 @@ trait ParallelTesting {
406406

407407
private final class RunTest(testSources: List[TestSource], times: Int, threadLimit: Option[Int], suppressAllOutput: Boolean)
408408
extends Test(testSources, times, threadLimit, suppressAllOutput) {
409-
410409
private def runMain(dir: JFile, testSource: TestSource): Array[String] = {
410+
def renderStackTrace(ex: Throwable): String =
411+
ex.getStackTrace
412+
.takeWhile(_.getMethodName != "invoke0")
413+
.mkString(" ", "\n ", "")
414+
411415
import java.io.ByteArrayOutputStream
412416
import java.net.{ URL, URLClassLoader }
413417

@@ -424,15 +428,15 @@ trait ParallelTesting {
424428
}
425429
catch {
426430
case ex: NoSuchMethodException =>
427-
echo(s"test in '$dir' did not contain method: ${ex.getMessage} ")
431+
echo(s"test in '$dir' did not contain method: ${ex.getMessage}\n${renderStackTrace(ex.getCause)}")
428432
failTestSource(testSource)
429433

430434
case ex: ClassNotFoundException =>
431-
echo(s"test in '$dir' did not contain class: ${ex.getMessage} ")
435+
echo(s"test in '$dir' did not contain class: ${ex.getMessage}\n${renderStackTrace(ex.getCause)}")
432436
failTestSource(testSource)
433437

434438
case ex: InvocationTargetException =>
435-
echo(s"An exception ocurred when running main: ${ex.getCause} ")
439+
echo(s"An exception ocurred when running main: ${ex.getCause}\n${renderStackTrace(ex.getCause)}")
436440
failTestSource(testSource)
437441
}
438442
printStream.toString("utf-8").lines.toArray

0 commit comments

Comments
 (0)