https://github.com/karmakrafts/iridium
Testing framework for Kotlin compiler plugins using a custom compiler driver.
https://github.com/karmakrafts/iridium
api junit junit-jupiter junit5 kotlin kotlin-compiler kotlin-compiler-plugin kotlin-framework kotlin-jvm test test-api testing testing-library unit-testing
Last synced: 3 months ago
JSON representation
Testing framework for Kotlin compiler plugins using a custom compiler driver.
- Host: GitHub
- URL: https://github.com/karmakrafts/iridium
- Owner: karmakrafts
- License: apache-2.0
- Created: 2025-05-23T23:03:58.000Z (5 months ago)
- Default Branch: master
- Last Pushed: 2025-07-04T20:41:38.000Z (4 months ago)
- Last Synced: 2025-07-04T21:32:30.952Z (4 months ago)
- Topics: api, junit, junit-jupiter, junit5, kotlin, kotlin-compiler, kotlin-compiler-plugin, kotlin-framework, kotlin-jvm, test, test-api, testing, testing-library, unit-testing
- Language: Kotlin
- Homepage: https://git.karmakrafts.dev/kk/iridium
- Size: 215 KB
- Stars: 5
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Iridium
[](https://git.karmakrafts.dev/kk/iridium/-/pipelines)
[](https://git.karmakrafts.dev/kk/iridium/-/packages)
[](https://git.karmakrafts.dev/kk/iridium/-/packages)
Iridium is an in-process compiler testing framework for Kotlin using the Kotlin embeddable compiler and Kotlin Test.
It allows testing compiler behaviour and FIR/IR compiler plugins.
It currently has the following main features:
* Support for Kotlin/JVM, Kotlin/JS and Kotlin/Native
* Fully integrated test compiler pipeline using the new `Fir2IrPipeline` with DSL
* Assertion matchers for compiler reports with DSL
* Assertion matchers for Kotlin IR with DSL
* Assertion matchers for Kotlin FIR with DSL
* Colored Kotlin IR highlighting in assertion errors and available as test API
* Automatic scope tracking to add more context to assertion errors
* Add dependencies by mentioning a library type once
### How to use it
First, add the official Maven Central repository to your `settings.gradle.kts`:
```kotlin
pluginManagement {
repositories {
maven("https://central.sonatype.com/repository/maven-snapshots")
mavenCentral()
}
}
dependencyResolutionManagement {
repositories {
maven("https://central.sonatype.com/repository/maven-snapshots")
mavenCentral()
}
}
```
Then add a dependency on the library in your root buildscript:
```kotlin
dependencies {
testImplementation("dev.karmakrafts.iridium:iridium:")
}
```
### Test DSL for reports, FIR and IR
```kotlin
@Test
fun `My compiler IR test`() = runCompilerTest {
pipeline {
defaultPipelineSpec()
}
source("""
@Suppress("UNCHECKED_CAST")
fun test(value: T): T = value
fun main(args: Array) {
println("Hello, World")
}
""".trimIndent()) // *1
compiler shouldNotReport { error() }
result irMatches {
getChild { it.name.asString() == "main" }.matches("main") {
returns { unit() }
hasValueParameter("args") { type(types.stringType.array()) }
}
getChild { it.name.asString() == "test" }.matches("test") {
hasAnnotation(type("kotlin/Suppress"))
hasTypeParameter("T")
returns { typeParameter("T") }
hasValueParameter("value") { typeParameter("T") }
}
containsChild { it.target.name.asString() == "println" }
}
}
```
**\*1: The source code assigned in the multiline string will have highlighting in supported IDEs.**