diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 4ab6544099..eb2569e1ed 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,6 +1,6 @@ [versions] kotlin = "1.7.10" -save-core = "0.3.3" +save-core = "0.4.0-SNAPSHOT" ktor = "2.1.0" okio = "3.2.0" serialization = "1.4.0" diff --git a/save-agent/src/linuxX64Main/kotlin/com/saveourtool/save/agent/SaveAgent.kt b/save-agent/src/linuxX64Main/kotlin/com/saveourtool/save/agent/SaveAgent.kt index abdeadbac2..e0ac0a078d 100644 --- a/save-agent/src/linuxX64Main/kotlin/com/saveourtool/save/agent/SaveAgent.kt +++ b/save-agent/src/linuxX64Main/kotlin/com/saveourtool/save/agent/SaveAgent.kt @@ -260,12 +260,10 @@ class SaveAgent(private val config: AgentConfiguration, .unzip() } - @Suppress("MAGIC_NUMBER", "MagicNumber") private fun TestResultDebugInfo.getCountWarningsAsLong(getter: (CountWarnings) -> Int?) = this.debugInfo ?.countWarnings ?.let { getter(it) } ?.toLong() - ?: 0L private fun readExecutionReportFromFile(jsonFile: String): List { val jsonFileContent = readFile(jsonFile).joinToString(separator = "") diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/ExecutionLabels.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/ExecutionLabels.kt index 41073e8deb..c5b80aebef 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/ExecutionLabels.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/ExecutionLabels.kt @@ -7,6 +7,7 @@ package com.saveourtool.save.frontend.components.basic +import com.saveourtool.save.core.result.CountWarnings import com.saveourtool.save.execution.ExecutionDto import com.saveourtool.save.execution.ExecutionStatus import com.saveourtool.save.frontend.externals.fontawesome.faRedo @@ -96,13 +97,29 @@ internal class ExecutionStatisticsValues(executionDto: ExecutionDto?) { ?.let { calculateRate(it.passedTests, it.allTests) } ?: "0" this.precisionRate = executionDto - ?.let { calculateRate(it.matchedChecks, it.matchedChecks + it.unexpectedChecks) } + ?.let { + if (allApplicable(it.matchedChecks, it.unexpectedChecks)) { + calculateRate(it.matchedChecks, it.matchedChecks + it.unexpectedChecks) + } else { + "N/A" + } + } ?: "0" this.recallRate = executionDto - ?.let { calculateRate(it.matchedChecks, it.matchedChecks + it.unmatchedChecks) } + ?.let { + if (allApplicable(it.matchedChecks, it.unmatchedChecks)) { + calculateRate(it.matchedChecks, it.matchedChecks + it.unmatchedChecks) + } else { + "N/A" + } + } ?: "0" } + private fun allApplicable(vararg values: Long): Boolean { + return values.all { !CountWarnings.isNotApplicable(it.toInt()) } + } + private fun calculateRate(numerator: Long, denominator: Long) = denominator.takeIf { it > 0 } ?.run { numerator.toDouble() / denominator } ?.let { it * 100 } diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/ExecutionView.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/ExecutionView.kt index e8f87539cb..70b8c97a3c 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/ExecutionView.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/ExecutionView.kt @@ -6,6 +6,7 @@ package com.saveourtool.save.frontend.components.views import com.saveourtool.save.agent.TestExecutionDto import com.saveourtool.save.core.logging.describe +import com.saveourtool.save.core.result.CountWarnings import com.saveourtool.save.domain.TestResultDebugInfo import com.saveourtool.save.domain.TestResultStatus import com.saveourtool.save.execution.ExecutionDto @@ -130,14 +131,14 @@ class ExecutionView : AbstractView(false) { column(id = "missing", header = "Missing", { unmatched }) { Fragment.create { td { - +"${it.value ?: ""}" + +formatCounter(it.value) } } } column(id = "matched", header = "Matched", { matched }) { Fragment.create { td { - +"${it.value ?: ""}" + +formatCounter(it.value) } } } @@ -299,6 +300,14 @@ class ExecutionView : AbstractView(false) { } ) + private fun formatCounter(count: Long?): String = count?.let { + if (CountWarnings.isNotApplicable(it.toInt())) { + "N/A" + } else { + it.toString() + } + } ?: "" + init { state.executionDto = null state.filters = TestExecutionFilters.empty