-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
140 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/main/kotlin/boo/fox/haskelllsp/runconfiguration/CabalTestConsoleProperties.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package boo.fox.haskelllsp.runconfiguration | ||
|
||
import com.intellij.execution.Executor | ||
import com.intellij.execution.configurations.RunConfiguration | ||
import com.intellij.execution.testframework.TestConsoleProperties | ||
import com.intellij.execution.testframework.sm.SMCustomMessagesParsing | ||
import com.intellij.execution.testframework.sm.runner.OutputToGeneralTestEventsConverter | ||
import com.intellij.execution.testframework.sm.runner.SMTRunnerConsoleProperties | ||
import com.intellij.execution.testframework.sm.runner.SMTestLocator | ||
|
||
class CabalTestConsoleProperties(config: RunConfiguration, executor: Executor) : SMTRunnerConsoleProperties( | ||
config, | ||
"Cabal", | ||
executor | ||
), SMCustomMessagesParsing { | ||
override fun getTestFrameworkName(): String = "Cabal" | ||
override fun getTestLocator(): SMTestLocator = CabalTestLocator() | ||
override fun createTestEventsConverter( | ||
testFrameworkName: String, | ||
consoleProperties: TestConsoleProperties | ||
): OutputToGeneralTestEventsConverter { | ||
return CabalTestOutputToGeneralTestEventsConverter(testFrameworkName, consoleProperties) | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/kotlin/boo/fox/haskelllsp/runconfiguration/CabalTestLocator.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package boo.fox.haskelllsp.runconfiguration | ||
|
||
import com.intellij.execution.Location | ||
import com.intellij.execution.testframework.sm.runner.SMTestLocator | ||
import com.intellij.openapi.project.Project | ||
import com.intellij.psi.PsiElement | ||
import com.intellij.psi.search.GlobalSearchScope | ||
|
||
class CabalTestLocator: SMTestLocator{ | ||
override fun getLocation( | ||
protocol: String, | ||
path: String, | ||
project: Project, | ||
scope: GlobalSearchScope | ||
): MutableList<Location<PsiElement>> = mutableListOf() | ||
} |
76 changes: 76 additions & 0 deletions
76
...in/boo/fox/haskelllsp/runconfiguration/CabalTestTestOutputToGeneralTestEventsConverter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package boo.fox.haskelllsp.runconfiguration | ||
|
||
import com.intellij.execution.process.ProcessOutputType | ||
import com.intellij.execution.testframework.TestConsoleProperties | ||
import com.intellij.execution.testframework.sm.runner.OutputToGeneralTestEventsConverter | ||
import com.intellij.openapi.diagnostic.Logger | ||
import com.intellij.openapi.util.Key | ||
import jetbrains.buildServer.messages.serviceMessages.* | ||
|
||
class CabalTestOutputToGeneralTestEventsConverter(testFrameworkName: String, consoleProperties: TestConsoleProperties) : | ||
OutputToGeneralTestEventsConverter(testFrameworkName, consoleProperties) { | ||
private val log: Logger = Logger.getInstance(CabalTestOutputToGeneralTestEventsConverter::class.java) | ||
private var previousTestSuite: String? = null | ||
private var testSuiteRunning = false | ||
private var expectingNewline = false | ||
private var unfinishedTestSuites = mutableListOf<String>() | ||
|
||
override fun processServiceMessages(text: String, outputType: Key<*>, visitor: ServiceMessageVisitor): Boolean { | ||
if(outputType == ProcessOutputType.STDERR) { | ||
return super.processServiceMessages(text, outputType, visitor) | ||
} | ||
Regex("""^\s+$""").find(text)?.let { matches -> | ||
if(expectingNewline) { | ||
expectingNewline = false | ||
testSuiteRunning = true | ||
} else { | ||
testSuiteRunning = false | ||
} | ||
if(unfinishedTestSuites.isNotEmpty()) { | ||
log.info("Unfinished test suites: $unfinishedTestSuites") | ||
unfinishedTestSuites.forEach { | ||
visitor.visitTestSuiteFinished(TestSuiteFinished(it)) | ||
} | ||
return super.processServiceMessages(text, outputType, visitor) | ||
} else { | ||
log.info("No unfinished test suites") | ||
} | ||
return super.processServiceMessages(text, outputType, visitor) | ||
} | ||
Regex("""Test suite (.+): RUNNING\.\.\.""").find(text)?.let { matches -> | ||
testSuiteRunning = true | ||
expectingNewline = true | ||
visitor.visitTestSuiteStarted(TestSuiteStarted(matches.groupValues[1])) | ||
return super.processServiceMessages(text, outputType, visitor) | ||
} | ||
Regex("""Test suite (.+): PASS""").find(text)?.let { matches -> | ||
testSuiteRunning = false | ||
expectingNewline = false | ||
visitor.visitTestSuiteFinished(TestSuiteFinished(matches.groupValues[1])) | ||
|
||
return super.processServiceMessages(text, outputType, visitor) | ||
} | ||
Regex("""( )(.+) \[([✘✔])]""").find(text)?.let { matches -> | ||
visitor.visitTestStarted(TestStarted(matches.groupValues[2], true, null)) | ||
if (matches.groupValues[3] == "✘") { | ||
visitor.visitTestFailed(TestFailed(matches.groupValues[2], "Test failed")) | ||
} | ||
visitor.visitTestFinished(TestFinished(matches.groupValues[2], 1)) | ||
return super.processServiceMessages(text, outputType, visitor) | ||
} | ||
if (testSuiteRunning) { | ||
Regex("""( +)?([\w-]+)""").find(text)?.let { matches -> | ||
if (previousTestSuite != null) { | ||
visitor.visitTestSuiteFinished(TestSuiteFinished(previousTestSuite!!)) | ||
unfinishedTestSuites.remove(previousTestSuite!!) | ||
} | ||
visitor.visitTestSuiteStarted(TestSuiteStarted(matches.groupValues[2])) | ||
unfinishedTestSuites.add(matches.groupValues[2]) | ||
previousTestSuite = matches.groupValues[2] | ||
} | ||
return super.processServiceMessages(text, outputType, visitor) | ||
} | ||
|
||
return super.processServiceMessages(text, outputType, visitor) | ||
} | ||
} |