Skip to content

Commit ca98d40

Browse files
committed
Fix python coverage database bug with access to database directory (#1553)
1 parent 8151788 commit ca98d40

File tree

2 files changed

+21
-16
lines changed

2 files changed

+21
-16
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
@@ -92,7 +92,8 @@ class PythonCodeGenerator(
9292
directoriesForSysPath: Set<String>,
9393
moduleToImport: String,
9494
additionalModules: Set<String> = emptySet(),
95-
fileForOutputName: String
95+
fileForOutputName: String,
96+
coverageDatabasePath: String,
9697
): String = withCustomContext(testClassCustomName = null) {
9798
context.withTestClassFileScope {
9899
clearContextRelatedStorage()
@@ -144,21 +145,22 @@ class PythonCodeGenerator(
144145
arguments.associateBy { argument -> CgLiteral(pythonStrClassId, "'${argument.name}'") }
145146
)
146147

147-
val fullpath = CgLiteral(pythonStrClassId, "'${method.moduleFilename}'")
148-
149-
val outputPath = CgLiteral(pythonStrClassId, "'$fileForOutputName'")
150-
151-
val executorCall = CgPythonFunctionCall(
152-
pythonNoneClassId,
153-
executorFunctionName,
154-
listOf(
155-
functionName,
156-
args,
157-
kwargs,
158-
fullpath,
159-
outputPath,
160-
)
148+
val fullpath = CgLiteral(pythonStrClassId, "'${method.moduleFilename.replace("\\", "\\\\")}'")
149+
val outputPath = CgLiteral(pythonStrClassId, "'$fileForOutputName'")
150+
val databasePath = CgLiteral(pythonStrClassId, "'$coverageDatabasePath'")
151+
152+
val executorCall = CgPythonFunctionCall(
153+
pythonNoneClassId,
154+
executorFunctionName,
155+
listOf(
156+
databasePath,
157+
functionName,
158+
args,
159+
kwargs,
160+
fullpath,
161+
outputPath,
161162
)
163+
)
162164

163165
parameters.forEach { it.accept(renderer) }
164166
executorCall.accept(renderer)

0 commit comments

Comments
 (0)