Skip to content

Commit 1c9571e

Browse files
committed
Add sandbox failures to SARIF report (#1276)
1 parent 6d7339f commit 1c9571e

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

utbot-framework/src/main/kotlin/org/utbot/sarif/SarifReport.kt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ class SarifReport(
207207

208208
// prepending stack trace by `method` call in generated tests
209209
val methodCallLocation: SarifPhysicalLocation? =
210-
findMethodCallInTestBody(utExecution.testMethodName, method.name)
210+
findMethodCallInTestBody(utExecution.testMethodName, method.name, utExecution)
211211
if (methodCallLocation != null) {
212212
val testFileName = sourceFinding.testsRelativePath.toPath().fileName
213213
val testClassName = testFileName.nameWithoutExtension
@@ -255,9 +255,15 @@ class SarifReport(
255255
generatedTestsCode.split('\n')
256256
}
257257

258-
private fun findMethodCallInTestBody(testMethodName: String?, methodName: String): SarifPhysicalLocation? {
258+
private fun findMethodCallInTestBody(
259+
testMethodName: String?,
260+
methodName: String,
261+
utExecution: UtExecution,
262+
): SarifPhysicalLocation? {
259263
if (testMethodName == null)
260264
return null
265+
if (utExecution.result is UtSandboxFailure) // if there is no method call in test
266+
return getRelatedLocations(utExecution).firstOrNull()?.physicalLocation
261267

262268
// searching needed test
263269
val testMethodStartsAt = testsBodyLines.indexOfFirst { line ->
@@ -343,6 +349,7 @@ class SarifReport(
343349
val implicitlyThrown = result is UtImplicitlyThrownException
344350
val overflowFailure = result is UtOverflowFailure && UtSettings.treatOverflowAsError
345351
val assertionError = result is UtExplicitlyThrownException && result.exception is AssertionError
346-
return implicitlyThrown || overflowFailure || assertionError
352+
val sandboxFailure = result is UtSandboxFailure
353+
return implicitlyThrown || overflowFailure || assertionError || sandboxFailure
347354
}
348355
}

0 commit comments

Comments
 (0)