aboutsummaryrefslogtreecommitdiff
path: root/integration-tests
diff options
context:
space:
mode:
authorAdam <897017+aSemy@users.noreply.github.com>2023-10-12 11:40:43 +1300
committerGitHub <noreply@github.com>2023-10-12 00:40:43 +0200
commit514cbb11962ba77abf5b35f7698b84f1aef1e813 (patch)
treea0e5f5c0320e1df579210cadd316ed8db2fee089 /integration-tests
parent33210a46c7f92f868af98efa04c31295c7a224bf (diff)
downloaddokka-514cbb11962ba77abf5b35f7698b84f1aef1e813.tar.gz
dokka-514cbb11962ba77abf5b35f7698b84f1aef1e813.tar.bz2
dokka-514cbb11962ba77abf5b35f7698b84f1aef1e813.zip
Fix Maven plugin help task (#3036)
Fixes #3035
Diffstat (limited to 'integration-tests')
-rw-r--r--integration-tests/maven/src/integrationTest/kotlin/org/jetbrains/dokka/it/maven/MavenIntegrationTest.kt50
-rw-r--r--integration-tests/src/main/kotlin/org/jetbrains/dokka/it/TestOutputCopier.kt2
2 files changed, 48 insertions, 4 deletions
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,12 +27,34 @@ 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)
.command(mavenBinaryFile.absolutePath, "dokka:dokka", "-U", "-e").start().awaitProcessResult()
@@ -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)
+ )
+ }
+ }
}
diff --git a/integration-tests/src/main/kotlin/org/jetbrains/dokka/it/TestOutputCopier.kt b/integration-tests/src/main/kotlin/org/jetbrains/dokka/it/TestOutputCopier.kt
index 681c9d53..2e2113a9 100644
--- a/integration-tests/src/main/kotlin/org/jetbrains/dokka/it/TestOutputCopier.kt
+++ b/integration-tests/src/main/kotlin/org/jetbrains/dokka/it/TestOutputCopier.kt
@@ -15,6 +15,6 @@ public interface TestOutputCopier {
System.getenv("DOKKA_TEST_OUTPUT_PATH")?.also { location ->
println("Copying to ${File(location).absolutePath}")
projectOutputLocation.copyRecursively(File(location))
- } ?: println("No path via env. varbiable 'DOKKA_TEST_OUTPUT_PATH' provided, skipping copying")
+ } ?: println("No path via env. variable 'DOKKA_TEST_OUTPUT_PATH' provided, skipping copying")
}
}