Skip to content

Commit

Permalink
Add generate-regression-suite param for cli
Browse files Browse the repository at this point in the history
  • Loading branch information
tamarinvs19 committed Jul 25, 2023
1 parent e3451d7 commit 94d293b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
8 changes: 8 additions & 0 deletions utbot-cli-python/src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ Run generated tests:
- `--test-framework [pytest|Unittest]`

Test framework to be used.

- `--runtime-exception-behaviour [PASS|FAIL]`

Expected behaviour for runtime exception.

- `--generate-regression-suite`

Generate regression test suite. Default error test suite generation only.

### `run_python` options

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ import mu.KotlinLogging
import org.parsers.python.PythonParser
import org.utbot.framework.codegen.domain.RuntimeExceptionTestsBehaviour
import org.utbot.framework.codegen.domain.TestFramework
import org.utbot.framework.plugin.api.UtExecutionSuccess
import org.utbot.python.PythonMethodHeader
import org.utbot.python.PythonTestGenerationConfig
import org.utbot.python.PythonTestSet
import org.utbot.python.utils.RequirementsInstaller
import org.utbot.python.TestFileInformation
import org.utbot.python.code.PythonCode
Expand Down Expand Up @@ -102,6 +104,9 @@ class PythonGenerateTestsCommand : CliktCommand(
.choice("PASS", "FAIL")
.default("FAIL")

private val generateRegressionSuite by option("--generate-regression-suite", help = "Generate regression test suite")
.flag(default = false)

private val testFramework: TestFramework
get() =
when (testFrameworkAsString) {
Expand Down Expand Up @@ -247,8 +252,19 @@ class PythonGenerateTestsCommand : CliktCommand(
val (mypyStorage, _) = processor.sourceCodeAnalyze()

logger.info("Generating tests...")
val testSets = processor.testGenerate(mypyStorage)
var testSets = processor.testGenerate(mypyStorage)
if (testSets.isEmpty()) return
if (!generateRegressionSuite) {
testSets = testSets.map { testSet ->
PythonTestSet(
testSet.method,
testSet.executions.filter { it.result is UtExecutionSuccess },
testSet.errors,
testSet.mypyReport,
testSet.classId
)
}
}

logger.info("Saving tests...")
val testCode = processor.testCodeGenerate(testSets)
Expand Down

0 comments on commit 94d293b

Please sign in to comment.