diff --git a/test_runner/src/main/kotlin/ftl/reports/api/CreateJUnitTestSuite.kt b/test_runner/src/main/kotlin/ftl/reports/api/CreateJUnitTestSuite.kt index 6517630b04..bb5e9c05a7 100644 --- a/test_runner/src/main/kotlin/ftl/reports/api/CreateJUnitTestSuite.kt +++ b/test_runner/src/main/kotlin/ftl/reports/api/CreateJUnitTestSuite.kt @@ -38,6 +38,6 @@ private fun Step.testSuiteName(): String { return listOf(map["Model"], map["Version"], map["Locale"], map["Orientation"]).joinToString("-") } -private fun List.sumTime() = this +private fun List.sumTime(): Double = this .map { it.time?.toDouble() ?: 0.0 } .reduce { acc, d -> acc + d } diff --git a/test_runner/src/main/kotlin/ftl/reports/api/CreateTestExecutionData.kt b/test_runner/src/main/kotlin/ftl/reports/api/CreateTestExecutionData.kt index 95676b039f..027279eefe 100644 --- a/test_runner/src/main/kotlin/ftl/reports/api/CreateTestExecutionData.kt +++ b/test_runner/src/main/kotlin/ftl/reports/api/CreateTestExecutionData.kt @@ -1,6 +1,7 @@ package ftl.reports.api import com.google.api.services.testing.model.TestExecution +import com.google.api.services.testing.model.ToolResultsStep import com.google.api.services.toolresults.model.ListTestCasesResponse import com.google.api.services.toolresults.model.Step import com.google.api.services.toolresults.model.Timestamp @@ -9,6 +10,7 @@ import ftl.reports.api.data.TestExecutionData import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.async import kotlinx.coroutines.awaitAll +import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.runBlocking internal fun List.createTestExecutionDataListAsync(): List = runBlocking { @@ -21,17 +23,26 @@ internal fun List.createTestExecutionDataListAsync(): List diff --git a/test_runner/src/main/kotlin/ftl/reports/api/PrepareForJUnitResult.kt b/test_runner/src/main/kotlin/ftl/reports/api/PrepareForJUnitResult.kt index a072193f8f..5e8f75ca7f 100644 --- a/test_runner/src/main/kotlin/ftl/reports/api/PrepareForJUnitResult.kt +++ b/test_runner/src/main/kotlin/ftl/reports/api/PrepareForJUnitResult.kt @@ -28,9 +28,8 @@ private fun TestExecutionData.reduceTestCases() = copy( testCases.sortedBy { testCase: TestCase -> testCase.startTime.asUnixTimestamp() }.run { - firstOrNull { it.stackTraces != null } ?: first() - }.apply { - flaky = testCases.isFlaky() + if (!isFlaky()) first() + else first { it.stackTraces != null }.apply { flaky = true } } } ) diff --git a/test_runner/src/main/kotlin/ftl/reports/api/ProcessFromApi.kt b/test_runner/src/main/kotlin/ftl/reports/api/ProcessFromApi.kt index f5df139bdf..4fa9b952b2 100644 --- a/test_runner/src/main/kotlin/ftl/reports/api/ProcessFromApi.kt +++ b/test_runner/src/main/kotlin/ftl/reports/api/ProcessFromApi.kt @@ -21,7 +21,7 @@ fun processXmlFromApi( .getTestExecutions() .createJUnitTestResult() -internal fun refreshTestMatrices( +private fun refreshTestMatrices( matrixIds: List, projectId: String ): List = runBlocking { @@ -35,6 +35,6 @@ internal fun refreshTestMatrices( }.awaitAll() } -internal fun List.getTestExecutions(): List = this +private fun List.getTestExecutions(): List = this .map(TestMatrix::getTestExecutions) .flatten() diff --git a/test_runner/src/main/kotlin/ftl/reports/xml/JUnitXml.kt b/test_runner/src/main/kotlin/ftl/reports/xml/JUnitXml.kt index a4c14af8a5..cda3835a7f 100644 --- a/test_runner/src/main/kotlin/ftl/reports/xml/JUnitXml.kt +++ b/test_runner/src/main/kotlin/ftl/reports/xml/JUnitXml.kt @@ -18,7 +18,7 @@ private val xmlMapper = XmlMapper(xmlModule) internal val xmlPrettyWriter = xmlMapper.writerWithDefaultPrettyPrinter() private fun xmlBytes(path: Path): ByteArray { - if (!path.toFile().exists()) RuntimeException("$path doesn't exist!") + if (!path.toFile().exists()) throw RuntimeException("$path doesn't exist!") return Files.readAllBytes(path) }