Skip to content

Commit 4e3d8a0

Browse files
committed
Unified error and exception clusters for all UtExecutions
1 parent d079944 commit 4e3d8a0

File tree

2 files changed

+26
-21
lines changed

2 files changed

+26
-21
lines changed

utbot-summary/src/main/kotlin/org/utbot/summary/Summarization.kt

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,9 @@ class Summarization(val sourceFile: File?, val invokeDescriptions: List<InvokeDe
221221
testSet: UtMethodTestSet
222222
): List<UtExecutionCluster> {
223223
val clustersToReturn: MutableList<UtExecutionCluster> = mutableListOf()
224-
val executionsProducedByFuzzer = testSet.executions.filterIsInstance<UtFuzzedExecution>()
224+
val testSetWithFuzzedExecutions = prepareTestSetWithFuzzedExecutions(testSet)
225+
val executionsProducedByFuzzer = testSetWithFuzzedExecutions.executions as List<UtFuzzedExecution>
226+
225227
if (executionsProducedByFuzzer.isNotEmpty()) {
226228
executionsProducedByFuzzer.forEach { utExecution ->
227229

@@ -243,8 +245,7 @@ class Summarization(val sourceFile: File?, val invokeDescriptions: List<InvokeDe
243245
utExecution.summary = testMethodName?.javaDoc
244246
}
245247

246-
247-
val clusteredExecutions = groupFuzzedExecutions(testSet)
248+
val clusteredExecutions = groupFuzzedExecutions(testSetWithFuzzedExecutions)
248249

249250
clusteredExecutions.forEach {
250251
clustersToReturn.add(
@@ -274,6 +275,19 @@ class Summarization(val sourceFile: File?, val invokeDescriptions: List<InvokeDe
274275
)
275276
}
276277

278+
/** Filter and copies fuzzed executions. */
279+
private fun prepareTestSetWithFuzzedExecutions(testSet: UtMethodTestSet): UtMethodTestSet {
280+
val executions = testSet.executions.filterIsInstance<UtFuzzedExecution>()
281+
282+
return UtMethodTestSet(
283+
method = testSet.method,
284+
executions = executions,
285+
jimpleBody = testSet.jimpleBody,
286+
errors = testSet.errors,
287+
clustersInfo = testSet.clustersInfo
288+
)
289+
}
290+
277291
/** Filter and copies executions with non-empty paths. */
278292
private fun prepareTestSetWithEmptyPaths(testSet: UtMethodTestSet): UtMethodTestSet {
279293
val executions =

utbot-summary/src/main/kotlin/org/utbot/summary/TagGenerator.kt

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,9 @@
11
package org.utbot.summary
22

3-
import org.utbot.framework.plugin.api.Step
4-
import org.utbot.framework.plugin.api.UtConcreteExecutionFailure
5-
import org.utbot.framework.plugin.api.UtSymbolicExecution
6-
import org.utbot.framework.plugin.api.UtExecutionResult
7-
import org.utbot.framework.plugin.api.UtExecutionSuccess
8-
import org.utbot.framework.plugin.api.UtExplicitlyThrownException
9-
import org.utbot.framework.plugin.api.UtImplicitlyThrownException
10-
import org.utbot.framework.plugin.api.UtOverflowFailure
11-
import org.utbot.framework.plugin.api.UtMethodTestSet
12-
import org.utbot.framework.plugin.api.UtSandboxFailure
13-
import org.utbot.framework.plugin.api.UtTimeoutException
3+
import org.utbot.framework.plugin.api.*
144
import org.utbot.framework.plugin.api.util.humanReadableName
155
import org.utbot.framework.plugin.api.util.isCheckedException
6+
import org.utbot.fuzzer.UtFuzzedExecution
167
import org.utbot.summary.UtSummarySettings.MIN_NUMBER_OF_EXECUTIONS_FOR_CLUSTERING
178
import org.utbot.summary.clustering.MatrixUniqueness
189
import org.utbot.summary.clustering.SplitSteps
@@ -28,7 +19,7 @@ class TagGenerator {
2819

2920
if (clusteredExecutions.isNotEmpty()) {
3021
val listOfSplitSteps = clusteredExecutions.map {
31-
val mUniqueness = MatrixUniqueness(it.executions)
22+
val mUniqueness = MatrixUniqueness(it.executions as List<UtSymbolicExecution>)
3223
mUniqueness.splitSteps()
3324
}
3425

@@ -63,7 +54,7 @@ class TagGenerator {
6354
traceTagClusters.add(
6455
TraceTagCluster(
6556
cluster.header,
66-
generateExecutionTags(cluster.executions, splitSteps),
57+
generateExecutionTags(cluster.executions as List<UtSymbolicExecution>, splitSteps),
6758
TraceTagWithoutExecution(
6859
commonStepsInCluster.toList(),
6960
cluster.executions.first().result,
@@ -131,7 +122,7 @@ fun groupExecutionsWithEmptyPaths(testSet: UtMethodTestSet): List<ExecutionClust
131122
* @return clustered executions
132123
*/
133124
fun groupFuzzedExecutions(testSet: UtMethodTestSet): List<ExecutionCluster> {
134-
val methodExecutions = testSet.executions.filterIsInstance<UtSymbolicExecution>()
125+
val methodExecutions = testSet.executions.filterIsInstance<UtFuzzedExecution>()
135126
val clusters = mutableListOf<ExecutionCluster>()
136127
val commentPrefix = "FUZZER:"
137128
val commentPostfix = "for method ${testSet.method.humanReadableName}"
@@ -202,7 +193,7 @@ private fun toClusterExecutions(testSet: UtMethodTestSet): List<ExecutionCluster
202193
}
203194

204195
private fun addClustersOfFailedExecutions(
205-
grouped: Map<ExecutionGroup, List<UtSymbolicExecution>>,
196+
grouped: Map<ExecutionGroup, List<UtExecution>>,
206197
commentPrefix: String,
207198
commentPostfix: String
208199
): List<FailedExecutionCluster> {
@@ -242,18 +233,18 @@ private fun UtExecutionResult.clusterKind() = when (this) {
242233
/**
243234
* Structure used to represent execution cluster with header
244235
*/
245-
sealed class ExecutionCluster(var header: String, val executions: List<UtSymbolicExecution>)
236+
sealed class ExecutionCluster(var header: String, val executions: List<UtExecution>)
246237

247238
/**
248239
* Represents successful execution cluster
249240
*/
250-
private class SuccessfulExecutionCluster(header: String, executions: List<UtSymbolicExecution>) :
241+
private class SuccessfulExecutionCluster(header: String, executions: List<UtExecution>) :
251242
ExecutionCluster(header, executions)
252243

253244
/**
254245
* Represents failed execution cluster
255246
*/
256-
private class FailedExecutionCluster(header: String, executions: List<UtSymbolicExecution>) :
247+
private class FailedExecutionCluster(header: String, executions: List<UtExecution>) :
257248
ExecutionCluster(header, executions)
258249

259250
/**

0 commit comments

Comments
 (0)