Skip to content

Commit

Permalink
Switch to kotlin 2.x supported compile testing lib
Browse files Browse the repository at this point in the history
* fix issues with test configuration
* Add missing expected class for annotation codegen
  • Loading branch information
geoff-powell committed Dec 9, 2024
1 parent 5a1ef95 commit 70b8a1d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ guava = { module = "com.google.guava:guava", version = "33.3.1-jre" }

kotlin-bom = { module = "org.jetbrains.kotlin:kotlin-bom", version.ref = "kotlin" }
kotlinpoet-ksp = { module = "com.squareup:kotlinpoet-ksp", version = "2.0.0" }
kotlin-compile-testing-ksp = { module = "com.github.tschuchortdev:kotlin-compile-testing-ksp", version = "1.6.0" }
kotlin-compile-testing-ksp = { module = "dev.zacsweers.kctfork:ksp", version = "0.7.0" }
kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "coroutines" }
kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ package app.cash.paparazzi.preview.processor
import com.google.common.truth.Truth.assertThat
import com.tschuchort.compiletesting.KotlinCompilation
import com.tschuchort.compiletesting.SourceFile
import com.tschuchort.compiletesting.kspAllWarningsAsErrors
import com.tschuchort.compiletesting.kspArgs
import com.tschuchort.compiletesting.configureKsp
import com.tschuchort.compiletesting.kspIncremental
import com.tschuchort.compiletesting.kspProcessorOptions
import com.tschuchort.compiletesting.symbolProcessorProviders
import com.tschuchort.compiletesting.useKsp2
import org.jetbrains.kotlin.compiler.plugin.ExperimentalCompilerApi
import org.junit.Rule
import org.junit.Test
Expand Down Expand Up @@ -201,13 +202,17 @@ class PreviewProcessorProviderTest {
.apply {
workingDir = File(temporaryFolder.root, "debug")
inheritClassPath = true
sources = sourceFiles.asList() + COMPOSE_SOURCES + PAPARAZZI_ANNOTATION_SOURCE
verbose = false

kspAllWarningsAsErrors = true
kspArgs["app.cash.paparazzi.preview.namespace"] = TEST_NAMESPACE
kspIncremental = true
symbolProcessorProviders = listOf(PreviewProcessorProvider())
sources = sourceFiles.asList() + COMPOSE_SOURCES + PAPARAZZI_ANNOTATION_SOURCE + PAPARAZZI_PREVIEW_DATA_SOURCE
verbose = true
// Needed for @PreviewParameterProvider annotation that uses `@JvmDefaultWithCompatibility`
kotlincArguments = listOf("-Xjvm-default=all")

configureKsp(useKsp2 = true) {
allWarningsAsErrors = true
kspProcessorOptions = mutableMapOf("app.cash.paparazzi.preview.namespace" to TEST_NAMESPACE)
kspIncremental = true
symbolProcessorProviders += PreviewProcessorProvider()
}
}

private companion object {
Expand Down Expand Up @@ -289,5 +294,19 @@ class PreviewProcessorProviderTest {
annotation class Paparazzi
""".trimIndent()
)

private val PAPARAZZI_PREVIEW_DATA_SOURCE = SourceFile.kotlin(
"PaparazziPreviewData.kt",
"""
package app.cash.paparazzi.annotations
import androidx.compose.runtime.Composable
data class PaparazziPreviewData(
val snapshotName: String,
val composable: @Composable () -> Unit
)
""".trimIndent()
)
}
}

0 comments on commit 70b8a1d

Please sign in to comment.