@@ -38,13 +38,12 @@ import java.util.*
38
38
import kotlin.io.path.pathString
39
39
import kotlin.random.Random
40
40
import kotlin.reflect.KProperty1
41
- import kotlin.reflect.full.declaredMemberProperties
42
41
import kotlin.reflect.full.memberProperties
43
42
44
- private val logger = KotlinLogging .logger{}
43
+ private val logger = KotlinLogging .logger {}
45
44
private val engineProcessLogDirectory = utBotTempDirectory.toFile().resolve(" rdEngineProcessLogs" )
46
45
47
- class EngineProcess (val lifetime : Lifetime ) {
46
+ class EngineProcess (val lifetime : Lifetime ) {
48
47
private val id = Random .nextLong()
49
48
private var count = 0
50
49
@@ -57,7 +56,9 @@ class EngineProcess(val lifetime:Lifetime) {
57
56
realPath = configPath
58
57
if (realPath == null ) {
59
58
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"?>
61
62
<Configuration>
62
63
<Appenders>
63
64
<Console name="Console" target="SYSTEM_OUT">
@@ -70,7 +71,9 @@ class EngineProcess(val lifetime:Lifetime) {
70
71
<AppenderRef ref="Console"/>
71
72
</Root>
72
73
</Loggers>
73
- </Configuration>""" )
74
+ </Configuration>"""
75
+ )
76
+ }.toPath()
74
77
realPath = configPath
75
78
}
76
79
}
@@ -81,7 +84,8 @@ class EngineProcess(val lifetime:Lifetime) {
81
84
// because we cannot load idea bundled lifetime or it will break everything
82
85
83
86
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
+ ? : " "
85
89
}
86
90
87
91
private val kryoHelper = KryoHelper (lifetime).apply {
@@ -153,12 +157,14 @@ class EngineProcess(val lifetime:Lifetime) {
153
157
}.initModels {
154
158
engineProcessModel
155
159
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 }
159
165
val sing: KProperty1 <AbstractSettings , * > = names.single()
160
166
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 " }
162
168
result.toString()
163
169
})
164
170
}
@@ -179,9 +185,18 @@ class EngineProcess(val lifetime:Lifetime) {
179
185
180
186
// suppose that only 1 simultaneous test generator process can be executed in idea
181
187
// 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 {
183
195
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
+ )
185
200
}
186
201
187
202
fun generate (
@@ -197,7 +212,7 @@ class EngineProcess(val lifetime:Lifetime) {
197
212
isFuzzingEnabled : Boolean ,
198
213
fuzzingValue : Double ,
199
214
searchDirectory : String
200
- ): List <UtMethodTestSet > = runBlocking {
215
+ ): List <UtMethodTestSet > = runBlocking {
201
216
val result = engineModel().generate.startSuspending(
202
217
lifetime,
203
218
GenerateParams (
0 commit comments