Skip to content

Commit ba0e82f

Browse files
committed
[utbot-java]
Review fix
1 parent 0e8bc90 commit ba0e82f

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/UtExecutionInstrumentation.kt

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@ object UtExecutionInstrumentation : Instrumentation<UtConcreteExecutionResult> {
8484
delegateInstrumentation,
8585
timeout
8686
).computeConcreteExecutionResult {
87-
var savedStatics: Map<FieldId, Any?>? = null
88-
8987
try {
9088
val (params, statics, cache) = this.executePhaseInTimeout(valueConstructionPhase) {
9189
val params = constructParameters(stateBefore)
@@ -100,7 +98,7 @@ object UtExecutionInstrumentation : Instrumentation<UtConcreteExecutionResult> {
10098
// invariants:
10199
// 1. phase must always complete if started as static reset relies on it
102100
// 2. phase must be fast as there are no incremental changes
103-
savedStatics = preparationPhase.start {
101+
postprocessingPhase.savedStatics = preparationPhase.start {
104102
val result = setStaticFields(statics)
105103
resetTrace()
106104
result
@@ -146,13 +144,10 @@ object UtExecutionInstrumentation : Instrumentation<UtConcreteExecutionResult> {
146144
coverage
147145
)
148146
} finally {
149-
// postprocessing
150-
savedStatics?.let {
151-
postprocessingPhase.start {
152-
resetStaticFields(it)
153-
}
147+
postprocessingPhase.start {
148+
resetStaticFields()
149+
valueConstructionPhase.resetMockMethods()
154150
}
155-
valueConstructionPhase.resetMockMethods()
156151
}
157152
}
158153
}

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,18 @@ import org.utbot.framework.plugin.api.util.jField
1010
*/
1111
class PostprocessingPhase : ExecutionPhase {
1212

13+
private var savedStaticsInstance: Map<FieldId, Any?>? = null
14+
15+
var savedStatics: Map<FieldId, Any?>
16+
get() = savedStaticsInstance!!
17+
set(value) {
18+
savedStaticsInstance = value
19+
}
20+
1321
override fun wrapError(e: Throwable): ExecutionPhaseException = ExecutionPhaseError(this.javaClass.simpleName, e)
1422

15-
fun resetStaticFields(staticFields: Map<FieldId, Any?>) {
16-
staticFields.forEach { (fieldId, value) ->
23+
fun resetStaticFields() {
24+
savedStatics.forEach { (fieldId, value) ->
1725
fieldId.jField.run {
1826
withAccessibility {
1927
set(null, value)

utbot-junit-contest/build.gradle

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ dependencies {
5656
implementation project(":utbot-analytics")
5757

5858

59-
implementation group: 'com.jetbrains.rd', name: 'rd-framework', version: rdVersion
60-
implementation group: 'com.jetbrains.rd', name: 'rd-core', version: rdVersion
6159
implementation("org.unittestbot.soot:soot-utbot-fork:${sootVersion}") {
6260
exclude group:'com.google.guava', module:'guava'
6361
}

0 commit comments

Comments
 (0)