-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
375 additions
and
44 deletions.
There are no files selected for viewing
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
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
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
54 changes: 54 additions & 0 deletions
54
src/functionalTest/kotlin/kotlinx/validation/test/JvmProjectTests.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,54 @@ | ||
/* | ||
* Copyright 2016-2024 JetBrains s.r.o. | ||
* Use of this source code is governed by the Apache 2.0 License that can be found in the LICENSE.txt file. | ||
*/ | ||
|
||
package kotlinx.validation.test | ||
|
||
import kotlinx.validation.api.* | ||
import kotlinx.validation.api.resolve | ||
import kotlinx.validation.api.test | ||
import org.assertj.core.api.Assertions | ||
import org.junit.Test | ||
|
||
class JvmProjectTests : BaseKotlinGradleTest() { | ||
@Test | ||
fun `apiDump for a project with generated sources only`() { | ||
val runner = test { | ||
buildGradleKts { | ||
resolve("/examples/gradle/base/withPlugin.gradle.kts") | ||
resolve("/examples/gradle/configuration/generatedSources/generatedJvmSources.gradle.kts") | ||
} | ||
// TODO: enable configuration cache back when we start skipping tasks correctly | ||
runner(withConfigurationCache = false) { | ||
arguments.add(":apiDump") | ||
} | ||
} | ||
runner.build().apply { | ||
assertTaskSuccess(":apiDump") | ||
|
||
val expectedApi = readFileList("/examples/classes/GeneratedSources.dump") | ||
Assertions.assertThat(rootProjectApiDump.readText()).isEqualToIgnoringNewLines(expectedApi) | ||
} | ||
} | ||
|
||
@Test | ||
fun `apiCheck for a project with generated sources only`() { | ||
val runner = test { | ||
buildGradleKts { | ||
resolve("/examples/gradle/base/withPlugin.gradle.kts") | ||
resolve("/examples/gradle/configuration/generatedSources/generatedJvmSources.gradle.kts") | ||
} | ||
apiFile(projectName = rootProjectDir.name) { | ||
resolve("/examples/classes/GeneratedSources.dump") | ||
} | ||
// TODO: enable configuration cache back when we start skipping tasks correctly | ||
runner(withConfigurationCache = false) { | ||
arguments.add(":apiCheck") | ||
} | ||
} | ||
runner.build().apply { | ||
assertTaskSuccess(":apiCheck") | ||
} | ||
} | ||
} |
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
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
14 changes: 14 additions & 0 deletions
14
src/functionalTest/resources/examples/classes/AnotherBuildConfig.klib.linuxX64Only.dump
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,14 @@ | ||
// Klib ABI Dump | ||
// Targets: [linuxX64] | ||
// Rendering settings: | ||
// - Signature version: 2 | ||
// - Show manifest properties: true | ||
// - Show declarations: true | ||
|
||
// Library unique name: <testproject> | ||
final class org.different.pack/BuildConfig { // org.different.pack/BuildConfig|null[0] | ||
constructor <init>() // org.different.pack/BuildConfig.<init>|<init>(){}[0] | ||
final fun f1(): kotlin/Int // org.different.pack/BuildConfig.f1|f1(){}[0] | ||
final val p1 // org.different.pack/BuildConfig.p1|{}p1[0] | ||
final fun <get-p1>(): kotlin/Int // org.different.pack/BuildConfig.p1.<get-p1>|<get-p1>(){}[0] | ||
} |
5 changes: 5 additions & 0 deletions
5
src/functionalTest/resources/examples/classes/GeneratedSources.dump
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,5 @@ | ||
public final class Generated { | ||
public fun <init> ()V | ||
public final fun helloCreator ()I | ||
} | ||
|
12 changes: 12 additions & 0 deletions
12
src/functionalTest/resources/examples/classes/GeneratedSources.klib.dump
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,12 @@ | ||
// Klib ABI Dump | ||
// Targets: [androidNativeArm32, androidNativeArm64, androidNativeX64, androidNativeX86, linuxArm64, linuxX64, mingwX64] | ||
// Rendering settings: | ||
// - Signature version: 2 | ||
// - Show manifest properties: true | ||
// - Show declarations: true | ||
|
||
// Library unique name: <testproject> | ||
final class /Generated { // /Generated|null[0] | ||
constructor <init>() // /Generated.<init>|<init>(){}[0] | ||
final fun helloCreator(): kotlin/Int // /Generated.helloCreator|helloCreator(){}[0] | ||
} |
21 changes: 21 additions & 0 deletions
21
...t/resources/examples/gradle/configuration/generatedSources/generatedJvmSources.gradle.kts
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,21 @@ | ||
abstract class GenerateSourcesTask : org.gradle.api.DefaultTask() { | ||
@get:org.gradle.api.tasks.OutputDirectory | ||
abstract val outputDirectory: org.gradle.api.file.DirectoryProperty | ||
|
||
@org.gradle.api.tasks.TaskAction | ||
fun generate() { | ||
outputDirectory.asFile.get().mkdirs() | ||
outputDirectory.file("Generated.kt").get().asFile.writeText(""" | ||
public class Generated { public fun helloCreator(): Int = 42 } | ||
""".trimIndent()) | ||
} | ||
} | ||
|
||
val srcgen = project.tasks.register("generateSources", GenerateSourcesTask::class.java) | ||
srcgen.configure { | ||
outputDirectory.set(project.layout.buildDirectory.get().dir("generated").dir("kotlin")) | ||
} | ||
|
||
project.sourceSets.getByName("main") { | ||
kotlin.srcDir(srcgen) | ||
} |
22 changes: 22 additions & 0 deletions
22
...Test/resources/examples/gradle/configuration/generatedSources/generatedSources.gradle.kts
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,22 @@ | ||
abstract class GenerateSourcesTask : org.gradle.api.DefaultTask() { | ||
@get:org.gradle.api.tasks.OutputDirectory | ||
abstract val outputDirectory: org.gradle.api.file.DirectoryProperty | ||
|
||
@org.gradle.api.tasks.TaskAction | ||
fun generate() { | ||
outputDirectory.asFile.get().mkdirs() | ||
outputDirectory.file("Generated.kt").get().asFile.writeText(""" | ||
public class Generated { public fun helloCreator(): Int = 42 } | ||
""".trimIndent()) | ||
} | ||
} | ||
|
||
val srcgen = project.tasks.register("generateSources", GenerateSourcesTask::class.java) | ||
srcgen.configure { | ||
outputDirectory.set(project.layout.buildDirectory.get().dir("generated").dir("kotlin")) | ||
} | ||
|
||
val kotlin = project.extensions.getByType(org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension::class.java) | ||
kotlin.sourceSets.getByName("commonMain") { | ||
kotlin.srcDir(srcgen) | ||
} |
Oops, something went wrong.