aboutsummaryrefslogtreecommitdiff
path: root/integration-tests/gradle
diff options
context:
space:
mode:
authorilya-g <ilya.gorbunov@jetbrains.com>2023-01-13 23:17:54 +0100
committerGitHub <noreply@github.com>2023-01-13 23:17:54 +0100
commitac932d43649a9b79780b0961f579e964f33d285e (patch)
tree522e752ad9ee358d71e3fb49ec49c4ce39b63073 /integration-tests/gradle
parent303c937a7c33fa9df5c28079c423ee071e87e410 (diff)
downloaddokka-ac932d43649a9b79780b0961f579e964f33d285e.tar.gz
dokka-ac932d43649a9b79780b0961f579e964f33d285e.tar.bz2
dokka-ac932d43649a9b79780b0961f579e964f33d285e.zip
Avoid snapshotting sourceLink.localDirectory input (#2807)
Diffstat (limited to 'integration-tests/gradle')
-rw-r--r--integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/BasicCachingIntegrationTest.kt35
-rw-r--r--integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/GradleRelocatedCachingIntegrationTest.kt6
2 files changed, 35 insertions, 6 deletions
diff --git a/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/BasicCachingIntegrationTest.kt b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/BasicCachingIntegrationTest.kt
index f47f7e2a..ada6c26c 100644
--- a/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/BasicCachingIntegrationTest.kt
+++ b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/BasicCachingIntegrationTest.kt
@@ -20,8 +20,39 @@ class BasicCachingIntegrationTest(override val versions: BuildVersions) : Abstra
@Test
fun execute() {
+ runAndAssertOutcomeAndContents(TaskOutcome.SUCCESS)
+ runAndAssertOutcomeAndContents(TaskOutcome.FROM_CACHE)
+ }
+
+ @Test
+ fun localDirectoryPointingToRoot() {
+ fun String.findAndReplace(oldValue: String, newValue: String): String {
+ assertTrue(oldValue in this, "Expected to replace '$oldValue'")
+ return replace(oldValue, newValue)
+ }
+ val projectKts = projectDir.resolve("build.gradle.kts")
+
+ projectKts.readText()
+ .findAndReplace("localDirectory.set(file(\"src/main\"))", "localDirectory.set(projectDir)")
+ .findAndReplace("integration-tests/gradle/projects/it-basic/src/main", "integration-tests/gradle/projects/it-basic")
+ .also { projectKts.writeText(it) }
+
+ runAndAssertOutcomeAndContents(TaskOutcome.SUCCESS)
+ projectDir.resolve("unrelated.txt").writeText("modified")
+ // despite projectDir is used as an input in localDirectory, changing its contents shouldn't invalidate the cache
+ runAndAssertOutcomeAndContents(TaskOutcome.FROM_CACHE)
+
+ projectKts.readText()
+ .findAndReplace("localDirectory.set(projectDir)", "localDirectory.set(file(\"src\"))")
+ .also { projectKts.writeText(it) }
+ // changing localDirectory path invalidates cached task results
runAndAssertOutcome(TaskOutcome.SUCCESS)
- runAndAssertOutcome(TaskOutcome.FROM_CACHE)
+ }
+
+
+ private fun runAndAssertOutcomeAndContents(expectedOutcome: TaskOutcome) {
+ runAndAssertOutcome(expectedOutcome)
+ File(projectDir, "build/dokka/html").assertHtmlOutputDir()
}
private fun runAndAssertOutcome(expectedOutcome: TaskOutcome) {
@@ -35,7 +66,5 @@ class BasicCachingIntegrationTest(override val versions: BuildVersions) : Abstra
).buildRelaxed()
assertEquals(expectedOutcome, assertNotNull(result.task(":dokkaHtml")).outcome)
-
- File(projectDir, "build/dokka/html").assertHtmlOutputDir()
}
}
diff --git a/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/GradleRelocatedCachingIntegrationTest.kt b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/GradleRelocatedCachingIntegrationTest.kt
index 28b8d22c..2ac129af 100644
--- a/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/GradleRelocatedCachingIntegrationTest.kt
+++ b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/GradleRelocatedCachingIntegrationTest.kt
@@ -21,11 +21,11 @@ class GradleRelocatedCachingIntegrationTest(override val versions: BuildVersions
@Test
fun execute() {
- runAndAssertOutcome(projectFolder(1), TaskOutcome.SUCCESS)
- runAndAssertOutcome(projectFolder(2), TaskOutcome.FROM_CACHE)
+ runAndAssertOutcomeAndContents(projectFolder(1), TaskOutcome.SUCCESS)
+ runAndAssertOutcomeAndContents(projectFolder(2), TaskOutcome.FROM_CACHE)
}
- private fun runAndAssertOutcome(project: File, expectedOutcome: TaskOutcome) {
+ private fun runAndAssertOutcomeAndContents(project: File, expectedOutcome: TaskOutcome) {
val result = createGradleRunner("clean", "dokkaHtml", "-i", "-s", "-Dorg.gradle.caching.debug=true", "--build-cache")
.withProjectDir(project)
.buildRelaxed()