Skip to content

Commit 6bff385

Browse files
DomonionAbdullinAM
authored andcommitted
Fix dump mode fail (UnitTestBot#1146)
* [utbot-rd] more logs, dump mode fixes * Pathseparator fix, removed useless scheduler
1 parent 674f9c0 commit 6bff385

File tree

8 files changed

+40
-45
lines changed

8 files changed

+40
-45
lines changed

utbot-framework-test/src/test/kotlin/org/utbot/examples/codegen/modifiers/ClassWithPrivateMutableFieldOfPrivateTypeTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ import org.utbot.tests.infrastructure.UtValueTestCaseChecker
1414
class ClassWithPrivateMutableFieldOfPrivateTypeTest : UtValueTestCaseChecker(
1515
testClass = ClassWithPrivateMutableFieldOfPrivateType::class,
1616
testCodeGeneration = true,
17-
languagePipelines = listOf(
18-
CodeGenerationLanguageLastStage(CodegenLanguage.JAVA),
19-
CodeGenerationLanguageLastStage(CodegenLanguage.KOTLIN, Compilation)
17+
pipelines = listOf(
18+
TestLastStage(CodegenLanguage.JAVA),
19+
TestLastStage(CodegenLanguage.KOTLIN, Compilation)
2020
)
2121
) {
2222
@Test

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package org.utbot.framework.plugin.api
22

3-
import com.google.protobuf.compiler.PluginProtos
43
import kotlinx.coroutines.CoroutineScope
54
import kotlinx.coroutines.GlobalScope
65
import kotlinx.coroutines.cancel
@@ -205,6 +204,7 @@ open class TestCaseGenerator(
205204
}
206205
} catch (e: Exception) {
207206
logger.error(e) {"Error in engine"}
207+
throw e
208208
}
209209
}
210210
controller.paused = true
@@ -213,6 +213,7 @@ open class TestCaseGenerator(
213213
// All jobs are in the method2controller now (paused). execute them with timeout
214214

215215
GlobalScope.launch {
216+
logger.debug("test generator global scope lifecycle check started")
216217
while (isActive) {
217218
var activeCount = 0
218219
for ((method, controller) in method2controller) {
@@ -238,6 +239,7 @@ open class TestCaseGenerator(
238239
}
239240
if (activeCount == 0) break
240241
}
242+
logger.debug("test generator global scope lifecycle check ended")
241243
}
242244
}
243245
}

utbot-framework/src/main/kotlin/org/utbot/framework/process/EngineMain.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,9 @@ private fun EngineProcessModel.setup(
112112
isFuzzingEnabled = params.isFuzzingEnabled
113113
fuzzingValue = params.fuzzingValue
114114
})
115+
.apply { logger.info("generation ended, starting summarization, result size: ${this.size}") }
115116
.map { it.summarize(Paths.get(params.searchDirectory)) }
117+
.apply { logger.info("summarization ended") }
116118
.filterNot { it.executions.isEmpty() && it.errors.isEmpty() }
117119

118120
val id = ++idCounter

utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/generator/UtTestsDialogProcessor.kt

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -155,25 +155,24 @@ object UtTestsDialogProcessor {
155155
}
156156

