Skip to content

Commit feabc8c

Browse files
committed
[utbot-rd]
more logs, dump mode fixes
1 parent a0738ed commit feabc8c

File tree

4 files changed

+34
-27
lines changed

4 files changed

+34
-27
lines changed

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

+3-1
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
@@ -186,6 +185,7 @@ open class TestCaseGenerator(
186185
}
187186
} catch (e: Exception) {
188187
logger.error(e) {"Error in engine"}
188+
throw e
189189
}
190190
}
191191
controller.paused = true
@@ -194,6 +194,7 @@ open class TestCaseGenerator(
194194
// All jobs are in the method2controller now (paused). execute them with timeout
195195

196196
GlobalScope.launch {
197+
logger.debug("test generator global scope lifecycle check started")
197198
while (isActive) {
198199
var activeCount = 0
199200
for ((method, controller) in method2controller) {
@@ -219,6 +220,7 @@ open class TestCaseGenerator(
219220
}
220221
if (activeCount == 0) break
221222
}
223+
logger.debug("test generator global scope lifecycle check ended")
222224
}
223225
}
224226
}

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

+2
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

+17-18
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-rd/src/main/kotlin/org/utbot/rd/ClientProcessUtil.kt

+12-8
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
}

0 commit comments

Comments
 (0)