Skip to content

Commit 564b9c2

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 8449c16 commit 564b9c2

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

Lines changed: 34 additions & 24 deletions
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
@@ -133,18 +134,23 @@ open class TestCaseGenerator(
133134
useSynthesis: Boolean = enableSynthesis,
134135
postConditionConstructor: PostConditionConstructor = EmptyPostCondition,
135136
): 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+
}
148154
}
149155

150156
fun generate(
@@ -171,8 +177,9 @@ open class TestCaseGenerator(
171177
controller.job = launch(currentUtContext) {
172178
if (!isActive) return@launch
173179

174-
//yield one to
175-
yield()
180+
try {
181+
//yield one to
182+
yield()
176183

177184
val engine: UtBotSymbolicEngine = createSymbolicEngine(
178185
controller,
@@ -184,18 +191,21 @@ open class TestCaseGenerator(
184191
EmptyPostCondition
185192
)
186193

187-
engineActions.map { engine.apply(it) }
194+
engineActions.map { engine.apply(it) }
188195

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" }
197199
}
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+
}
199209
}
200210
controller.paused = true
201211
}

0 commit comments

Comments
 (0)