@@ -2,18 +2,20 @@ package org.utbot.summary
2
2
3
3
import org.utbot.framework.plugin.api.Step
4
4
import org.utbot.framework.plugin.api.UtConcreteExecutionFailure
5
- import org.utbot.framework.plugin.api.UtSymbolicExecution
5
+ import org.utbot.framework.plugin.api.UtExecution
6
6
import org.utbot.framework.plugin.api.UtExecutionResult
7
7
import org.utbot.framework.plugin.api.UtExecutionSuccess
8
8
import org.utbot.framework.plugin.api.UtExplicitlyThrownException
9
9
import org.utbot.framework.plugin.api.UtImplicitlyThrownException
10
- import org.utbot.framework.plugin.api.UtOverflowFailure
11
10
import org.utbot.framework.plugin.api.UtMethodTestSet
11
+ import org.utbot.framework.plugin.api.UtOverflowFailure
12
12
import org.utbot.framework.plugin.api.UtSandboxFailure
13
13
import org.utbot.framework.plugin.api.UtStreamConsumingFailure
14
+ import org.utbot.framework.plugin.api.UtSymbolicExecution
14
15
import org.utbot.framework.plugin.api.UtTimeoutException
15
16
import org.utbot.framework.plugin.api.util.humanReadableName
16
17
import org.utbot.framework.plugin.api.util.isCheckedException
18
+ import org.utbot.fuzzer.UtFuzzedExecution
17
19
import org.utbot.summary.UtSummarySettings.MIN_NUMBER_OF_EXECUTIONS_FOR_CLUSTERING
18
20
import org.utbot.summary.clustering.MatrixUniqueness
19
21
import org.utbot.summary.clustering.SplitSteps
@@ -29,7 +31,7 @@ class TagGenerator {
29
31
30
32
if (clusteredExecutions.isNotEmpty()) {
31
33
val listOfSplitSteps = clusteredExecutions.map {
32
- val mUniqueness = MatrixUniqueness (it.executions)
34
+ val mUniqueness = MatrixUniqueness (it.executions as List < UtSymbolicExecution > )
33
35
mUniqueness.splitSteps()
34
36
}
35
37
@@ -64,7 +66,7 @@ class TagGenerator {
64
66
traceTagClusters.add(
65
67
TraceTagCluster (
66
68
cluster.header,
67
- generateExecutionTags(cluster.executions, splitSteps),
69
+ generateExecutionTags(cluster.executions as List < UtSymbolicExecution > , splitSteps),
68
70
TraceTagWithoutExecution (
69
71
commonStepsInCluster.toList(),
70
72
cluster.executions.first().result,
@@ -88,51 +90,67 @@ private fun generateExecutionTags(executions: List<UtSymbolicExecution>, splitSt
88
90
89
91
90
92
/* *
91
- * Splits executions into clusters
92
- * By default there is 5 types of clusters:
93
- * Success, UnexpectedFail, ExpectedCheckedThrow, ExpectedUncheckedThrow, UnexpectedUncheckedThrow
94
- * These are split by the type of execution result
93
+ * Splits executions with empty paths into clusters.
95
94
*
96
- * @return clustered executions
95
+ * @return clustered executions.
97
96
*/
98
97
fun groupExecutionsWithEmptyPaths (testSet : UtMethodTestSet ): List <ExecutionCluster > {
99
98
val methodExecutions = testSet.executions.filterIsInstance<UtSymbolicExecution >()
100
99
val clusters = mutableListOf<ExecutionCluster >()
101
- val commentPrefix = " OTHER:"
100
+ val commentPrefix = " OTHER:"
102
101
val commentPostfix = " for method ${testSet.method.humanReadableName} "
103
102
104
103
val grouped = methodExecutions.groupBy { it.result.clusterKind() }
105
104
106
105
val successfulExecutions = grouped[ExecutionGroup .SUCCESSFUL_EXECUTIONS ] ? : emptyList()
107
106
if (successfulExecutions.isNotEmpty()) {
108
107
clusters + = SuccessfulExecutionCluster (
109
- " $commentPrefix ${ExecutionGroup .SUCCESSFUL_EXECUTIONS .displayName} $commentPostfix " ,
110
- successfulExecutions.toList())
108
+ " $commentPrefix ${ExecutionGroup .SUCCESSFUL_EXECUTIONS .displayName} $commentPostfix " ,
109
+ successfulExecutions.toList()
110
+ )
111
111
}
112
112
113
- clusters + = grouped
114
- .filterNot { (kind, _) -> kind == ExecutionGroup .SUCCESSFUL_EXECUTIONS }
115
- .map { (suffixId, group) ->
116
- FailedExecutionCluster (" $commentPrefix ${suffixId.displayName} $commentPostfix " , group)
117
- }
113
+ clusters + = addClustersOfFailedExecutions(grouped, commentPrefix, commentPostfix)
114
+ return clusters
115
+ }
116
+
117
+ /* *
118
+ * Splits fuzzed executions into clusters.
119
+ *
120
+ * @return clustered executions.
121
+ */
122
+ fun groupFuzzedExecutions (testSet : UtMethodTestSet ): List <ExecutionCluster > {
123
+ val methodExecutions = testSet.executions.filterIsInstance<UtFuzzedExecution >()
124
+ val clusters = mutableListOf<ExecutionCluster >()
125
+ val commentPrefix = " FUZZER:"
126
+ val commentPostfix = " for method ${testSet.method.humanReadableName} "
127
+
128
+ val grouped = methodExecutions.groupBy { it.result.clusterKind() }
129
+
130
+ val successfulExecutions = grouped[ExecutionGroup .SUCCESSFUL_EXECUTIONS ] ? : emptyList()
131
+ if (successfulExecutions.isNotEmpty()) {
132
+ clusters + = SuccessfulExecutionCluster (
133
+ " $commentPrefix ${ExecutionGroup .SUCCESSFUL_EXECUTIONS .displayName} $commentPostfix " ,
134
+ successfulExecutions.toList()
135
+ )
136
+ }
137
+
138
+ clusters + = addClustersOfFailedExecutions(grouped, commentPrefix, commentPostfix)
118
139
return clusters
119
140
}
120
141
121
142
/* *
122
- * Splits executions produced by symbolic execution engine into clusters
123
- * By default there is 5 types of clusters:
124
- * Success, UnexpectedFail, ExpectedCheckedThrow, ExpectedUncheckedThrow, UnexpectedUncheckedThrow
125
- * These are split by the type of execution result
143
+ * Splits symbolic executions into clusters.
126
144
*
127
- * If Success cluster has more than MIN_NUMBER_OF_EXECUTIONS_FOR_CLUSTERING execution
128
- * then clustering algorithm splits those into more clusters
145
+ * If Success cluster has more than [ MIN_NUMBER_OF_EXECUTIONS_FOR_CLUSTERING] execution
146
+ * then clustering algorithm splits those into more clusters.
129
147
*
130
- * @return clustered executions
148
+ * @return clustered executions.
131
149
*/
132
150
private fun toClusterExecutions (testSet : UtMethodTestSet ): List <ExecutionCluster > {
133
151
val methodExecutions = testSet.executions.filterIsInstance<UtSymbolicExecution >()
134
152
val clusters = mutableListOf<ExecutionCluster >()
135
- val commentPrefix = " SYMBOLIC EXECUTION:"
153
+ val commentPrefix = " SYMBOLIC EXECUTION:"
136
154
val commentPostfix = " for method ${testSet.method.humanReadableName} "
137
155
138
156
val grouped = methodExecutions.groupBy { it.result.clusterKind() }
@@ -161,11 +179,21 @@ private fun toClusterExecutions(testSet: UtMethodTestSet): List<ExecutionCluster
161
179
}
162
180
}
163
181
164
- clusters + = grouped
182
+ clusters + = addClustersOfFailedExecutions(grouped, commentPrefix, commentPostfix)
183
+ return clusters
184
+ }
185
+
186
+ private fun addClustersOfFailedExecutions (
187
+ grouped : Map <ExecutionGroup , List <UtExecution >>,
188
+ commentPrefix : String ,
189
+ commentPostfix : String
190
+ ): List <FailedExecutionCluster > {
191
+ val clusters = grouped
165
192
.filterNot { (kind, _) -> kind == ExecutionGroup .SUCCESSFUL_EXECUTIONS }
166
193
.map { (suffixId, group) ->
167
- FailedExecutionCluster (" $commentPrefix ${suffixId.displayName} $commentPostfix " , group)
168
- }
194
+ FailedExecutionCluster (" $commentPrefix ${suffixId.displayName} $commentPostfix " , group)
195
+ }
196
+
169
197
return clusters
170
198
}
171
199
@@ -197,18 +225,18 @@ private fun UtExecutionResult.clusterKind() = when (this) {
197
225
/* *
198
226
* Structure used to represent execution cluster with header
199
227
*/
200
- sealed class ExecutionCluster (var header : String , val executions : List <UtSymbolicExecution >)
228
+ sealed class ExecutionCluster (var header : String , val executions : List <UtExecution >)
201
229
202
230
/* *
203
231
* Represents successful execution cluster
204
232
*/
205
- private class SuccessfulExecutionCluster (header : String , executions : List <UtSymbolicExecution >) :
233
+ private class SuccessfulExecutionCluster (header : String , executions : List <UtExecution >) :
206
234
ExecutionCluster (header, executions)
207
235
208
236
/* *
209
237
* Represents failed execution cluster
210
238
*/
211
- private class FailedExecutionCluster (header : String , executions : List <UtSymbolicExecution >) :
239
+ private class FailedExecutionCluster (header : String , executions : List <UtExecution >) :
212
240
ExecutionCluster (header, executions)
213
241
214
242
/* *
0 commit comments