aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/base/src/test')
-rw-r--r--plugins/base/src/test/kotlin/expectActuals/ExpectActualsTest.kt131
-rw-r--r--plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt91
-rw-r--r--plugins/base/src/test/kotlin/pageMerger/PageNodeMergerTest.kt66
-rw-r--r--plugins/base/src/test/kotlin/signatures/DivergentSignatureTest.kt135
-rw-r--r--plugins/base/src/test/resources/multiplatform/basicMultiplatformTest/jvmMain/kotlin/example/Clock.kt4
5 files changed, 307 insertions, 120 deletions
diff --git a/plugins/base/src/test/kotlin/expectActuals/ExpectActualsTest.kt b/plugins/base/src/test/kotlin/expectActuals/ExpectActualsTest.kt
new file mode 100644
index 00000000..090196b3
--- /dev/null
+++ b/plugins/base/src/test/kotlin/expectActuals/ExpectActualsTest.kt
@@ -0,0 +1,131 @@
+package expectActuals
+
+import org.jetbrains.dokka.pages.ClasslikePageNode
+import org.jetbrains.dokka.pages.PageNode
+import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest
+import org.junit.jupiter.api.Test
+import org.junit.jupiter.api.Assertions.assertTrue
+
+
+class ExpectActualsTest : AbstractCoreTest() {
+
+ fun PageNode.childrenRec(): List<PageNode> = listOf(this) + children.flatMap { it.childrenRec() }
+
+ @Test
+ fun `two same named expect actual classes`() {
+
+ val configuration = dokkaConfiguration {
+ sourceSets {
+ val common = sourceSet {
+ moduleName = "example"
+ name = "common"
+ displayName = "common"
+ analysisPlatform = "common"
+ sourceRoots = listOf("src/commonMain/kotlin/pageMerger/Test.kt")
+ }
+ val commonJ = sourceSet {
+ moduleName = "example"
+ name = "commonJ"
+ displayName = "commonJ"
+ analysisPlatform = "common"
+ sourceRoots = listOf("src/commonJMain/kotlin/pageMerger/Test.kt")
+ dependentSourceSets = setOf(common.sourceSetID)
+ }
+ val commonN = sourceSet {
+ moduleName = "example"
+ name = "commonN"
+ displayName = "commonN"
+ analysisPlatform = "common"
+ sourceRoots = listOf("src/commonNMain/kotlin/pageMerger/Test.kt")
+ dependentSourceSets = setOf(common.sourceSetID)
+ }
+ val js = sourceSet {
+ moduleName = "example"
+ name = "js"
+ displayName = "js"
+ analysisPlatform = "js"
+ dependentSourceSets = setOf(commonJ.sourceSetID)
+ sourceRoots = listOf("src/jsMain/kotlin/pageMerger/Test.kt")
+ }
+ val jvm = sourceSet {
+ moduleName = "example"
+ name = "jvm"
+ displayName = "jvm"
+ analysisPlatform = "jvm"
+ dependentSourceSets = setOf(commonJ.sourceSetID)
+ sourceRoots = listOf("src/jvmMain/kotlin/pageMerger/Test.kt")
+ }
+ val linuxX64 = sourceSet {
+ moduleName = "example"
+ name = "linuxX64"
+ displayName = "linuxX64"
+ analysisPlatform = "native"
+ dependentSourceSets = setOf(commonN.sourceSetID)
+ sourceRoots = listOf("src/linuxX64Main/kotlin/pageMerger/Test.kt")
+ }
+ val mingwX64 = sourceSet {
+ moduleName = "example"
+ name = "mingwX64"
+ displayName = "mingwX64"
+ analysisPlatform = "native"
+ dependentSourceSets = setOf(commonN.sourceSetID)
+ sourceRoots = listOf("src/mingwX64Main/kotlin/pageMerger/Test.kt")
+ }
+ }
+ }
+
+ testInline(
+ """
+ |/src/commonMain/kotlin/pageMerger/Test.kt
+ |package pageMerger
+ |
+ |/src/commonJMain/kotlin/pageMerger/Test.kt
+ |package pageMerger
+ |
+ |expect class A
+ |
+ |/src/commonNMain/kotlin/pageMerger/Test.kt
+ |package pageMerger
+ |
+ |expect class A
+ |
+ |/src/jsMain/kotlin/pageMerger/Test.kt
+ |package pageMerger
+ |
+ |actual class A
+ |
+ |/src/jvmMain/kotlin/pageMerger/Test.kt
+ |package pageMerger
+ |
+ |actual class A
+ |
+ |/src/linuxX64/kotlin/pageMerger/Test.kt
+ |package pageMerger
+ |
+ |actual class A
+ |
+ |/src/mingwX64Main/kotlin/pageMerger/Test.kt
+ |package pageMerger
+ |
+ |actual class A
+ |
+ """.trimMargin(),
+ configuration
+ ) {
+ pagesTransformationStage = {
+ println(it)
+ val allChildren = it.childrenRec().filterIsInstance<ClasslikePageNode>()
+ val jvmClass = allChildren.filter { it.name == "DoNotMerge(jvm)" }
+ val jsClass = allChildren.filter { it.name == "DoNotMerge(js)" }
+ val noClass = allChildren.filter { it.name == "DoNotMerge" }
+ assertTrue(jvmClass.size == 1) { "There can be only one DoNotMerge(jvm) page" }
+ assertTrue(jvmClass.first().documentable?.sourceSets?.single()?.analysisPlatform?.key == "jvm") { "DoNotMerge(jvm) should have only jvm sources" }
+
+ assertTrue(jsClass.size == 1) { "There can be only one DoNotMerge(js) page" }
+ assertTrue(jsClass.first().documentable?.sourceSets?.single()?.analysisPlatform?.key == "js") { "DoNotMerge(js) should have only js sources" }
+
+ assertTrue(noClass.isEmpty()) { "There can't be any DoNotMerge page" }
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt b/plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt
index 25400ca5..f8eba2fe 100644
--- a/plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt
+++ b/plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt
@@ -28,20 +28,33 @@ class LinkableContentTest : AbstractCoreTest() {
val configuration = dokkaConfiguration {
moduleName = "example"
sourceSets {
- sourceSet {
- analysisPlatform = "js"
- sourceRoots = listOf("jsMain", "commonMain", "jvmAndJsSecondCommonMain").map {
- Paths.get("$testDataDir/$it/kotlin").toString()
- }
+ val common = sourceSet {
+ name = "common"
+ displayName = "common"
+ analysisPlatform = "common"
+ sourceRoots = listOf(Paths.get("$testDataDir/commonMain/kotlin").toString())
+ }
+ val jvmAndJsSecondCommonMain = sourceSet {
+ name = "jvmAndJsSecondCommonMain"
+ displayName = "jvmAndJsSecondCommonMain"
+ analysisPlatform = "common"
+ dependentSourceSets = setOf(common.value.sourceSetID)
+ sourceRoots = listOf(Paths.get("$testDataDir/jvmAndJsSecondCommonMain/kotlin").toString())
+ }
+ val js = sourceSet {
name = "js"
+ displayName = "js"
+ analysisPlatform = "js"
+ dependentSourceSets = setOf(common.value.sourceSetID, jvmAndJsSecondCommonMain.value.sourceSetID)
+ sourceRoots = listOf(Paths.get("$testDataDir/jsMain/kotlin").toString())
includes = listOf(Paths.get("$includesDir/include2.md").toString())
}
- sourceSet {
- analysisPlatform = "jvm"
- sourceRoots = listOf("jvmMain", "commonMain", "jvmAndJsSecondCommonMain").map {
- Paths.get("$testDataDir/$it/kotlin").toString()
- }
+ val jvm = sourceSet {
name = "jvm"
+ displayName = "jvm"
+ analysisPlatform = "jvm"
+ dependentSourceSets = setOf(common.value.sourceSetID, jvmAndJsSecondCommonMain.value.sourceSetID)
+ sourceRoots = listOf(Paths.get("$testDataDir/jvmMain/kotlin").toString())
includes = listOf(Paths.get("$includesDir/include1.md").toString())
}
}
@@ -67,9 +80,25 @@ class LinkableContentTest : AbstractCoreTest() {
moduleName = "example"
sourceSets {
- sourceSet {
+ val common = sourceSet {
+ name = "common"
+ displayName = "common"
+ analysisPlatform = "common"
+ sourceRoots = listOf(Paths.get("$testDataDir/commonMain/kotlin").toString())
+ }
+ val jvmAndJsSecondCommonMain = sourceSet {
+ name = "jvmAndJsSecondCommonMain"
+ displayName = "jvmAndJsSecondCommonMain"
+ analysisPlatform = "common"
+ dependentSourceSets = setOf(common.value.sourceSetID)
+ sourceRoots = listOf(Paths.get("$testDataDir/jvmAndJsSecondCommonMain/kotlin").toString())
+ }
+ val js = sourceSet {
+ name = "js"
+ displayName = "js"
analysisPlatform = "js"
- sourceRoots = listOf("$testDataDir/jsMain/kotlin")
+ dependentSourceSets = setOf(common.value.sourceSetID, jvmAndJsSecondCommonMain.value.sourceSetID)
+ sourceRoots = listOf(Paths.get("$testDataDir/jsMain/kotlin").toString())
sourceLinks = listOf(
SourceLinkDefinitionImpl(
localDirectory = "$testDataDir/jsMain/kotlin",
@@ -77,11 +106,13 @@ class LinkableContentTest : AbstractCoreTest() {
remoteLineSuffix = "#L"
)
)
- name = "js"
}
- sourceSet {
+ val jvm = sourceSet {
+ name = "jvm"
+ displayName = "jvm"
analysisPlatform = "jvm"
- sourceRoots = listOf("$testDataDir/jvmMain/kotlin")
+ dependentSourceSets = setOf(common.value.sourceSetID, jvmAndJsSecondCommonMain.value.sourceSetID)
+ sourceRoots = listOf(Paths.get("$testDataDir/jvmMain/kotlin").toString())
sourceLinks = listOf(
SourceLinkDefinitionImpl(
localDirectory = "$testDataDir/jvmMain/kotlin",
@@ -89,7 +120,6 @@ class LinkableContentTest : AbstractCoreTest() {
remoteLineSuffix = "#L"
)
)
- name = "jvm"
}
}
}
@@ -131,16 +161,33 @@ class LinkableContentTest : AbstractCoreTest() {
val configuration = dokkaConfiguration {
moduleName = "example"
sourceSets {
- sourceSet {
- analysisPlatform = "js"
- sourceRoots = listOf("$testDataDir/jsMain/kotlin")
+ val common = sourceSet {
+ name = "common"
+ displayName = "common"
+ analysisPlatform = "common"
+ sourceRoots = listOf(Paths.get("$testDataDir/commonMain/kotlin").toString())
+ }
+ val jvmAndJsSecondCommonMain = sourceSet {
+ name = "jvmAndJsSecondCommonMain"
+ displayName = "jvmAndJsSecondCommonMain"
+ analysisPlatform = "common"
+ dependentSourceSets = setOf(common.value.sourceSetID)
+ sourceRoots = listOf(Paths.get("$testDataDir/jvmAndJsSecondCommonMain/kotlin").toString())
+ }
+ val js = sourceSet {
name = "js"
+ displayName = "js"
+ analysisPlatform = "js"
+ dependentSourceSets = setOf(common.value.sourceSetID, jvmAndJsSecondCommonMain.value.sourceSetID)
+ sourceRoots = listOf(Paths.get("$testDataDir/jsMain/kotlin").toString())
samples = listOf("$testDataDir/jsMain/resources/Samples.kt")
}
- sourceSet {
- analysisPlatform = "jvm"
- sourceRoots = listOf("$testDataDir/jvmMain/kotlin")
+ val jvm = sourceSet {
name = "jvm"
+ displayName = "jvm"
+ analysisPlatform = "jvm"
+ dependentSourceSets = setOf(common.value.sourceSetID, jvmAndJsSecondCommonMain.value.sourceSetID)
+ sourceRoots = listOf(Paths.get("$testDataDir/jvmMain/kotlin").toString())
samples = listOf("$testDataDir/jvmMain/resources/Samples.kt")
}
}
diff --git a/plugins/base/src/test/kotlin/pageMerger/PageNodeMergerTest.kt b/plugins/base/src/test/kotlin/pageMerger/PageNodeMergerTest.kt
index 935b9377..1a57ae02 100644
--- a/plugins/base/src/test/kotlin/pageMerger/PageNodeMergerTest.kt
+++ b/plugins/base/src/test/kotlin/pageMerger/PageNodeMergerTest.kt
@@ -1,5 +1,6 @@
package pageMerger
+import org.jetbrains.dokka.pages.ClasslikePageNode
import org.jetbrains.dokka.pages.ContentPage
import org.jetbrains.dokka.pages.PageNode
import org.junit.jupiter.api.Assertions.assertTrue
@@ -123,4 +124,69 @@ class PageNodeMergerTest : AbstractCoreTest() {
fun PageNode.childrenRec(): List<PageNode> = listOf(this) + children.flatMap { it.childrenRec() }
+
+ @Test
+ fun `should not be merged`() {
+
+ val configuration = dokkaConfiguration {
+ sourceSets {
+ val common = sourceSet {
+ moduleName = "example"
+ name = "common"
+ displayName = "common"
+ analysisPlatform = "common"
+ sourceRoots = listOf("src/commonMain/kotlin/pageMerger/Test.kt")
+ }
+ val js = sourceSet {
+ moduleName = "example"
+ name = "js"
+ displayName = "js"
+ analysisPlatform = "js"
+ dependentSourceSets = setOf(common.sourceSetID)
+ sourceRoots = listOf("src/jsMain/kotlin/pageMerger/Test.kt")
+ }
+ val jvm = sourceSet {
+ moduleName = "example"
+ name = "jvm"
+ displayName = "jvm"
+ analysisPlatform = "jvm"
+ dependentSourceSets = setOf(common.sourceSetID)
+ sourceRoots = listOf("src/jvmMain/kotlin/pageMerger/Test.kt")
+ }
+ }
+ }
+
+ testInline(
+ """
+ |/src/commonMain/kotlin/pageMerger/Test.kt
+ |package pageMerger
+ |
+ |/src/jsMain/kotlin/pageMerger/Test.kt
+ |package pageMerger
+ |
+ |annotation class DoNotMerge
+ |
+ |/src/jvmMain/kotlin/pageMerger/Test.kt
+ |package pageMerger
+ |
+ |annotation class DoNotMerge
+ """.trimMargin(),
+ configuration
+ ) {
+ pagesTransformationStage = {
+ println(it)
+ val allChildren = it.childrenRec().filterIsInstance<ClasslikePageNode>()
+ val jvmClass = allChildren.filter { it.name == "DoNotMerge(jvm)" }
+ val jsClass = allChildren.filter { it.name == "DoNotMerge(js)" }
+ val noClass = allChildren.filter { it.name == "DoNotMerge" }
+ assertTrue(jvmClass.size == 1) { "There can be only one DoNotMerge(jvm) page" }
+ assertTrue(jvmClass.first().documentable?.sourceSets?.single()?.analysisPlatform?.key == "jvm") { "DoNotMerge(jvm) should have only jvm sources" }
+
+ assertTrue(jsClass.size == 1) { "There can be only one DoNotMerge(js) page" }
+ assertTrue(jsClass.first().documentable?.sourceSets?.single()?.analysisPlatform?.key == "js") { "DoNotMerge(js) should have only js sources" }
+
+ assertTrue(noClass.isEmpty()) { "There can't be any DoNotMerge page" }
+ }
+ }
+ }
}
diff --git a/plugins/base/src/test/kotlin/signatures/DivergentSignatureTest.kt b/plugins/base/src/test/kotlin/signatures/DivergentSignatureTest.kt
index 2e8e0ef3..975373b6 100644
--- a/plugins/base/src/test/kotlin/signatures/DivergentSignatureTest.kt
+++ b/plugins/base/src/test/kotlin/signatures/DivergentSignatureTest.kt
@@ -10,40 +10,43 @@ import utils.TestOutputWriterPlugin
class DivergentSignatureTest : AbstractCoreTest() {
- @Test
- fun `group { common + jvm + js }`() {
-
- val testDataDir = getTestDataDir("multiplatform/basicMultiplatformTest").toAbsolutePath()
-
- val configuration = dokkaConfiguration {
- moduleName = "example"
- sourceSets {
- sourceSet {
- displayName = "js"
- name = "js"
- analysisPlatform = "js"
- sourceRoots = listOf("jsMain", "commonMain", "jvmAndJsSecondCommonMain").map {
- Paths.get("$testDataDir/$it/kotlin").toString()
- }
- }
- sourceSet {
- displayName = "jvm"
- name = "jvm"
- analysisPlatform = "jvm"
- sourceRoots = listOf("jvmMain", "commonMain", "jvmAndJsSecondCommonMain").map {
- Paths.get("$testDataDir/$it/kotlin").toString()
- }
- }
- sourceSet {
- displayName = "common"
- name = "common"
- analysisPlatform = "common"
- sourceRoots = listOf("commonMain").map {
- Paths.get("$testDataDir/$it/kotlin").toString()
- }
- }
+ val testDataDir = getTestDataDir("multiplatform/basicMultiplatformTest").toAbsolutePath()
+
+ val configuration = dokkaConfiguration {
+ moduleName = "example"
+ sourceSets {
+ val common = sourceSet {
+ name = "common"
+ displayName = "common"
+ analysisPlatform = "common"
+ sourceRoots = listOf(Paths.get("$testDataDir/commonMain/kotlin").toString())
+ }
+ val jvmAndJsSecondCommonMain = sourceSet {
+ name = "jvmAndJsSecondCommonMain"
+ displayName = "jvmAndJsSecondCommonMain"
+ analysisPlatform = "common"
+ dependentSourceSets = setOf(common.value.sourceSetID)
+ sourceRoots = listOf(Paths.get("$testDataDir/jvmAndJsSecondCommonMain/kotlin").toString())
+ }
+ val js = sourceSet {
+ name = "js"
+ displayName = "js"
+ analysisPlatform = "js"
+ dependentSourceSets = setOf(common.value.sourceSetID, jvmAndJsSecondCommonMain.value.sourceSetID)
+ sourceRoots = listOf(Paths.get("$testDataDir/jsMain/kotlin").toString())
+ }
+ val jvm = sourceSet {
+ name = "jvm"
+ displayName = "jvm"
+ analysisPlatform = "jvm"
+ dependentSourceSets = setOf(common.value.sourceSetID, jvmAndJsSecondCommonMain.value.sourceSetID)
+ sourceRoots = listOf(Paths.get("$testDataDir/jvmMain/kotlin").toString())
}
}
+ }
+
+ @Test
+ fun `group { common + jvm + js }`() {
val writerPlugin = TestOutputWriterPlugin()
@@ -55,7 +58,7 @@ class DivergentSignatureTest : AbstractCoreTest() {
val content = writerPlugin.renderedContent("example/example/-clock/get-time.html")
assert(content.count() == 1)
- assert(content.select("[data-filterable-current=example/js example/jvm example/common]").single().brief == "")
+ assert(content.select("[data-filterable-current=example/common example/jvm example/js]").single().brief == "common")
}
}
}
@@ -63,38 +66,6 @@ class DivergentSignatureTest : AbstractCoreTest() {
@Test
fun `group { common + jvm }, group { js }`() {
- val testDataDir = getTestDataDir("multiplatform/basicMultiplatformTest").toAbsolutePath()
-
- val configuration = dokkaConfiguration {
- moduleName = "example"
- sourceSets {
- sourceSet {
- displayName = "js"
- name = "js"
- analysisPlatform = "js"
- sourceRoots = listOf("jsMain", "commonMain", "jvmAndJsSecondCommonMain").map {
- Paths.get("$testDataDir/$it/kotlin").toString()
- }
- }
- sourceSet {
- displayName = "jvm"
- name = "jvm"
- analysisPlatform = "jvm"
- sourceRoots = listOf("jvmMain", "commonMain", "jvmAndJsSecondCommonMain").map {
- Paths.get("$testDataDir/$it/kotlin").toString()
- }
- }
- sourceSet {
- displayName = "common"
- name = "common"
- analysisPlatform = "common"
- sourceRoots = listOf("commonMain").map {
- Paths.get("$testDataDir/$it/kotlin").toString()
- }
- }
- }
- }
-
val writerPlugin = TestOutputWriterPlugin()
testFromData(
@@ -104,7 +75,7 @@ class DivergentSignatureTest : AbstractCoreTest() {
renderingStage = { _, _ ->
val content = writerPlugin.renderedContent("example/example/-clock/get-times-in-millis.html")
assert(content.count() == 2)
- assert(content.select("[data-filterable-current=example/jvm example/common]").single().brief == "Time in minis")
+ assert(content.select("[data-filterable-current=example/common example/jvm]").single().brief == "Time in minis common")
assert(content.select("[data-filterable-current=example/js]").single().brief == "JS implementation of getTimeInMillis js" )
}
}
@@ -113,38 +84,6 @@ class DivergentSignatureTest : AbstractCoreTest() {
@Test
fun `group { js }, group { jvm }, group { js }`() {
- val testDataDir = getTestDataDir("multiplatform/basicMultiplatformTest").toAbsolutePath()
-
- val configuration = dokkaConfiguration {
- moduleName = "example"
- sourceSets {
- sourceSet {
- displayName = "js"
- name = "js"
- analysisPlatform = "js"
- sourceRoots = listOf("jsMain", "commonMain", "jvmAndJsSecondCommonMain").map {
- Paths.get("$testDataDir/$it/kotlin").toString()
- }
- }
- sourceSet {
- displayName = "jvm"
- name = "jvm"
- analysisPlatform = "jvm"
- sourceRoots = listOf("jvmMain", "commonMain", "jvmAndJsSecondCommonMain").map {
- Paths.get("$testDataDir/$it/kotlin").toString()
- }
- }
- sourceSet {
- displayName = "common"
- name = "common"
- analysisPlatform = "common"
- sourceRoots = listOf("commonMain").map {
- Paths.get("$testDataDir/$it/kotlin").toString()
- }
- }
- }
- }
-
val writerPlugin = TestOutputWriterPlugin()
testFromData(
diff --git a/plugins/base/src/test/resources/multiplatform/basicMultiplatformTest/jvmMain/kotlin/example/Clock.kt b/plugins/base/src/test/resources/multiplatform/basicMultiplatformTest/jvmMain/kotlin/example/Clock.kt
index fec06207..6ad73db7 100644
--- a/plugins/base/src/test/resources/multiplatform/basicMultiplatformTest/jvmMain/kotlin/example/Clock.kt
+++ b/plugins/base/src/test/resources/multiplatform/basicMultiplatformTest/jvmMain/kotlin/example/Clock.kt
@@ -7,6 +7,10 @@ import greeteer.Greeter
*/
actual open class Clock {
actual fun getTime(): String = System.currentTimeMillis().toString()
+
+ /**
+ * Time in minis
+ */
actual fun getTimesInMillis(): String = System.currentTimeMillis().toString()
/**