Skip to content

Commit 33c61d1

Browse files
Fix review comments
1 parent 3f01700 commit 33c61d1

File tree

5 files changed

+15
-14
lines changed

5 files changed

+15
-14
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ data class Edge(val src: Stmt, val dst: Stmt, val decisionNum: Int)
3434
* [UtExecution]. This state represents the final state of the program execution, that is a throw or return from the outer
3535
* method.
3636
*
37-
* [CONCRETE] is a label for a state which is not suitable for further symbolic analysis and it is also not a terminal
38-
* state. Such states are only suitable for a concrete execution and may appear from [Assumption]s.
37+
* [CONCRETE] is a label for a state which is not suitable for further symbolic analysis, and it is also not a terminal
38+
* state. Such states are only suitable for a concrete execution and may result from [Assumption]s.
3939
*/
4040
enum class StateLabel {
4141
INTERMEDIATE,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ fun SootMethod.canRetrieveBody() =
111111
*/
112112
fun SootMethod.jimpleBody(): JimpleBody {
113113
declaringClass.adjustLevel(BODIES)
114+
require(canRetrieveBody()) { "Can't retrieve body for $this"}
114115
return retrieveActiveBody() as JimpleBody
115116
}
116117

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package org.utbot.engine
22

33
/**
44
* Represents a mutable _Context_ during the [ExecutionState] traversing. This _Context_ consists of all mutable and
5-
* immutable properties and fields which are created and updated during analysis of **one** Jimple instruction.
5+
* immutable properties and fields which are created and updated during analysis of a **single** Jimple instruction.
66
*
77
* Traverser functions should be implemented as an extension functions with [TraversalContext] as a receiver.
88
*
@@ -23,7 +23,7 @@ class TraversalContext {
2323
}
2424

2525
/**
26-
* New states from traversal.
26+
* New states obtained from the traversal.
2727
*/
2828
val nextStates: Collection<ExecutionState>
2929
get() = states

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

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import kotlinx.collections.immutable.persistentSetOf
66
import kotlinx.collections.immutable.toPersistentList
77
import kotlinx.collections.immutable.toPersistentMap
88
import kotlinx.collections.immutable.toPersistentSet
9-
import kotlinx.coroutines.CancellationException
109
import org.utbot.common.WorkaroundReason.HACK
1110
import org.utbot.common.WorkaroundReason.REMOVE_ANONYMOUS_CLASSES
1211
import org.utbot.common.findField
@@ -213,6 +212,7 @@ class Traverser(
213212
private val classLoader: ClassLoader
214213
get() = utContext.classLoader
215214

215+
// TODO: move this and other mutable fields to [TraversalContext]
216216
lateinit var environment: Environment
217217
private val solver: UtSolver
218218
get() = environment.state.solver
@@ -281,13 +281,9 @@ class Traverser(
281281
} catch (ex: Throwable) {
282282
environment.state.close()
283283

284-
if (ex !is CancellationException) {
285-
logger.error(ex) { "Test generation failed on stmt $currentStmt, symbolic stack trace:\n$symbolicStackTrace" }
286-
// TODO: enrich with nice description for known issues
287-
throw ex
288-
} else {
289-
logger.debug(ex) { "Cancellation happened" }
290-
}
284+
logger.error(ex) { "Test generation failed on stmt $currentStmt, symbolic stack trace:\n$symbolicStackTrace" }
285+
// TODO: enrich with nice description for known issues
286+
throw ex
291287
}
292288
queuedSymbolicStateUpdates = SymbolicStateUpdate()
293289
return context.nextStates
@@ -2991,7 +2987,8 @@ class Traverser(
29912987
implicitlyThrowException(NullPointerException(), setOf(notMarkedAndNull))
29922988
}
29932989

2994-
queuedSymbolicStateUpdates += canNotBeNull.asHardConstraint() }
2990+
queuedSymbolicStateUpdates += canNotBeNull.asHardConstraint()
2991+
}
29952992

29962993
private fun TraversalContext.divisionByZeroCheck(denom: PrimitiveValue) {
29972994
val equalsToZero = Eq(denom, 0)
@@ -3363,7 +3360,8 @@ class Traverser(
33633360
return
33643361
}
33653362

3366-
//toplevel method
3363+
// toplevel method
3364+
// TODO: investigate very strange behavior when some constraints are not added leading to failing CodegenExampleTest::firstExampleTest fails
33673365
val terminalExecutionState = environment.state.copy(
33683366
symbolicState = symbolicState,
33693367
methodResult = methodResult, // the way to put SymbolicResult into terminal state

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,8 @@ class UtBotSymbolicEngine(
351351
// So we need to make it throw CancelledException by method below:
352352
currentCoroutineContext().job.ensureActive()
353353
}
354+
355+
// TODO: think about concise modifying globalGraph in Traverser and UtBotSymbolicEngine
354356
globalGraph.visitNode(state)
355357
}
356358
}

0 commit comments

Comments
 (0)