From 8cf71e75643cd579f9a9c86f6d0c4dc362758d86 Mon Sep 17 00:00:00 2001 From: Adam Semenenko <152864218+adam-enko@users.noreply.github.com> Date: Wed, 4 Dec 2024 11:27:00 +0100 Subject: [PATCH] log dokka config --- .../gradle/build.gradle.kts | 6 ++++ .../kotlin/ExampleProjectsTest.kt | 29 ++++++++++++++----- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/dokka-integration-tests/gradle/build.gradle.kts b/dokka-integration-tests/gradle/build.gradle.kts index 742783b514..7a36aa4e83 100644 --- a/dokka-integration-tests/gradle/build.gradle.kts +++ b/dokka-integration-tests/gradle/build.gradle.kts @@ -226,6 +226,12 @@ testing { } } val testExampleProjects by suites.registering(JvmTestSuite::class) { + + dependencies { + implementation(platform(libs.kotlinxSerialization.bom)) + implementation(libs.kotlinxSerialization.json) + } + targets.configureEach { testTask.configure { diff --git a/dokka-integration-tests/gradle/src/testExampleProjects/kotlin/ExampleProjectsTest.kt b/dokka-integration-tests/gradle/src/testExampleProjects/kotlin/ExampleProjectsTest.kt index 6ac6857bd8..19cf1c44a5 100644 --- a/dokka-integration-tests/gradle/src/testExampleProjects/kotlin/ExampleProjectsTest.kt +++ b/dokka-integration-tests/gradle/src/testExampleProjects/kotlin/ExampleProjectsTest.kt @@ -11,6 +11,7 @@ import io.kotest.matchers.sequences.shouldNotBeEmpty import io.kotest.matchers.shouldBe import io.kotest.matchers.string.shouldContain import io.kotest.matchers.string.shouldNotContain +import kotlinx.serialization.json.Json import org.gradle.testkit.runner.GradleRunner import org.gradle.testkit.runner.TaskOutcome.FROM_CACHE import org.gradle.testkit.runner.TaskOutcome.UP_TO_DATE @@ -191,7 +192,7 @@ class ExampleProjectsTest { format: String, ) { val expectedDataDir = testCase.expectedDataDir.resolve(format) - val dokkaOutputDir = testCase.dokkaOutputDir.resolve(format) + val actualHtmlDir = testCase.dokkaOutputDir.resolve(format) assert(expectedDataDir.isDirectory()) { "Missing expectedDataDir: ${expectedDataDir.toUri()}" @@ -203,22 +204,34 @@ class ExampleProjectsTest { "--stacktrace", ) .build { - dokkaOutputDir.shouldBeADirectory() + actualHtmlDir.shouldBeADirectory() - withClue({ + val dokkaConfigurationJsonFiles = testCase.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()) """ - expectedDataDir: ${expectedDataDir.toUri()} - actualOutputDir: ${dokkaOutputDir.toUri()} + - ${dcFile.invariantSeparatorsPathString} + $compactJson """.trimIndent() - }) { + } + + withClue( + """ + |expectedDataDir: ${expectedDataDir.toUri()} + |actualHtmlDir: ${actualHtmlDir.toUri()} + |dokkaConfigurationJsons [${dokkaConfigurationJsonFiles.count()}]: + |$dokkaConfigContent + """.trimMargin() + ) { withClue("expect file trees are the same") { val expectedFileTree = expectedDataDir.toTreeString() - val actualFileTree = dokkaOutputDir.toTreeString() + val actualFileTree = actualHtmlDir.toTreeString() actualFileTree shouldBe expectedFileTree } withClue("expect directories are the same") { - dokkaOutputDir shouldBeADirectoryWithSameContentAs expectedDataDir + actualHtmlDir shouldBeADirectoryWithSameContentAs expectedDataDir } } }