1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
package com.google.devtools.ksp.test
import org.gradle.testkit.runner.GradleRunner
import org.junit.Assert
import org.junit.Rule
import org.junit.Test
import java.io.File
class GetSealedSubclassesIncIT {
@Rule
@JvmField
val project: TemporaryTestProject = TemporaryTestProject("sealed-subclasses", "test-processor")
@Test
fun testGetSealedSubclassesInc() {
val gradleRunner = GradleRunner.create().withProjectDir(project.root)
val expected2 = listOf(
"w: [ksp] Processing Impl1.kt",
"w: [ksp] Impl1 : []",
"w: [ksp] Processing Impl2.kt",
"w: [ksp] Impl2 : []",
"w: [ksp] Processing Sealed.kt",
"w: [ksp] Sealed : [Impl1, Impl2]",
)
val expected3 = listOf(
"w: [ksp] Processing Impl1.kt",
"w: [ksp] Impl1 : []",
"w: [ksp] Processing Impl2.kt",
"w: [ksp] Impl2 : []",
"w: [ksp] Processing Impl3.kt",
"w: [ksp] Impl3 : []",
"w: [ksp] Processing Sealed.kt",
"w: [ksp] Sealed : [Impl1, Impl2, Impl3]",
)
gradleRunner.withArguments("assemble").build().let { result ->
val outputs = result.output.lines().filter { it.startsWith("w: [ksp]") }
Assert.assertEquals(expected2, outputs)
}
File(project.root, "workload/src/main/kotlin/com/example/Impl3.kt").appendText("package com.example\n\n")
File(project.root, "workload/src/main/kotlin/com/example/Impl3.kt").appendText("class Impl3 : Sealed()\n")
gradleRunner.withArguments("assemble").build().let { result ->
val outputs = result.output.lines().filter { it.startsWith("w: [ksp]") }
Assert.assertEquals(expected3, outputs)
}
File(project.root, "workload/src/main/kotlin/com/example/Impl3.kt").delete()
gradleRunner.withArguments("assemble").build().let { result ->
val outputs = result.output.lines().filter { it.startsWith("w: [ksp]") }
Assert.assertEquals(expected2, outputs)
}
}
}
|