Skip to content

Commit 7392e6d

Browse files
rebase
1 parent 04fe674 commit 7392e6d

File tree

32 files changed

+223
-201
lines changed

32 files changed

+223
-201
lines changed

Diff for: utbot-core/src/main/kotlin/org/utbot/common/FileUtil.kt

+4-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,10 @@ object FileUtil {
9090

9191
for (clazz in classes) {
9292
val path = clazz.toClassFilePath()
93-
val resource = clazz.classLoader.getResource(path) ?: error("No such file: $path")
93+
val resource =
94+
clazz.classLoader.getResource(path)
95+
?: ClassLoader.getSystemClassLoader().getResource(path)
96+
?: error("No such file: $path")
9497

9598
if (resource.toURI().scheme == "jar") {
9699
val jarLocation = resource.toURI().extractJarName()

Diff for: utbot-framework-api/src/main/kotlin/org/utbot/framework/UtSettings.kt

+5-5
Original file line numberDiff line numberDiff line change
@@ -245,17 +245,17 @@ object UtSettings : AbstractSettings(logger, defaultKeyForSettingsPath, defaultS
245245
/**
246246
* Set to true to use grey-box fuzzing
247247
*/
248-
var useGreyBoxFuzzing: Boolean by getBooleanProperty(true)
248+
var useGreyBoxFuzzing: Boolean by getBooleanProperty(false)
249249

250250
/**
251-
* Set to true to use grey-box fuzzing in competition mode (without asserts generation)
251+
* Set to true to use UtCompositeModels in grey-box fuzzing process
252252
*/
253-
var greyBoxFuzzingCompetitionMode: Boolean by getBooleanProperty(true)
253+
var useCompositeModelsInGreyBoxFuzzing: Boolean by getBooleanProperty(false)
254254

255255
/**
256-
* Set to true to use UtCompositeModels in grey-box fuzzing process
256+
* Set to true to use grey-box fuzzing in competition mode (without asserts generation)
257257
*/
258-
var useCompositeModelsInGreyBoxFuzzing: Boolean by getBooleanProperty(false)
258+
var greyBoxFuzzingCompetitionMode: Boolean by getBooleanProperty(false)
259259

260260
/**
261261
* Set the total attempts to improve coverage by fuzzer.

Diff for: utbot-framework-api/src/main/kotlin/org/utbot/framework/plugin/api/UtExecutionResult.kt

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.utbot.framework.plugin.api
22

3+
import org.utbot.framework.plugin.api.util.objectClassId
34
import org.utbot.framework.plugin.api.visible.UtStreamConsumingException
45
import java.io.File
56
import java.util.LinkedList
@@ -105,6 +106,11 @@ inline fun UtExecutionResult.onFailure(action: (exception: Throwable) -> Unit):
105106
return this
106107
}
107108

109+
fun UtExecutionResult.getOrThrow(): UtModel = when (this) {
110+
is UtExecutionSuccess -> model
111+
is UtExecutionFailure -> throw exception
112+
}
113+
108114
fun UtExecutionResult.exceptionOrNull(): Throwable? = when (this) {
109115
is UtExecutionFailure -> rootCauseException
110116
is UtExecutionSuccess -> null

Diff for: utbot-framework-api/src/main/kotlin/org/utbot/framework/plugin/api/util/UtContext.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import org.utbot.common.currentThreadInfo
55
import org.utbot.framework.plugin.api.util.UtContext.Companion.setUtContext
66
import kotlin.coroutines.CoroutineContext
77
import kotlinx.coroutines.ThreadContextElement
8-
//import mu.KotlinLogging
8+
import mu.KotlinLogging
99

1010
val utContext: UtContext
1111
get() = UtContext.currentContext()
@@ -75,7 +75,7 @@ inline fun <T> withUtContext(context: UtContext, block: () -> T): T = setUtConte
7575
try {
7676
return@use block.invoke()
7777
} catch (e: Exception) {
78-
//KotlinLogging.logger("withUtContext").error { e }
78+
KotlinLogging.logger("withUtContext").error { e }
7979
throw e
8080
}
8181
}

Diff for: utbot-framework/src/main/kotlin/org/utbot/engine/UtBotSymbolicEngine.kt

+5-8
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,9 @@ import org.utbot.framework.UtSettings.pathSelectorStepsLimit
3232
import org.utbot.framework.UtSettings.pathSelectorType
3333
import org.utbot.framework.UtSettings.processUnknownStatesDuringConcreteExecution
3434
import org.utbot.framework.UtSettings.useDebugVisualization
35-
import org.utbot.framework.concrete.UtConcreteExecutionData
36-
import org.utbot.framework.concrete.UtConcreteExecutionResult
37-
import org.utbot.framework.concrete.UtExecutionInstrumentation
38-
import org.utbot.framework.concrete.UtFuzzingExecutionInstrumentation
3935
import org.utbot.framework.concrete.FuzzerConcreteExecutor
40-
import org.utbot.framework.concrete.constructors.UtModelConstructor
41-
import org.utbot.framework.concrete.phases.ValueConstructionContext
36+
import org.utbot.framework.concrete.UtFuzzingExecutionInstrumentation
37+
import org.utbot.framework.util.convertToAssemble
4238
import org.utbot.framework.plugin.api.*
4339
import org.utbot.framework.plugin.api.Step
4440
import org.utbot.framework.plugin.api.util.*
@@ -53,6 +49,8 @@ import org.utbot.instrumentation.ConcreteExecutor
5349
import org.utbot.instrumentation.instrumentation.execution.UtConcreteExecutionData
5450
import org.utbot.instrumentation.instrumentation.execution.UtConcreteExecutionResult
5551
import org.utbot.instrumentation.instrumentation.execution.UtExecutionInstrumentation
52+
import org.utbot.instrumentation.instrumentation.execution.constructors.UtModelConstructor
53+
import org.utbot.instrumentation.instrumentation.execution.phases.ValueConstructionContext
5654
import soot.jimple.Stmt
5755
import soot.tagkit.ParamNamesTag
5856
import java.lang.reflect.Method
@@ -447,8 +445,7 @@ class UtBotSymbolicEngine(
447445
collectConstantsForGreyBoxFuzzer(methodUnderTest.sootMethod, utModelConstructor),
448446
fuzzerUtModelConstructor,
449447
FuzzerConcreteExecutor(
450-
concreteExecutor.pathsToUserClasses,
451-
concreteExecutor.pathsToDependencyClasses
448+
concreteExecutor.pathsToUserClasses
452449
)::execute,
453450
ValueConstructionContext(UtFuzzingExecutionInstrumentation.instrumentationContext, true)::constructParameters,
454451
timeBudget

Diff for: utbot-framework/src/main/kotlin/org/utbot/external/api/UtBotJavaApi.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ object UtBotJavaApi {
7070

7171
val concreteExecutor = ConcreteExecutor(
7272
UtExecutionInstrumentation,
73-
classpath,
73+
classpath
7474
)
7575

7676
testSets.addAll(generateUnitTests(concreteExecutor, methodsForGeneration, classUnderTest))

Diff for: utbot-framework/src/main/kotlin/org/utbot/framework/codegen/domain/context/CgContext.kt

+1-2
Original file line numberDiff line numberDiff line change
@@ -551,9 +551,8 @@ data class CgContext(
551551
}
552552
}
553553

554-
private var nestedClassIndex = 0
555554
private fun createClassIdForNestedClass(testClassModel: TestClassModel): ClassId {
556-
val simpleName = "${testClassModel.classUnderTest.simpleName}Test${nestedClassIndex++}"
555+
val simpleName = "${testClassModel.classUnderTest.simpleName}Test"
557556
return BuiltinClassId(
558557
canonicalName = currentTestClass.canonicalName + "." + simpleName,
559558
simpleName = simpleName,

Diff for: utbot-framework/src/main/kotlin/org/utbot/framework/codegen/domain/models/CgElement.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ class CgClass(
134134
val body: CgClassBody,
135135
val isStatic: Boolean,
136136
val isNested: Boolean,
137-
): CgStatement {
137+
): CgElement {
138138
val packageName
139139
get() = id.packageName
140140

Diff for: utbot-framework/src/main/kotlin/org/utbot/framework/codegen/renderer/CgAbstractRenderer.kt

+1-9
Original file line numberDiff line numberDiff line change
@@ -623,15 +623,7 @@ abstract class CgAbstractRenderer(
623623
is Boolean -> toStringConstant()
624624
// String is "\"" + "str" + "\"", RawString is "str"
625625
is String -> if (asRawString) "$this".escapeCharacters() else toStringConstant()
626-
else -> {
627-
val t = this@toStringConstant.type
628-
val illegalType = t.toString().contains("$") || !t.isPublic
629-
if (this == null && UtSettings.greyBoxFuzzingCompetitionMode && !illegalType) {
630-
"(${this@toStringConstant.type}) null"
631-
} else {
632-
"$this"
633-
}
634-
}
626+
else -> "$this"
635627
}
636628
}
637629

Diff for: utbot-framework/src/main/kotlin/org/utbot/framework/codegen/renderer/CgJavaRenderer.kt

-5
Original file line numberDiff line numberDiff line change
@@ -238,11 +238,6 @@ internal class CgJavaRenderer(context: CgRendererContext, printer: CgPrinter = C
238238
renderExceptions(element)
239239
}
240240

241-
private fun getTypeStringRepresentation(typeId: ClassId): String =
242-
when {
243-
typeId.isArray -> getTypeStringRepresentation(typeId.elementClassId!!) + "[]"
244-
else -> typeId.toString()
245-
}
246241

247242
override fun renderMethodSignature(element: CgMockMethod) {
248243
val returnType = element.returnType.asString()

0 commit comments

Comments
 (0)