Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

USVM experimental integration into UnitTestBot #2732

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
dbeaf15
Add usvm engine option on UI
EgorkaKulikov Dec 11, 2023
8c4a3ea
Sens engine type data to engine process via Rd
EgorkaKulikov Dec 11, 2023
e1e7139
Use appropriate engine in flow
EgorkaKulikov Dec 11, 2023
3fc587e
Introduce `UtilMethodProviderPlaceholder` (#2717)
IlyaMuravjov Dec 13, 2023
5d68839
Make `TestCaseGenerator` use `UsvmSymbolicEngine` for entire class (#…
IlyaMuravjov Dec 13, 2023
24d1003
Initial implementation of usvm tests generation in UtBot flow
EgorkaKulikov Dec 18, 2023
4ad8c4a
Apply some improvements
EgorkaKulikov Dec 19, 2023
91803c2
Update usvm version and related updates in JcContainer
EgorkaKulikov Dec 19, 2023
7779a3b
Update usvm version and related updates in ClassScorer usages
EgorkaKulikov Dec 20, 2023
44f0c2a
Correct applyCommonMappings methods
EgorkaKulikov Dec 20, 2023
ce16821
Several UI corrections
EgorkaKulikov Dec 20, 2023
3b3ab15
Fix JcContainer caching
EgorkaKulikov Dec 20, 2023
3a0da82
Apply discussion fixes.
EgorkaKulikov Dec 21, 2023
cf23242
Fix enablement of useExperimentalEngine
EgorkaKulikov Dec 21, 2023
0108b05
Refactoring
tepa46 Dec 21, 2023
06529ea
Add assemble models in USVM symbolic engine
tepa46 Dec 21, 2023
aba7c4f
Update utResult value
tepa46 Dec 21, 2023
fe1cee7
Resrtore Python IDE
EgorkaKulikov Dec 22, 2023
351c10d
Do not initialize Jc-flow if timeout = 0
EgorkaKulikov Dec 22, 2023
aa84d2a
Fix `modificationsChain` mapping when removing `UtilMethodProviderPla…
IlyaMuravjov Dec 22, 2023
fd47bc7
Make `UtSymbolicExecution.copy` method also copy `containsMocking` field
IlyaMuravjov Dec 22, 2023
e30f887
Set `zip64 = true` in `:utbot-cli:jar` Gradle task
IlyaMuravjov Dec 22, 2023
c8fc4a5
Revert redundant refactoring
IlyaMuravjov Dec 22, 2023
c89b3b2
Use same `memoryScope` to resolve `uTest` and `symbolicResult`.
IlyaMuravjov Dec 22, 2023
8831369
Preserve identity when mapping `MissingState`
IlyaMuravjov Dec 22, 2023
392d784
Set `zip64 = true` in `:utbot-cli-go:jar`, `:utbot-cli-js:jar`, `:utb…
IlyaMuravjov Dec 22, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ springBootVersion=2.7.13
springSecurityVersion=5.8.5

approximationsVersion=bfce4eedde
usvmVersion=72924ad
usvmVersion=7b45e18b0e

# configuration for build server
#
Expand Down
1 change: 1 addition & 0 deletions utbot-cli-go/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ classes {
}

jar {
zip64 = true
manifest {
attributes 'Main-Class': 'org.utbot.cli.go.ApplicationKt'
attributes 'Bundle-SymbolicName': 'org.utbot.cli.go'
Expand Down
1 change: 1 addition & 0 deletions utbot-cli-js/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ classes {
}

jar {
zip64 = true
manifest {
attributes 'Main-Class': 'org.utbot.cli.js.ApplicationKt'
attributes 'Bundle-SymbolicName': 'org.utbot.cli.js'
Expand Down
1 change: 1 addition & 0 deletions utbot-cli-python/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ classes {
}

jar {
zip64 = true
manifest {
attributes 'Main-Class': 'org.utbot.cli.language.python.ApplicationKt'
attributes 'Bundle-SymbolicName': 'org.utbot.cli.language.python'
Expand Down
1 change: 1 addition & 0 deletions utbot-cli/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ classes {
}

jar {
zip64 = true
manifest {
attributes 'Main-Class': 'org.utbot.cli.ApplicationKt'
attributes 'Bundle-SymbolicName': 'org.utbot.cli'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ import kotlin.contracts.contract
import org.utbot.common.isAbstract
import org.utbot.framework.plugin.api.mapper.UtModelMapper
import org.utbot.framework.plugin.api.mapper.map
import org.utbot.framework.plugin.api.mapper.mapModelIfExists
import org.utbot.framework.plugin.api.mapper.mapModels
import org.utbot.framework.plugin.api.mapper.mapPreservingType
import org.utbot.framework.plugin.api.util.SpringModelUtils
import org.utbot.framework.process.OpenModulesContainer
Expand All @@ -73,6 +75,11 @@ data class UtMethodTestSet(
val clustersInfo: List<Pair<UtClusterInfo?, IntRange>> = listOf(null to executions.indices)
)

fun UtMethodTestSet.mapModels(mapper: UtModelMapper): UtMethodTestSet =
copy(executions = executions.map { it.mapModels(mapper) })

fun Collection<UtMethodTestSet>.mapModels(mapper: UtModelMapper) = map { it.mapModels(mapper) }

data class Step(
val stmt: Stmt,
val depth: Int,
Expand Down Expand Up @@ -145,11 +152,70 @@ abstract class UtExecution(
displayName: String? = this.displayName,
): UtExecution

open fun mapModels(mapper: UtModelMapper) = copy(
stateBefore = stateBefore.mapModels(mapper),
stateAfter = stateAfter.mapModels(mapper),
result = result.mapModelIfExists(mapper)
)

val executableToCall get() = stateBefore.executableToCall
}

interface UtExecutionWithInstrumentation {
val instrumentation: List<UtInstrumentation>
abstract class UtExecutionWithInstrumentation(
stateBefore: EnvironmentModels,
stateAfter: EnvironmentModels,
result: UtExecutionResult,
coverage: Coverage? = null,
summary: List<DocStatement>? = null,
testMethodName: String? = null,
displayName: String? = null,
val instrumentation: List<UtInstrumentation>,
) : UtExecution(
stateBefore = stateBefore,
stateAfter = stateAfter,
result = result,
coverage = coverage,
summary = summary,
testMethodName = testMethodName,
displayName = displayName,
) {
abstract fun copy(
stateBefore: EnvironmentModels = this.stateBefore,
stateAfter: EnvironmentModels = this.stateAfter,
result: UtExecutionResult = this.result,
coverage: Coverage? = this.coverage,
summary: List<DocStatement>? = this.summary,
testMethodName: String? = this.testMethodName,
displayName: String? = this.displayName,
instrumentation: List<UtInstrumentation> = this.instrumentation,
): UtExecution

override fun copy(
stateBefore: EnvironmentModels,
stateAfter: EnvironmentModels,
result: UtExecutionResult,
coverage: Coverage?,
summary: List<DocStatement>?,
testMethodName: String?,
displayName: String?,
): UtExecution = copy(
stateBefore = stateBefore,
stateAfter = stateAfter,
result = result,
instrumentation = instrumentation,
coverage = coverage,
summary = summary,
testMethodName = testMethodName,
displayName = displayName,
)

override fun mapModels(mapper: UtModelMapper): UtExecution =
copy(
stateBefore = stateBefore.mapModels(mapper),
stateAfter = stateAfter.mapModels(mapper),
result = result.mapModelIfExists(mapper),
instrumentation = instrumentation.map { it.mapModels(mapper) },
)
}

/**
Expand All @@ -167,15 +233,24 @@ class UtSymbolicExecution(
stateBefore: EnvironmentModels,
stateAfter: EnvironmentModels,
result: UtExecutionResult,
override val instrumentation: List<UtInstrumentation>,
instrumentation: List<UtInstrumentation>,
val path: MutableList<Step>,
val fullPath: List<Step>,
coverage: Coverage? = null,
summary: List<DocStatement>? = null,
testMethodName: String? = null,
displayName: String? = null,
/** Convenient view of the full symbolic path */ val symbolicSteps: List<SymbolicStep> = listOf(),
) : UtExecution(stateBefore, stateAfter, result, coverage, summary, testMethodName, displayName), UtExecutionWithInstrumentation {
) : UtExecutionWithInstrumentation(
stateBefore,
stateAfter,
result,
coverage,
summary,
testMethodName,
displayName,
instrumentation
) {
/**
* By design the 'before' and 'after' states contain info about the same fields.
* It means that it is not possible for a field to be present at 'before' and to be absent at 'after'.
Expand All @@ -193,7 +268,8 @@ class UtSymbolicExecution(
coverage: Coverage?,
summary: List<DocStatement>?,
testMethodName: String?,
displayName: String?
displayName: String?,
instrumentation: List<UtInstrumentation>,
): UtExecution = UtSymbolicExecution(
stateBefore = stateBefore,
stateAfter = stateAfter,
Expand All @@ -205,7 +281,9 @@ class UtSymbolicExecution(
summary = summary,
testMethodName = testMethodName,
displayName = displayName
)
).also {
it.containsMocking = containsMocking
}

override fun toString(): String = buildString {
append("UtSymbolicExecution(")
Expand Down Expand Up @@ -252,7 +330,9 @@ class UtSymbolicExecution(
summary = summary,
testMethodName = testMethodName,
displayName = displayName
)
).also {
it.containsMocking = containsMocking
}
}

/**
Expand Down Expand Up @@ -1369,19 +1449,49 @@ class BuiltinMethodId(
name: String,
returnType: ClassId,
parameters: List<ClassId>,
bypassesSandbox: Boolean = false,
// by default we assume that the builtin method is non-static and public
isStatic: Boolean = false,
isPublic: Boolean = true,
isProtected: Boolean = false,
isPrivate: Boolean = false
bypassesSandbox: Boolean,
override val modifiers: Int,
) : MethodId(classId, name, returnType, parameters, bypassesSandbox) {
override val modifiers: Int = ModifierFactory {
static = isStatic
public = isPublic
private = isPrivate
protected = isProtected
}
constructor(
classId: ClassId,
name: String,
returnType: ClassId,
parameters: List<ClassId>,
bypassesSandbox: Boolean = false,
// by default, we assume that the builtin method is non-static and public
isStatic: Boolean = false,
isPublic: Boolean = true,
isProtected: Boolean = false,
isPrivate: Boolean = false
) : this(
classId = classId,
name = name,
returnType = returnType,
parameters = parameters,
bypassesSandbox = bypassesSandbox,
modifiers = ModifierFactory {
static = isStatic
public = isPublic
private = isPrivate
protected = isProtected
}
)

fun copy(
classId: ClassId = this.classId,
name: String = this.name,
returnType: ClassId = this.returnType,
parameters: List<ClassId> = this.parameters,
bypassesSandbox: Boolean = this.bypassesSandbox,
modifiers: Int = this.modifiers,
) = BuiltinMethodId(
classId = classId,
name = name,
returnType = returnType,
parameters = parameters,
bypassesSandbox = bypassesSandbox,
modifiers = modifiers,
)
}

class BuiltinConstructorId(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.utbot.framework.plugin.api.mapper

import org.utbot.framework.plugin.api.EnvironmentModels
import org.utbot.framework.plugin.api.MissingState
import org.utbot.framework.plugin.api.UtDirectGetFieldModel
import org.utbot.framework.plugin.api.UtDirectSetFieldModel
import org.utbot.framework.plugin.api.UtExecutableCallModel
Expand Down Expand Up @@ -50,12 +51,15 @@ fun UtStatementCallModel.mapModels(mapper: UtModelMapper): UtStatementCallModel
)
}

fun EnvironmentModels.mapModels(mapper: UtModelMapper) = EnvironmentModels(
thisInstance = thisInstance?.map(mapper),
statics = statics.mapModelValues(mapper),
parameters = parameters.mapModels(mapper),
executableToCall = executableToCall,
)
fun EnvironmentModels.mapModels(mapper: UtModelMapper) = when (this) {
MissingState -> MissingState
else -> EnvironmentModels(
thisInstance = thisInstance?.map(mapper),
statics = statics.mapModelValues(mapper),
parameters = parameters.mapModels(mapper),
executableToCall = executableToCall,
)
}

fun UtExecutionResult.mapModelIfExists(mapper: UtModelMapper) = if (this.isSuccess) {
val successResult = this as UtExecutionSuccess
Expand All @@ -72,4 +76,4 @@ fun UtInstrumentation.mapModels(mapper: UtModelMapper) = when (this) {

fun UtExecution.mapStateBeforeModels(mapper: UtModelMapper) = copy(
stateBefore = stateBefore.mapModels(mapper)
)
)
2 changes: 2 additions & 0 deletions utbot-framework/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ dependencies {
api project(':utbot-rd')
api project(':utbot-modificators-analyzer')

api project(':utbot-usvm')

implementation group: 'com.jetbrains.rd', name: 'rd-framework', version: rdVersion
implementation group: 'com.jetbrains.rd', name: 'rd-core', version: rdVersion

Expand Down
Loading