Skip to content

Commit

Permalink
Make generate-junit-reports.sc script recover from test failures co…
Browse files Browse the repository at this point in the history
…ntaining no trace data (#3341)
  • Loading branch information
Gedochao authored Dec 3, 2024
1 parent 88a31cb commit dfa9f03
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions .github/scripts/generate-junit-reports.sc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import java.io.File
import scala.collection.mutable.ArrayBuffer
import scala.annotation.tailrec
import java.nio.file.Paths
import scala.util.Try

case class Trace(declaringClass: String, methodName: String, fileName: String, lineNumber: Int) {
override def toString: String = s"$declaringClass.$methodName($fileName:$lineNumber)"
Expand Down Expand Up @@ -97,11 +98,14 @@ val suites = tests.groupBy(_.fullyQualifiedName).map { case (suit, tests) =>
} time={test.duration.toString}>
{
test.failure.map { failure =>
val maybeTrace = Try(failure.trace(1)).toOption
val fileName = maybeTrace.map(_.fileName).getOrElse("unknown")
val lineNumber = maybeTrace.map(_.lineNumber).getOrElse(-1)
<failure message={failure.message} type="ERROR">
ERROR: {failure.message}
Category: {failure.name}
File: {failure.trace(1).fileName}
Line: {failure.trace(1).lineNumber}
File: {fileName}
Line: {lineNumber}
</failure>
}.orNull
}
Expand Down

0 comments on commit dfa9f03

Please sign in to comment.