From dbdc4d9ee0f7b616d737e225b5a658058a382c67 Mon Sep 17 00:00:00 2001 From: Mikhael Bogdanov Date: Thu, 27 Feb 2020 14:34:10 +0100 Subject: [PATCH] Move 'extractConfigurationKind' to base class, use it in KotlinMultiFileTestWithJava --- .../checkers/KotlinMultiFileTestWithJava.kt | 2 +- .../kotlin/codegen/CodegenTestCase.java | 18 ------------------ .../jetbrains/kotlin/test/KotlinBaseTest.kt | 15 +++++++++++++++ 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/checkers/KotlinMultiFileTestWithJava.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/checkers/KotlinMultiFileTestWithJava.kt index fdbeb97570d..e0117dd4ba8 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/checkers/KotlinMultiFileTestWithJava.kt +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/checkers/KotlinMultiFileTestWithJava.kt @@ -45,7 +45,7 @@ abstract class KotlinMultiFileTestWithJava ): KotlinCoreEnvironment { val configuration = KotlinTestUtils.newConfiguration( - getConfigurationKind(), + extractConfigurationKind(files), getTestJdkKind(files), getClasspath(file), if (isJavaSourceRootNeeded()) listOf(javaFilesDir) else emptyList() diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/CodegenTestCase.java b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/CodegenTestCase.java index dcc12bb9f22..49f7d506497 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/CodegenTestCase.java +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/CodegenTestCase.java @@ -727,24 +727,6 @@ public abstract class CodegenTestCase extends KotlinBaseTest files) { - boolean addRuntime = false; - boolean addReflect = false; - for (TestFile file : files) { - if (InTextDirectivesUtils.isDirectiveDefined(file.content, "WITH_RUNTIME")) { - addRuntime = true; - } - if (InTextDirectivesUtils.isDirectiveDefined(file.content, "WITH_REFLECT")) { - addReflect = true; - } - } - - return addReflect ? ConfigurationKind.ALL : - addRuntime ? ConfigurationKind.NO_KOTLIN_REFLECT : - ConfigurationKind.JDK_ONLY; - } - @NotNull protected static List extractJavacOptions(@NotNull List files) { List javacOptions = new ArrayList<>(0); diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinBaseTest.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinBaseTest.kt index 09d86f48a92..af3cedf6075 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinBaseTest.kt +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinBaseTest.kt @@ -55,6 +55,21 @@ abstract class KotlinBaseTest : KtUsefulTestCase() return TestJdkKind.MOCK_JDK } + protected open fun extractConfigurationKind(files: List): ConfigurationKind { + var addRuntime = false + var addReflect = false + for (file in files) { + if (InTextDirectivesUtils.isDirectiveDefined(file.content, "WITH_RUNTIME")) { + addRuntime = true + } + if (InTextDirectivesUtils.isDirectiveDefined(file.content, "WITH_REFLECT")) { + addReflect = true + } + } + return if (addReflect) ConfigurationKind.ALL else if (addRuntime) ConfigurationKind.NO_KOTLIN_REFLECT else ConfigurationKind.JDK_ONLY + } + + open class TestFile(@JvmField val name: String, @JvmField val content: String) : Comparable { override operator fun compareTo(other: TestFile): Int { return name.compareTo(other.name)