Refactor old test utility in LoadDescriptorUtil

Also make USE_TYPE_TABLE a flag in CompilerConfiguration instead of an extra
boolean parameter in numerous methods
This commit is contained in:
Alexander Udalov
2016-05-20 11:45:11 +03:00
parent 76d78ba666
commit 1492c71e88
7 changed files with 52 additions and 90 deletions
@@ -22,7 +22,6 @@ import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler
import org.jetbrains.kotlin.jvm.compiler.LoadDescriptorUtil
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
import org.jetbrains.kotlin.load.java.JvmBytecodeBinaryVersion
import org.jetbrains.kotlin.test.ConfigurationKind
import org.jetbrains.kotlin.test.KotlinTestUtils
import org.jetbrains.kotlin.test.testFramework.KtUsefulTestCase
import org.jetbrains.org.objectweb.asm.*
@@ -37,9 +36,9 @@ class WrongBytecodeVersionTest : KtUsefulTestCase() {
val usageSource = File(directory, "B.kt")
val tmpdir = KotlinTestUtils.tmpDir(javaClass.simpleName)
LoadDescriptorUtil.compileKotlinToDirAndGetAnalysisResult(
listOf(librarySource), tmpdir, testRootDisposable, ConfigurationKind.ALL, false
)
val environment = KotlinTestUtils.createEnvironmentWithMockJdkAndIdeaAnnotations(testRootDisposable)
LoadDescriptorUtil.compileKotlinToDirAndGetModule(listOf(librarySource), tmpdir, environment)
for (classFile in File(tmpdir, "library").listFiles { file -> file.extension == JavaClassFileType.INSTANCE.defaultExtension }) {
changeVersionInBytecode(classFile)
@@ -38,7 +38,10 @@ import java.net.URLClassLoader
abstract class AbstractLocalClassProtoTest : TestCaseWithTmpdir() {
protected fun doTest(filename: String) {
val source = File(filename)
LoadDescriptorUtil.compileKotlinToDirAndGetAnalysisResult(listOf(source), tmpdir, testRootDisposable, ConfigurationKind.ALL, false)
KotlinTestUtils.createEnvironmentWithMockJdkAndIdeaAnnotations(testRootDisposable).let { environment ->
LoadDescriptorUtil.compileKotlinToDirAndGetModule(listOf(source), tmpdir, environment)
}
val classNameSuffix = InTextDirectivesUtils.findStringWithPrefixes(source.readText(), "// CLASS_NAME_SUFFIX: ")
?: error("CLASS_NAME_SUFFIX directive not found in test data")