Skip to content

Commit

Permalink
a
Browse files Browse the repository at this point in the history
  • Loading branch information
whyoleg committed Jan 16, 2025
1 parent 71b9694 commit e8fee9a
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 30 deletions.
39 changes: 26 additions & 13 deletions sweetspi-tests/src/main/kotlin/TestVersions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,37 @@ data class TestVersions(
val kspVersion: String,
)

private const val MIN_GRADLE = "8.0.2"
private const val LATEST_GRADLE = "8.12"
private val KSP_VERSIONS = listOf(
"2.0.0-1.0.24",
"2.0.10-1.0.24",
"2.0.21-1.0.28",
"2.1.0-1.0.29",
"2.1.10-RC-1.0.29",
"2.1.20-Beta1-1.0.29",
)

abstract class TestVersionsProvider(private val versions: Sequence<TestVersions>) : ArgumentsProvider {
constructor(block: suspend SequenceScope<TestVersions>.() -> Unit) : this(sequence(block))

override fun provideArguments(context: ExtensionContext?): Stream<out Arguments> = versions.map { Arguments.of(it) }.asStream()

object All : TestVersionsProvider({
listOf(
"8.0.2", // oldest supported
"8.12", // latest stable
).forEach { gradleVersion ->
listOf(
"2.0.0-1.0.24", // oldest supported
"2.0.10-1.0.24",
"2.0.21-1.0.28",
"2.1.0-1.0.29",
"2.1.10-RC-1.0.29",
"2.1.20-Beta1-1.0.29",
).forEach { kspVersion ->
class LatestGradle : TestVersionsProvider({
KSP_VERSIONS.forEach { kspVersion ->
yield(
TestVersions(
gradleVersion = LATEST_GRADLE,
kotlinVersion = kspVersion.substringBeforeLast("-"),
kspVersion = kspVersion
)
)
}
})

class AllGradle : TestVersionsProvider({
listOf(MIN_GRADLE, LATEST_GRADLE).forEach { gradleVersion ->
KSP_VERSIONS.forEach { kspVersion ->
yield(
TestVersions(
gradleVersion = gradleVersion,
Expand Down
4 changes: 2 additions & 2 deletions sweetspi-tests/src/testPlugin/kotlin/JvmPluginTest.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 Oleg Yukhnevich. Use of this source code is governed by the Apache 2.0 license.
* Copyright (c) 2024-2025 Oleg Yukhnevich. Use of this source code is governed by the Apache 2.0 license.
*/

package dev.whyoleg.sweetspi.tests.plugin
Expand All @@ -13,7 +13,7 @@ class JvmPluginTest : AbstractTest() {
override val defaultTemplate: TestTemplate get() = TestTemplate.JVM

@ParameterizedTest
@ArgumentsSource(TestVersionsProvider.All::class)
@ArgumentsSource(TestVersionsProvider.AllGradle::class)
fun testKspIsExecuted(versions: TestVersions) {
val project = project(versions = versions) {
withSweetSpi()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 Oleg Yukhnevich. Use of this source code is governed by the Apache 2.0 license.
* Copyright (c) 2024-2025 Oleg Yukhnevich. Use of this source code is governed by the Apache 2.0 license.
*/

package dev.whyoleg.sweetspi.tests.plugin
Expand All @@ -12,7 +12,7 @@ class MultiplatformJvmPluginTest : AbstractTest() {
override val defaultTemplate: TestTemplate get() = TestTemplate.MULTIPLATFORM

@ParameterizedTest
@ArgumentsSource(TestVersionsProvider.All::class)
@ArgumentsSource(TestVersionsProvider.AllGradle::class)
fun testJvm(versions: TestVersions) {
val project = project(versions = versions) {
withSweetSpi()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 Oleg Yukhnevich. Use of this source code is governed by the Apache 2.0 license.
* Copyright (c) 2024-2025 Oleg Yukhnevich. Use of this source code is governed by the Apache 2.0 license.
*/

package dev.whyoleg.sweetspi.tests.plugin
Expand All @@ -12,7 +12,7 @@ class MultiplatformPluginTest : AbstractTest() {
override val defaultTemplate: TestTemplate get() = TestTemplate.MULTIPLATFORM

@ParameterizedTest
@ArgumentsSource(TestVersionsProvider.All::class)
@ArgumentsSource(TestVersionsProvider.AllGradle::class)
fun testAllTargets(versions: TestVersions) {
val project = project(versions = versions) {
withSweetSpi()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class MultiplatformJvmProcessorTest : AbstractTest() {
override val defaultTemplate: TestTemplate get() = TestTemplate.MULTIPLATFORM

@ParameterizedTest
@ArgumentsSource(TestVersionsProvider.All::class)
@ArgumentsSource(TestVersionsProvider.LatestGradle::class)
fun testJvmTargetOutput(versions: TestVersions) {
val project = project(versions) {
withSweetSpi()
Expand All @@ -42,7 +42,7 @@ class MultiplatformJvmProcessorTest : AbstractTest() {
}

@ParameterizedTest
@ArgumentsSource(TestVersionsProvider.All::class)
@ArgumentsSource(TestVersionsProvider.LatestGradle::class)
fun testJvmProviderNotExtendingService(versions: TestVersions) {
val project = project(versions) {
withSweetSpi()
Expand Down
2 changes: 1 addition & 1 deletion sweetspi-tests/src/testRuntime/kotlin/JvmRuntimeTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class JvmRuntimeTest : AbstractTest() {
override val defaultTemplate: TestTemplate get() = TestTemplate.JVM

@ParameterizedTest
@ArgumentsSource(TestVersionsProvider.All::class)
@ArgumentsSource(TestVersionsProvider.LatestGradle::class)
fun testRuntimeWorks(versions: TestVersions) {
val project = project(versions) {
withSweetSpi()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class MultiplatformCrossModuleRuntimeTest : AbstractTest() {
override val defaultTemplate: TestTemplate get() = TestTemplate.MULTIPLATFORM_MULTIMODULE

@ParameterizedTest
@ArgumentsSource(TestVersionsProvider.All::class)
@ArgumentsSource(TestVersionsProvider.LatestGradle::class)
fun test3ModulesInteraction(versions: TestVersions) {
val project = project(versions = versions) {
append(SETTINGS_GRADLE_KTS) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class MultiplatformJvmRuntimeTest : AbstractTest() {
}

@ParameterizedTest
@ArgumentsSource(TestVersionsProvider.All::class)
@ArgumentsSource(TestVersionsProvider.LatestGradle::class)
fun testSimple(versions: TestVersions) = jvmProject(versions) {
jvmMainFile(
"""
Expand All @@ -70,7 +70,7 @@ class MultiplatformJvmRuntimeTest : AbstractTest() {
}.runJvmTest()

@ParameterizedTest
@ArgumentsSource(TestVersionsProvider.All::class)
@ArgumentsSource(TestVersionsProvider.LatestGradle::class)
fun testMultipleServices(versions: TestVersions) = jvmProject(versions) {
jvmMainFile(
"""
Expand All @@ -90,7 +90,7 @@ class MultiplatformJvmRuntimeTest : AbstractTest() {
}.runJvmTest()

@ParameterizedTest
@ArgumentsSource(TestVersionsProvider.All::class)
@ArgumentsSource(TestVersionsProvider.LatestGradle::class)
fun testMultipleInheritance(versions: TestVersions) = jvmProject(versions) {
jvmMainFile(
"""
Expand All @@ -115,7 +115,7 @@ class MultiplatformJvmRuntimeTest : AbstractTest() {
}.runJvmTest()

@ParameterizedTest
@ArgumentsSource(TestVersionsProvider.All::class)
@ArgumentsSource(TestVersionsProvider.LatestGradle::class)
fun testFunction(versions: TestVersions) = jvmProject(versions) {
jvmMainFile(
"""
Expand All @@ -140,7 +140,7 @@ class MultiplatformJvmRuntimeTest : AbstractTest() {
}.runJvmTest()

@ParameterizedTest
@ArgumentsSource(TestVersionsProvider.All::class)
@ArgumentsSource(TestVersionsProvider.LatestGradle::class)
fun testFunctionErrorPropagation(versions: TestVersions) = jvmProject(versions) {
jvmMainFile(
"""
Expand All @@ -161,7 +161,7 @@ class MultiplatformJvmRuntimeTest : AbstractTest() {
}.runJvmTest()

@ParameterizedTest
@ArgumentsSource(TestVersionsProvider.All::class)
@ArgumentsSource(TestVersionsProvider.LatestGradle::class)
fun testProperty(versions: TestVersions) = jvmProject(versions) {
jvmMainFile(
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class MultiplatformRuntimeTest : AbstractTest() {
override val defaultTemplate: TestTemplate get() = TestTemplate.MULTIPLATFORM

@ParameterizedTest
@ArgumentsSource(TestVersionsProvider.All::class)
@ArgumentsSource(TestVersionsProvider.LatestGradle::class)
fun testAllTargets(versions: TestVersions) {
val project = project(versions = versions) {

Expand Down

0 comments on commit e8fee9a

Please sign in to comment.