11package org.utbot.framework.plugin.api
22
3+ import com.google.protobuf.compiler.PluginProtos
34import kotlinx.coroutines.CoroutineScope
45import kotlinx.coroutines.GlobalScope
56import kotlinx.coroutines.cancel
@@ -134,18 +135,23 @@ open class TestCaseGenerator(
134135 useSynthesis : Boolean = enableSynthesis,
135136 postConditionConstructor : PostConditionConstructor = EmptyPostCondition ,
136137 ): Flow <UtResult > {
137- val engine = createSymbolicEngine(
138- controller,
139- method,
140- mockStrategy,
141- chosenClassesToMockAlways,
142- executionTimeEstimator,
143- useSynthesis,
144- postConditionConstructor,
145- )
146- engineActions.map { engine.apply (it) }
147- engineActions.clear()
148- return defaultTestFlow(engine, executionTimeEstimator.userTimeout)
138+ try {
139+ val engine = createSymbolicEngine(
140+ controller,
141+ method,
142+ mockStrategy,
143+ chosenClassesToMockAlways,
144+ executionTimeEstimator,
145+ useSynthesis,
146+ postConditionConstructor,
147+ )
148+ engineActions.map { engine.apply (it) }
149+ engineActions.clear()
150+ return defaultTestFlow(engine, executionTimeEstimator.userTimeout)
151+ } catch (e: Exception ) {
152+ logger.error(e) {" Generate async failed" }
153+ throw e
154+ }
149155 }
150156
151157 fun generate (
@@ -172,8 +178,9 @@ open class TestCaseGenerator(
172178 controller.job = launch(currentUtContext) {
173179 if (! isActive) return @launch
174180
175- // yield one to
176- yield ()
181+ try {
182+ // yield one to
183+ yield ()
177184
178185 val engine: UtBotSymbolicEngine = createSymbolicEngine(
179186 controller,
@@ -185,18 +192,21 @@ open class TestCaseGenerator(
185192 EmptyPostCondition
186193 )
187194
188- engineActions.map { engine.apply (it) }
195+ engineActions.map { engine.apply (it) }
189196
190- generate(engine)
191- .catch {
192- logger.error(it) { " Error in flow" }
193- }
194- .collect {
195- when (it) {
196- is UtExecution -> method2executions.getValue(method) + = it
197- is UtError -> method2errors.getValue(method).merge(it.description, 1 , Int ::plus)
197+ generate(engine)
198+ .catch {
199+ logger.error(it) { " Error in flow" }
198200 }
199- }
201+ .collect {
202+ when (it) {
203+ is UtExecution -> method2executions.getValue(method) + = it
204+ is UtError -> method2errors.getValue(method).merge(it.description, 1 , Int ::plus)
205+ }
206+ }
207+ } catch (e: Exception ) {
208+ logger.error(e) {" Error in engine" }
209+ }
200210 }
201211 controller.paused = true
202212 }
0 commit comments