diff options
author | Goooler <wangzongler@gmail.com> | 2023-03-13 21:51:31 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-13 14:51:31 +0100 |
commit | 3ea414251d32108dab8b14d41a672e9834824690 (patch) | |
tree | 5f7a62f60e3d90ee97989cff8e5d748b180d091b /build-logic/src/main/kotlin/org/jetbrains/conventions/dokka-integration-test.gradle.kts | |
parent | 7a46cd329ac6ccbdb10195310197289947ee4104 (diff) | |
download | dokka-3ea414251d32108dab8b14d41a672e9834824690.tar.gz dokka-3ea414251d32108dab8b14d41a672e9834824690.tar.bz2 dokka-3ea414251d32108dab8b14d41a672e9834824690.zip |
Migrate buildSrc to composite build (#2912)
Diffstat (limited to 'build-logic/src/main/kotlin/org/jetbrains/conventions/dokka-integration-test.gradle.kts')
-rw-r--r-- | build-logic/src/main/kotlin/org/jetbrains/conventions/dokka-integration-test.gradle.kts | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/build-logic/src/main/kotlin/org/jetbrains/conventions/dokka-integration-test.gradle.kts b/build-logic/src/main/kotlin/org/jetbrains/conventions/dokka-integration-test.gradle.kts new file mode 100644 index 00000000..f9edb68e --- /dev/null +++ b/build-logic/src/main/kotlin/org/jetbrains/conventions/dokka-integration-test.gradle.kts @@ -0,0 +1,75 @@ +package org.jetbrains.conventions + +import org.gradle.api.tasks.testing.logging.TestExceptionFormat +import org.gradle.api.tasks.testing.logging.TestLogEvent + +plugins { + id("org.jetbrains.conventions.kotlin-jvm") +} + +val integrationTestSourceSet: SourceSet = sourceSets.create("integrationTest") { + compileClasspath += sourceSets.main.get().output + runtimeClasspath += sourceSets.main.get().output +} + +val integrationTestImplementation: Configuration by configurations.getting { + extendsFrom(configurations.implementation.get()) +} + +val integrationTestRuntimeOnly: Configuration by configurations.getting { + extendsFrom(configurations.runtimeOnly.get()) +} + +/** + * Dokka's integration test task is not cacheable because the HTML outputs + * it produces when running the tests are used for showcasing resulting documentation, + * which does not work well with caching. + * + * At the moment there are two problems that do not allow to make it cacheable: + * + * 1. The task's inputs are such that changes in Dokka's code do not invalidate the cache, + * because it is run with the same version of Dokka (`"DOKKA_VERSION"`) on the same + * test project inputs. + * 2. The tests generate HTML output which is then used to showcase documentation. + * The outputs are usually copied to a location from which it will be served. + * However, if the test is cacheable, it produces no outputs, so no documentation + * to showcase. It needs to be broken into two separate tasks: one cacheable for running + * the tests and producing HTML output, and another non-cacheable for copying the output. + * + * @see [org.jetbrains.dokka.it.TestOutputCopier] for more details on showcasing documentation + */ +@DisableCachingByDefault(because = "Contains incorrect inputs/outputs configuration, see the KDoc for details") +abstract class NonCacheableIntegrationTest : Test() + +val integrationTest by tasks.registering(NonCacheableIntegrationTest::class) { + maxHeapSize = "2G" + description = "Runs integration tests." + group = "verification" + useJUnit() + + testClassesDirs = integrationTestSourceSet.output.classesDirs + classpath = integrationTestSourceSet.runtimeClasspath + + setForkEvery(1) + project.properties["dokka_integration_test_parallelism"]?.toString()?.toIntOrNull()?.let { parallelism -> + maxParallelForks = parallelism + } + environment( + "isExhaustive", + project.properties["dokka_integration_test_is_exhaustive"]?.toString()?.toBoolean() + ?: System.getenv("DOKKA_INTEGRATION_TEST_IS_EXHAUSTIVE")?.toBoolean() + ?: false.toString() + ) + + testLogging { + exceptionFormat = TestExceptionFormat.FULL + events(TestLogEvent.SKIPPED, TestLogEvent.FAILED) + showExceptions = true + showCauses = true + showStackTraces = true + } +} + +tasks.check { + dependsOn(integrationTest) +} |