Skip to content

Commit 26a4530

Browse files
committed
[utbot-rider]
bug fix
1 parent dceb000 commit 26a4530

File tree

9 files changed

+39
-16
lines changed

9 files changed

+39
-16
lines changed

build.gradle.kts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ allprojects {
5353
}
5454
}
5555
withType<Test> {
56+
testLogging.showStandardStreams = true
57+
testLogging.showStackTraces = true
5658
// set heap size for the test JVM(s)
5759
minHeapSize = "128m"
5860
maxHeapSize = "3072m"
@@ -68,6 +70,9 @@ allprojects {
6870
override fun beforeTest(testDescriptor: TestDescriptor) {}
6971
override fun afterTest(testDescriptor: TestDescriptor, result: TestResult) {
7072
println("[$testDescriptor.classDisplayName] [$testDescriptor.displayName]: $result.resultType, length - ${(result.endTime - result.startTime) / 1000.0} sec")
73+
if (result.resultType == org.gradle.api.tasks.testing.TestResult.ResultType.FAILURE) {
74+
println("Exception: " + result.exception?.stackTraceToString())
75+
}
7176
}
7277

7378
override fun afterSuite(testDescriptor: TestDescriptor, result: TestResult) {

utbot-framework-api/src/main/kotlin/org/utbot/framework/plugin/api/Api.kt

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,16 @@ class UtFailedExecution(
215215
open class EnvironmentModels(
216216
val thisInstance: UtModel?,
217217
val parameters: List<UtModel>,
218-
val statics: Map<FieldId, UtModel>
218+
val statics: Map<FieldId, UtModel>,
219+
fromMissingState: Boolean
219220
) {
221+
constructor(thisInstance: UtModel?, parameters: List<UtModel>, statics: Map<FieldId, UtModel>): this(thisInstance, parameters, statics, false)
222+
223+
init {
224+
if (!fromMissingState && thisInstance == null && parameters.isEmpty() && statics.isEmpty()) {
225+
Exception("something is bad, constructing huawei models").printStackTrace()
226+
}
227+
}
220228
override fun toString() = buildString {
221229
append("this=$thisInstance")
222230
appendOptional("parameters", parameters)
@@ -234,8 +242,13 @@ open class EnvironmentModels(
234242
object MissingState : EnvironmentModels(
235243
thisInstance = null,
236244
parameters = emptyList(),
237-
statics = emptyMap()
238-
)
245+
statics = emptyMap(),
246+
fromMissingState = true
247+
) {
248+
override fun toString(): String {
249+
return "missing state"
250+
}
251+
}
239252

240253
/**
241254
* Error happened in traverse.

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import kotlinx.collections.immutable.persistentSetOf
77
import kotlinx.collections.immutable.toPersistentList
88
import kotlinx.collections.immutable.toPersistentMap
99
import kotlinx.collections.immutable.toPersistentSet
10+
import mu.KotlinLogging
1011
import org.utbot.common.WorkaroundReason.HACK
1112
import org.utbot.framework.UtSettings.ignoreStaticsFromTrustedLibraries
1213
import org.utbot.common.WorkaroundReason.IGNORE_STATICS_FROM_TRUSTED_LIBRARIES
@@ -224,6 +225,7 @@ import java.lang.reflect.TypeVariable
224225
import java.lang.reflect.WildcardType
225226

226227
private val CAUGHT_EXCEPTION = LocalVariable("@caughtexception")
228+
private val logger = KotlinLogging.logger {}
227229

228230
class Traverser(
229231
private val methodUnderTest: ExecutableId,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ import java.lang.reflect.Method
5151
import kotlin.math.min
5252
import kotlin.system.measureTimeMillis
5353

54-
val logger = KotlinLogging.logger {}
54+
private val logger = KotlinLogging.logger {}
5555
val pathLogger = KotlinLogging.logger(logger.name + ".path")
5656

5757
//in future we should put all timeouts here

utbot-framework/src/main/kotlin/org/utbot/framework/util/EngineUtils.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package org.utbot.framework.util
22

3+
import mu.KotlinLogging
4+
import org.utbot.common.logException
35
import org.utbot.framework.plugin.api.util.constructor.ValueConstructor
46
import org.utbot.framework.plugin.api.ExecutableId
57
import org.utbot.framework.plugin.api.MissingState
@@ -16,6 +18,8 @@ import java.util.concurrent.atomic.AtomicInteger
1618
import soot.SootMethod
1719

1820

21+
private val logger = KotlinLogging.logger { }
22+
1923
/**
2024
* Gets method or constructor id of SootMethod.
2125
*/
@@ -52,5 +56,5 @@ fun UtSymbolicExecution.hasThisInstance(): Boolean = when {
5256
// An execution must either have this instance or not.
5357
// This instance cannot be absent before execution and appear after
5458
// as well as it cannot be present before execution and disappear after.
55-
else -> error("Execution configuration must not change between states")
59+
else -> logger.logException { error("Execution configuration must not change between states") }
5660
}

utbot-framework/src/main/kotlin/org/utbot/framework/util/UtConcreteExecutionResultUtils.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package org.utbot.framework.util
22

33
import org.utbot.framework.assemble.AssembleModelGenerator
44
import org.utbot.framework.plugin.api.EnvironmentModels
5+
import org.utbot.framework.plugin.api.MissingState
56
import org.utbot.framework.plugin.api.UtExecutionSuccess
67
import org.utbot.framework.plugin.api.UtModel
78
import org.utbot.instrumentation.instrumentation.execution.UtConcreteExecutionResult
@@ -12,7 +13,7 @@ private fun UtConcreteExecutionResult.updateWithAssembleModels(
1213
): UtConcreteExecutionResult {
1314
val toAssemble: (UtModel) -> UtModel = { assembledUtModels.getOrDefault(it, it) }
1415

15-
val resolvedStateAfter = EnvironmentModels(
16+
val resolvedStateAfter = if (stateAfter is MissingState) MissingState else EnvironmentModels(
1617
stateAfter.thisInstance?.let { toAssemble(it) },
1718
stateAfter.parameters.map { toAssemble(it) },
1819
stateAfter.statics.mapValues { toAssemble(it.value) }

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,27 @@ import com.jetbrains.rd.util.getLogger
44
import org.utbot.instrumentation.instrumentation.execution.UtConcreteExecutionResult
55
import org.utbot.rd.logMeasure
66

7-
val logger = getLogger("Executionphase")
7+
private val logger = getLogger("ExecutionPhase")
88

9-
abstract class ExecutionPhaseException(override val message: String): Exception()
9+
abstract class ExecutionPhaseException(override val message: String) : Exception()
1010

1111
// InstrumentationProcessError
1212
class ExecutionPhaseError(phase: String, override val cause: Throwable) : ExecutionPhaseException(phase)
1313

1414
// Ok
15-
class ExecutionPhaseStop(phase: String, val result: UtConcreteExecutionResult): ExecutionPhaseException(phase )
15+
class ExecutionPhaseStop(phase: String, val result: UtConcreteExecutionResult) : ExecutionPhaseException(phase)
1616

1717
interface ExecutionPhase {
1818
fun wrapError(e: Throwable): ExecutionPhaseException
1919
}
2020

21-
fun <T: ExecutionPhase, R> T.start(block: T.() -> R): R =
21+
fun <T : ExecutionPhase, R> T.start(block: T.() -> R): R =
2222
try {
2323
logger.logMeasure(this.javaClass.simpleName) {
2424
this.block()
2525
}
26-
}
27-
catch (e: ExecutionPhaseStop) {
26+
} catch (e: ExecutionPhaseStop) {
2827
throw e
29-
}
30-
catch (e: Throwable) {
28+
} catch (e: Throwable) {
3129
throw this.wrapError(e)
3230
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class PhasesController(
6060
withUtContext(context) {
6161
phase.block()
6262
}
63-
} ?: throw TimeoutException("Timeout for phase $timeoutForCurrentPhase elapsed, controller timeout - $timeout")
63+
} ?: throw TimeoutException("Timeout $timeoutForCurrentPhase ms for phase ${phase.javaClass.simpleName} elapsed, controller timeout - $timeout")
6464

6565
val blockElapsed = stopWatch.get()
6666
currentlyElapsed += blockElapsed

utbot-rd/src/main/kotlin/org/utbot/rd/UtRdUtil.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ inline fun <T> Logger.logMeasure(tag: String = "", block: () -> T): T {
133133
return block()
134134
}
135135
catch (e: Throwable) {
136-
this.debug { "exception during evaluating $tag: ${e.printStackTrace()}" }
136+
this.debug { "exception during evaluating $tag: ${e.stackTraceToString()}" }
137137
throw e
138138
}
139139
finally {

0 commit comments

Comments
 (0)