From be3fea152ae5dcec5ba9a29d86a69010d6b2e428 Mon Sep 17 00:00:00 2001 From: Błażej Kardyś Date: Tue, 8 Sep 2020 12:10:59 +0200 Subject: Adding configuration mpp check for javadoc --- .../validity/MultiplatformConfiguredCheckerTest.kt | 80 ++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/validity/MultiplatformConfiguredCheckerTest.kt (limited to 'plugins/javadoc/src/test/kotlin') diff --git a/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/validity/MultiplatformConfiguredCheckerTest.kt b/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/validity/MultiplatformConfiguredCheckerTest.kt new file mode 100644 index 00000000..9d70f444 --- /dev/null +++ b/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/validity/MultiplatformConfiguredCheckerTest.kt @@ -0,0 +1,80 @@ +package org.jetbrains.dokka.javadoc.validity + +import org.jetbrains.dokka.DokkaConfigurationImpl +import org.jetbrains.dokka.DokkaException +import org.jetbrains.dokka.ExternalDocumentationLink +import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest +import org.junit.jupiter.api.Test +import kotlin.test.assertFalse +import kotlin.test.assertTrue + +class MultiplatformConfiguredCheckerTest : AbstractCoreTest() { + + val mppConfig: DokkaConfigurationImpl = dokkaConfiguration { + format = "javadoc" + sourceSets { + sourceSet { + sourceRoots = listOf("src") + analysisPlatform = "jvm" + externalDocumentationLinks = listOf( + ExternalDocumentationLink("https://docs.oracle.com/javase/8/docs/api/"), + ExternalDocumentationLink("https://kotlinlang.org/api/latest/jvm/stdlib/") + ) + } + sourceSet { + sourceRoots = listOf("src") + analysisPlatform = "js" + externalDocumentationLinks = listOf( + ExternalDocumentationLink("https://docs.oracle.com/javase/8/docs/api/"), + ExternalDocumentationLink("https://kotlinlang.org/api/latest/jvm/stdlib/") + ) + } + } + } + + val sppConfig: DokkaConfigurationImpl = dokkaConfiguration { + format = "javadoc" + sourceSets { + sourceSet { + sourceRoots = listOf("src") + analysisPlatform = "jvm" + externalDocumentationLinks = listOf( + ExternalDocumentationLink("https://docs.oracle.com/javase/8/docs/api/"), + ExternalDocumentationLink("https://kotlinlang.org/api/latest/jvm/stdlib/") + ) + } + } + } + + @Test + fun `mpp config should fail for javadoc`() { + testInline("", mppConfig) { + verificationStage = { verification -> + var mppDetected = false + try { + verification() + } catch (e: DokkaException) { + mppDetected = + e.localizedMessage == "Pre-generation validity check failed: ${MultiplatformConfiguredChecker.errorMessage}" + } + assertTrue(mppDetected, "MPP configuration not detected") + } + } + } + + @Test + fun `spp config should not fail for javadoc`() { + testInline("", sppConfig) { + verificationStage = { verification -> + var mppDetected = false + try { + verification() + } catch (e: DokkaException) { + mppDetected = + e.localizedMessage == "Pre-generation validity check failed: ${MultiplatformConfiguredChecker.errorMessage}" + } + assertFalse(mppDetected, "SPP taken as multiplatform") + } + } + } +} \ No newline at end of file -- cgit