From 1a552c1f64fc15a94c298e50a3dd614f3794c0e3 Mon Sep 17 00:00:00 2001 From: Kamil Doległo Date: Wed, 16 Sep 2020 09:29:25 +0200 Subject: Add integration tests for Kotlin projects --- .../kotlin/CoroutinesGradleIntegrationTest.kt | 50 ++++++++++++++++++++++ .../kotlin/SerializationGradleIntegrationTest.kt | 49 +++++++++++++++++++++ .../gradle/kotlin/StdlibGradleIntegrationTest.kt | 50 ++++++++++++++++++++++ 3 files changed, 149 insertions(+) create mode 100644 integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/kotlin/CoroutinesGradleIntegrationTest.kt create mode 100644 integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/kotlin/SerializationGradleIntegrationTest.kt create mode 100644 integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/kotlin/StdlibGradleIntegrationTest.kt (limited to 'integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka') diff --git a/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/kotlin/CoroutinesGradleIntegrationTest.kt b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/kotlin/CoroutinesGradleIntegrationTest.kt new file mode 100644 index 00000000..b4978ea9 --- /dev/null +++ b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/kotlin/CoroutinesGradleIntegrationTest.kt @@ -0,0 +1,50 @@ +package org.jetbrains.dokka.it.gradle.kotlin + +import org.gradle.testkit.runner.TaskOutcome +import org.jetbrains.dokka.it.S3Project +import org.jetbrains.dokka.it.copyAndApplyGitDiff +import org.jetbrains.dokka.it.gradle.* +import org.junit.runners.Parameterized +import java.io.File +import kotlin.test.* + +class CoroutinesGradleIntegrationTest(override val versions: BuildVersions) : AbstractGradleIntegrationTest(), + S3Project { + + companion object { + @get:JvmStatic + @get:Parameterized.Parameters(name = "{0}") + val versions = BuildVersions.permutations( + gradleVersions = listOf("6.3"), + kotlinVersions = listOf("1.4.10") + ) + } + + override val projectOutputLocation: File by lazy { File(projectDir, "build/dokka/htmlMultiModule") } + + @BeforeTest + fun prepareProjectFiles() { + val templateProjectDir = File("projects", "coroutines/kotlinx-coroutines") + templateProjectDir.listFiles().orEmpty() + .forEach { topLevelFile -> topLevelFile.copyRecursively(File(projectDir, topLevelFile.name)) } + + copyAndApplyGitDiff(File("projects", "coroutines/coroutines.diff")) + } + + @Test + fun execute() { + val result = createGradleRunner(":dokkaHtmlMultiModule", "-i", "-s").buildRelaxed() + + assertEquals(TaskOutcome.SUCCESS, assertNotNull(result.task(":dokkaHtmlMultiModule")).outcome) + + assertTrue(projectOutputLocation.isDirectory, "Missing dokka output directory") + + projectOutputLocation.allHtmlFiles().forEach { file -> +// assertContainsNoErrorClass(file) +// assertNoUnresolvedLinks(file) +// assertNoHrefToMissingLocalFileOrDirectory(file) + assertNoEmptyLinks(file) + assertNoEmptySpans(file) + } + } +} diff --git a/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/kotlin/SerializationGradleIntegrationTest.kt b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/kotlin/SerializationGradleIntegrationTest.kt new file mode 100644 index 00000000..e097369f --- /dev/null +++ b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/kotlin/SerializationGradleIntegrationTest.kt @@ -0,0 +1,49 @@ +package org.jetbrains.dokka.it.gradle.kotlin + +import org.gradle.testkit.runner.TaskOutcome +import org.jetbrains.dokka.it.S3Project +import org.jetbrains.dokka.it.copyAndApplyGitDiff +import org.jetbrains.dokka.it.gradle.* +import org.junit.runners.Parameterized +import java.io.File +import kotlin.test.* + +class SerializationGradleIntegrationTest(override val versions: BuildVersions) : AbstractGradleIntegrationTest(), + S3Project { + + companion object { + @get:JvmStatic + @get:Parameterized.Parameters(name = "{0}") + val versions = BuildVersions.permutations( + gradleVersions = listOf("6.3"), + kotlinVersions = listOf("1.4.10") + ) + } + + override val projectOutputLocation: File by lazy { File(projectDir, "build/dokka/htmlMultiModule") } + + @BeforeTest + fun prepareProjectFiles() { + val templateProjectDir = File("projects", "serialization/kotlinx-serialization") + templateProjectDir.listFiles().orEmpty() + .forEach { topLevelFile -> topLevelFile.copyRecursively(File(projectDir, topLevelFile.name)) } + copyAndApplyGitDiff(File("projects", "serialization/serialization.diff")) + } + + @Test + fun execute() { + val result = createGradleRunner(":dokkaHtmlMultiModule", "-i", "-s").buildRelaxed() + + assertEquals(TaskOutcome.SUCCESS, assertNotNull(result.task(":dokkaHtmlMultiModule")).outcome) + + assertTrue(projectOutputLocation.isDirectory, "Missing dokka output directory") + + projectOutputLocation.allHtmlFiles().forEach { file -> + assertContainsNoErrorClass(file) + assertNoUnresolvedLinks(file) +// assertNoHrefToMissingLocalFileOrDirectory(file) + assertNoEmptyLinks(file) + assertNoEmptySpans(file) + } + } +} diff --git a/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/kotlin/StdlibGradleIntegrationTest.kt b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/kotlin/StdlibGradleIntegrationTest.kt new file mode 100644 index 00000000..ca768962 --- /dev/null +++ b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/kotlin/StdlibGradleIntegrationTest.kt @@ -0,0 +1,50 @@ +package org.jetbrains.dokka.it.gradle.kotlin + +import org.gradle.testkit.runner.TaskOutcome +import org.jetbrains.dokka.it.S3Project +import org.jetbrains.dokka.it.copyAndApplyGitDiff +import org.jetbrains.dokka.it.gradle.* +import org.junit.runners.Parameterized +import java.io.File +import kotlin.test.* + +class StdlibGradleIntegrationTest(override val versions: BuildVersions) : AbstractGradleIntegrationTest(), + S3Project { + + companion object { + @get:JvmStatic + @get:Parameterized.Parameters(name = "{0}") + val versions = BuildVersions.permutations( + gradleVersions = listOf("5.6"), + kotlinVersions = listOf("1.4.10") + ) + } + + override val projectOutputLocation: File by lazy { File(projectDir, "build/dokka/kotlin-stdlib") } + + @BeforeTest + fun prepareProjectFiles() { + val templateProjectDir = File("projects", "stdlib/kotlin-dokka-stdlib") + templateProjectDir.listFiles().orEmpty() + .forEach { topLevelFile -> topLevelFile.copyRecursively(File(projectDir, topLevelFile.name)) } + + copyAndApplyGitDiff(File("projects", "stdlib/stdlib.diff")) + } + + @Test + fun execute() { + val result = createGradleRunner("callDokka", "-i", "-s").buildRelaxed() + + assertEquals(TaskOutcome.SUCCESS, assertNotNull(result.task(":callDokka")).outcome) + + assertTrue(projectOutputLocation.isDirectory, "Missing dokka output directory") + + projectOutputLocation.allHtmlFiles().forEach { file -> + assertContainsNoErrorClass(file) +// assertNoUnresolvedLinks(file) +// assertNoHrefToMissingLocalFileOrDirectory(file) + assertNoEmptyLinks(file) + assertNoEmptySpans(file) + } + } +} -- cgit