Skip to content

Commit

Permalink
Let configuration tests fail and not warn and add failing configurati…
Browse files Browse the repository at this point in the history
…on test with relative paths enabled
  • Loading branch information
rschattauer authored and JLLeitschuh committed Nov 6, 2023
1 parent 431af6b commit 2f3a679
Showing 1 changed file with 44 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import org.junit.jupiter.api.DisplayName
@GradleTestVersions
class ConfigurationCacheTest : AbstractPluginTest() {
private val configurationCacheFlag = "--configuration-cache"
private val configurationCacheWarnFlag = "--configuration-cache-problems=warn"

@DisplayName("Should support configuration cache without errors on running linting")
@CommonTest
Expand All @@ -29,15 +28,13 @@ class ConfigurationCacheTest : AbstractPluginTest() {

build(
configurationCacheFlag,
configurationCacheWarnFlag,
CHECK_PARENT_TASK_NAME
) {
assertThat(task(":$mainSourceSetCheckTaskName")?.outcome).isEqualTo(TaskOutcome.SUCCESS)
}

build(
configurationCacheFlag,
configurationCacheWarnFlag,
CHECK_PARENT_TASK_NAME
) {
assertThat(task(":$mainSourceSetCheckTaskName")?.outcome).isEqualTo(TaskOutcome.UP_TO_DATE)
Expand All @@ -58,15 +55,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 +72,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 All @@ -85,15 +124,13 @@ class ConfigurationCacheTest : AbstractPluginTest() {

build(
configurationCacheFlag,
configurationCacheWarnFlag,
INSTALL_GIT_HOOK_FORMAT_TASK
) {
assertThat(task(":$INSTALL_GIT_HOOK_FORMAT_TASK")?.outcome).isEqualTo(TaskOutcome.SUCCESS)
}

build(
configurationCacheFlag,
configurationCacheWarnFlag,
INSTALL_GIT_HOOK_FORMAT_TASK
) {
assertThat(task(":$INSTALL_GIT_HOOK_FORMAT_TASK")?.outcome).isEqualTo(TaskOutcome.SUCCESS)
Expand All @@ -110,15 +147,13 @@ class ConfigurationCacheTest : AbstractPluginTest() {

build(
configurationCacheFlag,
configurationCacheWarnFlag,
INSTALL_GIT_HOOK_CHECK_TASK
) {
assertThat(task(":$INSTALL_GIT_HOOK_CHECK_TASK")?.outcome).isEqualTo(TaskOutcome.SUCCESS)
}

build(
configurationCacheFlag,
configurationCacheWarnFlag,
INSTALL_GIT_HOOK_CHECK_TASK
) {
assertThat(task(":$INSTALL_GIT_HOOK_CHECK_TASK")?.outcome).isEqualTo(TaskOutcome.SUCCESS)
Expand Down

0 comments on commit 2f3a679

Please sign in to comment.