-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UTBot Python updates from SBFT version (#2725)
- Loading branch information
1 parent
fb60ec0
commit c7f2ac4
Showing
104 changed files
with
3,391 additions
and
1,754 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 6 additions & 4 deletions
10
utbot-cli-python/src/main/kotlin/org/utbot/cli/language/python/PythonCliProcessor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
375 changes: 220 additions & 155 deletions
375
utbot-cli-python/src/main/kotlin/org/utbot/cli/language/python/PythonGenerateTestsCommand.kt
Large diffs are not rendered by default.
Oops, something went wrong.
27 changes: 27 additions & 0 deletions
27
utbot-cli-python/src/main/kotlin/org/utbot/cli/language/python/TestWriter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package org.utbot.cli.language.python | ||
|
||
class TestWriter { | ||
private val testCode: MutableList<String> = mutableListOf() | ||
|
||
fun addTestCode(code: String) { | ||
testCode.add(code) | ||
} | ||
|
||
fun generateTestCode(): String { | ||
val (importLines, code) = testCode.fold(mutableListOf<String>() to StringBuilder()) { acc, s -> | ||
val lines = s.split(System.lineSeparator()) | ||
val firstClassIndex = lines.indexOfFirst { it.startsWith("class") } | ||
lines.take(firstClassIndex).forEach { line -> if (line !in acc.first) acc.first.add(line) } | ||
lines.drop(firstClassIndex).forEach { line -> acc.second.append(line + System.lineSeparator()) } | ||
acc.first to acc.second | ||
} | ||
val codeBuilder = StringBuilder() | ||
importLines.filter { it.isNotEmpty() }.forEach { | ||
codeBuilder.append(it) | ||
codeBuilder.append(System.lineSeparator()) | ||
} | ||
codeBuilder.append(System.lineSeparator()) | ||
codeBuilder.append(code) | ||
return codeBuilder.toString() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,4 +23,5 @@ env/ | |
venv/ | ||
.mypy_cache/ | ||
.dmypy.json | ||
dmypy.json | ||
dmypy.json | ||
utbot_executor.iml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "utbot-executor" | ||
version = "1.8.6" | ||
version = "1.9.19" | ||
description = "" | ||
authors = ["Vyacheslav Tamarin <[email protected]>"] | ||
readme = "README.md" | ||
|
@@ -19,3 +19,8 @@ build-backend = "poetry.core.masonry.api" | |
[tool.poetry.scripts] | ||
utbot-executor = "utbot_executor:utbot_executor" | ||
|
||
[tool.pytest.ini_options] | ||
log_cli = true | ||
log_cli_level = "DEBUG" | ||
log_cli_format = "%(asctime)s [%(levelname)6s] (%(filename)s:%(lineno)s) %(message)s" | ||
log_cli_date_format = "%Y-%m-%d %H:%M:%S" |
File renamed without changes.
45 changes: 45 additions & 0 deletions
45
utbot-python-executor/src/main/python/utbot_executor/tests/example/example.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import random | ||
|
||
from utbot_executor.config import CoverageConfig, HostConfig | ||
from utbot_executor.executor import PythonExecutor | ||
from utbot_executor.parser import ExecutionRequest, ExecutionSuccessResponse, MemoryMode | ||
from utbot_executor.utils import TraceMode | ||
|
||
|
||
def test_execution(): | ||
executor = PythonExecutor( | ||
CoverageConfig(HostConfig("localhost", random.randint(10 ** 5, 10 ** 6)), TraceMode.Instructions, True), False) | ||
id_ = '1500926645' | ||
serialized_arg = (r'{"objects":{"1500926644":{"strategy":"repr","id":"1500926644","typeinfo":{"module":"builtins",' | ||
r'"kind":"int"},"comparable":true,"value":"170141183460469231731687303715749887999"},' | ||
r'"1500926652":{"strategy":"list","id":"1500926652","typeinfo":{"module":"builtins",' | ||
r'"kind":"list"},"comparable":true,"items":["1500926644"]},"1500926650":{"strategy":"repr",' | ||
r'"id":"1500926650","typeinfo":{"module":"builtins","kind":"str"},"comparable":true,' | ||
r'"value":"\"x\""},"1500926646":{"strategy":"repr","id":"1500926646","typeinfo":{' | ||
r'"module":"builtins","kind":"int"},"comparable":true,"value":"1"},"1500926651":{' | ||
r'"strategy":"dict","id":"1500926651","typeinfo":{"module":"builtins","kind":"dict"},' | ||
r'"comparable":true,"items":{"1500926650":"1500926646"}},"1500926653":{"strategy":"list",' | ||
r'"id":"1500926653","typeinfo":{"module":"builtins","kind":"list"},"comparable":true,' | ||
r'"items":[]},"1500926654":{"strategy":"dict","id":"1500926654","typeinfo":{' | ||
r'"module":"builtins","kind":"dict"},"comparable":true,"items":{}},"1500926645":{' | ||
r'"strategy":"reduce","id":"1500926645","typeinfo":{"module":"my_func","kind":"A"},' | ||
r'"comparable":true,"constructor":{"module":"my_func","kind":"A"},"args":"1500926652",' | ||
r'"state":"1500926651","listitems":"1500926653","dictitems":"1500926654"}}}') | ||
request = ExecutionRequest( | ||
'f', | ||
'my_func', | ||
['my_func'], | ||
['./'], | ||
[id_], | ||
{}, | ||
serialized_arg, | ||
MemoryMode.REDUCE, | ||
'my_func.py', | ||
'0x1', | ||
) | ||
response = executor.run_reduce_function(request) | ||
|
||
assert isinstance(response, ExecutionSuccessResponse) | ||
|
||
assert response.status == "success" | ||
assert response.is_exception is False |
File renamed without changes.
1 change: 1 addition & 0 deletions
1
utbot-python-executor/src/main/python/utbot_executor/tests/example_input.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"functionName":"im_list","functionModule":"src.foo.foo","imports":["typing","builtins","src.foo.foo"],"syspaths":["/home/vyacheslav/PycharmProjects/pythonProject/src","/home/vyacheslav/PycharmProjects/pythonProject"],"argumentsIds":["1500000001"],"kwargumentsIds":{},"serializedMemory":"{\"objects\":{\"1500000002\":{\"strategy\":\"repr\",\"id\":\"1500000002\",\"typeinfo\":{\"module\":\"builtins\",\"kind\":\"int\"},\"comparable\":true,\"value\":\"9\"},\"1500000003\":{\"strategy\":\"repr\",\"id\":\"1500000003\",\"typeinfo\":{\"module\":\"builtins\",\"kind\":\"int\"},\"comparable\":true,\"value\":\"1\"},\"1500000004\":{\"strategy\":\"repr\",\"id\":\"1500000004\",\"typeinfo\":{\"module\":\"builtins\",\"kind\":\"int\"},\"comparable\":true,\"value\":\"0\"},\"1500000001\":{\"strategy\":\"iterator\",\"id\":\"1500000001\",\"typeinfo\":{\"module\":\"typing\",\"kind\":\"Iterator\"},\"comparable\":true,\"items\":[\"1500000002\",\"1500000003\",\"1500000004\"],\"exception\":{\"module\":\"builtins\",\"kind\":\"StopIteration\"}}}}","memoryMode":"REDUCE","filepath":"/home/vyacheslav/PycharmProjects/pythonProject/src/foo/foo.py","coverageId":"59682f01"} |
2 changes: 0 additions & 2 deletions
2
utbot-python-executor/src/main/python/utbot_executor/tests/pytest.ini
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.