From 168d9349c19ee9a6bbee7e64733037c3af3e3146 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Kwiecin=CC=81ski?= Date: Sat, 4 Feb 2023 19:11:25 +0100 Subject: [PATCH] Ensure readme contains valid code --- .../usefulness/functional/ExtensionTest.kt | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/ktlint-gradle-plugin/src/test/kotlin/io/github/usefulness/functional/ExtensionTest.kt b/ktlint-gradle-plugin/src/test/kotlin/io/github/usefulness/functional/ExtensionTest.kt index 8212fec..aff8f3e 100644 --- a/ktlint-gradle-plugin/src/test/kotlin/io/github/usefulness/functional/ExtensionTest.kt +++ b/ktlint-gradle-plugin/src/test/kotlin/io/github/usefulness/functional/ExtensionTest.kt @@ -181,4 +181,41 @@ internal class ExtensionTest : WithGradleTest.Kotlin() { assertThat(output).contains("com.pinterest:ktlint:0.46.0") } } + + @Test + fun `readme doc contains valid groovy code`() { + projectRoot.resolve("build.gradle") { + // language=groovy + val buildScript = + """ + plugins { + id 'kotlin' + id 'io.github.usefulness.ktlint-gradle-plugin' + } + + repositories { + mavenCentral() + } + + ktlint { + ignoreFailures = false + reporters = ["checkstyle", "html", "json", "plain", "sarif"] + experimentalRules = true + disabledRules = ["no-wildcard-imports", "experimental:annotation", "your-custom-rule:no-bugs"] + ktlintVersion = "0.48.2" + chunkSize = 50 + baselineFile.set(file("config/ktlint_baseline.xml")) + } + + """.trimIndent() + writeText(buildScript) + } + projectRoot.resolve("src/main/kotlin/FileName.kt") { + writeText(kotlinClass("FileName")) + } + + build("lintKotlin", "--dry-run").apply { + assertThat(output).contains(":lintKotlin SKIPPED") + } + } }