@@ -5,6 +5,7 @@ import org.utbot.framework.plugin.api.UtConcreteExecutionFailure
5
5
import org.utbot.framework.plugin.api.UtExecution
6
6
import org.utbot.framework.plugin.api.UtExecutionFailure
7
7
import org.utbot.framework.plugin.api.UtExecutionResult
8
+ import org.utbot.framework.plugin.api.UtExecutionSuccess
8
9
import org.utbot.framework.plugin.api.UtSymbolicExecution
9
10
import org.utbot.framework.util.calculateSize
10
11
import org.utbot.fuzzer.UtFuzzedExecution
@@ -41,9 +42,23 @@ fun <T : Any> minimizeTestCase(
41
42
42
43
fun minimizeExecutions (executions : List <UtExecution >): List <UtExecution > {
43
44
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].
47
62
48
63
val filteredExecutions = filterOutDuplicateCoverages(executions - unknownCoverageExecutions)
49
64
val (mapping, executionToPriorityMapping) = buildMapping(filteredExecutions)
0 commit comments