diff --git a/utbot-framework-test/src/test/kotlin/org/utbot/examples/codegen/modifiers/ClassWithPrivateMutableFieldOfPrivateTypeTest.kt b/utbot-framework-test/src/test/kotlin/org/utbot/examples/codegen/modifiers/ClassWithPrivateMutableFieldOfPrivateTypeTest.kt index 40e9d4be16..a31980f59e 100644 --- a/utbot-framework-test/src/test/kotlin/org/utbot/examples/codegen/modifiers/ClassWithPrivateMutableFieldOfPrivateTypeTest.kt +++ b/utbot-framework-test/src/test/kotlin/org/utbot/examples/codegen/modifiers/ClassWithPrivateMutableFieldOfPrivateTypeTest.kt @@ -14,9 +14,9 @@ import org.utbot.tests.infrastructure.UtValueTestCaseChecker class ClassWithPrivateMutableFieldOfPrivateTypeTest : UtValueTestCaseChecker( testClass = ClassWithPrivateMutableFieldOfPrivateType::class, testCodeGeneration = true, - languagePipelines = listOf( - CodeGenerationLanguageLastStage(CodegenLanguage.JAVA), - CodeGenerationLanguageLastStage(CodegenLanguage.KOTLIN, Compilation) + pipelines = listOf( + TestLastStage(CodegenLanguage.JAVA), + TestLastStage(CodegenLanguage.KOTLIN, Compilation) ) ) { @Test diff --git a/utbot-framework/src/main/kotlin/org/utbot/framework/plugin/api/TestCaseGenerator.kt b/utbot-framework/src/main/kotlin/org/utbot/framework/plugin/api/TestCaseGenerator.kt index d16101086c..cc61b8099e 100644 --- a/utbot-framework/src/main/kotlin/org/utbot/framework/plugin/api/TestCaseGenerator.kt +++ b/utbot-framework/src/main/kotlin/org/utbot/framework/plugin/api/TestCaseGenerator.kt @@ -1,6 +1,5 @@ package org.utbot.framework.plugin.api -import com.google.protobuf.compiler.PluginProtos import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.cancel @@ -186,6 +185,7 @@ open class TestCaseGenerator( } } catch (e: Exception) { logger.error(e) {"Error in engine"} + throw e } } controller.paused = true @@ -194,6 +194,7 @@ open class TestCaseGenerator( // All jobs are in the method2controller now (paused). execute them with timeout GlobalScope.launch { + logger.debug("test generator global scope lifecycle check started") while (isActive) { var activeCount = 0 for ((method, controller) in method2controller) { @@ -219,6 +220,7 @@ open class TestCaseGenerator( } if (activeCount == 0) break } + logger.debug("test generator global scope lifecycle check ended") } } } diff --git a/utbot-framework/src/main/kotlin/org/utbot/framework/process/EngineMain.kt b/utbot-framework/src/main/kotlin/org/utbot/framework/process/EngineMain.kt index 2c259bb2e7..37624646d6 100644 --- a/utbot-framework/src/main/kotlin/org/utbot/framework/process/EngineMain.kt +++ b/utbot-framework/src/main/kotlin/org/utbot/framework/process/EngineMain.kt @@ -112,7 +112,9 @@ private fun EngineProcessModel.setup( isFuzzingEnabled = params.isFuzzingEnabled fuzzingValue = params.fuzzingValue }) + .apply { logger.info("generation ended, starting summarization, result size: ${this.size}") } .map { it.summarize(Paths.get(params.searchDirectory)) } + .apply { logger.info("summarization ended") } .filterNot { it.executions.isEmpty() && it.errors.isEmpty() } val id = ++idCounter diff --git a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/generator/UtTestsDialogProcessor.kt b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/generator/UtTestsDialogProcessor.kt index 030d529321..6c652ab4e7 100644 --- a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/generator/UtTestsDialogProcessor.kt +++ b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/generator/UtTestsDialogProcessor.kt @@ -155,25 +155,24 @@ object UtTestsDialogProcessor { } for (srcClass in model.srcClasses) { - val (methods, className) = ReadAction.nonBlocking, String?>> { - val canonicalName = srcClass.canonicalName - val classId = proc.obtainClassId(canonicalName) - psi2KClass[srcClass] = classId - - val srcMethods = if (model.extractMembersFromSrcClasses) { - val chosenMethods = model.selectedMembers.filter { it.member is PsiMethod } - val chosenNestedClasses = - model.selectedMembers.mapNotNull { it.member as? PsiClass } - chosenMethods + chosenNestedClasses.flatMap { - it.extractClassMethodsIncludingNested(false) + val (methods, className) = DumbService.getInstance(project) + .runReadActionInSmartMode(Computable { + val canonicalName = srcClass.canonicalName + val classId = proc.obtainClassId(canonicalName) + psi2KClass[srcClass] = classId + + val srcMethods = if (model.extractMembersFromSrcClasses) { + val chosenMethods = model.selectedMembers.filter { it.member is PsiMethod } + val chosenNestedClasses = + model.selectedMembers.mapNotNull { it.member as? PsiClass } + chosenMethods + chosenNestedClasses.flatMap { + it.extractClassMethodsIncludingNested(false) + } + } else { + srcClass.extractClassMethodsIncludingNested(false) } - } else { - srcClass.extractClassMethodsIncludingNested(false) - } - DumbService.getInstance(project).runReadActionInSmartMode(Computable { - proc.findMethodsInClassMatchingSelected(classId, srcMethods) - }) to srcClass.name - }.executeSynchronously() + proc.findMethodsInClassMatchingSelected(classId, srcMethods) to srcClass.name + }) if (methods.isEmpty()) { logger.error { "No methods matching selected found in class $className." } 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 f44b56093f..6cf2db6779 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 @@ -102,7 +102,7 @@ class EngineProcess(parent: Lifetime, val project: Project) { val java = JdkInfoService.jdkInfoProvider.info.path.resolve("bin${File.separatorChar}${osSpecificJavaExecutable()}").toString() val cp = (this.javaClass.classLoader as PluginClassLoader).classPath.baseUrls.joinToString( - separator = if (isWindows) ";" else ":", + separator = File.pathSeparator, prefix = "\"", postfix = "\"" ) diff --git a/utbot-rd/src/main/kotlin/org/utbot/rd/ClientProcessUtil.kt b/utbot-rd/src/main/kotlin/org/utbot/rd/ClientProcessUtil.kt index 187b475ebc..0e3790aeb7 100644 --- a/utbot-rd/src/main/kotlin/org/utbot/rd/ClientProcessUtil.kt +++ b/utbot-rd/src/main/kotlin/org/utbot/rd/ClientProcessUtil.kt @@ -11,7 +11,9 @@ import com.jetbrains.rd.util.lifetime.isAlive import com.jetbrains.rd.util.lifetime.plusAssign import com.jetbrains.rd.util.threading.SingleThreadScheduler import com.jetbrains.rd.util.trace +import kotlinx.coroutines.CancellationException import kotlinx.coroutines.channels.Channel +import kotlinx.coroutines.channels.trySendBlocking import kotlinx.coroutines.runBlocking import kotlinx.coroutines.withTimeoutOrNull import org.utbot.common.* @@ -63,21 +65,23 @@ class CallsSynchronizer(private val ldef: LifetimeDefinition, val timeout: Durat private val synchronizer: Channel = Channel(1) - fun measureExecutionForTermination(block: () -> T): T = runBlocking { + init { + ldef.onTermination { synchronizer.close(CancellationException("Client terminated")) } + } + + fun measureExecutionForTermination(block: () -> T): T { try { - synchronizer.send(State.STARTED) - return@runBlocking block() + synchronizer.trySendBlocking(State.STARTED) + return block() } finally { - synchronizer.send(State.ENDED) + synchronizer.trySendBlocking(State.ENDED) } } fun measureExecutionForTermination(call: RdCall, block: (T) -> R) { call.set { it -> - runBlocking { - measureExecutionForTermination { - block(it) - } + measureExecutionForTermination { + block(it) } } } diff --git a/utbot-rd/src/main/kotlin/org/utbot/rd/UtRdCoroutineScope.kt b/utbot-rd/src/main/kotlin/org/utbot/rd/UtRdCoroutineScope.kt index f9a2a5a2ae..27571b74de 100644 --- a/utbot-rd/src/main/kotlin/org/utbot/rd/UtRdCoroutineScope.kt +++ b/utbot-rd/src/main/kotlin/org/utbot/rd/UtRdCoroutineScope.kt @@ -3,8 +3,9 @@ package org.utbot.rd import com.jetbrains.rd.framework.util.RdCoroutineScope import com.jetbrains.rd.framework.util.asCoroutineDispatcher import com.jetbrains.rd.util.lifetime.Lifetime +import com.jetbrains.rd.util.threading.SingleThreadScheduler -private val coroutineDispatcher = UtSingleThreadScheduler("UtCoroutineScheduler").asCoroutineDispatcher +private val coroutineDispatcher = SingleThreadScheduler(Lifetime.Eternal, "UtCoroutineScheduler").asCoroutineDispatcher class UtRdCoroutineScope(lifetime: Lifetime) : RdCoroutineScope(lifetime) { companion object { diff --git a/utbot-rd/src/main/kotlin/org/utbot/rd/UtSingleThreadScheduler.kt b/utbot-rd/src/main/kotlin/org/utbot/rd/UtSingleThreadScheduler.kt deleted file mode 100644 index f01e2ba29f..0000000000 --- a/utbot-rd/src/main/kotlin/org/utbot/rd/UtSingleThreadScheduler.kt +++ /dev/null @@ -1,13 +0,0 @@ -package org.utbot.rd - -import com.jetbrains.rd.util.error -import com.jetbrains.rd.util.getLogger -import com.jetbrains.rd.util.threading.SingleThreadSchedulerBase - -private val logger = getLogger() - -class UtSingleThreadScheduler(name: String) : SingleThreadSchedulerBase(name) { - override fun onException(ex: Throwable) { - logger.error { "exception on scheduler $name: $ex |> ${ex.stackTraceToString()}" } - } -} \ No newline at end of file