aboutsummaryrefslogtreecommitdiff
path: root/dokka-runners/dokkatoo/modules/dokkatoo-plugin-integration-tests/src/testIntegration/kotlin/AndroidProjectIntegrationTest.kt
diff options
context:
space:
mode:
Diffstat (limited to 'dokka-runners/dokkatoo/modules/dokkatoo-plugin-integration-tests/src/testIntegration/kotlin/AndroidProjectIntegrationTest.kt')
-rw-r--r--dokka-runners/dokkatoo/modules/dokkatoo-plugin-integration-tests/src/testIntegration/kotlin/AndroidProjectIntegrationTest.kt166
1 files changed, 166 insertions, 0 deletions
diff --git a/dokka-runners/dokkatoo/modules/dokkatoo-plugin-integration-tests/src/testIntegration/kotlin/AndroidProjectIntegrationTest.kt b/dokka-runners/dokkatoo/modules/dokkatoo-plugin-integration-tests/src/testIntegration/kotlin/AndroidProjectIntegrationTest.kt
new file mode 100644
index 00000000..9389a798
--- /dev/null
+++ b/dokka-runners/dokkatoo/modules/dokkatoo-plugin-integration-tests/src/testIntegration/kotlin/AndroidProjectIntegrationTest.kt
@@ -0,0 +1,166 @@
+package org.jetbrains.dokka.dokkatoo.tests.integration
+
+import org.jetbrains.dokka.dokkatoo.utils.*
+import io.kotest.core.spec.style.FunSpec
+import io.kotest.matchers.file.shouldBeAFile
+import io.kotest.matchers.file.shouldHaveSameStructureAndContentAs
+import io.kotest.matchers.file.shouldHaveSameStructureAs
+import io.kotest.matchers.shouldBe
+import io.kotest.matchers.string.shouldContain
+import io.kotest.matchers.string.shouldNotContain
+import java.io.File
+import kotlin.io.path.deleteIfExists
+
+/**
+ * Integration test for the `it-android-0` project in Dokka
+ *
+ * Runs Dokka & Dokkatoo, and compares the resulting HTML site.
+ */
+class AndroidProjectIntegrationTest : FunSpec({
+
+ val tempDir = GradleProjectTest.projectTestTempDir.resolve("it/it-android-0").toFile()
+
+ val dokkatooProject = initDokkatooProject(tempDir.resolve("dokkatoo"))
+ val dokkaProject = initDokkaProject(tempDir.resolve("dokka"))
+
+ context("when generating HTML") {
+ context("with Dokka") {
+ dokkaProject.runner
+ .addArguments(
+ "clean",
+ "dokkaHtml",
+ "--stacktrace",
+ )
+ .forwardOutput()
+ .build {
+ test("expect project builds successfully") {
+ output shouldContain "BUILD SUCCESSFUL"
+ }
+ }
+ }
+
+ context("with Dokkatoo") {
+ dokkatooProject.runner
+ .addArguments(
+ "clean",
+ "dokkatooGeneratePublicationHtml",
+ "--stacktrace",
+ )
+ .forwardOutput()
+ .build {
+ test("expect project builds successfully") {
+ output shouldContain "BUILD SUCCESSFUL"
+ }
+
+ test("expect all dokka workers are successful") {
+ dokkatooProject
+ .findFiles { it.name == "dokka-worker.log" }
+ .shouldBeSingleton { dokkaWorkerLog ->
+ dokkaWorkerLog.shouldBeAFile()
+ dokkaWorkerLog.readText().shouldNotContainAnyOf(
+ "[ERROR]",
+ "[WARN]",
+ )
+ }
+ }
+ }
+ }
+
+ test("expect the same HTML is generated") {
+
+ val dokkaHtmlDir = dokkaProject.projectDir.resolve("build/dokka/html")
+ val dokkatooHtmlDir = dokkatooProject.projectDir.resolve("build/dokka/html")
+
+ val expectedFileTree = dokkaHtmlDir.toTreeString()
+ val actualFileTree = dokkatooHtmlDir.toTreeString()
+ println((actualFileTree to expectedFileTree).sideBySide())
+ expectedFileTree shouldBe actualFileTree
+
+ dokkatooHtmlDir.toFile().shouldHaveSameStructureAs(dokkaHtmlDir.toFile())
+ dokkatooHtmlDir.toFile().shouldHaveSameStructureAndContentAs(dokkaHtmlDir.toFile())
+ }
+
+ test("Dokkatoo tasks should be cacheable") {
+ dokkatooProject.runner
+ .addArguments(
+ "dokkatooGeneratePublicationHtml",
+ "--stacktrace",
+ "--build-cache",
+ )
+ .forwardOutput()
+ .build {
+ output shouldContainAll listOf(
+ "Task :dokkatooGeneratePublicationHtml UP-TO-DATE",
+ )
+ }
+ }
+
+ context("expect Dokkatoo is compatible with Gradle Configuration Cache") {
+ dokkatooProject.file(".gradle/configuration-cache").toFile().deleteRecursively()
+ dokkatooProject.file("build/reports/configuration-cache").toFile().deleteRecursively()
+
+ val configCacheRunner =
+ dokkatooProject.runner
+ .addArguments(
+ "clean",
+ "dokkatooGeneratePublicationHtml",
+ "--stacktrace",
+ "--no-build-cache",
+ "--configuration-cache",
+ )
+ .forwardOutput()
+
+ test("first build should store the configuration cache") {
+ configCacheRunner.build {
+ output shouldContain "BUILD SUCCESSFUL"
+ output shouldContain "Configuration cache entry stored"
+ output shouldNotContain "problems were found storing the configuration cache"
+ }
+ }
+
+ test("second build should reuse the configuration cache") {
+ configCacheRunner.build {
+ output shouldContain "BUILD SUCCESSFUL"
+ output shouldContain "Configuration cache entry reused"
+ }
+ }
+ }
+ }
+})
+
+private fun initDokkaProject(
+ destinationDir: File,
+): GradleProjectTest {
+ return GradleProjectTest(destinationDir.toPath()).apply {
+ copyIntegrationTestProject("it-android-0/dokka")
+
+ gradleProperties = gradleProperties
+ .replace(
+ "dokka_it_android_gradle_plugin_version=4.2.2",
+ "dokka_it_android_gradle_plugin_version=8.0.2",
+ )
+
+ file("src/main/AndroidManifest.xml").deleteIfExists()
+
+ buildGradleKts += """
+
+ android {
+ namespace = "org.jetbrains.dokka.it.android"
+ }
+
+ java {
+ toolchain {
+ languageVersion.set(JavaLanguageVersion.of(17))
+ }
+ }
+ """.trimIndent()
+ }
+}
+
+private fun initDokkatooProject(
+ destinationDir: File,
+): GradleProjectTest {
+ return GradleProjectTest(destinationDir.toPath()).apply {
+ copyIntegrationTestProject("it-android-0/dokkatoo")
+ }
+}