-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Filter non-kotlin code out of generated sources (#263)
* Filter non-kotlin code out of generated sources * Single-pass filter and vague android sdk * Add test for filtering generated source files
- Loading branch information
1 parent
9b1fb3d
commit 526efa9
Showing
8 changed files
with
105 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/test/kotlin/io/bazel/kotlin/builder/tasks/jvm/KotlinJvmTaskExecutorTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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) | ||
} | ||
} |