Skip to content

Commit 57f18d7

Browse files
Refactor: remove runBlocking from tests
1 parent 653a8c8 commit 57f18d7

File tree

1 file changed

+21
-24
lines changed

1 file changed

+21
-24
lines changed

utbot-framework/src/main/kotlin/org/utbot/tests/infrastructure/TestSpecificTestCaseGenerator.kt

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
package org.utbot.tests.infrastructure
22

33
import kotlinx.coroutines.launch
4+
import kotlinx.coroutines.runBlocking
45
import mu.KotlinLogging
5-
import org.utbot.common.runBlockingWithCancellationPredicate
6-
import org.utbot.common.runIgnoringCancellationException
76
import org.utbot.engine.EngineController
87
import org.utbot.engine.Mocker
98
import org.utbot.engine.UtBotSymbolicEngine
@@ -61,32 +60,30 @@ class TestSpecificTestCaseGenerator(
6160
val forceMockListener = ForceMockListener.create(this, conflictTriggers, cancelJob = false)
6261
val forceStaticMockListener = ForceStaticMockListener.create(this, conflictTriggers, cancelJob = false)
6362

64-
runIgnoringCancellationException {
65-
runBlockingWithCancellationPredicate(isCanceled) {
66-
val controller = EngineController()
67-
controller.job = launch {
68-
super
69-
.generateAsync(controller, method, mockStrategy, mockAlwaysDefaults, defaultTimeEstimator)
70-
.collect {
71-
when (it) {
72-
is UtExecution -> {
73-
if (it is UtSymbolicExecution &&
74-
(conflictTriggers.triggered(Conflict.ForceMockHappened) ||
75-
conflictTriggers.triggered(Conflict.ForceStaticMockHappened))
76-
) {
77-
it.containsMocking = true
63+
runBlocking {
64+
val controller = EngineController()
65+
controller.job = launch {
66+
super
67+
.generateAsync(controller, method, mockStrategy, mockAlwaysDefaults, defaultTimeEstimator)
68+
.collect {
69+
when (it) {
70+
is UtExecution -> {
71+
if (it is UtSymbolicExecution &&
72+
(conflictTriggers.triggered(Conflict.ForceMockHappened) ||
73+
conflictTriggers.triggered(Conflict.ForceStaticMockHappened))
74+
) {
75+
it.containsMocking = true
7876

79-
conflictTriggers.reset(
80-
Conflict.ForceMockHappened,
81-
Conflict.ForceStaticMockHappened
82-
)
83-
}
84-
executions += it
77+
conflictTriggers.reset(
78+
Conflict.ForceMockHappened,
79+
Conflict.ForceStaticMockHappened
80+
)
8581
}
86-
is UtError -> errors.merge(it.description, 1, Int::plus)
82+
executions += it
8783
}
84+
is UtError -> errors.merge(it.description, 1, Int::plus)
8885
}
89-
}
86+
}
9087
}
9188
}
9289

0 commit comments

Comments
 (0)