-
Notifications
You must be signed in to change notification settings - Fork 416
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for DokkaSourceSetSpec conventions
- Loading branch information
Showing
1 changed file
with
133 additions
and
0 deletions.
There are no files selected for viewing
133 changes: 133 additions & 0 deletions
133
...a-runners/dokka-gradle-plugin/src/test/kotlin/engine/parameters/DokkaSourceSetSpecTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
/* | ||
* Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. | ||
*/ | ||
package org.jetbrains.dokka.gradle.engine.parameters | ||
|
||
import io.kotest.core.spec.style.FunSpec | ||
import io.kotest.matchers.collections.shouldBeEmpty | ||
import io.kotest.matchers.collections.shouldContainExactlyInAnyOrder | ||
import io.kotest.matchers.shouldBe | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.apply | ||
import org.gradle.kotlin.dsl.getByType | ||
import org.gradle.testfixtures.ProjectBuilder | ||
import org.jetbrains.dokka.gradle.DokkaExtension | ||
import org.jetbrains.dokka.gradle.DokkaPlugin | ||
import org.jetbrains.dokka.gradle.engine.parameters.VisibilityModifier.Public | ||
import org.jetbrains.dokka.gradle.utils.create_ | ||
import org.jetbrains.dokka.gradle.utils.enableV2Plugin | ||
|
||
class DokkaSourceSetSpecTest : FunSpec({ | ||
|
||
context("verify DokkaSourceSetSpec conventions") { | ||
val project = createProject() | ||
val dss = project.createDokkaSourceSetSpec("foo") | ||
|
||
test("analysisPlatform") { | ||
dss.analysisPlatform.orNull shouldBe KotlinPlatform.DEFAULT | ||
} | ||
test("apiVersion") { | ||
dss.apiVersion.orNull shouldBe null | ||
} | ||
test("classpath") { | ||
dss.classpath.shouldBeEmpty() | ||
} | ||
test("dependentSourceSets") { | ||
dss.dependentSourceSets.shouldBeEmpty() | ||
} | ||
test("displayName") { | ||
dss.displayName.orNull shouldBe "jvm" | ||
} | ||
test("documentedVisibilities") { | ||
dss.documentedVisibilities.orNull shouldBe setOf(Public) | ||
} | ||
test("enableAndroidDocumentationLink") { | ||
dss.enableAndroidDocumentationLink.orNull shouldBe false | ||
} | ||
test("enableJdkDocumentationLink") { | ||
dss.enableJdkDocumentationLink.orNull shouldBe true | ||
} | ||
test("enableKotlinStdLibDocumentationLink") { | ||
dss.enableKotlinStdLibDocumentationLink.orNull shouldBe true | ||
} | ||
test("externalDocumentationLinks") { | ||
dss.externalDocumentationLinks | ||
.map { it.run { "$name enabled:${enabled.orNull} url:${url.orNull} packageList:${packageListUrl.orNull}" } } | ||
.shouldContainExactlyInAnyOrder( | ||
"androidSdk enabled:false url:https://developer.android.com/reference/kotlin/ packageList:https://developer.android.com/reference/kotlin/package-list", | ||
"androidX enabled:false url:https://developer.android.com/reference/kotlin/ packageList:https://developer.android.com/reference/kotlin/androidx/package-list", | ||
"jdk enabled:true url:https://docs.oracle.com/en/java/javase/11/docs/api/ packageList:https://docs.oracle.com/en/java/javase/11/docs/api/element-list", | ||
"kotlinStdlib enabled:true url:https://kotlinlang.org/api/latest/jvm/stdlib/ packageList:https://kotlinlang.org/api/latest/jvm/stdlib/package-list", | ||
) | ||
} | ||
test("includes") { | ||
dss.includes.shouldBeEmpty() | ||
} | ||
test("jdkVersion") { | ||
dss.jdkVersion.orNull shouldBe 11 | ||
} | ||
test("languageVersion") { | ||
dss.languageVersion.orNull shouldBe null | ||
} | ||
test("name") { | ||
dss.name shouldBe "foo" | ||
} | ||
test("perPackageOptions") { | ||
dss.perPackageOptions.shouldBeEmpty() | ||
} | ||
test("reportUndocumented") { | ||
dss.reportUndocumented.orNull shouldBe false | ||
} | ||
test("samples") { | ||
dss.samples.shouldBeEmpty() | ||
} | ||
test("skipDeprecated") { | ||
dss.skipDeprecated.orNull shouldBe false | ||
} | ||
test("skipEmptyPackages") { | ||
dss.skipEmptyPackages.orNull shouldBe true | ||
} | ||
test("sourceLinks") { | ||
dss.sourceLinks.shouldBeEmpty() | ||
} | ||
test("sourceRoots") { | ||
dss.sourceRoots.shouldBeEmpty() | ||
} | ||
test("sourceSetId") { | ||
dss.sourceSetId.orNull?.toString() shouldBe "DokkaSourceSetIdSpec(:/foo)" | ||
} | ||
test("sourceSetScope") { | ||
dss.sourceSetScope.orNull shouldBe ":" | ||
dss.sourceSetScope.orNull shouldBe project.path | ||
} | ||
test("suppress") { | ||
dss.suppress.orNull shouldBe false | ||
} | ||
test("suppressGeneratedFiles") { | ||
dss.suppressGeneratedFiles.orNull shouldBe true | ||
} | ||
test("suppressedFiles") { | ||
dss.suppressedFiles.shouldBeEmpty() | ||
} | ||
} | ||
}) { | ||
companion object { | ||
private fun createProject(): Project { | ||
val project = ProjectBuilder.builder().build() | ||
project.enableV2Plugin() | ||
project.plugins.apply(type = DokkaPlugin::class) | ||
return project | ||
} | ||
|
||
private fun Project.createDokkaSourceSetSpec( | ||
name: String, | ||
configure: DokkaSourceSetSpec.() -> Unit = {} | ||
): DokkaSourceSetSpec { | ||
return extensions | ||
.getByType<DokkaExtension>() | ||
.dokkaSourceSets | ||
.create_(name, configure) | ||
} | ||
|
||
} | ||
} |