Skip to content

Commit 5274326

Browse files
Fix review comments
1 parent 8de3af5 commit 5274326

File tree

4 files changed

+11
-12
lines changed

4 files changed

+11
-12
lines changed

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: 6 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
@@ -211,7 +210,7 @@ class Traverser(
211210
private val classLoader: ClassLoader
212211
get() = utContext.classLoader
213212

214-
// TODO: get rid of it
213+
// TODO: move this and other mutable fields to [TraversalContext]
215214
lateinit var environment: Environment
216215
private val solver: UtSolver
217216
get() = environment.state.solver
@@ -280,13 +279,9 @@ class Traverser(
280279
} catch (ex: Throwable) {
281280
environment.state.close()
282281

283-
if (ex !is CancellationException) {
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
287-
} else {
288-
logger.debug(ex) { "Cancellation happened" }
289-
}
282+
logger.error(ex) { "Test generation failed on stmt $currentStmt, symbolic stack trace:\n$symbolicStackTrace" }
283+
// TODO: enrich with nice description for known issues
284+
throw ex
290285
}
291286
queuedSymbolicStateUpdates = SymbolicStateUpdate()
292287
return context.nextStates
@@ -3310,7 +3305,8 @@ class Traverser(
33103305
return
33113306
}
33123307

3313-
//toplevel method
3308+
// toplevel method
3309+
// TODO: investigate very strange behavior when some constraints are not added leading to failing CodegenExampleTest::firstExampleTest fails
33143310
val terminalExecutionState = environment.state.copy(
33153311
symbolicState = symbolicState,
33163312
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)