diff options
author | sebastian.sellmair <sebastian.sellmair@jetbrains.com> | 2020-07-20 10:38:22 +0200 |
---|---|---|
committer | Sebastian Sellmair <34319766+sellmair@users.noreply.github.com> | 2020-07-20 12:02:45 +0200 |
commit | fbed0982653cd20019fe3d56c6b4e5d7e7a72aad (patch) | |
tree | d3b703dab37df2d68563538b3613e801d1f1ae07 /runners/gradle-plugin/src/test | |
parent | 68cba1e81a6bc971e0cd0be535232cc99756cd81 (diff) | |
download | dokka-fbed0982653cd20019fe3d56c6b4e5d7e7a72aad.tar.gz dokka-fbed0982653cd20019fe3d56c6b4e5d7e7a72aad.tar.bz2 dokka-fbed0982653cd20019fe3d56c6b4e5d7e7a72aad.zip |
Implement DokkaConfigurationSerializableTest
Diffstat (limited to 'runners/gradle-plugin/src/test')
-rw-r--r-- | runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationJsonTest.kt (renamed from runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaConfigurationJsonTest.kt) | 5 | ||||
-rw-r--r-- | runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationSerializableTest.kt | 68 |
2 files changed, 70 insertions, 3 deletions
diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaConfigurationJsonTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationJsonTest.kt index b6cf2119..d80f43e4 100644 --- a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaConfigurationJsonTest.kt +++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationJsonTest.kt @@ -1,6 +1,5 @@ package org.jetbrains.dokka.gradle -import org.gradle.api.artifacts.FileCollectionDependency import org.gradle.kotlin.dsl.withType import org.gradle.testfixtures.ProjectBuilder import org.jetbrains.dokka.* @@ -8,7 +7,7 @@ import java.net.URL import kotlin.test.Test import kotlin.test.assertEquals -class GradleDokkaConfigurationJsonTest { +class DokkaConfigurationJsonTest { @Test fun `DokkaTask configuration toJsonString then parseJson`() { @@ -35,7 +34,7 @@ class GradleDokkaConfigurationJsonTest { link.url = URL("http://some.other.url") } sourceSet.collectKotlinTasks = { - println(this@GradleDokkaConfigurationJsonTest) + println(this@DokkaConfigurationJsonTest) println("This lambda is capturing the entire test") emptyList() } diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationSerializableTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationSerializableTest.kt new file mode 100644 index 00000000..70ecfcf0 --- /dev/null +++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationSerializableTest.kt @@ -0,0 +1,68 @@ +package org.jetbrains.dokka.gradle + +import org.gradle.kotlin.dsl.withType +import org.gradle.testfixtures.ProjectBuilder +import org.jetbrains.dokka.DokkaConfiguration +import org.jetbrains.dokka.toJsonString +import org.junit.Rule +import org.junit.rules.TemporaryFolder +import java.io.ObjectInputStream +import java.io.ObjectOutputStream +import java.net.URL +import kotlin.test.Test +import kotlin.test.assertEquals + +class DokkaConfigurationSerializableTest { + + @get:Rule + val temporaryFolder = TemporaryFolder() + + @Test + fun `DokkaTask configuration write to file then parse`() { + val project = ProjectBuilder.builder().build() + project.plugins.apply("org.jetbrains.dokka") + val dokkaTask = project.tasks.withType<DokkaTask>().first() + dokkaTask.plugins.withDependencies { dependencies -> + dependencies.clear() + } + dokkaTask.apply { + this.failOnWarning = true + this.offlineMode = true + this.outputDirectory = "customOutputDir" + this.cacheRoot = "customCacheRoot" + this.pluginsConfiguration["0"] = "a" + this.pluginsConfiguration["1"] = "b" + this.dokkaSourceSets.create("main") { sourceSet -> + sourceSet.moduleDisplayName = "moduleDisplayName" + sourceSet.displayName = "customSourceSetDisplayName" + sourceSet.reportUndocumented = true + + sourceSet.externalDocumentationLink { link -> + link.packageListUrl = URL("http://some.url") + link.url = URL("http://some.other.url") + } + sourceSet.collectKotlinTasks = { + emptyList() + } + + sourceSet.perPackageOption { packageOption -> + packageOption.includeNonPublic = true + packageOption.reportUndocumented = true + packageOption.skipDeprecated = true + } + } + } + + val sourceConfiguration = dokkaTask.getConfigurationOrThrow() + val configurationFile = temporaryFolder.root.resolve("config.bin") + ObjectOutputStream(configurationFile.outputStream()).use { stream -> + stream.writeObject(sourceConfiguration) + } + val parsedConfiguration = ObjectInputStream(configurationFile.inputStream()).use { stream -> + stream.readObject() as DokkaConfiguration + } + + /* Abusing toJsonString, since there is no proper .equals on the gradle implementations yet */ + assertEquals(sourceConfiguration.toJsonString(), parsedConfiguration.toJsonString()) + } +} |