From 88fbaed22ea6def40dc76c55a26527f8f0c0d4d8 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Wed, 14 Feb 2024 11:15:30 +0100 Subject: [PATCH] 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. --- .../configuration/JvmEnvironmentConfigurator.kt | 2 +- .../AbstractIrClassFileToSourceStubConverterTest.kt | 5 ++--- ...textTest.kt => AbstractIrKotlinKaptContextTest.kt} | 5 ++--- ...IrClassFileToSourceStubConverterTestGenerated.java | 3 +-- .../runners/IrKotlinKaptContextTestGenerated.java | 3 +-- ...tTestBase.kt => AbstractKotlinKapt4ContextTest.kt} | 11 +++-------- .../kotlin/kapt4/KotlinKapt4ContextTestGenerated.java | 3 +-- 7 files changed, 11 insertions(+), 21 deletions(-) rename plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/runners/{AbstractKotlinKaptContextTest.kt => AbstractIrKotlinKaptContextTest.kt} (88%) rename plugins/kapt4/test/org/jetbrains/kotlin/kapt4/{AbstractKotlinKapt4ContextTestBase.kt => AbstractKotlinKapt4ContextTest.kt} (80%) diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/configuration/JvmEnvironmentConfigurator.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/configuration/JvmEnvironmentConfigurator.kt index dff352de1d9..1c7532ef405 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/configuration/JvmEnvironmentConfigurator.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/configuration/JvmEnvironmentConfigurator.kt @@ -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()) diff --git a/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/runners/AbstractIrClassFileToSourceStubConverterTest.kt b/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/runners/AbstractIrClassFileToSourceStubConverterTest.kt index 08947ed3ff2..956e23ea086 100644 --- a/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/runners/AbstractIrClassFileToSourceStubConverterTest.kt +++ b/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/runners/AbstractIrClassFileToSourceStubConverterTest.kt @@ -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() } diff --git a/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/runners/AbstractKotlinKaptContextTest.kt b/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/runners/AbstractIrKotlinKaptContextTest.kt similarity index 88% rename from plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/runners/AbstractKotlinKaptContextTest.kt rename to plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/runners/AbstractIrKotlinKaptContextTest.kt index 69ff4685bf9..077c574ab81 100644 --- a/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/runners/AbstractKotlinKaptContextTest.kt +++ b/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/runners/AbstractIrKotlinKaptContextTest.kt @@ -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() } diff --git a/plugins/kapt3/kapt3-compiler/tests-gen/org/jetbrains/kotlin/kapt3/test/runners/IrClassFileToSourceStubConverterTestGenerated.java b/plugins/kapt3/kapt3-compiler/tests-gen/org/jetbrains/kotlin/kapt3/test/runners/IrClassFileToSourceStubConverterTestGenerated.java index d45def04495..18ebcb219e2 100644 --- a/plugins/kapt3/kapt3-compiler/tests-gen/org/jetbrains/kotlin/kapt3/test/runners/IrClassFileToSourceStubConverterTestGenerated.java +++ b/plugins/kapt3/kapt3-compiler/tests-gen/org/jetbrains/kotlin/kapt3/test/runners/IrClassFileToSourceStubConverterTestGenerated.java @@ -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 diff --git a/plugins/kapt3/kapt3-compiler/tests-gen/org/jetbrains/kotlin/kapt3/test/runners/IrKotlinKaptContextTestGenerated.java b/plugins/kapt3/kapt3-compiler/tests-gen/org/jetbrains/kotlin/kapt3/test/runners/IrKotlinKaptContextTestGenerated.java index e0be84c38e1..691111da08d 100644 --- a/plugins/kapt3/kapt3-compiler/tests-gen/org/jetbrains/kotlin/kapt3/test/runners/IrKotlinKaptContextTestGenerated.java +++ b/plugins/kapt3/kapt3-compiler/tests-gen/org/jetbrains/kotlin/kapt3/test/runners/IrKotlinKaptContextTestGenerated.java @@ -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 diff --git a/plugins/kapt4/test/org/jetbrains/kotlin/kapt4/AbstractKotlinKapt4ContextTestBase.kt b/plugins/kapt4/test/org/jetbrains/kotlin/kapt4/AbstractKotlinKapt4ContextTest.kt similarity index 80% rename from plugins/kapt4/test/org/jetbrains/kotlin/kapt4/AbstractKotlinKapt4ContextTestBase.kt rename to plugins/kapt4/test/org/jetbrains/kotlin/kapt4/AbstractKotlinKapt4ContextTest.kt index 418f1bf72c6..a04e0e0bf9b 100644 --- a/plugins/kapt4/test/org/jetbrains/kotlin/kapt4/AbstractKotlinKapt4ContextTestBase.kt +++ b/plugins/kapt4/test/org/jetbrains/kotlin/kapt4/AbstractKotlinKapt4ContextTest.kt @@ -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() } diff --git a/plugins/kapt4/tests-gen/org/jetbrains/kotlin/kapt4/KotlinKapt4ContextTestGenerated.java b/plugins/kapt4/tests-gen/org/jetbrains/kotlin/kapt4/KotlinKapt4ContextTestGenerated.java index a0790ad251d..1b8d3df6949 100644 --- a/plugins/kapt4/tests-gen/org/jetbrains/kotlin/kapt4/KotlinKapt4ContextTestGenerated.java +++ b/plugins/kapt4/tests-gen/org/jetbrains/kotlin/kapt4/KotlinKapt4ContextTestGenerated.java @@ -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