Skip to content

Commit

Permalink
test DGPv2 examples
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-enko committed Sep 19, 2024
1 parent c9ce2db commit 9794478
Show file tree
Hide file tree
Showing 642 changed files with 110,168 additions and 83 deletions.
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
57 changes: 54 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)
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)

if (jvm != null) {
javaLauncher = javaToolchains.launcherFor { languageVersion = jvm }
}
Expand All @@ -177,3 +195,36 @@ 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")
systemProperty
.inputDirectory("expectedDataDir", expectedDataDir)
.withPathSensitivity(RELATIVE)
}
}
}
}

tasks.check {
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

0 comments on commit 9794478

Please sign in to comment.