aboutsummaryrefslogtreecommitdiff
path: root/integration-tests/gradle/src/main/kotlin/org/jetbrains
diff options
context:
space:
mode:
authorsebastian.sellmair <sebastian.sellmair@jetbrains.com>2020-07-01 14:30:49 +0200
committerPaweł Marks <Kordyjan@users.noreply.github.com>2020-07-02 12:48:53 +0200
commitc0ce35627413103d64845ca3c56b9ceab0606b6b (patch)
tree5eef75366a143f27a4fc61aa6fa236889b01d718 /integration-tests/gradle/src/main/kotlin/org/jetbrains
parent1bd0cba71db2330a5e827860c4fa8c5b7eda12b4 (diff)
downloaddokka-c0ce35627413103d64845ca3c56b9ceab0606b6b.tar.gz
dokka-c0ce35627413103d64845ca3c56b9ceab0606b6b.tar.bz2
dokka-c0ce35627413103d64845ca3c56b9ceab0606b6b.zip
Re-implement first basic gradle integration test
Diffstat (limited to 'integration-tests/gradle/src/main/kotlin/org/jetbrains')
-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
3 files changed, 84 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
+ }
+}