Skip to content

Commit

Permalink
Merge pull request #127 from Banno/failure-pool-name
Browse files Browse the repository at this point in the history
Add non-trivial pool names to failure output
  • Loading branch information
joshschriever committed Sep 8, 2023
2 parents 9047d17 + 9118241 commit f065d05
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions gordon-plugin/src/main/kotlin/com/banno/gordon/TestResults.kt
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ internal fun Map<PoolName, Map<TestCase, TestResult>>.junitReports() =
is TestResult.NotRun -> element("error", "Unable to run test")
is TestResult.Failed -> element(
"failure",
result.failures.concatFailures()
result.failures.concatFailures(poolName = poolName)
)
is TestResult.Flaky -> element(
"system-err",
result.failures.concatFailures()
result.failures.concatFailures(poolName = poolName)
)
is TestResult.Passed -> Unit
}
Expand All @@ -96,10 +96,14 @@ internal fun Map<PoolName, Map<TestCase, TestResult>>.junitReports() =
}
}

private fun List<Failure>.concatFailures(): String = mapIndexed { index, it ->
"\n\nFailure ${index + 1}\nDevice: ${it.deviceSerial}\n${it.shellOutput}"
}
.joinToString(separator = "\n")
fun List<Failure>.concatFailures(poolName: PoolName): String = withIndex().flatMap { (index, failure) ->
listOfNotNull(
"\n\nFailure ${index + 1}",
"Pool: $poolName".takeIf { poolName !in setOf("All-Devices", failure.deviceSerial) },
"Device: ${failure.deviceSerial}",
failure.shellOutput
)
}.joinToString(separator = "\n")

private fun TestResult.duration(): Float? = when (this) {
is TestResult.Passed -> duration
Expand Down

0 comments on commit f065d05

Please sign in to comment.