Skip to content

Commit

Permalink
Ignore abstract class constructors (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeWharton authored Oct 28, 2024
1 parent 6205e61 commit b591220
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
plugins {
kotlin("jvm")
id("app.cash.burst")
}

dependencies {
testImplementation(kotlin("test"))
}
Original file line number Diff line number Diff line change
@@ -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 }
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
dependencyResolutionManagement {
versionCatalogs {
create("libs") {
from(files("../../../../../gradle/libs.versions.toml"))
}
}
}

include(":lib")
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -43,7 +44,7 @@ class BurstIrGenerationExtension(
return classDeclaration
}

if (classHasAtBurst) {
if (classHasAtBurst && classDeclaration.modality != Modality.ABSTRACT) {
ClassSpecializer(
pluginContext = pluginContext,
burstApis = burstApis,
Expand Down

0 comments on commit b591220

Please sign in to comment.