Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test DGPv2 example projects #3821

Merged
merged 23 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ docs-developer/** linguist-doc
examples/** linguist-documentation
dokka-integration-tests/gradle/projects/** linguist-documentation

dokka-integration-tests/gradle/src/testExampleProjects/expectedData/** linguist-generated
dokka-runners/dokka-gradle-plugin/src/testFunctional/resources/KotlinDslAccessorsTest/** linguist-generated

# Tell Git not to export certain files or directories when generating an archive.
# Since an archive doesn't contain git data, also exclude git metadata files.
.gitattributes export-ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
package dokkabuild.utils

import org.gradle.api.file.Directory
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.file.FileCollection
import org.gradle.api.file.RegularFile
import org.gradle.api.model.ObjectFactory
import org.gradle.api.provider.Provider
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.TaskInputFilePropertyBuilder
import org.gradle.api.tasks.TaskInputPropertyBuilder
import org.gradle.api.tasks.TaskOutputFilePropertyBuilder
import org.gradle.api.tasks.testing.Test
import org.gradle.kotlin.dsl.create
import org.gradle.kotlin.dsl.findByType
Expand Down Expand Up @@ -39,9 +39,10 @@ abstract class SystemPropertyAdder @Inject internal constructor(
) {
private val objects: ObjectFactory = task.project.objects

@JvmName("inputDirectoryProvider")
fun inputDirectory(
key: String,
value: DirectoryProperty,
value: Provider<out Directory>,
): TaskInputFilePropertyBuilder {
task.jvmArgumentProviders.add(
SystemPropertyArgumentProvider(key, value) {
Expand All @@ -52,18 +53,59 @@ abstract class SystemPropertyAdder @Inject internal constructor(
.withPropertyName("SystemProperty input directory $key")
}

@JvmName("inputDirectoryFile")
fun inputDirectory(
key: String,
value: Provider<File>,
): TaskInputFilePropertyBuilder =
inputDirectory(key, objects.directoryProperty().fileProvider(value))

fun inputDirectory(
key: String,
value: File,
): TaskInputFilePropertyBuilder =
inputDirectory(key, objects.directoryProperty().fileValue(value))

fun inputDirectory(
key: String,
value: Directory,
): TaskInputFilePropertyBuilder =
inputDirectory(key, objects.directoryProperty().apply { set(value) })


@JvmName("outputDirectoryProvider")
fun outputDirectory(
key: String,
value: Provider<out Directory>,
): TaskOutputFilePropertyBuilder {
task.jvmArgumentProviders.add(
SystemPropertyArgumentProvider(key, value) {
it.get().asFile.invariantSeparatorsPath
}
)
return task.outputs.dir(value)
.withPropertyName("SystemProperty input directory $key")
}

@JvmName("outputDirectoryFile")
fun outputDirectory(
key: String,
value: Provider<File>,
): TaskOutputFilePropertyBuilder =
outputDirectory(key, objects.directoryProperty().fileProvider(value))

fun outputDirectory(
key: String,
value: File,
): TaskOutputFilePropertyBuilder =
outputDirectory(key, objects.directoryProperty().fileValue(value))

fun outputDirectory(
key: String,
value: Directory,
): TaskOutputFilePropertyBuilder =
outputDirectory(key, objects.directoryProperty().apply { set(value) })

fun inputFile(
key: String,
file: RegularFile,
Expand Down
2 changes: 2 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ idea {
"dokka-runners/runner-cli/.kotlin",
"dokka-runners/runner-maven-plugin/.kotlin",
"dokka-runners/dokka-gradle-plugin/src/testFunctional/resources/KotlinDslAccessorsTest/",

"dokka-integration-tests/gradle/src/testExampleProjects/expectedData",
)
)
}
Expand Down
63 changes: 60 additions & 3 deletions dokka-integration-tests/gradle/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ plugins {
id("dokkabuild.kotlin-jvm")
id("dokkabuild.test-integration")
id("dokkabuild.dev-maven-publish")
`java-test-fixtures`
alias(libs.plugins.kotlinxSerialization)
}

dependencies {
val dokkaVersion = project.version.toString()

api(projects.utilities)

api(libs.jsoup)
Expand All @@ -25,7 +29,22 @@ dependencies {

api(gradleTestKit())

val dokkaVersion = project.version.toString()
testFixturesApi(libs.kotlin.test)
adam-enko marked this conversation as resolved.
Show resolved Hide resolved
testFixturesApi(libs.junit.jupiterApi)
testFixturesApi(libs.junit.jupiterParams)

testFixturesApi(gradleTestKit())

testFixturesApi(testFixtures("org.jetbrains.dokka:dokka-gradle-plugin:$dokkaVersion"))
testFixturesApi(platform(libs.kotest.bom))
testFixturesApi(libs.kotest.assertionsCore)
testFixturesApi(libs.kotest.assertionsJson)

testFixturesImplementation(platform(libs.kotlinxSerialization.bom))
testFixturesImplementation(libs.kotlinxSerialization.json)

testImplementation(testFixtures(project))

// We're using Gradle included-builds and dependency substitution, so we
// need to use the Gradle project name, *not* the published Maven artifact-id
devPublication("org.jetbrains.dokka:plugin-all-modules-page:$dokkaVersion")
Expand Down Expand Up @@ -64,6 +83,7 @@ tasks.withType<Test>().configureEach {
systemProperty("hostGradleUserHome", gradle.gradleUserHomeDir.invariantSeparatorsPath)
}


val templateSettingsGradleKts = layout.projectDirectory.file("projects/template.settings.gradle.kts")
val templateProjectsDir = layout.projectDirectory.dir("projects")

Expand Down Expand Up @@ -155,8 +175,6 @@ fun registerTestProjectSuite(
.inputFile("templateSettingsGradleKts", templateSettingsGradleKts)
.withPathSensitivity(NAME_ONLY)

devMavenPublish.configureTask(this)
whyoleg marked this conversation as resolved.
Show resolved Hide resolved

if (jvm != null) {
javaLauncher = javaToolchains.launcherFor { languageVersion = jvm }
}
Expand All @@ -177,3 +195,42 @@ val checkoutKotlinxSerialization by tasks.registering(GitCheckoutTask::class) {
commitId = "ed1b05707ec27f8864c8b42235b299bdb5e0015c"
destination = templateProjectsDir.dir("serialization/kotlinx-serialization")
}

testing {
suites.withType<JvmTestSuite>().configureEach {
dependencies {
implementation(testFixtures(project()))
}
targets.configureEach {
testTask.configure {
devMavenPublish.configureTask(this)
}
}
}
val testExampleProjects by suites.registering(JvmTestSuite::class) {
targets.configureEach {
testTask.configure {

val exampleGradleProjectsDir = projectDir.resolve("../../examples/gradle-v2")
systemProperty
.inputDirectory("exampleGradleProjectsDir", exampleGradleProjectsDir)
.withPathSensitivity(RELATIVE)

val expectedDataDir = layout.projectDirectory.dir("src/testExampleProjects/expectedData")
adam-enko marked this conversation as resolved.
Show resolved Hide resolved
systemProperty
.inputDirectory("expectedDataDir", expectedDataDir)
.withPathSensitivity(RELATIVE)

systemProperty.inputProperty(
whyoleg marked this conversation as resolved.
Show resolved Hide resolved
"junit.jupiter.execution.parallel.enabled",
dokkaBuild.isCI.map { !it },
)
systemProperty("junit.jupiter.execution.parallel.mode.default", "SAME_THREAD")
}
}
}
}

tasks.check {
adam-enko marked this conversation as resolved.
Show resolved Hide resolved
dependsOn(testing.suites)
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading