Skip to content

Commit bf272b6

Browse files
Vassiliy-KudryashovAbdullinAM
authored andcommitted
Vassiliy kudryashov/1021 plugin support idea 20222 new (UnitTestBot#1094)
Setup 222 versions for IntelliJ and plugins Fix wrong import Add try/catch temporary wrapping to obtain stacktrace Update soot version (commit hash) Get rid of commented lines, better logging added
1 parent 43efb96 commit bf272b6

File tree

1 file changed

+34
-24
lines changed

1 file changed

+34
-24
lines changed

utbot-framework/src/main/kotlin/org/utbot/framework/plugin/api/TestCaseGenerator.kt

+34-24
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.utbot.framework.plugin.api
22

3+
import com.google.protobuf.compiler.PluginProtos
34
import kotlinx.coroutines.CoroutineScope
45
import kotlinx.coroutines.GlobalScope
56
import 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

Comments
 (0)