Skip to content

Commit

Permalink
Exlcude internal part of stacktraces from JUnit errpr reports (#3617)
Browse files Browse the repository at this point in the history
(cherry picked from commit 6ea76bc)
  • Loading branch information
WojciechMazur committed Jan 19, 2024
1 parent a8a3b5a commit 9e01148
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,18 +160,20 @@ private[junit] final class Reporter(
else Ansi.filterAnsi(s)

private def logTrace(t: Throwable): Unit = {
val trace = t.getStackTrace.dropWhile { p =>
p.getFileName != null && {
p.getFileName.contains("StackTrace.scala") ||
p.getFileName.contains("Throwables.scala")
val trace = t.getStackTrace
.dropWhile { p =>
p.getClassName() != null && {
p.getClassName().startsWith("java.lang.StackTrace") ||
p.getClassName().startsWith("java.lang.Throwable")
}
}
}
val testFileName = {
if (settings.color) findTestFileName(trace)
else null
}
val i = trace.indexWhere { p =>
p.getFileName != null && p.getFileName.contains("JUnitExecuteTest.scala")
p.getClassName() != null &&
p.getClassName().startsWith("scala.scalanative.junit.")
} - 1
val m = if (i > 0) i else trace.length - 1
logStackTracePart(trace, m, trace.length - m - 1, t, testFileName)
Expand Down

0 comments on commit 9e01148

Please sign in to comment.