Kapt, minor: Move test logic for KaptFlags to the new base class
This commit is contained in:
+1
-22
@@ -60,7 +60,7 @@ import java.io.PrintStream
|
||||
import java.util.*
|
||||
import com.sun.tools.javac.util.List as JavacList
|
||||
|
||||
abstract class AbstractKotlinKapt3Test : CodegenTestCase() {
|
||||
abstract class AbstractKotlinKapt3Test : KotlinKapt3TestBase() {
|
||||
companion object {
|
||||
const val FILE_SEPARATOR = "\n\n////////////////////\n\n"
|
||||
val ERR_BYTE_STREAM = ByteArrayOutputStream()
|
||||
@@ -69,13 +69,6 @@ abstract class AbstractKotlinKapt3Test : CodegenTestCase() {
|
||||
val messageCollector = PrintingMessageCollector(ERR_PRINT_STREAM, MessageRenderer.PLAIN_FULL_PATHS, false)
|
||||
}
|
||||
|
||||
val kaptFlags = mutableListOf<KaptFlag>()
|
||||
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
kaptFlags.clear()
|
||||
}
|
||||
|
||||
override fun tearDown() {
|
||||
ERR_BYTE_STREAM.reset()
|
||||
super.tearDown()
|
||||
@@ -205,8 +198,6 @@ abstract class AbstractKotlinKapt3Test : CodegenTestCase() {
|
||||
}
|
||||
}
|
||||
|
||||
protected fun File.isOptionSet(name: String) = this.useLines { lines -> lines.any { it.trim() == "// $name" } }
|
||||
|
||||
protected fun File.getRawOptionValues(name: String) = this.useLines { lines ->
|
||||
lines.filter { it.startsWith("// $name") }.toList()
|
||||
}
|
||||
@@ -248,18 +239,6 @@ open class AbstractClassFileToSourceStubConverterTest : AbstractKotlinKapt3Test(
|
||||
fun testSuppressWarning() {}
|
||||
|
||||
override fun doTest(filePath: String) {
|
||||
val wholeFile = File(filePath)
|
||||
|
||||
kaptFlags.add(KaptFlag.MAP_DIAGNOSTIC_LOCATIONS)
|
||||
|
||||
if (wholeFile.isOptionSet("CORRECT_ERROR_TYPES")) {
|
||||
kaptFlags.add(KaptFlag.CORRECT_ERROR_TYPES)
|
||||
}
|
||||
|
||||
if (wholeFile.isOptionSet("STRICT_MODE")) {
|
||||
kaptFlags.add(KaptFlag.STRICT)
|
||||
}
|
||||
|
||||
super.doTest(filePath)
|
||||
doTestWithJdk9(AbstractClassFileToSourceStubConverterTest::class.java, filePath)
|
||||
doTestWithJdk11(AbstractClassFileToSourceStubConverterTest::class.java, filePath)
|
||||
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.kapt3.test
|
||||
|
||||
import org.jetbrains.kotlin.base.kapt3.KaptFlag
|
||||
import org.jetbrains.kotlin.codegen.CodegenTestCase
|
||||
import java.io.File
|
||||
|
||||
abstract class KotlinKapt3TestBase : CodegenTestCase() {
|
||||
val kaptFlags = mutableListOf<KaptFlag>()
|
||||
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
kaptFlags.clear()
|
||||
}
|
||||
|
||||
protected fun File.isOptionSet(name: String) = this.useLines { lines -> lines.any { it.trim() == "// $name" } }
|
||||
|
||||
override fun doTest(filePath: String) {
|
||||
val wholeFile = File(filePath)
|
||||
|
||||
kaptFlags.add(KaptFlag.MAP_DIAGNOSTIC_LOCATIONS)
|
||||
|
||||
fun handleFlag(flag: KaptFlag) {
|
||||
if (wholeFile.isOptionSet(flag.name)) {
|
||||
kaptFlags.add(flag)
|
||||
}
|
||||
}
|
||||
|
||||
handleFlag(KaptFlag.CORRECT_ERROR_TYPES)
|
||||
handleFlag(KaptFlag.STRICT)
|
||||
handleFlag(KaptFlag.DUMP_DEFAULT_PARAMETER_VALUES)
|
||||
|
||||
super.doTest(filePath)
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// STRICT_MODE
|
||||
// STRICT
|
||||
|
||||
class Foo(private val string: String) {
|
||||
val bar = Bar("bar")
|
||||
|
||||
Reference in New Issue
Block a user