Skip to content

Commit 4cec911

Browse files
authored
fix: show run icons only for files in tests directory (#395)
1 parent 1b273db commit 4cec911

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

clion-plugin/src/main/kotlin/org/utbot/cpp/clion/plugin/ui/testsResults/UTBotTestRunLineMarkerProvider.kt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ import com.intellij.openapi.diagnostic.Logger
99
import com.intellij.openapi.editor.markup.GutterIconRenderer
1010
import com.intellij.psi.PsiElement
1111
import javax.swing.Icon
12+
import kotlin.io.path.name
1213
import org.utbot.cpp.clion.plugin.actions.generate.RunWithCoverageAction
14+
import org.utbot.cpp.clion.plugin.settings.settings
1315
import org.utbot.cpp.clion.plugin.ui.services.TestsResultsStorage
16+
import org.utbot.cpp.clion.plugin.utils.localPath
1417
import testsgen.Testgen
1518

1619
class UTBotTestRunLineMarkerProvider : LineMarkerProvider {
@@ -42,6 +45,7 @@ class UTBotTestRunLineMarkerProvider : LineMarkerProvider {
4245
if (element.firstChild != null
4346
|| !elementRequiresIcon
4447
|| element.containingFile.name.endsWith(".h")
48+
|| !isElementInTestFileGeneratedByUTBot(element)
4549
) {
4650
return null
4751
}
@@ -51,7 +55,13 @@ class UTBotTestRunLineMarkerProvider : LineMarkerProvider {
5155
return UTBotRunWithCoverageLineMarkerInfo(element, message, getStatusIcon(element))
5256
}
5357

54-
private fun getStatusIcon(element: PsiElement): Icon {
58+
private fun isElementInTestFileGeneratedByUTBot(element: PsiElement) =
59+
element.containingFile.virtualFile.localPath.let {
60+
it.toString().startsWith(element.project.settings.testsDirPath.toString()) &&
61+
it.name.contains("test")
62+
}
63+
64+
fun getStatusIcon(element: PsiElement): Icon {
5565
// return icon for Running All Tests
5666
if (element.canPlaceAllTestsIcon()) {
5767
return AllIcons.RunConfigurations.TestState.Run_run

0 commit comments

Comments
 (0)