Move 'extractConfigurationKind' to base class, use it in KotlinMultiFileTestWithJava
This commit is contained in:
+1
-1
@@ -45,7 +45,7 @@ abstract class KotlinMultiFileTestWithJava<M : KotlinBaseTest.TestModule, F : Ko
|
||||
files: List<F>
|
||||
): KotlinCoreEnvironment {
|
||||
val configuration = KotlinTestUtils.newConfiguration(
|
||||
getConfigurationKind(),
|
||||
extractConfigurationKind(files),
|
||||
getTestJdkKind(files),
|
||||
getClasspath(file),
|
||||
if (isJavaSourceRootNeeded()) listOf(javaFilesDir) else emptyList()
|
||||
|
||||
@@ -727,24 +727,6 @@ public abstract class CodegenTestCase extends KotlinBaseTest<KotlinBaseTest.Test
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected ConfigurationKind extractConfigurationKind(@NotNull List<TestFile> 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<String> extractJavacOptions(@NotNull List<TestFile> files) {
|
||||
List<String> javacOptions = new ArrayList<>(0);
|
||||
|
||||
@@ -55,6 +55,21 @@ abstract class KotlinBaseTest<F : KotlinBaseTest.TestFile> : KtUsefulTestCase()
|
||||
return TestJdkKind.MOCK_JDK
|
||||
}
|
||||
|
||||
protected open fun extractConfigurationKind(files: List<F>): 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<TestFile> {
|
||||
override operator fun compareTo(other: TestFile): Int {
|
||||
return name.compareTo(other.name)
|
||||
|
||||
Reference in New Issue
Block a user