@@ -5,6 +5,7 @@ import org.utbot.framework.plugin.api.ExecutableId
5
5
import org.utbot.framework.plugin.api.FieldId
6
6
import org.utbot.framework.plugin.api.UtClusterInfo
7
7
import org.utbot.framework.plugin.api.UtExecution
8
+ import org.utbot.framework.plugin.api.UtExecutionFailure
8
9
import org.utbot.framework.plugin.api.UtExecutionSuccess
9
10
import org.utbot.framework.plugin.api.UtMethodTestSet
10
11
import org.utbot.framework.plugin.api.util.executableId
@@ -36,12 +37,19 @@ data class CgMethodTestSet private constructor(
36
37
*/
37
38
fun splitExecutionsByResult () : List <CgMethodTestSet > {
38
39
val successfulExecutions = executions.filter { it.result is UtExecutionSuccess }
39
- val executionsByResult: Map <ClassId , List <UtExecution >> =
40
- if (successfulExecutions.isNotEmpty()) {
41
- successfulExecutions.groupBy { (it.result as UtExecutionSuccess ).model.classId }
42
- } else {
43
- mapOf (objectClassId to executions)
44
- }
40
+ val failureExecutions = executions.filter { it.result is UtExecutionFailure }
41
+
42
+ val executionsByResult: MutableMap <ClassId , List <UtExecution >> =
43
+ successfulExecutions
44
+ .groupBy { (it.result as UtExecutionSuccess ).model.classId }.toMutableMap()
45
+
46
+ // if we have failure executions, we add them to the first successful executions group
47
+ val groupClassId = executionsByResult.keys.firstOrNull()
48
+ if (groupClassId != null ) {
49
+ executionsByResult[groupClassId] = executionsByResult[groupClassId]!! + failureExecutions
50
+ } else {
51
+ executionsByResult[objectClassId] = failureExecutions
52
+ }
45
53
46
54
return executionsByResult.map{ (_, executions) -> substituteExecutions(executions) }
47
55
}
@@ -52,15 +60,8 @@ data class CgMethodTestSet private constructor(
52
60
* A separate test set is created for each combination of modified statics.
53
61
*/
54
62
fun splitExecutionsByChangedStatics (): List <CgMethodTestSet > {
55
- val successfulExecutions = executions.filter { it.result is UtExecutionSuccess }
56
63
val executionsByStaticsUsage: Map <Set <FieldId >, List <UtExecution >> =
57
- if (successfulExecutions.isNotEmpty()) {
58
- successfulExecutions.groupBy {
59
- it.stateBefore.statics.keys
60
- }
61
- } else {
62
- mapOf (executions.first().stateBefore.statics.keys to executions)
63
- }
64
+ executions.groupBy { it.stateBefore.statics.keys }
64
65
65
66
return executionsByStaticsUsage.map { (_, executions) -> substituteExecutions(executions) }
66
67
}
0 commit comments