Skip to content

Commit

Permalink
Run analysis-kotlin-api tests with K2 analysis (#3358)
Browse files Browse the repository at this point in the history
  • Loading branch information
IgnatBeresnev authored Nov 20, 2023
1 parent f333e42 commit 9ce37af
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 5 deletions.
5 changes: 4 additions & 1 deletion dokka-subprojects/analysis-kotlin-api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import dokkabuild.overridePublicationArtifactId
plugins {
id("dokkabuild.kotlin-jvm")
id("dokkabuild.publish-jvm")
id("dokkabuild.test-k2")
`java-test-fixtures`
}

Expand All @@ -18,7 +19,9 @@ dependencies {
testFixturesApi(projects.dokkaSubprojects.dokkaCore)

testImplementation(kotlin("test"))
testImplementation(projects.dokkaSubprojects.analysisKotlinDescriptors)

symbolsTestConfiguration(project(path = ":dokka-subprojects:analysis-kotlin-symbols", configuration = "shadow"))
descriptorsTestConfiguration(project(path = ":dokka-subprojects:analysis-kotlin-descriptors", configuration = "shadow"))
}

disableTestFixturesPublishing()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,12 @@ class SampleMixedJvmAnalysisTest {
val secondClasslike = pckg.classlikes[1]
assertEquals("MyJavaFileInJava", secondClasslike.name)

val firstFunction = pckg.functions[0]
// TODO #3250 address unstable order
val functions = pckg.functions.sortedBy { it.name }
val firstFunction = functions[0]
assertEquals("bar", firstFunction.name)

val secondFunction = pckg.functions[1]
val secondFunction = functions[1]
assertEquals("foo", secondFunction.name)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ data class TestDokkaSourceSet (
*/
val analysisPlatform: Platform,

/**
* Display name of the source set, used both internally and externally
*
* @see DokkaConfiguration.DokkaSourceSet.displayName
*/
val displayName: String,

/**
* A unique identifier of this source set in the scope of the project.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ fun TestDokkaConfiguration.toDokkaConfiguration(projectDir: File): DokkaConfigur

private fun TestDokkaSourceSet.toDokkaSourceSet(relativeToDir: File): DokkaConfiguration.DokkaSourceSet {
val analysisPlatform = this.analysisPlatform
val displayName = this.displayName
val sourceSetID = this.sourceSetID
val dependentSourceSets = this.dependentSourceSets
val sourceRoots = this.sourceRoots.mapToSet { it.relativeTo(relativeToDir) }
Expand All @@ -109,6 +110,9 @@ private fun TestDokkaSourceSet.toDokkaSourceSet(relativeToDir: File): DokkaConfi
override val analysisPlatform: Platform
get() = analysisPlatform

override val displayName: String
get() = displayName

override val sourceSetID: DokkaSourceSetID
get() = sourceSetID

Expand Down Expand Up @@ -142,8 +146,6 @@ private fun TestDokkaSourceSet.toDokkaSourceSet(relativeToDir: File): DokkaConfi
* analysis (i.e starts throwing an exception), a corresponding
* test property should be added along with the mapping.
*/
override val displayName: String
get() = throw NotImplementedError("Not expected to be used by analysis modules")
@Suppress("OVERRIDE_DEPRECATION")
override val includeNonPublic: Boolean
get() = throw NotImplementedError("Not expected to be used by analysis modules")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class JavaTestSourceSetBuilder : BaseTestDokkaSourceSetBuilder() {
override fun build(): TestDokkaSourceSet {
return TestDokkaSourceSet(
analysisPlatform = Platform.jvm,
displayName = "JavaJvmSourceSet",
sourceSetID = DokkaSourceSetID(scopeId = "project", sourceSetName = "java"),
dependentSourceSets = setOf(),
sourceRoots = additionalSourceRoots + setOf(JavaTestProject.DEFAULT_SOURCE_ROOT),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class KotlinJvmTestSourceSetBuilder : BaseTestDokkaSourceSetBuilder() {
override fun build(): TestDokkaSourceSet {
return TestDokkaSourceSet(
analysisPlatform = Platform.jvm,
displayName = "KotlinJvmSourceSet",
sourceSetID = DokkaSourceSetID(scopeId = "project", sourceSetName = "kotlin"),
dependentSourceSets = setOf(),
sourceRoots = additionalSourceRoots + setOf(KotlinJvmTestProject.DEFAULT_SOURCE_ROOT),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class MixedJvmTestSourceSetBuilder : BaseTestDokkaSourceSetBuilder() {
override fun build(): TestDokkaSourceSet {
return TestDokkaSourceSet(
analysisPlatform = Platform.jvm,
displayName = "MixedJvmSourceSet",
sourceSetID = DokkaSourceSetID(scopeId = "project", sourceSetName = "jvm"),
dependentSourceSets = setOf(),
sourceRoots = additionalSourceRoots + setOf(
Expand Down

0 comments on commit 9ce37af

Please sign in to comment.