in plugin-bazel-event-service/src/main/kotlin/bazel/handlers/build/TestResultHandler.kt [25:83]
override fun handle(ctx: BuildEventHandlerContext): Boolean {
if (!ctx.event.hasTestResult()) {
return false
}
val event = ctx.event.testResult
if (ctx.verbosity.atLeast(Verbosity.Detailed)) {
val id = ctx.event.id
val status = testStatusConverter.convert(event.status)
val testAttemptDurationMillis =
event.testAttemptDuration
.let { Duration.ofSeconds(it.seconds, it.nanos.toLong()) }
.toMillis()
ctx.writer.message(
buildString {
append("${id.testResult.label} test:")
append(" $status ".apply(status.toColor()))
if (ctx.verbosity.atLeast(Verbosity.Verbose)) {
append(", details: \"${event.statusDetails}\"".apply(Color.Details))
append(
(
", attempt: ${id.testResult.attempt}" +
", runs: ${id.testResult.run}" +
", shard: ${id.testResult.shard}" +
", duration: $testAttemptDurationMillis(ms)" +
", cached locally: ${event.cachedLocally}"
).apply(Color.Details),
)
}
},
)
}
val tests = event.testActionOutputList.map { fileConverter.convert(it) }
if (ctx.verbosity.atLeast(Verbosity.Verbose)) {
tests.forEach { test ->
if (ctx.verbosity.atLeast(Verbosity.Verbose)) {
ctx.writer.message("$test".apply(Color.Items))
}
}
}
val isLastAttempt = ctx.event.childrenList.isEmpty()
if (isLastAttempt) {
tests
.filter { it.name.endsWith(".xml") || it.name.endsWith(".log") }
.forEach { testResults ->
readTestResults(
ctx,
testResults,
isRemoteCacheHit = event.executionInfo.cachedRemotely,
)
}
}
return true
}