aboutsummaryrefslogtreecommitdiff
path: root/integration-tests/gradle/src
diff options
context:
space:
mode:
Diffstat (limited to 'integration-tests/gradle/src')
-rw-r--r--integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/AbstractGradleIntegrationTest.kt49
-rw-r--r--integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/BuildVersions.kt6
-rw-r--r--integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/utils.kt29
-rw-r--r--integration-tests/gradle/src/test/kotlin/org/jetbrains/dokka/it/gradle/BasicTest.kt121
4 files changed, 205 insertions, 0 deletions
diff --git a/integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/AbstractGradleIntegrationTest.kt b/integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/AbstractGradleIntegrationTest.kt
new file mode 100644
index 00000000..271720fe
--- /dev/null
+++ b/integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/AbstractGradleIntegrationTest.kt
@@ -0,0 +1,49 @@
+package org.jetbrains.dokka.it.gradle
+
+import org.gradle.testkit.runner.GradleRunner
+import org.junit.Rule
+import org.junit.rules.TemporaryFolder
+import java.io.File
+import kotlin.test.assertFalse
+import kotlin.test.assertTrue
+
+abstract class AbstractGradleIntegrationTest {
+
+ @get:Rule
+ val projectTemporaryFolder = TemporaryFolder()
+
+ val projectPath get() = projectTemporaryFolder.root.toPath()
+
+ val projectDir get() = projectTemporaryFolder.root
+
+
+ fun createGradleRunner(
+ buildVersions: BuildVersions, arguments: Array<String>
+ ): GradleRunner {
+ return GradleRunner.create()
+ .withProjectDir(projectDir)
+ .withGradleVersion(buildVersions.gradleVersion)
+ .forwardOutput()
+ .withArguments("-Pkotlin_version=${buildVersions.kotlinVersion}", *arguments)
+ .withDebug(true)
+
+ }
+
+ protected fun assertContainsNoErrorClass(file: File) {
+ val fileText = file.readText()
+ assertFalse(
+ fileText.contains("ERROR CLASS", ignoreCase = true),
+ "Unexpected `ERROR CLASS` in ${file.path}\n" + fileText
+ )
+ }
+
+ protected fun assertNoUnresolvedLInks(file: File) {
+ val regex = Regex("[\"']#[\"']")
+ val fileText = file.readText()
+ assertFalse(
+ fileText.contains(regex),
+ "Unexpected unresolved link in ${file.path}\n" + fileText
+ )
+ }
+}
+
diff --git a/integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/BuildVersions.kt b/integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/BuildVersions.kt
new file mode 100644
index 00000000..6aa41e7a
--- /dev/null
+++ b/integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/BuildVersions.kt
@@ -0,0 +1,6 @@
+package org.jetbrains.dokka.it.gradle
+
+data class BuildVersions(
+ val gradleVersion: String,
+ val kotlinVersion: String
+)
diff --git a/integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/utils.kt b/integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/utils.kt
new file mode 100644
index 00000000..2516b151
--- /dev/null
+++ b/integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/utils.kt
@@ -0,0 +1,29 @@
+package org.jetbrains.dokka.it.gradle
+
+import java.io.IOException
+import java.nio.file.*
+import java.nio.file.attribute.BasicFileAttributes
+
+fun Path.copy(to: Path) {
+ Files.walkFileTree(this, CopyFileVisitor(this, to))
+}
+
+class CopyFileVisitor(private var sourcePath: Path, private val targetPath: Path) : SimpleFileVisitor<Path>() {
+ @Throws(IOException::class)
+ override fun preVisitDirectory(
+ dir: Path,
+ attrs: BasicFileAttributes
+ ): FileVisitResult {
+ Files.createDirectories(targetPath.resolve(sourcePath.relativize(dir)))
+ return FileVisitResult.CONTINUE
+ }
+
+ @Throws(IOException::class)
+ override fun visitFile(
+ file: Path,
+ attrs: BasicFileAttributes
+ ): FileVisitResult {
+ Files.copy(file, targetPath.resolve(sourcePath.relativize(file)), StandardCopyOption.REPLACE_EXISTING)
+ return FileVisitResult.CONTINUE
+ }
+}
diff --git a/integration-tests/gradle/src/test/kotlin/org/jetbrains/dokka/it/gradle/BasicTest.kt b/integration-tests/gradle/src/test/kotlin/org/jetbrains/dokka/it/gradle/BasicTest.kt
new file mode 100644
index 00000000..deba4a16
--- /dev/null
+++ b/integration-tests/gradle/src/test/kotlin/org/jetbrains/dokka/it/gradle/BasicTest.kt
@@ -0,0 +1,121 @@
+package org.jetbrains.dokka.it.gradle
+
+import org.gradle.testkit.runner.TaskOutcome
+import java.io.File
+import kotlin.test.*
+
+class BasicTest : AbstractGradleIntegrationTest() {
+
+ @Test
+ fun `gradle 5_6_4 kotlin 1_3_72`() {
+ execute(
+ BuildVersions(
+ gradleVersion = "5.6.4",
+ kotlinVersion = "1.3.72"
+ )
+ )
+ }
+
+ @Test
+ fun `gradle 5_6_4 kotlin 1_3_30`() {
+ execute(
+ BuildVersions(
+ gradleVersion = "5.6.4",
+ kotlinVersion = "1.3.30"
+ )
+ )
+ }
+
+ @Test
+ fun `gradle 5_6_4 kotlin 1_4_M2_eap_70`() {
+ execute(
+ BuildVersions(
+ gradleVersion = "5.6.4",
+ kotlinVersion = "1.4-M2-eap-70"
+ )
+ )
+ }
+
+ @Test
+ fun `gradle 6_1_1 kotlin 1_3_72`() {
+ execute(
+ BuildVersions(
+ gradleVersion = "6.1.1",
+ kotlinVersion = "1.3.72"
+ )
+ )
+ }
+
+ @Test
+ fun `gradle 6_5_1 kotlin 1_4_M2_eap_70`() {
+ execute(
+ BuildVersions(
+ gradleVersion = "6.5.1",
+ kotlinVersion = "1.4-M2-eap-70"
+ )
+ )
+ }
+
+ @BeforeTest
+ fun prepareProjectFiles() {
+ val templateProjectDir = File("projects", "it-basic")
+
+ templateProjectDir.listFiles().orEmpty()
+ .filter { it.isFile }
+ .forEach { topLevelFile -> topLevelFile.copyTo(File(projectDir, topLevelFile.name)) }
+
+ File(templateProjectDir, "src").copyRecursively(File(projectDir, "src"))
+ }
+
+ @Test
+ fun `gradle 6_5_1 kotlin 1_3_72`() {
+ execute(
+ BuildVersions(
+ gradleVersion = "6.5.1",
+ kotlinVersion = "1.3.72"
+ )
+ )
+ }
+
+ private fun execute(versions: BuildVersions) {
+ val result = createGradleRunner(
+ buildVersions = versions,
+ arguments = arrayOf("dokka", "--stacktrace")
+ ).build()
+ assertEquals(TaskOutcome.SUCCESS, assertNotNull(result.task(":dokka")).outcome)
+
+ val dokkaOutputDir = File(projectDir, "build/dokka")
+ assertTrue(dokkaOutputDir.isDirectory, "Missing dokka output directory")
+
+ val imagesDir = File(dokkaOutputDir, "images")
+ assertTrue(imagesDir.isDirectory, "Missing images directory")
+
+ val scriptsDir = File(dokkaOutputDir, "scripts")
+ assertTrue(scriptsDir.isDirectory, "Missing scripts directory")
+
+ val stylesDir = File(dokkaOutputDir, "styles")
+ assertTrue(stylesDir.isDirectory, "Missing styles directory")
+
+ val navigationHtml = File(dokkaOutputDir, "navigation.html")
+ assertTrue(navigationHtml.isFile, "Missing navigation.html")
+
+ val moduleOutputDir = File(dokkaOutputDir, "it-basic")
+ assertTrue(moduleOutputDir.isDirectory, "Missing module directory")
+
+ val moduleIndexHtml = File(moduleOutputDir, "index.html")
+ assertTrue(moduleIndexHtml.isFile, "Missing module index.html")
+
+ val modulePackageDir = File(moduleOutputDir, "it.basic")
+ assertTrue(modulePackageDir.isDirectory, "Missing module package directory")
+
+ val modulePackageIndexHtml = File(modulePackageDir, "index.html")
+ assertTrue(modulePackageIndexHtml.isFile, "Missing module package index.html")
+
+ dokkaOutputDir.walkTopDown()
+ .filter { file -> file.extension == "html" }
+ .forEach { file ->
+ assertContainsNoErrorClass(file)
+ assertNoUnresolvedLInks(file)
+ }
+ }
+}