Skip to content

Latest commit

 

History

History
72 lines (54 loc) · 2.49 KB

File metadata and controls

72 lines (54 loc) · 2.49 KB

Slack

Maven Central Maven Snapshots Gradleup Snapshots

Kctf

Kctf is a Gradle Plugin for the Kotlin Compiler Test Framework (KCTF).

It factors some of the Gradle configuration and boilerplate needed to setup tests for your Kotlin compiler plugin.

Get started

Configure your build

plugins {
  id("org.jetbrains.kotlin.jvm")
  id("com.gradleup.kctf").version("2.3.10-0.0.2")
}

dependencies {
  // Add the kctf runtime, it pulls the kotlin test framework transitively
  testImplementation("org.gradleup.kctf:kctf-runtime:2.3.10-0.0.2")
}

Write your abstract tests in src/test/kotlin/com/example:

@TestMetadata("compiler-tests/src/test/data/box")
open class AbstractBoxTest : AbstractFirLightTreeBlackBoxCodegenTest() {
  override fun configure(builder: TestConfigurationBuilder) {
    super.configure(builder)

    with(builder) {
      configurePlugin()

      defaultDirectives {
        +FULL_JDK
        +WITH_STDLIB
        +IGNORE_DEXING
      }
    }
  }
}

Call the kctfGenerateSources task:

./gradlew kctfGenerateSources

Kctf generates your test in src/test/java:

/** This class is generated by {@link kctf.MainKt}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("compiler-tests/src/test/data/diagnostic")
@TestDataPath("$PROJECT_ROOT")
public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
  // ...
}