1
1
package org.utbot.framework.plugin.api
2
2
3
+ import com.google.protobuf.compiler.PluginProtos
3
4
import kotlinx.coroutines.CoroutineScope
4
5
import kotlinx.coroutines.GlobalScope
5
6
import kotlinx.coroutines.cancel
@@ -133,18 +134,23 @@ open class TestCaseGenerator(
133
134
useSynthesis : Boolean = enableSynthesis,
134
135
postConditionConstructor : PostConditionConstructor = EmptyPostCondition ,
135
136
): Flow <UtResult > {
136
- val engine = createSymbolicEngine(
137
- controller,
138
- method,
139
- mockStrategy,
140
- chosenClassesToMockAlways,
141
- executionTimeEstimator,
142
- useSynthesis,
143
- postConditionConstructor,
144
- )
145
- engineActions.map { engine.apply (it) }
146
- engineActions.clear()
147
- return defaultTestFlow(engine, executionTimeEstimator.userTimeout)
137
+ try {
138
+ val engine = createSymbolicEngine(
139
+ controller,
140
+ method,
141
+ mockStrategy,
142
+ chosenClassesToMockAlways,
143
+ executionTimeEstimator,
144
+ useSynthesis,
145
+ postConditionConstructor,
146
+ )
147
+ engineActions.map { engine.apply (it) }
148
+ engineActions.clear()
149
+ return defaultTestFlow(engine, executionTimeEstimator.userTimeout)
150
+ } catch (e: Exception ) {
151
+ logger.error(e) {" Generate async failed" }
152
+ throw e
153
+ }
148
154
}
149
155
150
156
fun generate (
@@ -171,8 +177,9 @@ open class TestCaseGenerator(
171
177
controller.job = launch(currentUtContext) {
172
178
if (! isActive) return @launch
173
179
174
- // yield one to
175
- yield ()
180
+ try {
181
+ // yield one to
182
+ yield ()
176
183
177
184
val engine: UtBotSymbolicEngine = createSymbolicEngine(
178
185
controller,
@@ -184,18 +191,21 @@ open class TestCaseGenerator(
184
191
EmptyPostCondition
185
192
)
186
193
187
- engineActions.map { engine.apply (it) }
194
+ engineActions.map { engine.apply (it) }
188
195
189
- generate(engine)
190
- .catch {
191
- logger.error(it) { " Error in flow" }
192
- }
193
- .collect {
194
- when (it) {
195
- is UtExecution -> method2executions.getValue(method) + = it
196
- is UtError -> method2errors.getValue(method).merge(it.description, 1 , Int ::plus)
196
+ generate(engine)
197
+ .catch {
198
+ logger.error(it) { " Error in flow" }
197
199
}
198
- }
200
+ .collect {
201
+ when (it) {
202
+ is UtExecution -> method2executions.getValue(method) + = it
203
+ is UtError -> method2errors.getValue(method).merge(it.description, 1 , Int ::plus)
204
+ }
205
+ }
206
+ } catch (e: Exception ) {
207
+ logger.error(e) {" Error in engine" }
208
+ }
199
209
}
200
210
controller.paused = true
201
211
}
0 commit comments