diff --git a/utbot-framework-api/src/main/kotlin/org/utbot/framework/UtSettings.kt b/utbot-framework-api/src/main/kotlin/org/utbot/framework/UtSettings.kt index 3cd629adf0..b82cd8f879 100644 --- a/utbot-framework-api/src/main/kotlin/org/utbot/framework/UtSettings.kt +++ b/utbot-framework-api/src/main/kotlin/org/utbot/framework/UtSettings.kt @@ -282,6 +282,15 @@ object UtSettings : AbstractSettings( */ var logConcreteExecutionErrors by getBooleanProperty(false) + + /** + * Property useful only for idea + * If true - runs engine process with the ability to attach a debugger + * @see runChildProcessWithDebug + * @see org.utbot.intellij.plugin.process.EngineProcess + */ + var runIdeaProcessWithDebug by getBooleanProperty(false) + /** * Number of branch instructions using for clustering executions in the test minimization phase. */ diff --git a/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/Settings.kt b/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/Settings.kt index 0b3cf8c032..ce290b11b6 100644 --- a/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/Settings.kt +++ b/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/Settings.kt @@ -30,13 +30,5 @@ object Settings { */ const val runChildProcessWithDebug = false - /** - * Property useful only for idea - * If true - runs engine process with the ability to attach a debugger - * @see runChildProcessWithDebug - * @see org.utbot.intellij.plugin.process.EngineProcess - */ - const val runIdeaProcessWithDebug = false - var defaultConcreteExecutorPoolSize = 10 } \ No newline at end of file diff --git a/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/process/ChildProcess.kt b/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/process/ChildProcess.kt index e49e207fa2..cd535fd128 100644 --- a/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/process/ChildProcess.kt +++ b/utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/process/ChildProcess.kt @@ -121,15 +121,22 @@ private fun ChildProcessModel.setup(kryoHelper: KryoHelper, synchronizer: CallsS synchronizer.measureExecutionForTermination(invokeMethodCommand) { params -> logger.debug { "received invokeMethod request: ${params.classname}, ${params.signature}" } val clazz = HandlerClassesLoader.loadClass(params.classname) - val res = instrumentation.invoke( - clazz, - params.signature, - kryoHelper.readObject(params.arguments), - kryoHelper.readObject(params.parameters) - ) - - logger.debug { "invokeMethod result: $res" } - InvokeMethodCommandResult(kryoHelper.writeObject(res)) + val res = kotlin.runCatching { + instrumentation.invoke( + clazz, + params.signature, + kryoHelper.readObject(params.arguments), + kryoHelper.readObject(params.parameters) + ) + } + res.fold({ + logger.debug { "invokeMethod success" } + InvokeMethodCommandResult(kryoHelper.writeObject(it)) + }) { + logger.debug { "invokeMethod failure" } + logger.error(it) + throw it + } } synchronizer.measureExecutionForTermination(setInstrumentation) { params -> logger.debug { "setInstrumentation request" } diff --git a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/process/EngineProcess.kt b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/process/EngineProcess.kt index 26809779f5..c4f56c42f9 100644 --- a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/process/EngineProcess.kt +++ b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/process/EngineProcess.kt @@ -17,6 +17,7 @@ import kotlinx.coroutines.sync.withLock import mu.KotlinLogging import org.utbot.common.* import org.utbot.framework.UtSettings +import org.utbot.framework.UtSettings.runIdeaProcessWithDebug import org.utbot.framework.codegen.* import org.utbot.framework.codegen.model.UtilClassKind import org.utbot.framework.plugin.api.* @@ -29,7 +30,6 @@ import org.utbot.framework.process.generated.* import org.utbot.framework.process.generated.Signature import org.utbot.framework.util.Conflict import org.utbot.framework.util.ConflictTriggers -import org.utbot.instrumentation.Settings import org.utbot.instrumentation.util.KryoHelper import org.utbot.intellij.plugin.models.GenerateTestsModel import org.utbot.intellij.plugin.ui.TestReportUrlOpeningListener @@ -96,7 +96,7 @@ class EngineProcess(parent: Lifetime, val project: Project) { } private fun debugArgument(): String { - return "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,quiet=y,address=5005".takeIf { Settings.runIdeaProcessWithDebug } + return "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,quiet=y,address=5005".takeIf { runIdeaProcessWithDebug } ?: "" }