diff options
author | Dmitry Jemerov <yole@jetbrains.com> | 2015-10-28 12:15:40 +0100 |
---|---|---|
committer | Dmitry Jemerov <yole@jetbrains.com> | 2015-10-29 11:57:22 +0100 |
commit | 47ccfb0937fa70d727a540d3d9a0bbbc6f1bfc6d (patch) | |
tree | 51cff592a4c5d63f69e2a4328fdf9d8bce444025 /test/src/TestAPI.kt | |
parent | cdeca8f3ba28c1b974ae81ef1ae1e80b007b1111 (diff) | |
download | dokka-47ccfb0937fa70d727a540d3d9a0bbbc6f1bfc6d.tar.gz dokka-47ccfb0937fa70d727a540d3d9a0bbbc6f1bfc6d.tar.bz2 dokka-47ccfb0937fa70d727a540d3d9a0bbbc6f1bfc6d.zip |
loading the JDK and the Kotlin runtime in tests is now optional
Diffstat (limited to 'test/src/TestAPI.kt')
-rw-r--r-- | test/src/TestAPI.kt | 47 |
1 files changed, 34 insertions, 13 deletions
diff --git a/test/src/TestAPI.kt b/test/src/TestAPI.kt index ce200bfe..59b6495b 100644 --- a/test/src/TestAPI.kt +++ b/test/src/TestAPI.kt @@ -13,7 +13,10 @@ import org.junit.Assert import java.io.File import kotlin.test.fail -public fun verifyModel(vararg roots: ContentRoot, verifier: (DocumentationModule) -> Unit) { +public fun verifyModel(vararg roots: ContentRoot, + withJdk: Boolean = false, + withKotlinRuntime: Boolean = false, + verifier: (DocumentationModule) -> Unit) { val messageCollector = object : MessageCollector { override fun report(severity: CompilerMessageSeverity, message: String, location: CompilerMessageLocation) { when (severity) { @@ -32,10 +35,14 @@ public fun verifyModel(vararg roots: ContentRoot, verifier: (DocumentationModule } val environment = AnalysisEnvironment(messageCollector) { - val stringRoot = PathManager.getResourceRoot(String::class.java, "/java/lang/String.class") - addClasspath(File(stringRoot)) - val kotlinPairRoot = PathManager.getResourceRoot(Pair::class.java, "/kotlin/Pair.class") - addClasspath(File(kotlinPairRoot)) + if (withJdk || withKotlinRuntime) { + val stringRoot = PathManager.getResourceRoot(String::class.java, "/java/lang/String.class") + addClasspath(File(stringRoot)) + } + if (withKotlinRuntime) { + val kotlinPairRoot = PathManager.getResourceRoot(Pair::class.java, "/kotlin/Pair.class") + addClasspath(File(kotlinPairRoot)) + } addRoots(roots.toList()) } val options = DocumentationOptions(includeNonPublic = true, skipEmptyPackages = false, sourceLinks = listOf<SourceLinkDefinition>()) @@ -44,19 +51,29 @@ public fun verifyModel(vararg roots: ContentRoot, verifier: (DocumentationModule Disposer.dispose(environment) } -public fun verifyModel(source: String, verifier: (DocumentationModule) -> Unit) { - verifyModel(contentRootFromPath(source), verifier = verifier) +public fun verifyModel(source: String, + withJdk: Boolean = false, + withKotlinRuntime: Boolean = false, + verifier: (DocumentationModule) -> Unit) { + verifyModel(contentRootFromPath(source), withJdk = withJdk, withKotlinRuntime = withKotlinRuntime, verifier = verifier) } -public fun verifyPackageMember(kotlinSource: String, verifier: (DocumentationNode) -> Unit) { - verifyModel(kotlinSource) { model -> +public fun verifyPackageMember(kotlinSource: String, + withJdk: Boolean = false, + withKotlinRuntime: Boolean = false, + verifier: (DocumentationNode) -> Unit) { + verifyModel(kotlinSource, withJdk = withJdk, withKotlinRuntime = withKotlinRuntime) { model -> val pkg = model.members.single() verifier(pkg.members.single()) } } -public fun verifyOutput(roots: Array<ContentRoot>, outputExtension: String, outputGenerator: (DocumentationModule, StringBuilder) -> Unit) { - verifyModel(*roots) { +public fun verifyOutput(roots: Array<ContentRoot>, + outputExtension: String, + withJdk: Boolean = false, + withKotlinRuntime: Boolean = false, + outputGenerator: (DocumentationModule, StringBuilder) -> Unit) { + verifyModel(*roots, withJdk = withJdk, withKotlinRuntime = withKotlinRuntime) { val output = StringBuilder() outputGenerator(it, output) val ext = outputExtension.removePrefix(".") @@ -66,8 +83,12 @@ public fun verifyOutput(roots: Array<ContentRoot>, outputExtension: String, outp } } -public fun verifyOutput(path: String, outputExtension: String, outputGenerator: (DocumentationModule, StringBuilder) -> Unit) { - verifyOutput(arrayOf(contentRootFromPath(path)), outputExtension, outputGenerator) +public fun verifyOutput(path: String, + outputExtension: String, + withJdk: Boolean = false, + withKotlinRuntime: Boolean = false, + outputGenerator: (DocumentationModule, StringBuilder) -> Unit) { + verifyOutput(arrayOf(contentRootFromPath(path)), outputExtension, withJdk, withKotlinRuntime, outputGenerator) } public fun assertEqualsIgnoringSeparators(expectedOutput: String, output: String) { |