Tests: minor, do not use target backend in kapt tests

These tests now only make sense for JVM_IR. Incidentally this fixes the
JVM illegal access warnings from generateTests, because the test
framework no longer tries to instantiate these tests (which leads to
`doOpenInternalPackagesIfRequired`) to determine the target backend.

The change in JvmEnvironmentConfigurator is needed so that JVM tests
without target backend would default to JVM IR instead of the old
backend.

Also rename files to match the class names.
This commit is contained in:
Alexander Udalov
2024-02-14 11:15:30 +01:00
committed by Space Team
parent 879cdd5952
commit 88fbaed22e
7 changed files with 11 additions and 21 deletions
@@ -222,7 +222,7 @@ open class JvmEnvironmentConfigurator(testServices: TestServices) : EnvironmentC
}
configuration.addJvmClasspathRoots(getLibraryFilesExceptRealRuntime(testServices, configurationKind, module.directives))
val isIr = module.targetBackend?.isIR == true
val isIr = module.targetBackend?.isIR != false
configuration.put(JVMConfigurationKeys.IR, isIr)
configuration.putIfAbsent(CommonConfigurationKeys.EVALUATED_CONST_TRACKER, EvaluatedConstTracker.create())
@@ -13,17 +13,16 @@ import org.jetbrains.kotlin.kapt3.test.KaptRegularExtensionForTestConfigurator
import org.jetbrains.kotlin.kapt3.test.KaptTestDirectives.MAP_DIAGNOSTIC_LOCATIONS
import org.jetbrains.kotlin.kapt3.test.handlers.ClassFileToSourceKaptStubHandler
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
import org.jetbrains.kotlin.test.TargetBackend
import org.jetbrains.kotlin.test.backend.BlackBoxCodegenSuppressor
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
import org.jetbrains.kotlin.test.directives.ConfigurationDirectives.WITH_STDLIB
import org.jetbrains.kotlin.test.model.DependencyKind
import org.jetbrains.kotlin.test.model.FrontendKinds
import org.jetbrains.kotlin.test.runners.AbstractKotlinCompilerWithTargetBackendTest
import org.jetbrains.kotlin.test.runners.AbstractKotlinCompilerTest
import org.jetbrains.kotlin.test.services.configuration.CommonEnvironmentConfigurator
import org.jetbrains.kotlin.test.services.configuration.JvmEnvironmentConfigurator
open class AbstractIrClassFileToSourceStubConverterTest : AbstractKotlinCompilerWithTargetBackendTest(TargetBackend.JVM_IR) {
open class AbstractIrClassFileToSourceStubConverterTest : AbstractKotlinCompilerTest() {
init {
doOpenInternalPackagesIfRequired()
}
@@ -13,15 +13,14 @@ import org.jetbrains.kotlin.kapt3.test.KaptRegularExtensionForTestConfigurator
import org.jetbrains.kotlin.kapt3.test.KaptTestDirectives.MAP_DIAGNOSTIC_LOCATIONS
import org.jetbrains.kotlin.kapt3.test.handlers.KaptContextHandler
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
import org.jetbrains.kotlin.test.TargetBackend
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
import org.jetbrains.kotlin.test.model.DependencyKind
import org.jetbrains.kotlin.test.model.FrontendKinds
import org.jetbrains.kotlin.test.runners.AbstractKotlinCompilerWithTargetBackendTest
import org.jetbrains.kotlin.test.runners.AbstractKotlinCompilerTest
import org.jetbrains.kotlin.test.services.configuration.CommonEnvironmentConfigurator
import org.jetbrains.kotlin.test.services.configuration.JvmEnvironmentConfigurator
open class AbstractIrKotlinKaptContextTest : AbstractKotlinCompilerWithTargetBackendTest(TargetBackend.JVM_IR) {
abstract class AbstractIrKotlinKaptContextTest : AbstractKotlinCompilerTest() {
init {
doOpenInternalPackagesIfRequired()
}
@@ -7,7 +7,6 @@ package org.jetbrains.kotlin.kapt3.test.runners;
import com.intellij.testFramework.TestDataPath;
import org.jetbrains.kotlin.test.util.KtTestUtil;
import org.jetbrains.kotlin.test.TargetBackend;
import org.jetbrains.kotlin.test.TestMetadata;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
@@ -40,7 +39,7 @@ public class IrClassFileToSourceStubConverterTestGenerated extends AbstractIrCla
@Test
public void testAllFilesPresentInConverter() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/kapt3/kapt3-compiler/testData/converter"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/kapt3/kapt3-compiler/testData/converter"), Pattern.compile("^(.+)\\.kt$"), null, true);
}
@Test
@@ -7,7 +7,6 @@ package org.jetbrains.kotlin.kapt3.test.runners;
import com.intellij.testFramework.TestDataPath;
import org.jetbrains.kotlin.test.util.KtTestUtil;
import org.jetbrains.kotlin.test.TargetBackend;
import org.jetbrains.kotlin.test.TestMetadata;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
@@ -22,7 +21,7 @@ import java.util.regex.Pattern;
public class IrKotlinKaptContextTestGenerated extends AbstractIrKotlinKaptContextTest {
@Test
public void testAllFilesPresentInKotlinRunner() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/kapt3/kapt3-compiler/testData/kotlinRunner"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/kapt3/kapt3-compiler/testData/kotlinRunner"), Pattern.compile("^(.+)\\.kt$"), null, true);
}
@Test
@@ -6,23 +6,18 @@
package org.jetbrains.kotlin.kapt4
import org.jetbrains.kotlin.kapt3.base.util.doOpenInternalPackagesIfRequired
import org.jetbrains.kotlin.kapt3.test.*
import org.jetbrains.kotlin.kapt3.test.KaptEnvironmentConfigurator
import org.jetbrains.kotlin.kapt3.test.KaptTestDirectives.MAP_DIAGNOSTIC_LOCATIONS
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
import org.jetbrains.kotlin.test.TargetBackend
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
import org.jetbrains.kotlin.test.directives.ConfigurationDirectives.WITH_STDLIB
import org.jetbrains.kotlin.test.model.DependencyKind
import org.jetbrains.kotlin.test.model.FrontendKinds
import org.jetbrains.kotlin.test.runners.AbstractKotlinCompilerWithTargetBackendTest
import org.jetbrains.kotlin.test.runners.AbstractKotlinCompilerTest
import org.jetbrains.kotlin.test.services.configuration.CommonEnvironmentConfigurator
import org.jetbrains.kotlin.test.services.configuration.JvmEnvironmentConfigurator
open class AbstractKotlinKapt4ContextTest : AbstractKotlinKapt4ContextTestBase(TargetBackend.JVM_IR)
abstract class AbstractKotlinKapt4ContextTestBase(
targetBackend: TargetBackend
) : AbstractKotlinCompilerWithTargetBackendTest(targetBackend) {
open class AbstractKotlinKapt4ContextTest : AbstractKotlinCompilerTest() {
init {
doOpenInternalPackagesIfRequired()
}
@@ -7,7 +7,6 @@ package org.jetbrains.kotlin.kapt4;
import com.intellij.testFramework.TestDataPath;
import org.jetbrains.kotlin.test.util.KtTestUtil;
import org.jetbrains.kotlin.test.TargetBackend;
import org.jetbrains.kotlin.test.TestMetadata;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
@@ -40,7 +39,7 @@ public class KotlinKapt4ContextTestGenerated extends AbstractKotlinKapt4ContextT
@Test
public void testAllFilesPresentInConverter() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter"), Pattern.compile("^(.+)\\.kt$"), null, true);
}
@Test