Skip to content

Commit aba4ea5

Browse files
committed
Refactor test-mokkery-compiler to test default and minimum Kotlin version
1 parent 02c8aa3 commit aba4ea5

File tree

129 files changed

+711
-133
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+711
-133
lines changed

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[versions]
2-
kotlinMininumSupported="2.3.0"
2+
kotlinMininumSupported = "2.3.0"
33
kotlin = "2.3.20-Beta2"
44
kotlinx-coroutines = "1.10.2"
55
buildconfig = "5.7.0"
Lines changed: 71 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import org.gradle.kotlin.dsl.libs
2+
13
plugins {
24
kotlin("jvm")
35
}
@@ -9,47 +11,82 @@ kotlin {
911

1012
val mokkeryRuntimeClasspath by configurations.registering
1113

14+
val testBase by sourceSets.registering
15+
1216
dependencies {
13-
testImplementation(project(":mokkery-plugin"))
14-
testImplementation(project(":mokkery-core-tooling"))
15-
testImplementation(libs.kotlin.compiler)
16-
testImplementation(libs.kotlin.compiler.test.framework)
17-
testImplementation(libs.kotlin.test.junit5)
18-
testRuntimeOnly(libs.kotlin.reflect)
19-
testRuntimeOnly(libs.kotlin.script.runtime)
20-
testRuntimeOnly(libs.kotlin.annotations.jvm)
17+
val testBaseCompileOnly by configurations
18+
testBaseCompileOnly(project(":mokkery-plugin"))
19+
testBaseCompileOnly(project(":mokkery-core-tooling"))
20+
testBaseCompileOnly(libs.kotlin.compiler)
21+
testBaseCompileOnly(libs.kotlin.compiler.test.framework)
2122
mokkeryRuntimeClasspath(project(":mokkery-runtime"))
2223
}
2324

24-
tasks.register<JavaExec>("generateTests") {
25+
testVariant(kotlinVersion = libs.versions.kotlin.get(), alias = "Default")
26+
testVariant(kotlinVersion = libs.versions.kotlinMininumSupported.get(), alias = "Minimum")
27+
28+
val generateTests by tasks.registering {
2529
group = "verification"
26-
systemProperty("mokkeryRuntime.classpath", mokkeryRuntimeClasspath.get().asPath)
27-
inputs
28-
.dir(layout.projectDirectory.dir("src/test/data"))
29-
.withPropertyName("testData")
30-
.withPathSensitivity(PathSensitivity.RELATIVE)
31-
outputs
32-
.dir(layout.projectDirectory.dir("src/test/java"))
33-
.withPropertyName("generatedTests")
34-
classpath = sourceSets.test.get().runtimeClasspath
35-
mainClass.set("dev.mokkery.tests.GenerateTestsKt")
36-
workingDir = rootDir
30+
dependsOn(tasks.named("generateTestsDefault"))
31+
dependsOn(tasks.named("generateTestsMinimum"))
32+
}
33+
tasks.test {
34+
dependsOn(tasks.named("testDefault"))
35+
dependsOn(tasks.named("testMinimum"))
3736
}
3837

39-
tasks.withType<Test> {
40-
dependsOn(mokkeryRuntimeClasspath)
41-
inputs
42-
.dir(layout.projectDirectory.dir("src/test/data"))
43-
.withPropertyName("testData")
44-
.withPathSensitivity(PathSensitivity.RELATIVE)
45-
46-
workingDir = rootDir
47-
48-
useJUnitPlatform()
38+
fun Project.testVariant(kotlinVersion: String, alias: String = "") {
39+
val sourceSet = sourceSets.register("test$alias") {
40+
java.srcDir("src/test$alias/java")
41+
java.srcDir("src/test$alias/kotlin")
42+
compileClasspath += testBase.get().output
43+
runtimeClasspath += testBase.get().output
44+
}
45+
dependencies {
46+
val testImplementation by configurations.named(sourceSet.get().implementationConfigurationName)
47+
val testRuntimeOnly by configurations.named(sourceSet.get().runtimeOnlyConfigurationName)
48+
testImplementation(project(":mokkery-plugin"))
49+
testImplementation(project(":mokkery-core-tooling"))
50+
testImplementation("org.jetbrains.kotlin:kotlin-compiler:$kotlinVersion")
51+
testImplementation("org.jetbrains.kotlin:kotlin-compiler-internal-test-framework:$kotlinVersion")
52+
testImplementation(libs.kotlin.test.junit5)
53+
testRuntimeOnly(libs.kotlin.reflect)
54+
testRuntimeOnly(libs.kotlin.script.runtime)
55+
testRuntimeOnly(libs.kotlin.annotations.jvm)
56+
}
4957

50-
systemProperty("mokkeryRuntime.classpath", mokkeryRuntimeClasspath.get().asPath)
58+
tasks.register<JavaExec>("generateTests$alias") {
59+
group = "verification"
60+
val testData = layout.projectDirectory.dir("src/${testBase.get().name}/data")
61+
val testsRoot = layout.projectDirectory.dir("src/test$alias/java")
62+
systemProperty("testDataRoot", testData.asFile.relativeTo(rootDir))
63+
systemProperty("testsRoot", testsRoot.asFile.relativeTo(rootDir))
64+
systemProperty("mokkery.runtimeClasspath", mokkeryRuntimeClasspath.get().asPath)
65+
inputs
66+
.dir(testData)
67+
.withPropertyName("testData")
68+
.withPathSensitivity(PathSensitivity.RELATIVE)
69+
outputs
70+
.dir(testsRoot)
71+
.withPropertyName("generatedTestsRoot")
72+
classpath += sourceSet.get().runtimeClasspath
73+
mainClass.set("dev.mokkery.tests.GenerateTestsKt")
74+
workingDir = rootDir
75+
}
5176

52-
// Properties required to run the internal test framework.
53-
systemProperty("idea.ignore.disabled.plugins", "true")
54-
systemProperty("idea.home.path", rootDir)
77+
tasks.register("test$alias", Test::class) {
78+
group = "verification"
79+
testClassesDirs += sourceSet.get().output.classesDirs
80+
classpath += sourceSet.get().runtimeClasspath
81+
dependsOn(mokkeryRuntimeClasspath)
82+
inputs
83+
.dir(layout.projectDirectory.dir("src/${testBase.get().name}/data"))
84+
.withPropertyName("testData")
85+
.withPathSensitivity(PathSensitivity.RELATIVE)
86+
workingDir = rootDir
87+
useJUnitPlatform()
88+
systemProperty("mokkery.runtimeClasspath", mokkeryRuntimeClasspath.get().asPath)
89+
systemProperty("idea.ignore.disabled.plugins", "true")
90+
systemProperty("idea.home.path", rootDir)
91+
}
5592
}

test-mokkery-compiler/src/test/kotlin/dev/mokkery/tests/GenerateTests.kt

Lines changed: 0 additions & 15 deletions
This file was deleted.

test-mokkery-compiler/src/test/data/diagnostic/FirDiagnosticsNotReportedWhenDisabled.fir.diag.txt renamed to test-mokkery-compiler/src/testBase/data/diagnostic/FirDiagnosticsNotReportedWhenDisabled.fir.diag.txt

File renamed without changes.

test-mokkery-compiler/src/test/data/diagnostic/FirDiagnosticsNotReportedWhenDisabled.kt renamed to test-mokkery-compiler/src/testBase/data/diagnostic/FirDiagnosticsNotReportedWhenDisabled.kt

File renamed without changes.

test-mokkery-compiler/src/test/data/diagnostic/matchers/declarations/MatcherArgMatcherParamMustNotBeAnnotatedWithMatcher.fir.diag.txt renamed to test-mokkery-compiler/src/testBase/data/diagnostic/matchers/declarations/MatcherArgMatcherParamMustNotBeAnnotatedWithMatcher.fir.diag.txt

File renamed without changes.

test-mokkery-compiler/src/test/data/diagnostic/matchers/declarations/MatcherArgMatcherParamMustNotBeAnnotatedWithMatcher.kt renamed to test-mokkery-compiler/src/testBase/data/diagnostic/matchers/declarations/MatcherArgMatcherParamMustNotBeAnnotatedWithMatcher.kt

File renamed without changes.

test-mokkery-compiler/src/test/data/diagnostic/matchers/declarations/MatcherMokkeryMatcherScopeParamMustNotBeAnnotatedWithMatcher.fir.diag.txt renamed to test-mokkery-compiler/src/testBase/data/diagnostic/matchers/declarations/MatcherMokkeryMatcherScopeParamMustNotBeAnnotatedWithMatcher.fir.diag.txt

File renamed without changes.

test-mokkery-compiler/src/test/data/diagnostic/matchers/declarations/MatcherMokkeryMatcherScopeParamMustNotBeAnnotatedWithMatcher.kt renamed to test-mokkery-compiler/src/testBase/data/diagnostic/matchers/declarations/MatcherMokkeryMatcherScopeParamMustNotBeAnnotatedWithMatcher.kt

File renamed without changes.

test-mokkery-compiler/src/test/data/diagnostic/matchers/declarations/MatcherMustBeFinal.diag.txt renamed to test-mokkery-compiler/src/testBase/data/diagnostic/matchers/declarations/MatcherMustBeFinal.diag.txt

File renamed without changes.

0 commit comments

Comments
 (0)