Skip to content

Commit

Permalink
Fix incorrect test file path in SARIF report (#1216)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmvpm committed Oct 24, 2022
1 parent 12ad92c commit 26512ce
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ object CodeGenerationController {
val file = filePointer.containingFile

val srcClassPath = srcClass.containingFile.virtualFile.toNioPath()
val sarifReport = saveSarifReport(
saveSarifReport(
proc,
testSetsId,
testClassUpdated,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@ import com.intellij.psi.PsiClass
import com.intellij.openapi.progress.ProgressIndicator
import org.utbot.common.PathUtil.classFqnToPath
import org.utbot.intellij.plugin.ui.utils.getOrCreateSarifReportsPath
import com.intellij.openapi.vfs.VfsUtil
import java.util.concurrent.CountDownLatch
import mu.KotlinLogging
import org.utbot.framework.plugin.api.ClassId
import org.utbot.intellij.plugin.generator.UtTestsDialogProcessor
import org.utbot.intellij.plugin.models.GenerateTestsModel
import org.utbot.intellij.plugin.process.EngineProcess
import org.utbot.sarif.Sarif
import org.utbot.intellij.plugin.ui.utils.getOrCreateSarifReportsPath
import org.utbot.intellij.plugin.util.IntelliJApiHelper
import java.nio.file.Path

object SarifReportIdea {
Expand Down Expand Up @@ -43,16 +40,14 @@ object SarifReportIdea {
}
val reportFilePath = sarifReportsPath.resolve("${classFqnToPath(classFqn)}Report.sarif")

IntelliJApiHelper.run(IntelliJApiHelper.Target.THREAD_POOL, indicator) {
try {
val sarifReportAsJson = proc.writeSarif(reportFilePath, testSetsId, generatedTestsCode, sourceFinding)
val sarifReport = Sarif.fromJson(sarifReportAsJson)
srcClassPathToSarifReport[srcClassPath] = sarifReport
} catch (e: Exception) {
logger.error { e }
} finally {
reportsCountDown.countDown()
}
try {
val sarifReportAsJson = proc.writeSarif(reportFilePath, testSetsId, generatedTestsCode, sourceFinding)
val sarifReport = Sarif.fromJson(sarifReportAsJson)
srcClassPathToSarifReport[srcClassPath] = sarifReport
} catch (e: Exception) {
logger.error { e }
} finally {
reportsCountDown.countDown()
}
}
}
Expand Down

0 comments on commit 26512ce

Please sign in to comment.