Skip to content

Commit 04ed20e

Browse files
Vassiliy kudryashov/1021 plugin support idea 20222 new (#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 53c3b3f commit 04ed20e

File tree

1 file changed

+33
-23
lines changed

1 file changed

+33
-23
lines changed

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

+33-23
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
@@ -124,10 +125,15 @@ open class TestCaseGenerator(
124125
chosenClassesToMockAlways: Set<ClassId> = Mocker.javaDefaultClasses.mapTo(mutableSetOf()) { it.id },
125126
executionTimeEstimator: ExecutionTimeEstimator = ExecutionTimeEstimator(utBotGenerationTimeoutInMillis, 1)
126127
): 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+
}
131137
}
132138

133139
fun generate(
@@ -154,29 +160,33 @@ open class TestCaseGenerator(
154160
controller.job = launch(currentUtContext) {
155161
if (!isActive) return@launch
156162

157-
//yield one to
158-
yield()
163+
try {
164+
//yield one to
165+
yield()
159166

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+
)
167174

168-
engineActions.map { engine.apply(it) }
175+
engineActions.map { engine.apply(it) }
169176

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" }
178180
}
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+
}
180190
}
181191
controller.paused = true
182192
}

0 commit comments

Comments
 (0)