Skip to content

Commit 15a56f9

Browse files
committed
Fix python coverage database bug with access to database directory (#1553)
1 parent d07a67b commit 15a56f9

File tree

3 files changed

+22
-17
lines changed

3 files changed

+22
-17
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,13 +335,16 @@ class PythonEngine(
335335
when (val evaluationResult = jobResult.evalResult) {
336336
is PythonEvaluationError -> {
337337
if (evaluationResult.status != 0) {
338+
val errorMessage = "Error evaluation: ${evaluationResult.status}, ${evaluationResult.message}, ${evaluationResult.stackTrace}"
339+
logger.info { errorMessage }
338340
emit(
339341
UtError(
340-
"Error evaluation: ${evaluationResult.status}, ${evaluationResult.message}",
342+
errorMessage,
341343
Throwable(evaluationResult.stackTrace.joinToString("\n"))
342344
)
343345
)
344346
} else {
347+
logger.info { "Python evaluation error: ${evaluationResult.message}" }
345348
emit(
346349
UtError(
347350
evaluationResult.message,

utbot-python/src/main/kotlin/org/utbot/python/framework/codegen/model/PythonCodeGenerator.kt

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ class PythonCodeGenerator(
108108
directoriesForSysPath: Set<String>,
109109
moduleToImport: String,
110110
additionalModules: Set<String> = emptySet(),
111-
fileForOutputName: String
111+
fileForOutputName: String,
112+
coverageDatabasePath: String,
112113
): String = withCustomContext(testClassCustomName = null) {
113114
context.withTestClassFileScope {
114115
clearContextRelatedStorage()
@@ -160,21 +161,22 @@ class PythonCodeGenerator(
160161
arguments.associateBy { argument -> CgLiteral(pythonStrClassId, "'${argument.name}'") }
161162
)
162163

163-
val fullpath = CgLiteral(pythonStrClassId, "'${method.moduleFilename}'")
164-
165-
val outputPath = CgLiteral(pythonStrClassId, "'$fileForOutputName'")
166-
167-
val executorCall = CgPythonFunctionCall(
168-
pythonNoneClassId,
169-
executorFunctionName,
170-
listOf(
171-
functionName,
172-
args,
173-
kwargs,
174-
fullpath,
175-
outputPath,
176-
)
164+
val fullpath = CgLiteral(pythonStrClassId, "'${method.moduleFilename.replace("\\", "\\\\")}'")
165+
val outputPath = CgLiteral(pythonStrClassId, "'$fileForOutputName'")
166+
val databasePath = CgLiteral(pythonStrClassId, "'$coverageDatabasePath'")
167+
168+
val executorCall = CgPythonFunctionCall(
169+
pythonNoneClassId,
170+
executorFunctionName,
171+
listOf(
172+
databasePath,
173+
functionName,
174+
args,
175+
kwargs,
176+
fullpath,
177+
outputPath,
177178
)
179+
)
178180

179181
parameters.forEach { it.accept(renderer) }
180182
executorCall.accept(renderer)

utbot-python/src/main/resources/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ astor
33
typeshed-client
44
coverage
55
utbot-executor==0.1.7
6-
utbot-mypy-runner==0.1.4
6+
utbot-mypy-runner==0.1.10

0 commit comments

Comments
 (0)