Skip to content

Commit

Permalink
feat(intellij): implemented show test status on gutter icon
Browse files Browse the repository at this point in the history
  • Loading branch information
d-biehl committed Jan 12, 2025
1 parent c730eb3 commit 678e5e8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@ package dev.robotcode.robotcode4ij.execution
import com.intellij.execution.lineMarker.RunLineMarkerContributor
import com.intellij.icons.AllIcons
import com.intellij.psi.PsiElement
import com.intellij.util.Urls.newLocalFileUrl
import com.intellij.util.Urls.newUrl
import dev.robotcode.robotcode4ij.testing.testManger

class RobotCodeRunLineMarkerContributor : RunLineMarkerContributor() {
override fun getInfo(element: PsiElement): Info? {
var testElement = element.project.testManger.findTestItem(element) ?: return null
var icon = AllIcons.RunConfigurations.TestState.Run
if (testElement.type == "suite") {
icon = AllIcons.RunConfigurations.TestState.Run_run
}

val uri = newUrl(
"robotcode", "/", newLocalFileUrl(testElement.source!!).toString()
).addParameters(mapOf("line" to ((testElement.lineno ?: 1) - 1).toString()))

var icon = getTestStateIcon(uri.toString(), element.project, testElement.type != "test")
return withExecutorActions(icon)
}

Expand Down
2 changes: 2 additions & 0 deletions packages/runner/src/robotcode/runner/cli/discover/discover.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ class TestItem(CamelSnakeMixin):
id: str
name: str
longname: str
lineno: Optional[int] = None
uri: Optional[DocumentUri] = None
rel_source: Optional[str] = None
source: Optional[str] = None
Expand Down Expand Up @@ -345,6 +346,7 @@ def visit_test(self, test: TestCase) -> None:
id=f"{absolute_path or ''};{test.longname};{test.lineno}",
name=test.name,
longname=test.longname,
lineno=test.lineno,
uri=str(Uri.from_path(absolute_path)) if absolute_path else None,
source=str(test.source),
rel_source=get_rel_source(test.source),
Expand Down

0 comments on commit 678e5e8

Please sign in to comment.