Use compiler arguments for Java against Kotlin highlighting tests

This is needed for the next commit to check jvm-default options

 #KT-41130 In Progress
This commit is contained in:
Mikhail Zarechenskiy
2021-03-18 13:08:10 +03:00
committed by TeamCityServer
parent 111e54c8c1
commit 641f08d561
4 changed files with 20 additions and 5 deletions
@@ -1,3 +1,3 @@
// LANGUAGE_LEVEL 1.8
// WITH_RUNTIME
// KOTLINC_EXTRA_OPTS -jvm-target, 1.8, -Xjvm-default=enable
// COMPILER_ARGUMENTS: -jvm-target, 1.8, -Xjvm-default=enable
@@ -1,3 +1,3 @@
// LANGUAGE_LEVEL 1.8
// WITH_RUNTIME
// KOTLINC_EXTRA_OPTS -jvm-target, 1.8
// COMPILER_ARGUMENTS: -jvm-target, 1.8
@@ -9,6 +9,7 @@ import com.intellij.openapi.roots.ModuleRootModificationUtil
import com.intellij.openapi.util.io.FileUtil
import com.intellij.openapi.util.io.FileUtilRt
import org.jetbrains.kotlin.idea.test.AstAccessControl
import org.jetbrains.kotlin.idea.test.CompilerTestDirectives
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase
import org.jetbrains.kotlin.test.InTextDirectivesUtils
import org.jetbrains.kotlin.test.KotlinTestUtils
@@ -23,12 +24,14 @@ abstract class AbstractJavaAgainstKotlinBinariesCheckerTest : AbstractJavaAgains
return
}
val languageLevelOption = InTextDirectivesUtils.findListWithPrefixes(configFileText ?: "", "// KOTLINC_EXTRA_OPTS")
val compilerArguments = InTextDirectivesUtils.findListWithPrefixes(
configFileText ?: "", CompilerTestDirectives.COMPILER_ARGUMENTS_DIRECTIVE
)
val libraryJar = MockLibraryUtilExt.compileJvmLibraryToJar(
PluginTestCaseBase.getTestDataPathBase() + "/kotlinAndJavaChecker/javaAgainstKotlin/" + getTestName(false) + ".kt",
"libFor$testName",
extraOptions = languageLevelOption
extraOptions = compilerArguments
)
val jarUrl = "jar://" + FileUtilRt.toSystemIndependentName(libraryJar.absolutePath) + "!/"
ModuleRootModificationUtil.addModuleLibrary(module, jarUrl)
@@ -6,10 +6,22 @@
package org.jetbrains.kotlin.checkers
import org.jetbrains.kotlin.idea.perf.forceUsingOldLightClassesForTest
import org.jetbrains.kotlin.idea.test.withCustomCompilerOptions
abstract class AbstractJavaAgainstKotlinSourceCheckerTest : AbstractJavaAgainstKotlinCheckerTest() {
fun doTest(path: String) {
doTest(true, true, path.replace(".kt", ".java"), path)
fun doTest() {
doTest(true, true, path.replace(".kt", ".java"), path)
}
val configFile = configFileText
if (configFile != null) {
withCustomCompilerOptions(configFile, project, module) {
doTest()
}
} else {
doTest()
}
}
}