Skip to content

Commit f376b1a

Browse files
committed
[utbot-rd]
more jdk api fixes
1 parent 4f68777 commit f376b1a

File tree

3 files changed

+32
-15
lines changed

3 files changed

+32
-15
lines changed

utbot-framework-test/src/test/kotlin/org/utbot/framework/modificators/UtBotFieldModificatorsTest.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import org.junit.jupiter.api.Assertions.assertEquals
2424
import org.junit.jupiter.api.Assertions.assertTrue
2525
import org.junit.jupiter.api.BeforeEach
2626
import org.junit.jupiter.api.Test
27+
import org.utbot.common.nameOfPackage
2728
import org.utbot.framework.plugin.services.JdkInfoDefaultProvider
2829
import org.utbot.framework.util.SootUtils
2930

@@ -192,7 +193,7 @@ internal class UtBotFieldModificatorsTest {
192193

193194
//We use sorting here to make comparing with sorted in advance expected collections easier
194195
private fun runFieldModificatorsSearch(analysisMode: AnalysisMode) =
195-
fieldsModificatorsSearcher.findModificators(analysisMode, PrimitiveModifications::class.java.packageName)
196+
fieldsModificatorsSearcher.findModificators(analysisMode, PrimitiveModifications::class.java.nameOfPackage)
196197
.map { (key, value) ->
197198
val modificatorNames = value.filterNot { it.name.startsWith("direct_set_") }.map { it.name }
198199
key.name to modificatorNames.toSortedSet()

utbot-framework/src/main/kotlin/org/utbot/engine/Mocks.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import java.util.concurrent.atomic.AtomicInteger
1717
import kotlin.reflect.KFunction2
1818
import kotlin.reflect.KFunction5
1919
import kotlinx.collections.immutable.persistentListOf
20+
import org.utbot.common.nameOfPackage
2021
import org.utbot.engine.util.mockListeners.MockListenerController
2122
import org.utbot.framework.util.isInaccessibleViaReflection
2223
import soot.BooleanType
@@ -345,7 +346,7 @@ val assumeBytecodeSignature: String
345346
val assumeOrExecuteConcretelyBytecodeSignature: String
346347
get() = assumeOrExecuteConcretelyMethod.executableId.signature
347348

348-
internal val UTBOT_OVERRIDE_PACKAGE_NAME = UtOverrideMock::class.java.packageName
349+
internal val UTBOT_OVERRIDE_PACKAGE_NAME = UtOverrideMock::class.java.nameOfPackage
349350

350351
private val arraycopyMethod : KFunction5<Array<out Any>, Int, Array<out Any>, Int, Int, Unit> = UtArrayMock::arraycopy
351352
internal val utArrayMockArraycopyMethodName = arraycopyMethod.name

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

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,12 @@ import java.util.*
3838
import kotlin.io.path.pathString
3939
import kotlin.random.Random
4040
import kotlin.reflect.KProperty1
41-
import kotlin.reflect.full.declaredMemberProperties
4241
import kotlin.reflect.full.memberProperties
4342

44-
private val logger = KotlinLogging.logger{}
43+
private val logger = KotlinLogging.logger {}
4544
private val engineProcessLogDirectory = utBotTempDirectory.toFile().resolve("rdEngineProcessLogs")
4645

47-
class EngineProcess(val lifetime:Lifetime) {
46+
class EngineProcess(val lifetime: Lifetime) {
4847
private val id = Random.nextLong()
4948
private var count = 0
5049

@@ -57,7 +56,9 @@ class EngineProcess(val lifetime:Lifetime) {
5756
realPath = configPath
5857
if (realPath == null) {
5958
utBotTempDirectory.toFile().mkdirs()
60-
configPath = Files.writeString(utBotTempDirectory.toFile().resolve("EngineProcess_log4j2.xml").toPath(), """<?xml version="1.0" encoding="UTF-8"?>
59+
configPath = utBotTempDirectory.toFile().resolve("EngineProcess_log4j2.xml").apply {
60+
writeText(
61+
"""<?xml version="1.0" encoding="UTF-8"?>
6162
<Configuration>
6263
<Appenders>
6364
<Console name="Console" target="SYSTEM_OUT">
@@ -70,7 +71,9 @@ class EngineProcess(val lifetime:Lifetime) {
7071
<AppenderRef ref="Console"/>
7172
</Root>
7273
</Loggers>
73-
</Configuration>""")
74+
</Configuration>"""
75+
)
76+
}.toPath()
7477
realPath = configPath
7578
}
7679
}
@@ -81,7 +84,8 @@ class EngineProcess(val lifetime:Lifetime) {
8184
// because we cannot load idea bundled lifetime or it will break everything
8285

8386
private fun debugArgument(): String {
84-
return "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,quiet=y,address=5005".takeIf{ Settings.runIdeaProcessWithDebug} ?: ""
87+
return "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,quiet=y,address=5005".takeIf { Settings.runIdeaProcessWithDebug }
88+
?: ""
8589
}
8690

8791
private val kryoHelper = KryoHelper(lifetime).apply {
@@ -153,12 +157,14 @@ class EngineProcess(val lifetime:Lifetime) {
153157
}.initModels {
154158
engineProcessModel
155159
settingsModel.settingFor.set { params ->
156-
SettingForResult(AbstractSettings.allSettings[params.key]?.let {settings: AbstractSettings ->
157-
val members: Collection<KProperty1<AbstractSettings, *>> = settings.javaClass.kotlin.memberProperties
158-
val names: List<KProperty1<AbstractSettings, *>> = members.filter { it.name == params.propertyName }
160+
SettingForResult(AbstractSettings.allSettings[params.key]?.let { settings: AbstractSettings ->
161+
val members: Collection<KProperty1<AbstractSettings, *>> =
162+
settings.javaClass.kotlin.memberProperties
163+
val names: List<KProperty1<AbstractSettings, *>> =
164+
members.filter { it.name == params.propertyName }
159165
val sing: KProperty1<AbstractSettings, *> = names.single()
160166
val result = sing.get(settings)
161-
logger.trace {"request for settings ${params.key}:${params.propertyName} - $result"}
167+
logger.trace { "request for settings ${params.key}:${params.propertyName} - $result" }
162168
result.toString()
163169
})
164170
}
@@ -179,9 +185,18 @@ class EngineProcess(val lifetime:Lifetime) {
179185

180186
// suppose that only 1 simultaneous test generator process can be executed in idea
181187
// so every time test generator is created - we just overwrite previous
182-
fun createTestGenerator(buildDir: String, classPath: String?, dependencyPaths: String, jdkInfo: JdkInfo,isCancelled: (Unit) -> Boolean) = runBlocking {
188+
fun createTestGenerator(
189+
buildDir: String,
190+
classPath: String?,
191+
dependencyPaths: String,
192+
jdkInfo: JdkInfo,
193+
isCancelled: (Unit) -> Boolean
194+
) = runBlocking {
183195
engineModel().isCancelled.set(handler = isCancelled)
184-
engineModel().createTestGenerator.startSuspending(lifetime, TestGeneratorParams(buildDir, classPath, dependencyPaths, JdkInfo(jdkInfo.path.pathString, jdkInfo.version)))
196+
engineModel().createTestGenerator.startSuspending(
197+
lifetime,
198+
TestGeneratorParams(buildDir, classPath, dependencyPaths, JdkInfo(jdkInfo.path.pathString, jdkInfo.version))
199+
)
185200
}
186201

187202
fun generate(
@@ -197,7 +212,7 @@ class EngineProcess(val lifetime:Lifetime) {
197212
isFuzzingEnabled: Boolean,
198213
fuzzingValue: Double,
199214
searchDirectory: String
200-
): List<UtMethodTestSet> = runBlocking {
215+
): List<UtMethodTestSet> = runBlocking {
201216
val result = engineModel().generate.startSuspending(
202217
lifetime,
203218
GenerateParams(

0 commit comments

Comments
 (0)