@@ -5,6 +5,7 @@ import org.utbot.framework.plugin.api.UtConcreteExecutionFailure
55import org.utbot.framework.plugin.api.UtExecution
66import org.utbot.framework.plugin.api.UtExecutionFailure
77import org.utbot.framework.plugin.api.UtExecutionResult
8+ import org.utbot.framework.plugin.api.UtExecutionSuccess
89import org.utbot.framework.plugin.api.UtSymbolicExecution
910import org.utbot.framework.util.calculateSize
1011import org.utbot.fuzzer.UtFuzzedExecution
@@ -41,9 +42,23 @@ fun <T : Any> minimizeTestCase(
4142
4243fun minimizeExecutions (executions : List <UtExecution >): List <UtExecution > {
4344 val unknownCoverageExecutions =
44- executions.filter { it.coverage?.coveredInstructions.isNullOrEmpty() }.toSet()
45- // ^^^ here we add executions with empty or null coverage, because it happens only if a concrete execution failed,
46- // so we don't know the actual coverage for such executions
45+ executions
46+ .filter { it.coverage?.coveredInstructions.isNullOrEmpty() }
47+ .groupBy {
48+ it.result.javaClass to (
49+ (it.result as ? UtExecutionSuccess )?.model ? : (it.result as ? UtExecutionFailure )?.exception
50+ )?.javaClass
51+ }
52+ .values
53+ .flatMap { executionsGroup ->
54+ val executionToSize = executionsGroup.associateWith { it.stateBefore.calculateSize() }
55+ executionsGroup
56+ .sortedBy { executionToSize[it] }
57+ .take(UtSettings .maxUnknownCoverageExecutionsPerMethodPerResultType)
58+ }
59+ .toSet()
60+ // Here we add executions with empty or null coverage, because if concrete execution failed, we don't know actual coverage.
61+ // The amount of such executions is limited with [UtSettings.maxUnknownCoverageExecutionsPerMethodPerResultType].
4762
4863 val filteredExecutions = filterOutDuplicateCoverages(executions - unknownCoverageExecutions)
4964 val (mapping, executionToPriorityMapping) = buildMapping(filteredExecutions)
0 commit comments