Skip to content

Commit 472a971

Browse files
committed
Construct shallow result models during non-rerun runs
1 parent bd21af8 commit 472a971

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/constructors/UtModelConstructor.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class UtModelConstructor(
4141
private val constructedObjects = IdentityHashMap<Any, UtModel>()
4242

4343
companion object {
44-
private const val DEFAULT_MAX_DEPTH = 7L
44+
const val DEFAULT_MAX_DEPTH = 7L
4545

4646
fun createOnlyUserClassesConstructor(
4747
pathsToUserClasses: Set<String>,

utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/phases/ModelConstructionPhase.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,28 @@ class ModelConstructionPhase(
4040
}
4141
}
4242

43+
private val constructorConfiguration = ConstructorConfiguration()
4344
private lateinit var constructor: UtModelConstructor
4445

4546
class ConstructorConfiguration {
4647
lateinit var cache: IdentityHashMap<Any, UtModel>
4748
lateinit var strategy: UtCompositeModelStrategy
49+
var maxDepth: Long = UtModelConstructor.DEFAULT_MAX_DEPTH
50+
}
51+
52+
fun preconfigureConstructor(block: ConstructorConfiguration.() -> Unit) {
53+
constructorConfiguration.block()
4854
}
4955

5056
fun configureConstructor(block: ConstructorConfiguration.() -> Unit) {
51-
ConstructorConfiguration().run {
57+
constructorConfiguration.run {
5258
block()
5359
constructor = UtModelConstructor(
5460
objectToModelCache = cache,
5561
utModelWithCompositeOriginConstructorFinder = utModelWithCompositeOriginConstructorFinder,
5662
compositeModelStrategy = strategy,
5763
idGenerator = idGenerator,
64+
maxDepth = maxDepth,
5865
)
5966
}
6067
}

utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/spring/SpringUtExecutionInstrumentation.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ class SpringUtExecutionInstrumentation(
107107

108108
return try {
109109
delegateInstrumentation.invoke(clazz, methodSignature, arguments, parameters) { invokeBasePhases ->
110+
if (!parameters.isRerun)
111+
modelConstructionPhase.preconfigureConstructor { maxDepth = 0 }
112+
110113
phasesWrapper {
111114
// NB! beforeTestMethod() and afterTestMethod() are intentionally called inside phases,
112115
// so they are executed in one thread with method under test

0 commit comments

Comments
 (0)