@@ -8,14 +8,12 @@ import org.junit.Rule
88import org.junit.Test
99import java.io.File
1010
11- class IncrementalEmptyCPIT () {
11+ class IncrementalEmptyCPIT {
1212 @Rule
1313 @JvmField
1414 val project: TemporaryTestProject =
1515 TemporaryTestProject (" incremental-classpath2" , " incremental-classpath" )
1616
17- private val emptyMessage = setOf (" w: [ksp] processing done" )
18-
1917 private val prop2Dirty = listOf (
2018 " l1/src/main/kotlin/p1/TopProp1.kt" to setOf (
2119 " w: [ksp] p1/K1.kt" ,
@@ -25,29 +23,55 @@ class IncrementalEmptyCPIT() {
2523 )
2624
2725 @Test
28- fun testCPChangesForProperties () {
26+ fun testTrivialChanges () {
27+ // Trivial (non-AST) changes should not result in re-processing.
2928 val gradleRunner = GradleRunner .create().withProjectDir(project.root)
3029
3130 gradleRunner.withArguments(" clean" , " assemble" ).build().let { result ->
3231 Assert .assertEquals(TaskOutcome .SUCCESS , result.task(" :workload:assemble" )?.outcome)
3332 }
3433
35- // Dummy changes
3634 prop2Dirty.forEach { (src, _) ->
3735 File (project.root, src).appendText(" \n\n " )
3836 gradleRunner.withArguments(" assemble" ).build().let { result ->
39- // Trivial changes should not result in re-processing.
4037 Assert .assertEquals(TaskOutcome .UP_TO_DATE , result.task(" :workload:kspKotlin" )?.outcome)
4138 }
4239 }
40+ }
4341
44- // Value changes. It is not really used but should still trigger reprocessing of aggregating outputs.
45- prop2Dirty.forEach { (src, expectedDirties) ->
42+ @Test
43+ fun testValueChanges () {
44+ // Value changes should not result in re-processing, since values are not part of the AST.
45+ val gradleRunner = GradleRunner .create().withProjectDir(project.root)
46+
47+ gradleRunner.withArguments(" clean" , " assemble" ).build().let { result ->
48+ Assert .assertEquals(TaskOutcome .SUCCESS , result.task(" :workload:assemble" )?.outcome)
49+ }
50+
51+ prop2Dirty.forEach { (src, _) ->
4652 File (project.root, src).writeText(" package p1\n\n val MyTopProp1: Int = 1" )
4753 gradleRunner.withArguments(" assemble" ).build().let { result ->
48- // Value changes will result in re-processing of aggregating outputs.
4954 Assert .assertEquals(TaskOutcome .UP_TO_DATE , result.task(" :workload:kspKotlin" )?.outcome)
5055 }
5156 }
5257 }
58+
59+ @Test
60+ fun testTypeChanges () {
61+ // Type changes should result in re-processing of aggregating outputs, since such changes apply to the AST.
62+ val gradleRunner = GradleRunner .create().withProjectDir(project.root)
63+
64+ gradleRunner.withArguments(" clean" , " assemble" ).build().let { result ->
65+ Assert .assertEquals(TaskOutcome .SUCCESS , result.task(" :workload:assemble" )?.outcome)
66+ }
67+
68+ prop2Dirty.forEach { (src, expectedDirties) ->
69+ File (project.root, src).writeText(" package p1\n\n val MyTopProp1: Boolean = true" )
70+ gradleRunner.withArguments(" assemble" ).build().let { result ->
71+ Assert .assertEquals(TaskOutcome .SUCCESS , result.task(" :workload:kspKotlin" )?.outcome)
72+ val dirties = result.output.lines().filter { it.startsWith(" w: [ksp]" ) }.toSet()
73+ Assert .assertEquals(expectedDirties, dirties)
74+ }
75+ }
76+ }
5377}
0 commit comments