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
@@ -134,18 +135,23 @@ open class TestCaseGenerator(
134
135
useSynthesis : Boolean = enableSynthesis,
135
136
postConditionConstructor : PostConditionConstructor = EmptyPostCondition ,
136
137
): 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
+ }
149
155
}
150
156
151
157
fun generate (
@@ -172,8 +178,9 @@ open class TestCaseGenerator(
172
178
controller.job = launch(currentUtContext) {
173
179
if (! isActive) return @launch
174
180
175
- // yield one to
176
- yield ()
181
+ try {
182
+ // yield one to
183
+ yield ()
177
184
178
185
val engine: UtBotSymbolicEngine = createSymbolicEngine(
179
186
controller,
@@ -185,18 +192,21 @@ open class TestCaseGenerator(
185
192
EmptyPostCondition
186
193
)
187
194
188
- engineActions.map { engine.apply (it) }
195
+ engineActions.map { engine.apply (it) }
189
196
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" }
198
200
}
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
+ }
200
210
}
201
211
controller.paused = true
202
212
}
0 commit comments