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
@@ -124,10 +125,15 @@ open class TestCaseGenerator(
124125 chosenClassesToMockAlways : Set <ClassId > = Mocker .javaDefaultClasses.mapTo(mutableSetOf()) { it.id },
125126 executionTimeEstimator : ExecutionTimeEstimator = ExecutionTimeEstimator (utBotGenerationTimeoutInMillis, 1)
126127 ): Flow <UtResult > {
127- val engine = createSymbolicEngine(controller, method, mockStrategy, chosenClassesToMockAlways, executionTimeEstimator)
128- engineActions.map { engine.apply (it) }
129- engineActions.clear()
130- return defaultTestFlow(engine, executionTimeEstimator.userTimeout)
128+ try {
129+ val engine = createSymbolicEngine(controller, method, mockStrategy, chosenClassesToMockAlways, executionTimeEstimator)
130+ engineActions.map { engine.apply (it) }
131+ engineActions.clear()
132+ return defaultTestFlow(engine, executionTimeEstimator.userTimeout)
133+ } catch (e: Exception ) {
134+ logger.error(e) {" Generate async failed" }
135+ throw e
136+ }
131137 }
132138
133139 fun generate (
@@ -154,29 +160,33 @@ open class TestCaseGenerator(
154160 controller.job = launch(currentUtContext) {
155161 if (! isActive) return @launch
156162
157- // yield one to
158- yield ()
163+ try {
164+ // yield one to
165+ yield ()
159166
160- val engine: UtBotSymbolicEngine = createSymbolicEngine(
161- controller,
162- method,
163- mockStrategy,
164- chosenClassesToMockAlways,
165- executionTimeEstimator
166- )
167+ val engine: UtBotSymbolicEngine = createSymbolicEngine(
168+ controller,
169+ method,
170+ mockStrategy,
171+ chosenClassesToMockAlways,
172+ executionTimeEstimator
173+ )
167174
168- engineActions.map { engine.apply (it) }
175+ engineActions.map { engine.apply (it) }
169176
170- generate(engine)
171- .catch {
172- logger.error(it) { " Error in flow" }
173- }
174- .collect {
175- when (it) {
176- is UtExecution -> method2executions.getValue(method) + = it
177- is UtError -> method2errors.getValue(method).merge(it.description, 1 , Int ::plus)
177+ generate(engine)
178+ .catch {
179+ logger.error(it) { " Error in flow" }
178180 }
179- }
181+ .collect {
182+ when (it) {
183+ is UtExecution -> method2executions.getValue(method) + = it
184+ is UtError -> method2errors.getValue(method).merge(it.description, 1 , Int ::plus)
185+ }
186+ }
187+ } catch (e: Exception ) {
188+ logger.error(e) {" Error in engine" }
189+ }
180190 }
181191 controller.paused = true
182192 }
0 commit comments