157157
for (srcClass in model.srcClasses) {
158-
val (methods, className) = ReadAction.nonBlocking<Pair<List<ExecutableId>, String?>> {
159-
val canonicalName = srcClass.canonicalName
160-
val classId = proc.obtainClassId(canonicalName)
161-
psi2KClass[srcClass] = classId
162-
163-
val srcMethods = if (model.extractMembersFromSrcClasses) {
164-
val chosenMethods = model.selectedMembers.filter { it.member is PsiMethod }
165-
val chosenNestedClasses =
166-
model.selectedMembers.mapNotNull { it.member as? PsiClass }
167-
chosenMethods + chosenNestedClasses.flatMap {
168-
it.extractClassMethodsIncludingNested(false)
158+
val (methods, className) = DumbService.getInstance(project)
159+
.runReadActionInSmartMode(Computable {
160+
val canonicalName = srcClass.canonicalName
161+
val classId = proc.obtainClassId(canonicalName)
162+
psi2KClass[srcClass] = classId
163+
164+
val srcMethods = if (model.extractMembersFromSrcClasses) {
165+
val chosenMethods = model.selectedMembers.filter { it.member is PsiMethod }
166+
val chosenNestedClasses =
167+
model.selectedMembers.mapNotNull { it.member as? PsiClass }
168+
chosenMethods + chosenNestedClasses.flatMap {
169+
it.extractClassMethodsIncludingNested(false)
170+
}
171+
} else {
172+
srcClass.extractClassMethodsIncludingNested(false)
169173
}
170-
} else {
171-
srcClass.extractClassMethodsIncludingNested(false)
172-
}
173-
DumbService.getInstance(project).runReadActionInSmartMode(Computable {
174-
proc.findMethodsInClassMatchingSelected(classId, srcMethods)
175-
}) to srcClass.name
176-
}.executeSynchronously()
174+
proc.findMethodsInClassMatchingSelected(classId, srcMethods) to srcClass.name
175+
})
177176

178177
if (methods.isEmpty()) {
179178
logger.error { "No methods matching selected found in class $className." }

utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/process/EngineProcess.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class EngineProcess(parent: Lifetime, val project: Project) {
102102
val java =
103103
JdkInfoService.jdkInfoProvider.info.path.resolve("bin${File.separatorChar}${osSpecificJavaExecutable()}").toString()
104104
val cp = (this.javaClass.classLoader as PluginClassLoader).classPath.baseUrls.joinToString(
105-
separator = if (isWindows) ";" else ":",
105+
separator = File.pathSeparator,
106106
prefix = "\"",
107107
postfix = "\""
108108
)

utbot-rd/src/main/kotlin/org/utbot/rd/ClientProcessUtil.kt

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ import com.jetbrains.rd.util.lifetime.isAlive
1111
import com.jetbrains.rd.util.lifetime.plusAssign
1212
import com.jetbrains.rd.util.threading.SingleThreadScheduler
1313
import com.jetbrains.rd.util.trace
14+
import kotlinx.coroutines.CancellationException
1415
import kotlinx.coroutines.channels.Channel
16+
import kotlinx.coroutines.channels.trySendBlocking
1517
import kotlinx.coroutines.runBlocking
1618
import kotlinx.coroutines.withTimeoutOrNull
1719
import org.utbot.common.*
@@ -63,21 +65,23 @@ class CallsSynchronizer(private val ldef: LifetimeDefinition, val timeout: Durat
6365

6466
private val synchronizer: Channel<State> = Channel(1)
6567

66-
fun <T> measureExecutionForTermination(block: () -> T): T = runBlocking {
68+
init {
69+
ldef.onTermination { synchronizer.close(CancellationException("Client terminated")) }
70+
}
71+
72+
fun <T> measureExecutionForTermination(block: () -> T): T {
6773
try {
68-
synchronizer.send(State.STARTED)
69-
return@runBlocking block()
74+
synchronizer.trySendBlocking(State.STARTED)
75+
return block()
7076
} finally {
71-
synchronizer.send(State.ENDED)
77+
synchronizer.trySendBlocking(State.ENDED)
7278
}
7379
}
7480

7581
fun <T, R> measureExecutionForTermination(call: RdCall<T, R>, block: (T) -> R) {
7682
call.set { it ->
77-
runBlocking {
78-
measureExecutionForTermination {
79-
block(it)
80-
}
83+
measureExecutionForTermination {
84+
block(it)
8185
}
8286
}
8387
}

utbot-rd/src/main/kotlin/org/utbot/rd/UtRdCoroutineScope.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ package org.utbot.rd
33
import com.jetbrains.rd.framework.util.RdCoroutineScope
44
import com.jetbrains.rd.framework.util.asCoroutineDispatcher
55
import com.jetbrains.rd.util.lifetime.Lifetime
6+
import com.jetbrains.rd.util.threading.SingleThreadScheduler
67

7-
private val coroutineDispatcher = UtSingleThreadScheduler("UtCoroutineScheduler").asCoroutineDispatcher
8+
private val coroutineDispatcher = SingleThreadScheduler(Lifetime.Eternal, "UtCoroutineScheduler").asCoroutineDispatcher
89

910
class UtRdCoroutineScope(lifetime: Lifetime) : RdCoroutineScope(lifetime) {
1011
companion object {

utbot-rd/src/main/kotlin/org/utbot/rd/UtSingleThreadScheduler.kt

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)