Skip to content

Commit

Permalink
Add failing configuration test with relative paths enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
rschattauer committed Oct 30, 2023
1 parent 431af6b commit 0775934
Showing 1 changed file with 45 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.jlleitschuh.gradle.ktlint

import org.assertj.core.api.Assertions.assertThat
import org.gradle.testkit.runner.BuildResult
import org.gradle.testkit.runner.TaskOutcome
import org.gradle.util.GradleVersion
import org.jlleitschuh.gradle.ktlint.tasks.KtLintFormatTask
Expand Down Expand Up @@ -58,15 +59,13 @@ class ConfigurationCacheTest : AbstractPluginTest() {
val formatTaskName = KtLintFormatTask.buildTaskNameForSourceSet("main")
build(
configurationCacheFlag,
configurationCacheWarnFlag,
FORMAT_PARENT_TASK_NAME
) {
assertThat(task(":$formatTaskName")?.outcome).isEqualTo(TaskOutcome.SUCCESS)
assertThat(task(":$mainSourceSetFormatTaskName")?.outcome).isEqualTo(TaskOutcome.SUCCESS)
}
build(
configurationCacheFlag,
configurationCacheWarnFlag,
FORMAT_PARENT_TASK_NAME,
"--debug"
) {
Expand All @@ -77,6 +76,50 @@ class ConfigurationCacheTest : AbstractPluginTest() {
}
}

@DisplayName("Should support configuration cache on running format tasks with relative paths")
@CommonTest
fun configurationCacheForFormatTasksWithRelativePaths(gradleVersion: GradleVersion) {
project(gradleVersion) {
buildGradle.appendText(
//language=Groovy
"""
repositories {
jcenter()
}
ktlint {
relative = true
reporters {
reporter "plain"
reporter "checkstyle"
}
}
""".trimIndent()
)
val sourceFile = "\nval foo = \"bar\"\n"
createSourceFile(
"src/main/kotlin/CleanSource.kt",
sourceFile
)
val formatTaskName = KtLintFormatTask.buildTaskNameForSourceSet("main")
build(
configurationCacheFlag,
FORMAT_PARENT_TASK_NAME
) {
assertThat(task(":$formatTaskName")?.outcome).isEqualTo(TaskOutcome.SUCCESS)
assertThat(task(":$mainSourceSetFormatTaskName")?.outcome).isEqualTo(TaskOutcome.SUCCESS)
}
build(
configurationCacheFlag,
FORMAT_PARENT_TASK_NAME,
) {
assertThat(task(":$formatTaskName")?.outcome).isEqualTo(TaskOutcome.UP_TO_DATE)
assertThat(task(":$mainSourceSetFormatTaskName")?.outcome).isEqualTo(TaskOutcome.UP_TO_DATE)
assertThat(output).contains("Reusing configuration cache.")
}
}
}

@DisplayName("Should support configuration cache for git hook format install task")
@CommonTest
internal fun configurationCacheForGitHookFormatInstallTask(gradleVersion: GradleVersion) {
Expand Down

0 comments on commit 0775934

Please sign in to comment.