From 514cbb11962ba77abf5b35f7698b84f1aef1e813 Mon Sep 17 00:00:00 2001 From: Adam <897017+aSemy@users.noreply.github.com> Date: Thu, 12 Oct 2023 11:40:43 +1300 Subject: Fix Maven plugin help task (#3036) Fixes #3035 --- .../dokka/it/maven/MavenIntegrationTest.kt | 50 ++++++++++++++++++++-- 1 file changed, 47 insertions(+), 3 deletions(-) (limited to 'integration-tests/maven/src/integrationTest/kotlin/org/jetbrains/dokka') diff --git a/integration-tests/maven/src/integrationTest/kotlin/org/jetbrains/dokka/it/maven/MavenIntegrationTest.kt b/integration-tests/maven/src/integrationTest/kotlin/org/jetbrains/dokka/it/maven/MavenIntegrationTest.kt index 92bdc45e..7606072c 100644 --- a/integration-tests/maven/src/integrationTest/kotlin/org/jetbrains/dokka/it/maven/MavenIntegrationTest.kt +++ b/integration-tests/maven/src/integrationTest/kotlin/org/jetbrains/dokka/it/maven/MavenIntegrationTest.kt @@ -4,9 +4,10 @@ package org.jetbrains.dokka.it.maven +import org.intellij.lang.annotations.Language import org.jetbrains.dokka.it.AbstractIntegrationTest -import org.jetbrains.dokka.it.awaitProcessResult import org.jetbrains.dokka.it.ProcessResult +import org.jetbrains.dokka.it.awaitProcessResult import java.io.File import kotlin.test.* @@ -26,11 +27,33 @@ class MavenIntegrationTest : AbstractIntegrationTest() { writeText(readText().replace("\$dokka_version", currentDokkaVersion)) } val customResourcesDir = File(templateProjectDir, "customResources") - if(customResourcesDir.exists() && customResourcesDir.isDirectory) { + if (customResourcesDir.exists() && customResourcesDir.isDirectory) { customResourcesDir.copyRecursively(File(projectDir, "customResources"), overwrite = true) } } + @Test + fun `dokka help`() { + val result = ProcessBuilder().directory(projectDir) + .command(mavenBinaryFile.absolutePath, "dokka:help", "-U", "-e") + .start() + .awaitProcessResult() + + // format the output to remove blank lines and make newlines system-independent + val output = result.output.lines().filter { it.isNotBlank() }.joinToString("\n") + + assertContains( + output, + """ + |This plugin has 4 goals: + |dokka:dokka + |dokka:help + |dokka:javadoc + |dokka:javadocJar + """.trimMargin() + ) + } + @Test fun `dokka dokka`() { val result = ProcessBuilder().directory(projectDir) @@ -67,7 +90,12 @@ class MavenIntegrationTest : AbstractIntegrationTest() { ) assertTrue(stylesDir.resolve("custom-style-to-add.css").isFile) projectDir.allHtmlFiles().forEach { file -> - if(file.name != "navigation.html") assertTrue("custom-style-to-add.css" in file.readText(), "custom styles not added to html file ${file.name}") + if (file.name != "navigation.html") { + assertTrue( + "custom-style-to-add.css" in file.readText(), + "custom styles not added to html file ${file.name}" + ) + } } assertTrue(stylesDir.resolve("custom-style-to-add.css").readText().contains("""/* custom stylesheet */""")) assertTrue(imagesDir.resolve("custom-resource.svg").isFile) @@ -172,4 +200,20 @@ class MavenIntegrationTest : AbstractIntegrationTest() { ) ) } + + companion object { + /* + * TODO replace with kotlin.test.assertContains after migrating to Kotlin language version 1.5+ + */ + fun assertContains( + charSequence: CharSequence, + @Language("TEXT") other: CharSequence, + ignoreCase: Boolean = false + ) { + asserter.assertTrue( + { "Expected the char sequence to contain the substring.\nCharSequence <$charSequence>, substring <$other>, ignoreCase <$ignoreCase>." }, + charSequence.contains(other, ignoreCase) + ) + } + } } -- cgit