diff options
author | Ilya Ryzhenkov <orangy@jetbrains.com> | 2014-07-11 17:11:35 +0400 |
---|---|---|
committer | Ilya Ryzhenkov <orangy@jetbrains.com> | 2014-07-11 17:11:35 +0400 |
commit | 044e1b86602662c78bb2ed12b9d645ab10b23429 (patch) | |
tree | 91ca7ece2011b71fa10d0b184ccfa234fbe3130d /test/src/TestAPI.kt | |
parent | 9fec3e15c94969f98596ac04130af6e2d9368a89 (diff) | |
download | dokka-044e1b86602662c78bb2ed12b9d645ab10b23429.tar.gz dokka-044e1b86602662c78bb2ed12b9d645ab10b23429.tar.bz2 dokka-044e1b86602662c78bb2ed12b9d645ab10b23429.zip |
Setup test framework and empty DocumentationModel to kickstart test development.
Diffstat (limited to 'test/src/TestAPI.kt')
-rw-r--r-- | test/src/TestAPI.kt | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/test/src/TestAPI.kt b/test/src/TestAPI.kt new file mode 100644 index 00000000..80dc47d5 --- /dev/null +++ b/test/src/TestAPI.kt @@ -0,0 +1,36 @@ +package com.jetbrains.dokka.tests + +import org.jetbrains.jet.cli.common.messages.* +import com.intellij.openapi.util.* +import com.jetbrains.dokka.* +import kotlin.test.fail + +public fun verifyFiles(vararg files: String, verifier: (DocumentationModel) -> Unit) { + val messageCollector = object : MessageCollector { + override fun report(severity: CompilerMessageSeverity, message: String, location: CompilerMessageLocation) { + when (severity) { + CompilerMessageSeverity.WARNING, + CompilerMessageSeverity.LOGGING, + CompilerMessageSeverity.OUTPUT, + CompilerMessageSeverity.INFO, + CompilerMessageSeverity.ERROR -> { + println("$severity: $message at $location") + } + CompilerMessageSeverity.EXCEPTION -> { + fail("$severity: $message at $location") + } + } + } + } + + val environment = AnalysesEnvironment(messageCollector) { + addSources(files.toList()) + } + + val result = environment.processFiles { context, file -> + context.createDocumentation(file) + }.fold(DocumentationModel()) {(aggregate, item) -> aggregate.merge(item) } + verifier(result) + Disposer.dispose(environment) +} + |