Skip to content

Commit

Permalink
improve logging dokka config
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-enko committed Nov 26, 2024
1 parent d38aece commit a04eae9
Showing 1 changed file with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import io.kotest.assertions.withClue
import io.kotest.matchers.sequences.shouldBeEmpty
import io.kotest.matchers.shouldBe
import io.kotest.matchers.string.shouldContain
import kotlinx.serialization.json.Json
import org.gradle.testkit.runner.TaskOutcome.*
import org.jetbrains.dokka.gradle.utils.*
import org.jetbrains.dokka.gradle.utils.addArguments
Expand All @@ -31,7 +32,6 @@ class KotlinMultiplatformIT {
project.runner
.addArguments(
":dokkaGenerate",
"--rerun-tasks", // TODO remove before merging
)
.build {
withClue("expect project builds successfully") {
Expand All @@ -43,23 +43,22 @@ class KotlinMultiplatformIT {
val expectedHtml = project.projectDir.resolve("expectedData/html")
val actualHtmlDir = project.projectDir.resolve("build/dokka/html")

val dokkaConfigurationJsons = project
.findFiles { it.name == "dokka-configuration.json" }
.joinToString("\n\n") {
"""
---
${it.invariantSeparatorsPathString}
${it.readText()}
---
""".trimIndent()
}
val dokkaConfigurationJsonFiles = project.findFiles { it.name == "dokka-configuration.json" }
val dokkaConfigContent = dokkaConfigurationJsonFiles.joinToString("\n\n") { dcFile ->
// re-encode the JSON to a compact format, to prevent the log output being completely spammed
val compactJson = Json.parseToJsonElement(dcFile.readText())
"""
- ${dcFile.invariantSeparatorsPathString}
$compactJson
""".trimIndent()
}

withClue(
"""
|expectedHtml: ${expectedHtml.toUri()}
|actualHtmlDir: ${actualHtmlDir.toUri()}
|dokkaConfigurationJsons:
|$dokkaConfigurationJsons
|dokkaConfigurationJsons [${dokkaConfigurationJsonFiles.count()}]:
|$dokkaConfigContent
""".trimMargin()
) {
val expectedFileTree = expectedHtml.toTreeString()
Expand Down

0 comments on commit a04eae9

Please sign in to comment.