Skip to content

Commit 3a532c6

Browse files
committed
Add usvm
1 parent e4e83db commit 3a532c6

File tree

18 files changed

+222
-123
lines changed

18 files changed

+222
-123
lines changed

build.gradle.kts

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import java.text.SimpleDateFormat
2-
import org.gradle.api.JavaVersion.*
32
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
43

54
group = "org.utbot"
@@ -137,13 +136,27 @@ allprojects {
137136
}
138137
}
139138

139+
// from GRADLE_USER_HOME/gradle.properties
140+
val githubUserFromHome: String? by project
141+
val githubTokenFromHome: String? by project // with permission to read packages
142+
143+
val githubUser: String = githubUserFromHome ?: System.getenv("GITHUB_ACTOR") ?: error("githubUser not defined")
144+
val githubToken: String = githubTokenFromHome ?: System.getenv("GITHUB_TOKEN") ?: error("githubToken not defined")
145+
140146
repositories {
141147
mavenCentral()
142148
maven("https://jitpack.io")
143149
maven("https://s01.oss.sonatype.org/content/repositories/orgunittestbotsoot-1004/")
144150
maven("https://plugins.gradle.org/m2")
145151
maven("https://www.jetbrains.com/intellij-repository/releases")
146152
maven("https://cache-redirector.jetbrains.com/maven-central")
153+
maven {
154+
url = uri("https://maven.pkg.github.com/UnitTestBot/usvm")
155+
credentials {
156+
username = githubUser
157+
password = githubToken
158+
}
159+
}
147160
}
148161

149162
dependencies {
@@ -209,3 +222,29 @@ configure(
209222
}
210223
}
211224
}
225+
226+
// from GRADLE_USER_HOME/gradle.properties
227+
val githubUserFromHome: String? by project
228+
val githubTokenFromHome: String? by project // with permission to read packages
229+
230+
val githubUser: String = githubUserFromHome ?: System.getenv("GITHUB_ACTOR") ?: error("githubUser not defined")
231+
val githubToken: String = githubTokenFromHome ?: System.getenv("GITHUB_TOKEN") ?: error("githubToken not defined")
232+
233+
configure(
234+
listOf(
235+
project(":utbot-python"),
236+
project(":utbot-intellij-python"),
237+
project(":utbot-intellij-main"),
238+
project(":utbot-cli-python"),
239+
)
240+
) {
241+
repositories {
242+
maven {
243+
url = uri("https://maven.pkg.github.com/UnitTestBot/usvm")
244+
credentials {
245+
username = githubUser
246+
password = githubToken
247+
}
248+
}
249+
}
250+
}

utbot-cli-python/src/main/kotlin/org/utbot/cli/language/python/PythonGenerateTestsCommand.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,10 +280,10 @@ class PythonGenerateTestsCommand : CliktCommand(
280280
)
281281

282282
logger.info("Loading information about Python types...")
283-
val (mypyStorage, mypyReport) = processor.sourceCodeAnalyze()
283+
val mypyConfig = processor.sourceCodeAnalyze()
284284

