From 6d1e25756c3e8c43ce4d5721e7665f439a19e47c Mon Sep 17 00:00:00 2001 From: Andrzej Ratajczak Date: Wed, 8 Jul 2020 10:33:26 +0200 Subject: Move common base test utils to submodule --- plugins/base/build.gradle.kts | 5 +-- .../test/kotlin/renderers/RenderingOnlyTestBase.kt | 48 -------------------- .../src/test/kotlin/renderers/defaultSourceSet.kt | 31 ------------- .../renderers/html/HtmlRenderingOnlyTestBase.kt | 11 ----- .../base/src/test/kotlin/utils/TestOutputWriter.kt | 32 ------------- plugins/base/test-utils/build.gradle.kts | 4 ++ .../main/kotlin/renderers/RenderingOnlyTestBase.kt | 8 ++++ .../src/main/kotlin/renderers/TestPage.kt | 52 ++++++++++++++++++++++ .../src/main/kotlin/renderers/defaultSourceSet.kt | 31 +++++++++++++ .../src/main/kotlin/utils/TestOutputWriter.kt | 32 +++++++++++++ 10 files changed, 128 insertions(+), 126 deletions(-) delete mode 100644 plugins/base/src/test/kotlin/renderers/RenderingOnlyTestBase.kt delete mode 100644 plugins/base/src/test/kotlin/renderers/defaultSourceSet.kt delete mode 100644 plugins/base/src/test/kotlin/utils/TestOutputWriter.kt create mode 100644 plugins/base/test-utils/build.gradle.kts create mode 100644 plugins/base/test-utils/src/main/kotlin/renderers/RenderingOnlyTestBase.kt create mode 100644 plugins/base/test-utils/src/main/kotlin/renderers/TestPage.kt create mode 100644 plugins/base/test-utils/src/main/kotlin/renderers/defaultSourceSet.kt create mode 100644 plugins/base/test-utils/src/main/kotlin/utils/TestOutputWriter.kt (limited to 'plugins/base') diff --git a/plugins/base/build.gradle.kts b/plugins/base/build.gradle.kts index 08d1054a..1cedf354 100644 --- a/plugins/base/build.gradle.kts +++ b/plugins/base/build.gradle.kts @@ -4,8 +4,6 @@ plugins { id("com.jfrog.bintray") } -val testUtils by configurations.creating - dependencies { val coroutines_version: String by project implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version") @@ -14,8 +12,7 @@ dependencies { implementation("org.jsoup:jsoup:1.12.1") implementation("org.jetbrains.kotlinx:kotlinx-html-jvm:0.6.10") testImplementation(project(":test-tools")) - - testUtils(sourceSets.test.get().output) + testImplementation(project(":plugins:base:test-utils")) } task("copy_frontend", Copy::class) { diff --git a/plugins/base/src/test/kotlin/renderers/RenderingOnlyTestBase.kt b/plugins/base/src/test/kotlin/renderers/RenderingOnlyTestBase.kt deleted file mode 100644 index b5523d50..00000000 --- a/plugins/base/src/test/kotlin/renderers/RenderingOnlyTestBase.kt +++ /dev/null @@ -1,48 +0,0 @@ -package renderers - -import org.jetbrains.dokka.base.signatures.KotlinSignatureProvider -import org.jetbrains.dokka.base.translators.documentables.PageContentBuilder -import org.jetbrains.dokka.links.DRI -import org.jetbrains.dokka.model.Documentable -import org.jetbrains.dokka.pages.ContentNode -import org.jetbrains.dokka.pages.ContentPage -import org.jetbrains.dokka.pages.PageNode -import org.jetbrains.dokka.pages.RootPageNode -import org.jetbrains.dokka.testApi.context.MockContext -import org.jetbrains.dokka.utilities.DokkaConsoleLogger -import renderers.html.EmptyCommentConverter - -abstract class RenderingOnlyTestBase { - abstract val context: MockContext - abstract val renderedContent: T -} - -class TestPage(callback: PageContentBuilder.DocumentableContentBuilder.() -> Unit) : RootPageNode(), ContentPage { - override val dri: Set = setOf(DRI.topLevel) - override val documentable: Documentable? = null - override val embeddedResources: List = emptyList() - override val name: String - get() = "testPage" - override val children: List - get() = emptyList() - - override val content: ContentNode = PageContentBuilder( - EmptyCommentConverter, - KotlinSignatureProvider(EmptyCommentConverter, DokkaConsoleLogger), - DokkaConsoleLogger - ).contentFor( - DRI.topLevel, - emptySet(), - block = callback - ) - - override fun modified( - name: String, - content: ContentNode, - dri: Set, - embeddedResources: List, - children: List - ) = this - - override fun modified(name: String, children: List) = this -} diff --git a/plugins/base/src/test/kotlin/renderers/defaultSourceSet.kt b/plugins/base/src/test/kotlin/renderers/defaultSourceSet.kt deleted file mode 100644 index 7358d2c2..00000000 --- a/plugins/base/src/test/kotlin/renderers/defaultSourceSet.kt +++ /dev/null @@ -1,31 +0,0 @@ -package renderers - -import org.jetbrains.dokka.DokkaSourceSetID -import org.jetbrains.dokka.DokkaSourceSetImpl -import org.jetbrains.dokka.Platform - -val defaultSourceSet = DokkaSourceSetImpl( - moduleDisplayName = "DEFAULT", - displayName = "DEFAULT", - sourceSetID = DokkaSourceSetID("DEFAULT", "DEFAULT"), - classpath = emptyList(), - sourceRoots = emptyList(), - dependentSourceSets = emptySet(), - samples = emptyList(), - includes = emptyList(), - includeNonPublic = false, - includeRootPackage = false, - reportUndocumented = false, - skipEmptyPackages = true, - skipDeprecated = false, - jdkVersion = 8, - sourceLinks = emptyList(), - perPackageOptions = emptyList(), - externalDocumentationLinks = emptyList(), - languageVersion = null, - apiVersion = null, - noStdlibLink = false, - noJdkLink = false, - suppressedFiles = emptyList(), - analysisPlatform = Platform.DEFAULT -) diff --git a/plugins/base/src/test/kotlin/renderers/html/HtmlRenderingOnlyTestBase.kt b/plugins/base/src/test/kotlin/renderers/html/HtmlRenderingOnlyTestBase.kt index 4f51a97d..f93eccb5 100644 --- a/plugins/base/src/test/kotlin/renderers/html/HtmlRenderingOnlyTestBase.kt +++ b/plugins/base/src/test/kotlin/renderers/html/HtmlRenderingOnlyTestBase.kt @@ -65,14 +65,3 @@ private fun Any.accepts(n: Node) { else -> throw IllegalArgumentException("$this is not proper matcher") } } - - -internal object EmptyCommentConverter : CommentsToContentConverter { - override fun buildContent( - docTag: DocTag, - dci: DCI, - sourceSets: Set, - styles: Set