From 766070724333f06957a52e8960d7a23a68613ace Mon Sep 17 00:00:00 2001 From: Adam <897017+aSemy@users.noreply.github.com> Date: Tue, 15 Aug 2023 12:34:32 +0200 Subject: [PATCH] minor Windows integration tests improvements (#112) * update to Gradle 8.2.1 * fix KotlinMultiplatformFunctionalTest on Windows * re-enable integration tests on Windows * remove custom min/max heap size for workers * mark min/max heap as optional * skip CI integration tests on Windows --- .github/workflows/tests.yml | 11 ++++++++--- gradle/wrapper/gradle-wrapper.properties | 2 +- .../kotlin/AndroidProjectIntegrationTest.kt | 2 -- .../kotlin/BasicProjectIntegrationTest.kt | 3 --- .../src/main/kotlin/DokkatooBasePlugin.kt | 3 --- .../src/main/kotlin/tasks/DokkatooGenerateTask.kt | 6 ++++-- .../src/testFixtures/kotlin/stringUtils.kt | 8 ++++++++ .../kotlin/KotlinMultiplatformFunctionalTest.kt | 2 +- 8 files changed, 22 insertions(+), 15 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2ed69ae2..e0d03be5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -24,9 +24,14 @@ jobs: gradle-check: strategy: matrix: - os: [ macos-latest, ubuntu-latest, windows-latest ] - task: - - "check --continue" + include: + - os: macos-latest + task: "check --continue" + - os: ubuntu-latest + task: "check --continue" + - os: windows-latest + # don't run integration tests on Windows because Gradle OOMs https://github.com/adamko-dev/dokkatoo/issues/10 + task: "check --continue -x :modules:dokkatoo-plugin-integration-tests:check" fail-fast: false uses: ./.github/workflows/gradle_task.yml with: diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 62f495df..9f4197d5 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/modules/dokkatoo-plugin-integration-tests/src/testIntegration/kotlin/AndroidProjectIntegrationTest.kt b/modules/dokkatoo-plugin-integration-tests/src/testIntegration/kotlin/AndroidProjectIntegrationTest.kt index b29c0186..98f1b989 100644 --- a/modules/dokkatoo-plugin-integration-tests/src/testIntegration/kotlin/AndroidProjectIntegrationTest.kt +++ b/modules/dokkatoo-plugin-integration-tests/src/testIntegration/kotlin/AndroidProjectIntegrationTest.kt @@ -1,7 +1,6 @@ package dev.adamko.dokkatoo.tests.integration import dev.adamko.dokkatoo.utils.* -import io.kotest.core.annotation.EnabledIf import io.kotest.core.spec.style.FunSpec import io.kotest.matchers.file.shouldBeAFile import io.kotest.matchers.file.shouldHaveSameStructureAndContentAs @@ -18,7 +17,6 @@ import kotlin.io.path.deleteIfExists * * Runs Dokka & Dokkatoo, and compares the resulting HTML site. */ -@EnabledIf(NotWindowsCondition::class) // https://github.com/adamko-dev/dokkatoo/issues/10 class AndroidProjectIntegrationTest : FunSpec({ val tempDir = GradleProjectTest.projectTestTempDir.resolve("it/it-android-0").toFile() diff --git a/modules/dokkatoo-plugin-integration-tests/src/testIntegration/kotlin/BasicProjectIntegrationTest.kt b/modules/dokkatoo-plugin-integration-tests/src/testIntegration/kotlin/BasicProjectIntegrationTest.kt index ade39202..a5fef8d3 100644 --- a/modules/dokkatoo-plugin-integration-tests/src/testIntegration/kotlin/BasicProjectIntegrationTest.kt +++ b/modules/dokkatoo-plugin-integration-tests/src/testIntegration/kotlin/BasicProjectIntegrationTest.kt @@ -1,9 +1,7 @@ package dev.adamko.dokkatoo.tests.integration -import dev.adamko.dokkatoo.internal.DokkatooConstants.DOKKA_VERSION import dev.adamko.dokkatoo.utils.* import dev.adamko.dokkatoo.utils.GradleProjectTest.Companion.projectTestTempDir -import io.kotest.core.annotation.EnabledIf import io.kotest.core.spec.style.FunSpec import io.kotest.matchers.file.shouldBeAFile import io.kotest.matchers.file.shouldHaveSameStructureAndContentAs @@ -19,7 +17,6 @@ import java.io.File * * Runs Dokka & Dokkatoo, and compares the resulting HTML site. */ -@EnabledIf(NotWindowsCondition::class) // https://github.com/adamko-dev/dokkatoo/issues/10 class BasicProjectIntegrationTest : FunSpec({ val tempDir = projectTestTempDir.resolve("it/it-basic").toFile() diff --git a/modules/dokkatoo-plugin/src/main/kotlin/DokkatooBasePlugin.kt b/modules/dokkatoo-plugin/src/main/kotlin/DokkatooBasePlugin.kt index 7e109d14..b0cd33c6 100644 --- a/modules/dokkatoo-plugin/src/main/kotlin/DokkatooBasePlugin.kt +++ b/modules/dokkatoo-plugin/src/main/kotlin/DokkatooBasePlugin.kt @@ -75,9 +75,6 @@ constructor( cacheDirectory.convention(dokkatooExtension.dokkatooCacheDirectory) workerDebugEnabled.convention(false) workerLogFile.convention(temporaryDir.resolve("dokka-worker.log")) - // increase memory - DokkaGenerator is hungry https://github.com/Kotlin/dokka/issues/1405 - workerMinHeapSize.convention("512m") - workerMaxHeapSize.convention("1g") workerJvmArgs.set( listOf( //"-XX:MaxMetaspaceSize=512m", diff --git a/modules/dokkatoo-plugin/src/main/kotlin/tasks/DokkatooGenerateTask.kt b/modules/dokkatoo-plugin/src/main/kotlin/tasks/DokkatooGenerateTask.kt index 71fb4858..193c5ad5 100644 --- a/modules/dokkatoo-plugin/src/main/kotlin/tasks/DokkatooGenerateTask.kt +++ b/modules/dokkatoo-plugin/src/main/kotlin/tasks/DokkatooGenerateTask.kt @@ -78,9 +78,11 @@ constructor( abstract val workerDebugEnabled: Property /** @see JavaForkOptions.getMinHeapSize */ @get:Input + @get:Optional abstract val workerMinHeapSize: Property /** @see JavaForkOptions.getMaxHeapSize */ @get:Input + @get:Optional abstract val workerMaxHeapSize: Property /** @see JavaForkOptions.jvmArgs */ @get:Input @@ -113,8 +115,8 @@ constructor( classpath.from(runtimeClasspath) forkOptions { defaultCharacterEncoding = "UTF-8" - minHeapSize = workerMinHeapSize.get() - maxHeapSize = workerMaxHeapSize.get() + minHeapSize = workerMinHeapSize.orNull + maxHeapSize = workerMaxHeapSize.orNull enableAssertions = true debug = workerDebugEnabled.get() jvmArgs = workerJvmArgs.get() diff --git a/modules/dokkatoo-plugin/src/testFixtures/kotlin/stringUtils.kt b/modules/dokkatoo-plugin/src/testFixtures/kotlin/stringUtils.kt index ff8d124d..d9e2828c 100644 --- a/modules/dokkatoo-plugin/src/testFixtures/kotlin/stringUtils.kt +++ b/modules/dokkatoo-plugin/src/testFixtures/kotlin/stringUtils.kt @@ -1,5 +1,6 @@ package dev.adamko.dokkatoo.utils + fun String.splitToPair(delimiter: String): Pair = substringBefore(delimiter) to substringAfter(delimiter) @@ -11,3 +12,10 @@ fun String.uppercaseFirstChar(): String = mapFirstChar(Character::toTitleCase) private inline fun String.mapFirstChar( transform: (Char) -> Char ): String = if (isNotEmpty()) transform(this[0]) + substring(1) else this + + +/** Split a string into lines, sort the lines, and re-join them (using [separator]). */ +fun String.sortLines(separator: String = "\n") = + lines() + .sorted() + .joinToString(separator) diff --git a/modules/dokkatoo-plugin/src/testFunctional/kotlin/KotlinMultiplatformFunctionalTest.kt b/modules/dokkatoo-plugin/src/testFunctional/kotlin/KotlinMultiplatformFunctionalTest.kt index 889c7e1d..b628f055 100644 --- a/modules/dokkatoo-plugin/src/testFunctional/kotlin/KotlinMultiplatformFunctionalTest.kt +++ b/modules/dokkatoo-plugin/src/testFunctional/kotlin/KotlinMultiplatformFunctionalTest.kt @@ -58,6 +58,7 @@ class KotlinMultiplatformFunctionalTest : FunSpec({ test("with element-list") { project.projectDir.resolve("build/dokka/html/test/package-list").shouldBeAFile() project.projectDir.resolve("build/dokka/html/test/package-list").toFile().readText() + .sortLines() .shouldContain( /* language=text */ """ |${'$'}dokka.format:html-v1 |${'$'}dokka.linkExtension:html @@ -67,7 +68,6 @@ class KotlinMultiplatformFunctionalTest : FunSpec({ |${'$'}dokka.location:com.project/Hello/Hello/#/PointingToDeclaration/test/com.project/-hello/-hello.html |${'$'}dokka.location:com.project/Hello/sayHello/#kotlinx.serialization.json.JsonObject/PointingToDeclaration/test/com.project/-hello/say-hello.html |com.project - | """.trimMargin() ) }