285285
logger.info("Generating tests...")
286-
var testSets = processor.testGenerate(mypyStorage, mypyReport)
286+
var testSets = processor.testGenerate(mypyConfig)
287287
if (testSets.isEmpty()) return
288288
if (doNotGenerateRegressionSuite) {
289289
testSets = testSets.map { testSet ->

utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/PythonDialogProcessor.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ object PythonDialogProcessor {
287287

288288
localUpdateIndicator(ProgressRange.ANALYZE, "Analyze module ${model.currentPythonModule}", 0.5)
289289

290-
val (mypyStorage, mypyReport) = processor.sourceCodeAnalyze()
290+
val mypyConfig = processor.sourceCodeAnalyze()
291291

292292
localUpdateIndicator(ProgressRange.ANALYZE, "Analyze module ${model.currentPythonModule}", 1.0)
293293

@@ -300,7 +300,7 @@ object PythonDialogProcessor {
300300
model.timeout,
301301
)
302302
try {
303-
val testSets = processor.testGenerate(mypyStorage, mypyReport)
303+
val testSets = processor.testGenerate(mypyConfig)
304304
timerHandler.cancel(true)
305305
if (testSets.isEmpty()) return@forEachIndexed
306306

@@ -312,7 +312,7 @@ object PythonDialogProcessor {
312312

313313
logger.info(
314314
"Finished test generation for the following functions: ${
315-
testSets.joinToString { it.method.name }
315+
testSets.map { it.method.name }.toSet().joinToString()
316316
}"
317317
)
318318
} finally {

utbot-python-executor/src/main/python/utbot_executor/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "utbot-executor"
3-
version = "1.9.0.dev9"
3+
version = "1.9.0.dev10"
44
description = ""
55
authors = ["Vyacheslav Tamarin <vyacheslav.tamarin@yandex.ru>"]
66
readme = "README.md"

utbot-python-executor/src/main/python/utbot_executor/utbot_executor/deep_serialization/memory_objects.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,10 @@ def initialize(self) -> None:
332332
for key, value in dictitems.items():
333333
deserialized_obj[key] = value
334334

335-
comparable = self.obj == deserialized_obj
335+
try:
336+
comparable = self.obj == deserialized_obj
337+
except:
338+
comparable = False
336339

337340
super()._initialize(deserialized_obj, comparable)
338341

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.9.0.dev9
1+
1.9.0.dev10

utbot-python-types/src/main/kotlin/org/utbot/python/newtyping/mypy/RunMypy.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class MypyBuildDirectory(
1919
val fileForMypyStdout = File(root, mypyStdoutFilename)
2020
val fileForMypyStderr = File(root, mypyStderrFilename)
2121
val fileForMypyExitStatus = File(root, mypyExitStatusFilename)
22-
private val dirForCache = File(root, mypyCacheDirectoryName)
22+
val dirForCache = File(root, mypyCacheDirectoryName)
2323

2424
init {
2525
val configContent = """

utbot-python/build.gradle.kts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ val intellijPluginVersion: String? by rootProject
22
val kotlinLoggingVersion: String? by rootProject
33
val apacheCommonsTextVersion: String? by rootProject
44
val jacksonVersion: String? by rootProject
5-
val ideType: String? by rootProject
6-
val pythonCommunityPluginVersion: String? by rootProject
7-
val pythonUltimatePluginVersion: String? by rootProject
85
val log4j2Version: String? by rootProject
96

107
dependencies {
@@ -13,6 +10,8 @@ dependencies {
1310
api(project(":utbot-python-parser"))
1411
api(project(":utbot-python-types"))
1512
api(project(":utbot-python-executor"))
13+
api("org.usvm:usvm-python-runner:74d8ccc")
14+
1615
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.1")
1716
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
1817
implementation(group = "org.apache.commons", name = "commons-lang3", version = "3.12.0")

utbot-python/src/main/kotlin/org/utbot/python/PythonTestCaseGenerator.kt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,13 @@ import org.utbot.framework.plugin.api.UtError
77
import org.utbot.framework.plugin.api.UtExecutionSuccess
88
import org.utbot.python.engine.GlobalPythonEngine
99
import org.utbot.python.framework.api.python.PythonUtExecution
10-
import org.utbot.python.newtyping.mypy.MypyInfoBuild
11-
import org.utbot.python.newtyping.mypy.MypyReportLine
1210

1311
private val logger = KotlinLogging.logger {}
1412
private const val MAX_EMPTY_COVERAGE_TESTS = 5
1513

1614
class PythonTestCaseGenerator(
1715
private val configuration: PythonTestGenerationConfig,
18-
private val mypyStorage: MypyInfoBuild,
19-
private val mypyReportLine: List<MypyReportLine>
16+
private val mypyConfig: MypyConfig,
2017
) {
2118
private val withMinimization = configuration.withMinimization
2219

@@ -26,8 +23,7 @@ class PythonTestCaseGenerator(
2623
val engine = GlobalPythonEngine(
2724
method = method,
2825
configuration = configuration,
29-
mypyStorage,
30-
mypyReportLine,
26+
mypyConfig,
3127
until,
3228
)
3329
try {

utbot-python/src/main/kotlin/org/utbot/python/PythonTestGenerationConfig.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import org.utbot.framework.codegen.domain.RuntimeExceptionTestsBehaviour
44
import org.utbot.framework.codegen.domain.TestFramework
55
import org.utbot.python.coverage.CoverageOutputFormat
66
import org.utbot.python.coverage.PythonCoverageMode
7+
import org.utbot.python.newtyping.mypy.MypyBuildDirectory
8+
import org.utbot.python.newtyping.mypy.MypyInfoBuild
9+
import org.utbot.python.newtyping.mypy.MypyReportLine
710
import java.nio.file.Path
811

912
data class TestFileInformation(
@@ -27,4 +30,10 @@ class PythonTestGenerationConfig(
2730
val coverageMeasureMode: PythonCoverageMode = PythonCoverageMode.Instructions,
2831
val sendCoverageContinuously: Boolean = true,
2932
val coverageOutputFormat: CoverageOutputFormat = CoverageOutputFormat.Lines,
33+
)
34+
35+
data class MypyConfig(
36+
val mypyStorage: MypyInfoBuild,
37+
val mypyReportLine: List<MypyReportLine>,
38+
val mypyBuildDirectory: MypyBuildDirectory,
3039
)

0 commit comments

Comments
 (0)