diff options
Diffstat (limited to 'runners/gradle-integration-tests')
8 files changed, 149 insertions, 5 deletions
diff --git a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/RebuildAfterSourceChangeTest.kt b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/RebuildAfterSourceChangeTest.kt new file mode 100644 index 00000000..42e79696 --- /dev/null +++ b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/RebuildAfterSourceChangeTest.kt @@ -0,0 +1,69 @@ +package org.jetbrains.dokka.gradle + +import org.gradle.testkit.runner.TaskOutcome +import org.junit.Test +import java.nio.file.Path +import kotlin.test.assertEquals + +class RebuildAfterSourceChangeTest : AbstractDokkaGradleTest() { + + fun prepareTestData(testDataRootPath: String): Pair<Path, Path> { + val testDataRoot = testDataFolder.resolve(testDataRootPath) + val tmpRoot = testProjectDir.root.toPath() + + testDataRoot.resolve("src").copy(tmpRoot.resolve("src")) + testDataRoot.resolve("build.gradle").copy(tmpRoot.resolve("build.gradle")) + testDataRoot.resolve("settings.gradle").copy(tmpRoot.resolve("settings.gradle")) + + return testDataRoot to tmpRoot + } + + private fun doTest(gradleVersion: String, kotlinVersion: String) { + + val (testDataRoot, tmpRoot) = prepareTestData("sourcesChange") + val docsOutput = "build/dokka" + + configure(gradleVersion, kotlinVersion, arguments = arrayOf("dokka", "--stacktrace")).build().let { result -> + println(result.output) + + assertEquals(TaskOutcome.SUCCESS, result.task(":dokka")?.outcome) + } + + + configure(gradleVersion, kotlinVersion, arguments = arrayOf("dokka", "--stacktrace")).build().let { result -> + println(result.output) + + assertEquals(TaskOutcome.UP_TO_DATE, result.task(":dokka")?.outcome) + } + + checkOutputStructure("sourcesChange/fileTree.txt", docsOutput) + + testDataRoot.resolve("src1").copy(tmpRoot.resolve("src")) + + configure(gradleVersion, kotlinVersion, arguments = arrayOf("dokka", "--stacktrace")).build().let { result -> + println(result.output) + + assertEquals(TaskOutcome.SUCCESS, result.task(":dokka")?.outcome) + } + + + checkOutputStructure("sourcesChange/fileTree1.txt", docsOutput) + + } + + + @Test + fun `test kotlin 1_1_2 and gradle 3_5`() { + doTest("3.5", "1.1.2") + } + + @Test + fun `test kotlin 1_0_7 and gradle 2_14_1`() { + doTest("2.14.1", "1.0.7") + } + + @Test + fun `test kotlin 1_1_2 and gradle 4_0`() { + doTest("4.0", "1.1.2") + } +}
\ No newline at end of file diff --git a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/Utils.kt b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/Utils.kt index d44459b1..6f17af22 100644 --- a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/Utils.kt +++ b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/Utils.kt @@ -3,10 +3,7 @@ package org.jetbrains.dokka.gradle import com.intellij.rt.execution.junit.FileComparisonFailure import java.io.File import java.io.IOException -import java.nio.file.FileVisitResult -import java.nio.file.Files -import java.nio.file.Path -import java.nio.file.SimpleFileVisitor +import java.nio.file.* import java.nio.file.attribute.BasicFileAttributes @@ -48,7 +45,7 @@ class CopyFileVisitor(private var sourcePath: Path?, private val targetPath: Pat @Throws(IOException::class) override fun visitFile(file: Path, attrs: BasicFileAttributes): FileVisitResult { - Files.copy(file, targetPath.resolve(sourcePath?.relativize(file))) + Files.copy(file, targetPath.resolve(sourcePath?.relativize(file)), StandardCopyOption.REPLACE_EXISTING) return FileVisitResult.CONTINUE } } diff --git a/runners/gradle-integration-tests/testData/sourcesChange/build.gradle b/runners/gradle-integration-tests/testData/sourcesChange/build.gradle new file mode 100644 index 00000000..bc20e1cf --- /dev/null +++ b/runners/gradle-integration-tests/testData/sourcesChange/build.gradle @@ -0,0 +1,39 @@ +buildscript { + repositories { + mavenCentral() + jcenter() + maven { url "http://dl.bintray.com/kotlin/kotlin-eap-1.1" } + maven { url "https://dl.bintray.com/kotlin/kotlin-dev" } + } + dependencies { + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$test_kotlin_version" + } +} + +plugins { + id 'org.jetbrains.dokka' +} + +apply plugin: 'kotlin' +apply plugin: 'org.jetbrains.dokka' + +repositories { + mavenCentral() + jcenter() + maven { + url "http://dl.bintray.com/kotlin/kotlin-eap-1.1" + } + maven { + url "https://dl.bintray.com/kotlin/kotlin-dev" + } +} + +dependencies { + compile group: 'org.jetbrains.kotlin', name: 'kotlin-runtime', version: test_kotlin_version + compile group: 'org.jetbrains.kotlin', name: 'kotlin-reflect', version: test_kotlin_version +} + + +dokka { + dokkaFatJar = new File(dokka_fatjar) +}
\ No newline at end of file diff --git a/runners/gradle-integration-tests/testData/sourcesChange/fileTree.txt b/runners/gradle-integration-tests/testData/sourcesChange/fileTree.txt new file mode 100644 index 00000000..09f3724b --- /dev/null +++ b/runners/gradle-integration-tests/testData/sourcesChange/fileTree.txt @@ -0,0 +1,10 @@ +/ + sources-change/ + alltypes.html + demo/ + hello.html + index.html + index-outline.html + index.html + package-list + style.css diff --git a/runners/gradle-integration-tests/testData/sourcesChange/fileTree1.txt b/runners/gradle-integration-tests/testData/sourcesChange/fileTree1.txt new file mode 100644 index 00000000..eeb377f7 --- /dev/null +++ b/runners/gradle-integration-tests/testData/sourcesChange/fileTree1.txt @@ -0,0 +1,11 @@ +/ + sources-change/ + alltypes.html + demo/ + hello.html + index.html + world.html + index-outline.html + index.html + package-list + style.css diff --git a/runners/gradle-integration-tests/testData/sourcesChange/settings.gradle b/runners/gradle-integration-tests/testData/sourcesChange/settings.gradle new file mode 100644 index 00000000..3fb032bf --- /dev/null +++ b/runners/gradle-integration-tests/testData/sourcesChange/settings.gradle @@ -0,0 +1 @@ +rootProject.name = "sourcesChange"
\ No newline at end of file diff --git a/runners/gradle-integration-tests/testData/sourcesChange/src/main/kotlin/demo/HelloWorld.kt b/runners/gradle-integration-tests/testData/sourcesChange/src/main/kotlin/demo/HelloWorld.kt new file mode 100644 index 00000000..c54dea50 --- /dev/null +++ b/runners/gradle-integration-tests/testData/sourcesChange/src/main/kotlin/demo/HelloWorld.kt @@ -0,0 +1,6 @@ +package demo + +/** + * @return Hello + */ +fun hello(): String = "Hello"
\ No newline at end of file diff --git a/runners/gradle-integration-tests/testData/sourcesChange/src1/main/kotlin/demo/HelloWorld.kt b/runners/gradle-integration-tests/testData/sourcesChange/src1/main/kotlin/demo/HelloWorld.kt new file mode 100644 index 00000000..53f22ff5 --- /dev/null +++ b/runners/gradle-integration-tests/testData/sourcesChange/src1/main/kotlin/demo/HelloWorld.kt @@ -0,0 +1,11 @@ +package demo + +/** + * @return Hello + */ +fun hello(): String = "Hello" + +/** + * @return World + */ +fun world(): String = "World"
\ No newline at end of file |