Skip to content

Fix dump mode fail #1146

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 13, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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")
}
}
}
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -155,25 +155,24 @@ object UtTestsDialogProcessor {
}

for (srcClass in model.srcClasses) {
val (methods, className) = ReadAction.nonBlocking<Pair<List<ExecutableId>, 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." }
Original file line number Diff line number Diff line change
@@ -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 = "\""
)
20 changes: 12 additions & 8 deletions utbot-rd/src/main/kotlin/org/utbot/rd/ClientProcessUtil.kt
Original file line number Diff line number Diff line change
@@ -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<State> = Channel(1)

fun <T> measureExecutionForTermination(block: () -> T): T = runBlocking {
init {
ldef.onTermination { synchronizer.close(CancellationException("Client terminated")) }
}

fun <T> 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 <T, R> measureExecutionForTermination(call: RdCall<T, R>, block: (T) -> R) {
call.set { it ->
runBlocking {
measureExecutionForTermination {
block(it)
}
measureExecutionForTermination {
block(it)
}
}
}
3 changes: 2 additions & 1 deletion utbot-rd/src/main/kotlin/org/utbot/rd/UtRdCoroutineScope.kt
Original file line number Diff line number Diff line change
@@ -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 {
13 changes: 0 additions & 13 deletions utbot-rd/src/main/kotlin/org/utbot/rd/UtSingleThreadScheduler.kt

This file was deleted.