aboutsummaryrefslogtreecommitdiff
path: root/dokka-subprojects/plugin-base/src/test/kotlin/content/inheritors
diff options
context:
space:
mode:
authorIgnat Beresnev <ignat.beresnev@jetbrains.com>2023-11-10 11:46:54 +0100
committerGitHub <noreply@github.com>2023-11-10 11:46:54 +0100
commit8e5c63d035ef44a269b8c43430f43f5c8eebfb63 (patch)
tree1b915207b2b9f61951ddbf0ff2e687efd053d555 /dokka-subprojects/plugin-base/src/test/kotlin/content/inheritors
parenta44efd4ba0c2e4ab921ff75e0f53fc9335aa79db (diff)
downloaddokka-8e5c63d035ef44a269b8c43430f43f5c8eebfb63.tar.gz
dokka-8e5c63d035ef44a269b8c43430f43f5c8eebfb63.tar.bz2
dokka-8e5c63d035ef44a269b8c43430f43f5c8eebfb63.zip
Restructure the project to utilize included builds (#3174)
* Refactor and simplify artifact publishing * Update Gradle to 8.4 * Refactor and simplify convention plugins and build scripts Fixes #3132 --------- Co-authored-by: Adam <897017+aSemy@users.noreply.github.com> Co-authored-by: Oleg Yukhnevich <whyoleg@gmail.com>
Diffstat (limited to 'dokka-subprojects/plugin-base/src/test/kotlin/content/inheritors')
-rw-r--r--dokka-subprojects/plugin-base/src/test/kotlin/content/inheritors/ContentForInheritorsTest.kt499
1 files changed, 499 insertions, 0 deletions
diff --git a/dokka-subprojects/plugin-base/src/test/kotlin/content/inheritors/ContentForInheritorsTest.kt b/dokka-subprojects/plugin-base/src/test/kotlin/content/inheritors/ContentForInheritorsTest.kt
new file mode 100644
index 00000000..245592cc
--- /dev/null
+++ b/dokka-subprojects/plugin-base/src/test/kotlin/content/inheritors/ContentForInheritorsTest.kt
@@ -0,0 +1,499 @@
+/*
+ * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
+ */
+
+package content.inheritors
+
+import matchers.content.*
+import org.jetbrains.dokka.DokkaConfiguration
+import org.jetbrains.dokka.PluginConfigurationImpl
+import org.jetbrains.dokka.base.DokkaBase
+import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest
+import utils.OnlyDescriptors
+import utils.classSignature
+import utils.findTestType
+import kotlin.test.Test
+import kotlin.test.assertEquals
+
+class ContentForInheritorsTest : BaseAbstractTest() {
+ private val testConfiguration = dokkaConfiguration {
+ sourceSets {
+ sourceSet {
+ sourceRoots = listOf("src/")
+ analysisPlatform = "jvm"
+ }
+ }
+ }
+
+ private val mppTestConfiguration = dokkaConfiguration {
+ moduleName = "example"
+ sourceSets {
+ val common = sourceSet {
+ name = "common"
+ displayName = "common"
+ analysisPlatform = "common"
+ sourceRoots = listOf("src/commonMain/kotlin/pageMerger/Test.kt")
+ }
+ sourceSet {
+ name = "jvm"
+ displayName = "jvm"
+ analysisPlatform = "jvm"
+ dependentSourceSets = setOf(common.value.sourceSetID)
+ sourceRoots = listOf("src/jvmMain/kotlin/pageMerger/Test.kt")
+ }
+ sourceSet {
+ name = "linuxX64"
+ displayName = "linuxX64"
+ analysisPlatform = "native"
+ dependentSourceSets = setOf(common.value.sourceSetID)
+ sourceRoots = listOf("src/linuxX64Main/kotlin/pageMerger/Test.kt")
+ }
+ }
+ pluginsConfigurations.add(
+ PluginConfigurationImpl(
+ DokkaBase::class.qualifiedName!!,
+ DokkaConfiguration.SerializationFormat.JSON,
+ """{ "mergeImplicitExpectActualDeclarations": true }""",
+ )
+ )
+ }
+
+
+ //Case from skiko library
+ private val mppTestConfigurationSharedAsPlatform = dokkaConfiguration {
+ moduleName = "example"
+ sourceSets {
+ val common = sourceSet {
+ name = "common"
+ displayName = "common"
+ analysisPlatform = "common"
+ sourceRoots = listOf("src/commonMain/kotlin/pageMerger/Test.kt")
+ }
+ val jvm = sourceSet {
+ name = "jvm"
+ displayName = "jvm"
+ analysisPlatform = "jvm"
+ dependentSourceSets = setOf(common.value.sourceSetID)
+ sourceRoots = listOf("src/jvmMain/kotlin/pageMerger/Test.kt")
+ }
+ sourceSet {
+ name = "android"
+ displayName = "android"
+ analysisPlatform = "jvm"
+ dependentSourceSets = setOf(jvm.value.sourceSetID)
+ sourceRoots = listOf("src/androidMain/kotlin/pageMerger/Test.kt")
+ }
+ sourceSet {
+ name = "awt"
+ displayName = "awt"
+ analysisPlatform = "jvm"
+ dependentSourceSets = setOf(jvm.value.sourceSetID)
+ sourceRoots = listOf("src/awtMain/kotlin/pageMerger/Test.kt")
+ }
+
+ }
+ }
+
+ @Test
+ fun `class with one inheritor has table in description`() {
+ testInline(
+ """
+ |/src/main/kotlin/test/source.kt
+ |package test
+ |
+ |class Parent
+ |
+ |class Foo : Parent()
+ """.trimIndent(), testConfiguration
+ ) {
+ pagesTransformationStage = { module ->
+ val page = module.findTestType("test", "Parent")
+ page.content.assertNode {
+ group {
+ header(1) { +"Parent" }
+ platformHinted {
+ classSignature(
+ emptyMap(),
+ "",
+ "",
+ emptySet(),
+ "Parent"
+ )
+ header(4) { +"Inheritors" }
+ table {
+ group {
+ link { +"Foo" }
+ }
+ }
+ }
+ }
+ skipAllNotMatching()
+ }
+ }
+ }
+ }
+
+ @OnlyDescriptors("Order of inheritors is different in K2")
+ @Test
+ fun `interface with few inheritors has table in description`() {
+ testInline(
+ """
+ |/src/main/kotlin/test/source.kt
+ |package test
+ |
+ |interface Parent
+ |
+ |class Foo : Parent()
+ |class Bar : Parent()
+ """.trimIndent(), testConfiguration
+ ) {
+ pagesTransformationStage = { module ->
+ val page = module.findTestType("test", "Parent")
+ page.content.assertNode {
+ group {
+ header(1) { +"Parent" }
+ platformHinted {
+ group {
+ +"interface "
+ link {
+ +"Parent"
+ }
+ }
+ header(4) { +"Inheritors" }
+ table {
+ group {
+ link { +"Foo" }
+ }
+ group {
+ link { +"Bar" }
+ }
+ }
+ }
+ }
+ skipAllNotMatching()
+ }
+ }
+ }
+ }
+
+ @Test
+ fun `inherit from one of multiplatoforms actuals`() {
+ testInline(
+ """
+ |/src/commonMain/kotlin/pageMerger/Test.kt
+ |package pageMerger
+ |
+ |expect open class Parent
+ |
+ |/src/jvmMain/kotlin/pageMerger/Test.kt
+ |package pageMerger
+ |
+ |actual open class Parent
+ |
+ |/src/linuxX64Main/kotlin/pageMerger/Test.kt
+ |package pageMerger
+ |
+ |actual open class Parent
+ |class Child: Parent()
+ |
+ """.trimMargin(),
+ mppTestConfiguration
+ ) {
+ pagesTransformationStage = { module ->
+ val page = module.findTestType("pageMerger", "Parent")
+ page.content.assertNode {
+ group {
+ header(1) { +"Parent" }
+ platformHinted {
+ group {
+ +"expect open class "
+ link {
+ +"Parent"
+ }
+ }
+ group {
+ +"actual open class "
+ link {
+ +"Parent"
+ }
+ }
+ group {
+ +"actual open class "
+ link {
+ +"Parent"
+ }
+ }
+ header(4) { +"Inheritors" }
+ table {
+ group {
+ link { +"Child" }
+ }
+ check {
+ assertEquals(1, sourceSets.size)
+ assertEquals(
+ "linuxX64",
+ this.sourceSets.first().name
+ )
+ }
+ }
+ }
+ }
+ skipAllNotMatching()
+ }
+ }
+ }
+ }
+
+ @Test
+ fun `inherit from class in common code`() {
+ testInline(
+ """
+ |/src/commonMain/kotlin/pageMerger/Test.kt
+ |package pageMerger
+ |
+ |open class Parent
+ |
+ |/src/jvmMain/kotlin/pageMerger/Test.kt
+ |package pageMerger
+ |
+ |class Child : Parent()
+ |
+ """.trimMargin(),
+ mppTestConfiguration
+ ) {
+ pagesTransformationStage = { module ->
+ val page = module.findTestType("pageMerger", "Parent")
+ page.content.assertNode {
+ group {
+ header(1) { +"Parent" }
+ platformHinted {
+ group {
+ +"open class "
+ link {
+ +"Parent"
+ }
+ }
+ header(4) { +"Inheritors" }
+ table {
+ group {
+ link { +"Child" }
+ }
+ check {
+ assertEquals(1, sourceSets.size)
+ assertEquals(
+ "common",
+ this.sourceSets.first().name
+ )
+ }
+ }
+ }
+ }
+ skipAllNotMatching()
+ }
+ }
+ }
+ }
+
+
+ @Test
+ fun `inheritors from merged classes`() {
+ testInline(
+ """
+ |/src/linuxX64Main/kotlin/pageMerger/Test.kt
+ |package pageMerger
+ |
+ |open class Parent
+ |class LChild : Parent()
+ |
+ |/src/jvmMain/kotlin/pageMerger/Test.kt
+ |package pageMerger
+ |
+ |open class Parent
+ |class JChild : Parent()
+ |
+ """.trimMargin(),
+ mppTestConfiguration
+ ) {
+ pagesTransformationStage = { module ->
+ val page = module.findTestType("pageMerger", "Parent")
+ page.content.assertNode {
+ group {
+ header(1) { +"Parent" }
+ platformHinted {
+ group {
+ +"open class "
+ link {
+ +"Parent"
+ }
+ }
+ header(4) { +"Inheritors" }
+ table {
+ group {
+ link { +"JChild" }
+ }
+ check {
+ assertEquals(1, sourceSets.size)
+ assertEquals(
+ "jvm",
+ this.sourceSets.first().name
+ )
+ }
+ }
+ group {
+ +"open class "
+ link {
+ +"Parent"
+ }
+ }
+ header(4) { +"Inheritors" }
+ table {
+ group {
+ link { +"LChild" }
+ }
+ check {
+ assertEquals(1, sourceSets.size)
+ assertEquals(
+ "linuxX64",
+ this.sourceSets.first().name
+ )
+ }
+ }
+ }
+ }
+ skipAllNotMatching()
+ }
+ }
+ }
+ }
+
+
+ @Test
+ fun `merged inheritors from merged classes`() {
+ testInline(
+ """
+ |/src/linuxX64Main/kotlin/pageMerger/Test.kt
+ |package pageMerger
+ |
+ |open class Parent
+ |class Child : Parent()
+ |
+ |/src/jvmMain/kotlin/pageMerger/Test.kt
+ |package pageMerger
+ |
+ |open class Parent
+ |class Child : Parent()
+ |
+ """.trimMargin(),
+ mppTestConfiguration
+ ) {
+ pagesTransformationStage = { module ->
+ val page = module.findTestType("pageMerger", "Parent")
+ page.content.assertNode {
+ group {
+ header(1) { +"Parent" }
+ platformHinted {
+ group {
+ +"open class "
+ link {
+ +"Parent"
+ }
+ }
+ header(4) { +"Inheritors" }
+ table {
+ group {
+ link { +"Child" }
+ }
+ check {
+ assertEquals(1, sourceSets.size)
+ assertEquals(
+ "jvm",
+ this.sourceSets.first().name
+ )
+ }
+ }
+ group {
+ +"open class "
+ link {
+ +"Parent"
+ }
+ }
+ header(4) { +"Inheritors" }
+ table {
+ group {
+ link { +"Child" }
+ }
+ check {
+ assertEquals(1, sourceSets.size)
+ assertEquals(
+ "linuxX64",
+ this.sourceSets.first().name
+ )
+ }
+ }
+ }
+ }
+ skipAllNotMatching()
+ }
+ }
+ }
+ }
+
+ @Test
+ fun `parent in shared source set that analyse as platform`() {
+ testInline(
+ """
+ |/src/jvmMain/kotlin/pageMerger/Test.kt
+ |package pageMerger
+ |
+ |interface Parent
+ |
+ |/src/androidMain/kotlin/pageMerger/Test.kt
+ |package pageMerger
+ |
+ |class Child : Parent
+ |
+ |/src/awtMain/kotlin/pageMerger/Test.kt
+ |package pageMerger
+ |
+ |class AwtChild : Parent
+ |class Child : Parent
+ |
+ """.trimMargin(),
+ mppTestConfigurationSharedAsPlatform
+ ) {
+ pagesTransformationStage = { module ->
+ val page = module.findTestType("pageMerger", "Parent")
+ page.content.assertNode {
+ group {
+ header(1) { +"Parent" }
+ platformHinted {
+ group {
+ +"interface "
+ link {
+ +"Parent"
+ }
+ }
+ header(4) { +"Inheritors" }
+ table {
+ group {
+ link { +"Child" }
+ }
+ group {
+ link { +"AwtChild" }
+ }
+ check {
+ assertEquals(1, sourceSets.size)
+ assertEquals(
+ "jvm",
+ this.sourceSets.first().name
+ )
+ }
+ }
+ }
+ }
+ skipAllNotMatching()
+ }
+ }
+ }
+ }
+}