aboutsummaryrefslogtreecommitdiff
path: root/integration-tests/cli/src/integrationTest/kotlin/org/jetbrains/dokka
diff options
context:
space:
mode:
authorsebastian.sellmair <sebastian.sellmair@jetbrains.com>2020-07-07 11:08:34 +0200
committerSebastian Sellmair <34319766+sellmair@users.noreply.github.com>2020-07-07 13:31:38 +0200
commitcb20227d354b1b74ca6784d55ea75cc8b5281abd (patch)
tree2284ff9b5535a735655a9ad0ee436f2aa4e68a07 /integration-tests/cli/src/integrationTest/kotlin/org/jetbrains/dokka
parent72e6c72774f65308ce1da807bc0fa5798575d013 (diff)
downloaddokka-cb20227d354b1b74ca6784d55ea75cc8b5281abd.tar.gz
dokka-cb20227d354b1b74ca6784d55ea75cc8b5281abd.tar.bz2
dokka-cb20227d354b1b74ca6784d55ea75cc8b5281abd.zip
Implement simple cli integration test
Diffstat (limited to 'integration-tests/cli/src/integrationTest/kotlin/org/jetbrains/dokka')
-rw-r--r--integration-tests/cli/src/integrationTest/kotlin/org/jetbrains/dokka/it/cli/CliIntegrationTest.kt82
1 files changed, 82 insertions, 0 deletions
diff --git a/integration-tests/cli/src/integrationTest/kotlin/org/jetbrains/dokka/it/cli/CliIntegrationTest.kt b/integration-tests/cli/src/integrationTest/kotlin/org/jetbrains/dokka/it/cli/CliIntegrationTest.kt
new file mode 100644
index 00000000..5e24c1cd
--- /dev/null
+++ b/integration-tests/cli/src/integrationTest/kotlin/org/jetbrains/dokka/it/cli/CliIntegrationTest.kt
@@ -0,0 +1,82 @@
+package org.jetbrains.dokka.it.cli
+
+import java.io.File
+import kotlin.test.BeforeTest
+import kotlin.test.Test
+import kotlin.test.assertEquals
+import kotlin.test.assertTrue
+
+class CliIntegrationTest : AbstractCliIntegrationTest() {
+
+ @BeforeTest
+ fun copyProject() {
+ val templateProjectDir = File("projects", "it-cli")
+ templateProjectDir.copyRecursively(projectDir)
+ }
+
+ @Test
+ fun runHelp() {
+ val process = ProcessBuilder("java", "-jar", cliJarFile.path, "-h")
+ .redirectErrorStream(true)
+ .start()
+
+ val result = process.awaitProcessResult()
+ assertEquals(0, result.exitCode, "Expected exitCode 0 (Success)")
+ assertTrue("Usage: " in result.output)
+ }
+
+ @Test
+ fun runCli() {
+ val dokkaOutputDir = File(projectDir, "output")
+ assertTrue(dokkaOutputDir.mkdirs())
+ val process = ProcessBuilder(
+ "java", "-jar", cliJarFile.path,
+ "-outputDir", dokkaOutputDir.path,
+ "-format", "html",
+ "-pluginsClasspath", basePluginJarFile.path,
+ "-sourceSet",
+ buildString {
+ append(" -moduleName it-cli")
+ append(" -moduleDisplayName CLI-Example")
+ append(" -sourceSetName cliMain")
+ append(" -src ${File(projectDir, "src").path}")
+ append(" -jdkVersion 8")
+ append(" -analysisPlatform jvm")
+ append(" -reportUndocumented")
+ append(" -skipDeprecated")
+ }
+ )
+ .redirectErrorStream(true)
+ .start()
+
+ val result = process.awaitProcessResult()
+ assertEquals(0, result.exitCode, "Expected exitCode 0 (Success)")
+
+ val extensionLoadedRegex = Regex("""Extension: org\.jetbrains\.dokka\.base\.DokkaBase""")
+ val amountOfExtensionsLoaded = extensionLoadedRegex.findAll(result.output).count()
+
+ assertTrue(
+ amountOfExtensionsLoaded > 10,
+ "Expected more than 10 extensions being present (found $amountOfExtensionsLoaded)"
+ )
+
+ assertTrue(dokkaOutputDir.isDirectory, "Missing dokka output directory")
+
+ val imagesDir = File(dokkaOutputDir, "images")
+ assertTrue(imagesDir.isDirectory, "Missing images directory")
+
+ val scriptsDir = File(dokkaOutputDir, "scripts")
+ assertTrue(scriptsDir.isDirectory, "Missing scripts directory")
+
+ val stylesDir = File(dokkaOutputDir, "styles")
+ assertTrue(stylesDir.isDirectory, "Missing styles directory")
+
+ val navigationHtml = File(dokkaOutputDir, "navigation.html")
+ assertTrue(navigationHtml.isFile, "Missing navigation.html")
+
+ projectDir.allHtmlFiles().forEach { file ->
+ assertContainsNoErrorClass(file)
+ assertNoUnresolvedLInks(file)
+ }
+ }
+}