aboutsummaryrefslogtreecommitdiff
path: root/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka
diff options
context:
space:
mode:
authorSimon Ogorodnik <Simon.Ogorodnik@jetbrains.com>2017-11-02 05:32:50 +0300
committerSimon Ogorodnik <Simon.Ogorodnik@jetbrains.com>2017-11-02 18:00:04 +0300
commit2290bcbd6efc8ac8d36b88d37b4281c1a90b106c (patch)
tree93a499093e1b56fd603f99b08f8e0271fe20c49c /runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka
parenta10c1f852813ea1c0e4f15b3c25a7a5388bbc996 (diff)
downloaddokka-2290bcbd6efc8ac8d36b88d37b4281c1a90b106c.tar.gz
dokka-2290bcbd6efc8ac8d36b88d37b4281c1a90b106c.tar.bz2
dokka-2290bcbd6efc8ac8d36b88d37b4281c1a90b106c.zip
Fix not rebuilding on source change
Fixes #227
Diffstat (limited to 'runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka')
-rw-r--r--runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/RebuildAfterSourceChangeTest.kt69
-rw-r--r--runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/Utils.kt7
2 files changed, 71 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
}
}