diff options
author | Ignat Beresnev <ignat.beresnev@jetbrains.com> | 2023-04-21 20:17:55 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-21 20:17:55 +0200 |
commit | f90b4287399d9fedb7e11295d853b0bda98e11e9 (patch) | |
tree | 449e7ee4ca1ca039c7c46c2f8202c788b28d8971 /integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka | |
parent | eb50c4f28d978fcd914b819d523e8da607d05b0c (diff) | |
download | dokka-f90b4287399d9fedb7e11295d853b0bda98e11e9.tar.gz dokka-f90b4287399d9fedb7e11295d853b0bda98e11e9.tar.bz2 dokka-f90b4287399d9fedb7e11295d853b0bda98e11e9.zip |
Add Gradle integration tests for configuration (#2963)
Diffstat (limited to 'integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka')
-rw-r--r-- | integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/ConfigurationTest.kt | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/ConfigurationTest.kt b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/ConfigurationTest.kt new file mode 100644 index 00000000..6a6ff86a --- /dev/null +++ b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/ConfigurationTest.kt @@ -0,0 +1,72 @@ +@file:Suppress("FunctionName") + +package org.jetbrains.dokka.it.gradle + +import org.gradle.testkit.runner.TaskOutcome +import org.junit.runners.Parameterized.Parameters +import java.io.File +import kotlin.test.* + +/** + * Tests for Dokka's configuration options of the Gradle runner. + * + * Options can be checked to work in combination with each other: + * for instance, you can check that `reportUndocumented` and `failOnWarning` + * work in synergy when both set to true. + * + * Configuration options can be passed as project properties using Gradle CLI arguments. + * For example, passing `-Pname=value` to Gradle will create a project-wide property with + * key `name` and value `value`, which you can use to set the corresponding option's value + * using Dokka's configuration DSL. + */ +class ConfigurationTest(override val versions: BuildVersions) : AbstractGradleIntegrationTest() { + + companion object { + @get:JvmStatic + @get:Parameters(name = "{0}") + val versions = listOf(TestedVersions.LATEST) + } + + @BeforeTest + fun prepareProjectFiles() { + val templateProjectDir = File("projects", "it-configuration") + + templateProjectDir.listFiles().orEmpty() + .filter { it.isFile } + .forEach { topLevelFile -> topLevelFile.copyTo(File(projectDir, topLevelFile.name)) } + + File(templateProjectDir, "src").copyRecursively(File(projectDir, "src")) + } + + /** + * The test project contains some undocumented declarations, so if both `reportUndocumented` + * and `failOnWarning` are enabled - it should fail + */ + @Test + fun `should fail with DokkaException and readable message if failOnWarning is triggered`() { + val result = createGradleRunner( + "-info", + "-stacktrace", + "-Preport_undocumented=true", + "-Pfail_on_warning=true", + "dokkaHtml" + ).buildAndFail() + + assertEquals(TaskOutcome.FAILED, assertNotNull(result.task(":dokkaHtml")).outcome) + + result.output.contains("> Task :dokkaHtml FAILED") + result.output.contains( + """ + FAILURE: Build failed with an exception\\. + + \* What went wrong: + Execution failed for task ':dokkaHtml'\\. + > Failed with warningCount=\d and errorCount=\d + """.trimIndent().toRegex() + ) + + result.output.contains( + "Caused by: org\\.jetbrains\\.dokka\\.DokkaException: Failed with warningCount=\\d and errorCount=\\d".toRegex() + ) + } +} |