diff options
Diffstat (limited to 'integration-tests/gradle/src/main/kotlin/org/jetbrains')
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 + } +} |