Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore abstract class constructors #44

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
originalParent = currentFile,
Expand Down