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
@@ -124,10 +125,15 @@ open class TestCaseGenerator(
124
125
chosenClassesToMockAlways : Set <ClassId > = Mocker .javaDefaultClasses.mapTo(mutableSetOf()) { it.id },
125
126
executionTimeEstimator : ExecutionTimeEstimator = ExecutionTimeEstimator (utBotGenerationTimeoutInMillis, 1)
126
127
): 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
+ }
131
137
}
132
138
133
139
fun generate (
@@ -154,29 +160,33 @@ open class TestCaseGenerator(
154
160
controller.job = launch(currentUtContext) {
155
161
if (! isActive) return @launch
156
162
157
- // yield one to
158
- yield ()
163
+ try {
164
+ // yield one to
165
+ yield ()
159
166
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
+ )
167
174
168
- engineActions.map { engine.apply (it) }
175
+ engineActions.map { engine.apply (it) }
169
176
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" }
178
180
}
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
+ }
180
190
}
181
191
controller.paused = true
182
192
}
0 commit comments