diff --git a/CHANGELOG.md b/CHANGELOG.md index e7654de..5cf450f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,11 @@ ## [Unreleased] [Unreleased]: https://github.com/cashapp/burst/compare/0.6.0...HEAD +**Fixed** + + * Do not attempt to parameterize constructors of `abstract` test classes. + + ## [0.6.0] *(2024-10-23)* [0.6.0]: https://github.com/cashapp/burst/releases/tag/0.6.0 diff --git a/burst-gradle-plugin/src/test/kotlin/app/cash/burst/gradle/BurstGradlePluginTest.kt b/burst-gradle-plugin/src/test/kotlin/app/cash/burst/gradle/BurstGradlePluginTest.kt index 74253aa..bb277a1 100644 --- a/burst-gradle-plugin/src/test/kotlin/app/cash/burst/gradle/BurstGradlePluginTest.kt +++ b/burst-gradle-plugin/src/test/kotlin/app/cash/burst/gradle/BurstGradlePluginTest.kt @@ -112,6 +112,26 @@ class BurstGradlePluginTest { assertThat(sampleSpecialization.skipped).isFalse() } + @Test + fun abstractClasses() { + val projectDir = File("src/test/projects/abstractClasses") + + val taskName = ":lib:test" + val result = createRunner(projectDir, "clean", taskName).build() + assertThat(result.task(taskName)!!.outcome).isIn(*SUCCESS_OUTCOMES) + + val testResults = projectDir.resolve("lib/build/test-results") + val testXmlFile = testResults.resolve("test/TEST-CoffeeTest.xml") + + val testSuite = readTestSuite(testXmlFile) + + assertThat(testSuite.testCases.map { it.name }).containsExactlyInAnyOrder( + "test_Milk", + "test_None", + "test_Oat", + ) + } + @Test fun classParameters() { val projectDir = File("src/test/projects/classParameters") diff --git a/burst-gradle-plugin/src/test/projects/abstractClasses/build.gradle.kts b/burst-gradle-plugin/src/test/projects/abstractClasses/build.gradle.kts new file mode 100644 index 0000000..66fc2bb --- /dev/null +++ b/burst-gradle-plugin/src/test/projects/abstractClasses/build.gradle.kts @@ -0,0 +1,37 @@ +import org.jetbrains.kotlin.gradle.dsl.JvmTarget +import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile + +buildscript { + repositories { + maven { + url = file("$rootDir/../../../../../build/testMaven").toURI() + } + mavenCentral() + google() + } + dependencies { + classpath("app.cash.burst:burst-gradle-plugin:${project.property("burstVersion")}") + classpath(libs.kotlin.gradlePlugin) + } +} + +allprojects { + repositories { + maven { + url = file("$rootDir/../../../../../build/testMaven").toURI() + } + mavenCentral() + google() + } + + tasks.withType(JavaCompile::class.java).configureEach { + sourceCompatibility = "1.8" + targetCompatibility = "1.8" + } + + tasks.withType(KotlinJvmCompile::class.java).configureEach { + compilerOptions { + jvmTarget.set(JvmTarget.JVM_1_8) + } + } +} diff --git a/burst-gradle-plugin/src/test/projects/abstractClasses/lib/build.gradle.kts b/burst-gradle-plugin/src/test/projects/abstractClasses/lib/build.gradle.kts new file mode 100644 index 0000000..36cb092 --- /dev/null +++ b/burst-gradle-plugin/src/test/projects/abstractClasses/lib/build.gradle.kts @@ -0,0 +1,8 @@ +plugins { + kotlin("jvm") + id("app.cash.burst") +} + +dependencies { + testImplementation(kotlin("test")) +} diff --git a/burst-gradle-plugin/src/test/projects/abstractClasses/lib/src/test/kotlin/CoffeeTest.kt b/burst-gradle-plugin/src/test/projects/abstractClasses/lib/src/test/kotlin/CoffeeTest.kt new file mode 100644 index 0000000..11bcd29 --- /dev/null +++ b/burst-gradle-plugin/src/test/projects/abstractClasses/lib/src/test/kotlin/CoffeeTest.kt @@ -0,0 +1,16 @@ +import app.cash.burst.Burst +import kotlin.test.Test + +@Burst +abstract class BaseCoffeeTest( + private val name: String, +) { + @Test + fun test(dairy: Dairy) { + println("running $name $dairy") + } +} + +class CoffeeTest : BaseCoffeeTest("decaf") + +enum class Dairy { None, Milk, Oat } diff --git a/burst-gradle-plugin/src/test/projects/abstractClasses/settings.gradle.kts b/burst-gradle-plugin/src/test/projects/abstractClasses/settings.gradle.kts new file mode 100644 index 0000000..78eeed4 --- /dev/null +++ b/burst-gradle-plugin/src/test/projects/abstractClasses/settings.gradle.kts @@ -0,0 +1,9 @@ +dependencyResolutionManagement { + versionCatalogs { + create("libs") { + from(files("../../../../../gradle/libs.versions.toml")) + } + } +} + +include(":lib") diff --git a/burst-kotlin-plugin/src/main/kotlin/app/cash/burst/kotlin/BurstIrGenerationExtension.kt b/burst-kotlin-plugin/src/main/kotlin/app/cash/burst/kotlin/BurstIrGenerationExtension.kt index 0c6afc2..5990ad4 100644 --- a/burst-kotlin-plugin/src/main/kotlin/app/cash/burst/kotlin/BurstIrGenerationExtension.kt +++ b/burst-kotlin-plugin/src/main/kotlin/app/cash/burst/kotlin/BurstIrGenerationExtension.kt @@ -19,6 +19,7 @@ import org.jetbrains.kotlin.backend.common.IrElementTransformerVoidWithContext import org.jetbrains.kotlin.backend.common.extensions.IrGenerationExtension import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext import org.jetbrains.kotlin.cli.common.messages.MessageCollector +import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.ir.IrStatement import org.jetbrains.kotlin.ir.declarations.IrClass import org.jetbrains.kotlin.ir.declarations.IrModuleFragment @@ -43,7 +44,7 @@ class BurstIrGenerationExtension( return classDeclaration } - if (classHasAtBurst) { + if (classHasAtBurst && classDeclaration.modality != Modality.ABSTRACT) { ClassSpecializer( pluginContext = pluginContext, originalParent = currentFile,