Skip to content

Commit fe87dec

Browse files
ZacSweerstschuchortdev
authored andcommitted
Add options for enabling incremental and incremental logging
1 parent 2b36f91 commit fe87dec

File tree

2 files changed

+39
-0
lines changed
  • ksp/src
    • main/kotlin/com/tschuchort/compiletesting
    • test/kotlin/com/tschuchort/compiletesting

2 files changed

+39
-0
lines changed

ksp/src/main/kotlin/com/tschuchort/compiletesting/Ksp.kt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,26 @@ var KotlinCompilation.kspArgs: MutableMap<String, String>
4444
registrar.options = value
4545
}
4646

47+
/**
48+
* Controls for enabling incremental processing in KSP.
49+
*/
50+
var KotlinCompilation.kspIncremental: Boolean
51+
get() = getKspRegistrar().incremental
52+
set(value) {
53+
val registrar = getKspRegistrar()
54+
registrar.incremental = value
55+
}
56+
57+
/**
58+
* Controls for enabling incremental processing logs in KSP.
59+
*/
60+
var KotlinCompilation.kspIncrementalLog: Boolean
61+
get() = getKspRegistrar().incrementalLog
62+
set(value) {
63+
val registrar = getKspRegistrar()
64+
registrar.incrementalLog = value
65+
}
66+
4767
private val KotlinCompilation.kspJavaSourceDir: File
4868
get() = kspSourcesDir.resolve("java")
4969

@@ -100,6 +120,9 @@ private class KspCompileTestingComponentRegistrar(
100120

101121
var options: MutableMap<String, String> = mutableMapOf()
102122

123+
var incremental: Boolean = false
124+
var incrementalLog: Boolean = false
125+
103126
override fun registerProjectComponents(project: MockProject, configuration: CompilerConfiguration) {
104127
if (processors.isEmpty()) {
105128
return
@@ -109,6 +132,9 @@ private class KspCompileTestingComponentRegistrar(
109132

110133
this.processingOptions.putAll(compilation.kspArgs)
111134

135+
this.incremental = this@KspCompileTestingComponentRegistrar.incremental
136+
this.incrementalLog = this@KspCompileTestingComponentRegistrar.incrementalLog
137+
112138
this.cachesDir = compilation.kspCachesDir.also {
113139
it.deleteRecursively()
114140
it.mkdirs()

ksp/src/test/kotlin/com/tschuchort/compiletesting/KspTest.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,19 @@ class KspTest {
130130
}
131131
}
132132

133+
@Test
134+
fun incremental() {
135+
KotlinCompilation().apply {
136+
// Disabled by default
137+
assertThat(kspIncremental).isFalse()
138+
assertThat(kspIncrementalLog).isFalse()
139+
kspIncremental = true
140+
assertThat(kspIncremental).isTrue()
141+
kspIncrementalLog = true
142+
assertThat(kspIncrementalLog).isTrue()
143+
}
144+
}
145+
133146
@Test
134147
fun outputDirectoryContents() {
135148
val compilation = KotlinCompilation().apply {

0 commit comments

Comments
 (0)