Skip to content

Commit 8151788

Browse files
committed
Add isCancelled to fuzzing
1 parent 3783816 commit 8151788

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

utbot-python/src/main/kotlin/org/utbot/python/PythonEngine.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import kotlinx.coroutines.currentCoroutineContext
44
import kotlinx.coroutines.flow.Flow
55
import kotlinx.coroutines.flow.asFlow
66
import kotlinx.coroutines.flow.flow
7-
import kotlinx.coroutines.flow.isActive
87
import kotlinx.coroutines.isActive
98
import mu.KotlinLogging
109
import org.utbot.framework.plugin.api.*
@@ -204,7 +203,7 @@ class PythonEngine(
204203
)
205204
}
206205

207-
fun newFuzzing(parameters: List<Type>): Flow<UtResult> = flow {
206+
fun newFuzzing(parameters: List<Type>, isCancelled: () -> Boolean): Flow<UtResult> = flow {
208207
val additionalModules = selectedTypeMap.values.flatMap {
209208
getModulesFromAnnotation(it)
210209
}.toSet()
@@ -219,7 +218,7 @@ class PythonEngine(
219218
val coveredLines = initialCoveredLines.toMutableSet()
220219

221220
PythonFuzzing(pythonTypeStorage!!) { description, parameterValues ->
222-
if (coverageLimit < 0)
221+
if (coverageLimit < 0 || isCancelled())
223222
return@PythonFuzzing PythonFeedback(control = Control.STOP)
224223

225224
// if (parameterValues.all { it.classId.name == "UNDEF_VALUE" }) {

utbot-python/src/main/kotlin/org/utbot/python/PythonTestCaseGenerator.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ object PythonTestCaseGenerator {
100100
// var coverageLimit = 10
101101

102102
runBlockingWithCancellationPredicate(isCancelled) {
103-
engine.newFuzzing(args).collect {
103+
engine.newFuzzing(args, isCancelled).collect {
104104
val coveredBefore = coveredLines.size
105105

106106
generated += 1

0 commit comments

Comments
 (0)