Skip to content

Commit 7d92741

Browse files
committed
Work for sbft
1 parent c5a1926 commit 7d92741

File tree

109 files changed

+3792
-1522
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+3792
-1522
lines changed

.github/workflows/publish-plugin-from-branch.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ jobs:
8787
cd ${{ matrix.configuration.directory }}/build/distributions
8888
unzip ${{ matrix.configuration.directory }}-${{ env.VERSION }}.zip
8989
rm ${{ matrix.configuration.directory }}-${{ env.VERSION }}.zip
90-
9190
- name: Archive UTBot IntelliJ IDEA plugin
9291
if: ${{ inputs.upload-artifact == 'true' }}
9392
uses: actions/upload-artifact@v3

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+
}

gradlew

100644100755
File mode changed.

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import mu.KotlinLogging
1010
import org.apache.logging.log4j.LogManager
1111
import org.apache.logging.log4j.core.config.Configurator
1212
import org.slf4j.event.Level
13+
import org.utbot.cli.language.python.sbft.SbftGenerateTestsCommand
1314
import java.util.*
1415
import kotlin.system.exitProcess
1516

@@ -29,10 +30,13 @@ class UtBotPythonCli : CliktCommand(name = "UnitTestBot Python Command Line Inte
2930

3031
fun main(args: Array<String>) = try {
3132
UtBotPythonCli().subcommands(
32-
PythonGenerateTestsCommand(),
33-
PythonRunTestsCommand(),
34-
PythonTypeInferenceCommand()
33+
SbftGenerateTestsCommand()
3534
).main(args)
35+
// UtBotPythonCli().subcommands(
36+
// PythonGenerateTestsCommand(),
37+
// PythonRunTestsCommand(),
38+
// PythonTypeInferenceCommand()
39+
// ).main(args)
3640
} catch (ex: Throwable) {
3741
ex.printStackTrace()
3842
exitProcess(1)

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

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import org.utbot.python.PythonMethodHeader
1515
import org.utbot.python.PythonTestGenerationConfig
1616
import org.utbot.python.PythonTestSet
1717
import org.utbot.python.TestFileInformation
18+
import org.utbot.python.UsvmConfig
1819
import org.utbot.python.utils.RequirementsInstaller
1920
import org.utbot.python.code.PythonCode
2021
import org.utbot.python.coverage.PythonCoverageMode
@@ -130,6 +131,17 @@ class PythonGenerateTestsCommand : CliktCommand(
130131
.choice("INSTRUCTIONS", "LINES")
131132
.default("LINES")
132133

134+
private val javaCmd by option(
135+
"--java-cmd",
136+
help = "(required) Path to Java command (ONLY FOR USVM)."
137+
).required()
138+
139+
private val usvmDirectory by option(
140+
"--usvm-dir",
141+
help = "(required) Path to usvm directory (ONLY FOR USVM)."
142+
).required()
143+
144+
133145
private val testFramework: TestFramework
134146
get() =
135147
when (testFrameworkAsString) {
@@ -269,6 +281,7 @@ class PythonGenerateTestsCommand : CliktCommand(
269281
coverageMeasureMode = PythonCoverageMode.parse(coverageMeasureMode),
270282
sendCoverageContinuously = !doNotSendCoverageContinuously,
271283
coverageOutputFormat = CoverageOutputFormat.parse(coverageOutputFormat),
284+
usvmConfig = UsvmConfig(javaCmd, usvmDirectory)
272285
)
273286

274287
val processor = PythonCliProcessor(
@@ -280,19 +293,17 @@ class PythonGenerateTestsCommand : CliktCommand(
280293
)
281294

282295
logger.info("Loading information about Python types...")
283-
val (mypyStorage, _) = processor.sourceCodeAnalyze()
296+
val mypyConfig = processor.sourceCodeAnalyze()
284297

285298
logger.info("Generating tests...")
286-
var testSets = processor.testGenerate(mypyStorage)
299+
var testSets = processor.testGenerate(mypyConfig)
287300
if (testSets.isEmpty()) return
288301
if (doNotGenerateRegressionSuite) {
289302
testSets = testSets.map { testSet ->
290303
PythonTestSet(
291304
testSet.method,
292305
testSet.executions.filterNot { it.result is UtExecutionSuccess },
293306
testSet.errors,
294-
testSet.mypyReport,
295-
testSet.classId,
296307
testSet.executionsNumber
297308
)
298309
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package org.utbot.cli.language.python.sbft
2+
3+
import org.utbot.python.PythonTestGenerationConfig
4+
import org.utbot.python.PythonTestGenerationProcessor
5+
import org.utbot.python.PythonTestSet
6+
7+
class SbftCliProcessor(
8+
override val configuration: PythonTestGenerationConfig,
9+
) : PythonTestGenerationProcessor() {
10+
override fun saveTests(testsCode: String) { }
11+
12+
override fun notGeneratedTestsAction(testedFunctions: List<String>) {}
13+
14+
override fun processCoverageInfo(testSets: List<PythonTestSet>) {}
15+
}

0 commit comments

Comments
 (0)