forked from bazelbuild/rules_kotlin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
KotlinJvmTaskExecutorTest.kt
50 lines (42 loc) · 1.87 KB
/
KotlinJvmTaskExecutorTest.kt
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
package io.bazel.kotlin.builder.tasks.jvm
import io.bazel.kotlin.builder.KotlinJsTestBuilder
import io.bazel.kotlin.builder.KotlinJvmTestBuilder
import io.bazel.kotlin.model.JvmCompilationTask
import org.junit.Test
import kotlin.test.assertEquals
import kotlin.test.assertFalse
import kotlin.test.assertNotNull
import kotlin.test.assertTrue
class KotlinJvmTaskExecutorTest {
private val ctx = KotlinJvmTestBuilder()
@Test
fun testSimpleGeneratedNonJvmSourcesIgnored() {
ctx.resetForNext()
ctx.writeGeneratedSourceFile(
"AGenClass.kt",
arrayOf("package something.gen;", "class AGenClass{}"))
ctx.writeGeneratedSourceFile(
"AnotherGenClass.java",
arrayOf("package something.gen;", "class AnotherGenClass{}"))
ctx.writeGeneratedSourceFile(
"ignore-me.txt",
arrayOf("contents do not matter"))
ctx.writeSourceFile(
"ignore-me-regular-src.kt",
arrayOf("contents do not matter"))
ctx.writeSourceFile(
"ignore-me-another-regular-src.java",
arrayOf("contents do not matter"))
val compileTask = ctx.buildTask()
assertFalse(compileTask.hasInputs())
val expandedCompileTask = compileTask.expandWithGeneratedSources()
assertFalse(compileTask.hasInputs())
assertTrue(expandedCompileTask.hasInputs())
assertNotNull(expandedCompileTask.inputs.javaSourcesList.find {
path -> path.endsWith("a_test_1/generated_sources/AnotherGenClass.java") })
assertEquals(expandedCompileTask.inputs.javaSourcesCount, 1)
assertNotNull(expandedCompileTask.inputs.kotlinSourcesList.find {
path -> path.endsWith("a_test_1/generated_sources/AGenClass.kt") })
assertEquals(expandedCompileTask.inputs.kotlinSourcesCount, 1)
}
}