From 72aa3d146567a1841fc1b97450144719e6138308 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Thu, 2 Apr 2015 03:14:46 +0300 Subject: [PATCH] Use mock JDK in compiler tests where full JDK is not needed - move some of boxWithStdlib tests under fullJdk/ directory, where they will be compiled against the full JDK - introduce FULL_JDK in-text directive for the reflection test as only 4 tests out of 654 needed the full JDK --- .../tests/CodegenTestsOnAndroidGenerator.java | 11 +- .../reflection/mapping/javaFields.kt | 1 + .../jvmAnnotationFlags.kt} | 0 .../{ => fullJdk}/native/default.kt | 0 .../native/nativePropertyAccessors.kt | 0 .../{ => fullJdk}/native/privateStatic.kt | 0 .../{ => fullJdk}/native/simpleNative.kt | 0 .../{ => fullJdk}/native/staticNative.kt | 0 .../{ => fullJdk}/native/topLevel.kt | 0 .../platformTypeAssertionStackTrace.kt} | 0 .../{ => fullJdk}/regressions/collections.kt | 0 .../{ => fullJdk}/regressions/kt1202.kt | 0 .../{ => fullJdk}/regressions/kt1406.kt | 0 .../{ => fullJdk}/regressions/kt1770.kt | 0 .../{ => fullJdk}/regressions/kt274.kt | 0 .../{ => fullJdk}/regressions/kt528.kt | 0 .../{ => fullJdk}/regressions/kt529.kt | 0 .../{ => fullJdk}/regressions/kt533.kt | 0 .../regressions}/kt6485.kt | 0 .../{ => fullJdk}/regressions/kt864.kt | 0 .../synchronized/nonLocalReturn.kt} | 0 .../modality/ModalityOfFakeOverrides.java | 1 + .../modality/ModalityOfFakeOverrides.kt | 1 + .../platformTypes/notnullTypeArgument.kt | 3 +- .../platformTypes/nullableTypeArgument.kt | 3 +- .../AbstractBlackBoxCodegenTest.java | 34 ++- ...lackBoxWithStdlibCodegenTestGenerated.java | 268 +++++++++--------- .../AbstractJvmRuntimeDescriptorLoaderTest.kt | 14 +- .../repl/AbstractReplInterpreterTest.kt | 6 +- .../builtins/LoadBuiltinsTest.java | 2 +- .../jetbrains/kotlin/test/JetTestUtils.java | 6 - 31 files changed, 189 insertions(+), 161 deletions(-) rename compiler/testData/codegen/boxWithStdlib/{annotations/jvmFlags.kt => fullJdk/jvmAnnotationFlags.kt} (100%) rename compiler/testData/codegen/boxWithStdlib/{ => fullJdk}/native/default.kt (100%) rename compiler/testData/codegen/boxWithStdlib/{ => fullJdk}/native/nativePropertyAccessors.kt (100%) rename compiler/testData/codegen/boxWithStdlib/{ => fullJdk}/native/privateStatic.kt (100%) rename compiler/testData/codegen/boxWithStdlib/{ => fullJdk}/native/simpleNative.kt (100%) rename compiler/testData/codegen/boxWithStdlib/{ => fullJdk}/native/staticNative.kt (100%) rename compiler/testData/codegen/boxWithStdlib/{ => fullJdk}/native/topLevel.kt (100%) rename compiler/testData/codegen/boxWithStdlib/{platformTypes/assertionStackTrace.kt => fullJdk/platformTypeAssertionStackTrace.kt} (100%) rename compiler/testData/codegen/boxWithStdlib/{ => fullJdk}/regressions/collections.kt (100%) rename compiler/testData/codegen/boxWithStdlib/{ => fullJdk}/regressions/kt1202.kt (100%) rename compiler/testData/codegen/boxWithStdlib/{ => fullJdk}/regressions/kt1406.kt (100%) rename compiler/testData/codegen/boxWithStdlib/{ => fullJdk}/regressions/kt1770.kt (100%) rename compiler/testData/codegen/boxWithStdlib/{ => fullJdk}/regressions/kt274.kt (100%) rename compiler/testData/codegen/boxWithStdlib/{ => fullJdk}/regressions/kt528.kt (100%) rename compiler/testData/codegen/boxWithStdlib/{ => fullJdk}/regressions/kt529.kt (100%) rename compiler/testData/codegen/boxWithStdlib/{ => fullJdk}/regressions/kt533.kt (100%) rename compiler/testData/codegen/boxWithStdlib/{reified => fullJdk/regressions}/kt6485.kt (100%) rename compiler/testData/codegen/boxWithStdlib/{ => fullJdk}/regressions/kt864.kt (100%) rename compiler/testData/codegen/boxWithStdlib/{nonLocalReturns/synchronized.kt => fullJdk/synchronized/nonLocalReturn.kt} (100%) diff --git a/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/CodegenTestsOnAndroidGenerator.java b/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/CodegenTestsOnAndroidGenerator.java index a7bb986674a..18364a3fcb2 100644 --- a/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/CodegenTestsOnAndroidGenerator.java +++ b/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/CodegenTestsOnAndroidGenerator.java @@ -33,6 +33,7 @@ import org.jetbrains.kotlin.idea.JetFileType; import org.jetbrains.kotlin.psi.JetFile; import org.jetbrains.kotlin.test.ConfigurationKind; import org.jetbrains.kotlin.test.JetTestUtils; +import org.jetbrains.kotlin.test.TestJdkKind; import org.jetbrains.kotlin.utils.Printer; import org.junit.Assert; @@ -137,9 +138,13 @@ public class CodegenTestsOnAndroidGenerator extends UsefulTestCase { } private KotlinCoreEnvironment createEnvironment(boolean isFullJdk) { - return isFullJdk - ? JetTestUtils.createEnvironmentWithFullJdk(myTestRootDisposable) - : JetTestUtils.createEnvironmentWithMockJdkAndIdeaAnnotations(myTestRootDisposable, ConfigurationKind.JDK_AND_ANNOTATIONS); + return isFullJdk ? + JetTestUtils.createEnvironmentWithJdkAndNullabilityAnnotationsFromIdea( + myTestRootDisposable, ConfigurationKind.ALL, TestJdkKind.FULL_JDK + ) : + JetTestUtils.createEnvironmentWithMockJdkAndIdeaAnnotations( + myTestRootDisposable, ConfigurationKind.JDK_AND_ANNOTATIONS + ); } public boolean shouldWriteFilesOnDisk() { diff --git a/compiler/testData/codegen/boxAgainstJava/reflection/mapping/javaFields.kt b/compiler/testData/codegen/boxAgainstJava/reflection/mapping/javaFields.kt index 76baeaf3855..bb2102216e9 100644 --- a/compiler/testData/codegen/boxAgainstJava/reflection/mapping/javaFields.kt +++ b/compiler/testData/codegen/boxAgainstJava/reflection/mapping/javaFields.kt @@ -1,3 +1,4 @@ +// FULL_JDK import javaFields as J import java.lang.reflect.* diff --git a/compiler/testData/codegen/boxWithStdlib/annotations/jvmFlags.kt b/compiler/testData/codegen/boxWithStdlib/fullJdk/jvmAnnotationFlags.kt similarity index 100% rename from compiler/testData/codegen/boxWithStdlib/annotations/jvmFlags.kt rename to compiler/testData/codegen/boxWithStdlib/fullJdk/jvmAnnotationFlags.kt diff --git a/compiler/testData/codegen/boxWithStdlib/native/default.kt b/compiler/testData/codegen/boxWithStdlib/fullJdk/native/default.kt similarity index 100% rename from compiler/testData/codegen/boxWithStdlib/native/default.kt rename to compiler/testData/codegen/boxWithStdlib/fullJdk/native/default.kt diff --git a/compiler/testData/codegen/boxWithStdlib/native/nativePropertyAccessors.kt b/compiler/testData/codegen/boxWithStdlib/fullJdk/native/nativePropertyAccessors.kt similarity index 100% rename from compiler/testData/codegen/boxWithStdlib/native/nativePropertyAccessors.kt rename to compiler/testData/codegen/boxWithStdlib/fullJdk/native/nativePropertyAccessors.kt diff --git a/compiler/testData/codegen/boxWithStdlib/native/privateStatic.kt b/compiler/testData/codegen/boxWithStdlib/fullJdk/native/privateStatic.kt similarity index 100% rename from compiler/testData/codegen/boxWithStdlib/native/privateStatic.kt rename to compiler/testData/codegen/boxWithStdlib/fullJdk/native/privateStatic.kt diff --git a/compiler/testData/codegen/boxWithStdlib/native/simpleNative.kt b/compiler/testData/codegen/boxWithStdlib/fullJdk/native/simpleNative.kt similarity index 100% rename from compiler/testData/codegen/boxWithStdlib/native/simpleNative.kt rename to compiler/testData/codegen/boxWithStdlib/fullJdk/native/simpleNative.kt diff --git a/compiler/testData/codegen/boxWithStdlib/native/staticNative.kt b/compiler/testData/codegen/boxWithStdlib/fullJdk/native/staticNative.kt similarity index 100% rename from compiler/testData/codegen/boxWithStdlib/native/staticNative.kt rename to compiler/testData/codegen/boxWithStdlib/fullJdk/native/staticNative.kt diff --git a/compiler/testData/codegen/boxWithStdlib/native/topLevel.kt b/compiler/testData/codegen/boxWithStdlib/fullJdk/native/topLevel.kt similarity index 100% rename from compiler/testData/codegen/boxWithStdlib/native/topLevel.kt rename to compiler/testData/codegen/boxWithStdlib/fullJdk/native/topLevel.kt diff --git a/compiler/testData/codegen/boxWithStdlib/platformTypes/assertionStackTrace.kt b/compiler/testData/codegen/boxWithStdlib/fullJdk/platformTypeAssertionStackTrace.kt similarity index 100% rename from compiler/testData/codegen/boxWithStdlib/platformTypes/assertionStackTrace.kt rename to compiler/testData/codegen/boxWithStdlib/fullJdk/platformTypeAssertionStackTrace.kt diff --git a/compiler/testData/codegen/boxWithStdlib/regressions/collections.kt b/compiler/testData/codegen/boxWithStdlib/fullJdk/regressions/collections.kt similarity index 100% rename from compiler/testData/codegen/boxWithStdlib/regressions/collections.kt rename to compiler/testData/codegen/boxWithStdlib/fullJdk/regressions/collections.kt diff --git a/compiler/testData/codegen/boxWithStdlib/regressions/kt1202.kt b/compiler/testData/codegen/boxWithStdlib/fullJdk/regressions/kt1202.kt similarity index 100% rename from compiler/testData/codegen/boxWithStdlib/regressions/kt1202.kt rename to compiler/testData/codegen/boxWithStdlib/fullJdk/regressions/kt1202.kt diff --git a/compiler/testData/codegen/boxWithStdlib/regressions/kt1406.kt b/compiler/testData/codegen/boxWithStdlib/fullJdk/regressions/kt1406.kt similarity index 100% rename from compiler/testData/codegen/boxWithStdlib/regressions/kt1406.kt rename to compiler/testData/codegen/boxWithStdlib/fullJdk/regressions/kt1406.kt diff --git a/compiler/testData/codegen/boxWithStdlib/regressions/kt1770.kt b/compiler/testData/codegen/boxWithStdlib/fullJdk/regressions/kt1770.kt similarity index 100% rename from compiler/testData/codegen/boxWithStdlib/regressions/kt1770.kt rename to compiler/testData/codegen/boxWithStdlib/fullJdk/regressions/kt1770.kt diff --git a/compiler/testData/codegen/boxWithStdlib/regressions/kt274.kt b/compiler/testData/codegen/boxWithStdlib/fullJdk/regressions/kt274.kt similarity index 100% rename from compiler/testData/codegen/boxWithStdlib/regressions/kt274.kt rename to compiler/testData/codegen/boxWithStdlib/fullJdk/regressions/kt274.kt diff --git a/compiler/testData/codegen/boxWithStdlib/regressions/kt528.kt b/compiler/testData/codegen/boxWithStdlib/fullJdk/regressions/kt528.kt similarity index 100% rename from compiler/testData/codegen/boxWithStdlib/regressions/kt528.kt rename to compiler/testData/codegen/boxWithStdlib/fullJdk/regressions/kt528.kt diff --git a/compiler/testData/codegen/boxWithStdlib/regressions/kt529.kt b/compiler/testData/codegen/boxWithStdlib/fullJdk/regressions/kt529.kt similarity index 100% rename from compiler/testData/codegen/boxWithStdlib/regressions/kt529.kt rename to compiler/testData/codegen/boxWithStdlib/fullJdk/regressions/kt529.kt diff --git a/compiler/testData/codegen/boxWithStdlib/regressions/kt533.kt b/compiler/testData/codegen/boxWithStdlib/fullJdk/regressions/kt533.kt similarity index 100% rename from compiler/testData/codegen/boxWithStdlib/regressions/kt533.kt rename to compiler/testData/codegen/boxWithStdlib/fullJdk/regressions/kt533.kt diff --git a/compiler/testData/codegen/boxWithStdlib/reified/kt6485.kt b/compiler/testData/codegen/boxWithStdlib/fullJdk/regressions/kt6485.kt similarity index 100% rename from compiler/testData/codegen/boxWithStdlib/reified/kt6485.kt rename to compiler/testData/codegen/boxWithStdlib/fullJdk/regressions/kt6485.kt diff --git a/compiler/testData/codegen/boxWithStdlib/regressions/kt864.kt b/compiler/testData/codegen/boxWithStdlib/fullJdk/regressions/kt864.kt similarity index 100% rename from compiler/testData/codegen/boxWithStdlib/regressions/kt864.kt rename to compiler/testData/codegen/boxWithStdlib/fullJdk/regressions/kt864.kt diff --git a/compiler/testData/codegen/boxWithStdlib/nonLocalReturns/synchronized.kt b/compiler/testData/codegen/boxWithStdlib/fullJdk/synchronized/nonLocalReturn.kt similarity index 100% rename from compiler/testData/codegen/boxWithStdlib/nonLocalReturns/synchronized.kt rename to compiler/testData/codegen/boxWithStdlib/fullJdk/synchronized/nonLocalReturn.kt diff --git a/compiler/testData/loadJava/compiledJava/modality/ModalityOfFakeOverrides.java b/compiler/testData/loadJava/compiledJava/modality/ModalityOfFakeOverrides.java index b46961635d8..e2d8dd8cd30 100644 --- a/compiler/testData/loadJava/compiledJava/modality/ModalityOfFakeOverrides.java +++ b/compiler/testData/loadJava/compiledJava/modality/ModalityOfFakeOverrides.java @@ -1,3 +1,4 @@ +// FULL_JDK package test; import org.jetbrains.annotations.NotNull; diff --git a/compiler/testData/loadJava/compiledKotlin/fromLoadJava/modality/ModalityOfFakeOverrides.kt b/compiler/testData/loadJava/compiledKotlin/fromLoadJava/modality/ModalityOfFakeOverrides.kt index 3597ab24a1c..750c321d057 100644 --- a/compiler/testData/loadJava/compiledKotlin/fromLoadJava/modality/ModalityOfFakeOverrides.kt +++ b/compiler/testData/loadJava/compiledKotlin/fromLoadJava/modality/ModalityOfFakeOverrides.kt @@ -1,3 +1,4 @@ +// FULL_JDK package test import java.util.AbstractList diff --git a/compiler/testData/loadJava/compiledKotlin/platformTypes/notnullTypeArgument.kt b/compiler/testData/loadJava/compiledKotlin/platformTypes/notnullTypeArgument.kt index 099efd304a9..66b057946e8 100644 --- a/compiler/testData/loadJava/compiledKotlin/platformTypes/notnullTypeArgument.kt +++ b/compiler/testData/loadJava/compiledKotlin/platformTypes/notnullTypeArgument.kt @@ -1,3 +1,4 @@ +// FULL_JDK package test -class C: java.util.ArrayList() \ No newline at end of file +class C: java.util.ArrayList() diff --git a/compiler/testData/loadJava/compiledKotlin/platformTypes/nullableTypeArgument.kt b/compiler/testData/loadJava/compiledKotlin/platformTypes/nullableTypeArgument.kt index 7536b7c5eb2..285ff687053 100644 --- a/compiler/testData/loadJava/compiledKotlin/platformTypes/nullableTypeArgument.kt +++ b/compiler/testData/loadJava/compiledKotlin/platformTypes/nullableTypeArgument.kt @@ -1,3 +1,4 @@ +// FULL_JDK package test -class C: java.util.ArrayList() \ No newline at end of file +class C: java.util.ArrayList() diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/generated/AbstractBlackBoxCodegenTest.java b/compiler/tests/org/jetbrains/kotlin/codegen/generated/AbstractBlackBoxCodegenTest.java index 7263d0877aa..d2d24a2ec7a 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/generated/AbstractBlackBoxCodegenTest.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/generated/AbstractBlackBoxCodegenTest.java @@ -19,7 +19,9 @@ package org.jetbrains.kotlin.codegen.generated; import com.intellij.openapi.util.io.FileUtil; import com.intellij.util.ArrayUtil; import com.intellij.util.Processor; +import kotlin.Charsets; import kotlin.KotlinPackage; +import kotlin.io.IoPackage; import org.jetbrains.annotations.NotNull; import org.jetbrains.kotlin.cli.common.output.outputUtils.OutputUtilsPackage; import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles; @@ -29,6 +31,7 @@ import org.jetbrains.kotlin.codegen.GenerationUtils; import org.jetbrains.kotlin.config.CompilerConfiguration; import org.jetbrains.kotlin.psi.JetFile; import org.jetbrains.kotlin.test.ConfigurationKind; +import org.jetbrains.kotlin.test.InTextDirectivesUtils; import org.jetbrains.kotlin.test.JetTestUtils; import org.jetbrains.kotlin.test.TestJdkKind; import org.jetbrains.kotlin.utils.UtilsPackage; @@ -63,7 +66,9 @@ public abstract class AbstractBlackBoxCodegenTest extends CodegenTestCase { } public void doTestWithStdlib(@NotNull String filename) { - myEnvironment = JetTestUtils.createEnvironmentWithFullJdk(getTestRootDisposable()); + myEnvironment = JetTestUtils.createEnvironmentWithJdkAndNullabilityAnnotationsFromIdea( + getTestRootDisposable(), ConfigurationKind.ALL, getTestJdkKind(filename) + ); blackBoxFileByFullPath(filename); } @@ -89,16 +94,29 @@ public abstract class AbstractBlackBoxCodegenTest extends CodegenTestCase { blackBox(); } + // NOTE: tests under fullJdk/ are run with FULL_JDK instead of MOCK_JDK + @NotNull + private static TestJdkKind getTestJdkKind(@NotNull String sourcePath) { + if (sourcePath.contains("compiler/testData/codegen/boxWithStdlib/fullJdk")) { + return TestJdkKind.FULL_JDK; + } + + return InTextDirectivesUtils.isDirectiveDefined( + IoPackage.readText(new File(sourcePath), Charsets.UTF_8), "FULL_JDK" + ) ? TestJdkKind.FULL_JDK : TestJdkKind.MOCK_JDK; + } + private void blackBoxFileAgainstJavaByFullPath(@NotNull String ktFileFullPath) { String ktFile = relativePath(new File(ktFileFullPath)); File javaClassesTempDirectory = compileJava(ktFile.replaceFirst("\\.kt$", ".java")); - myEnvironment = - KotlinCoreEnvironment.createForTests(getTestRootDisposable(), - JetTestUtils.compilerConfigurationForTests(ConfigurationKind.ALL, TestJdkKind.FULL_JDK, - JetTestUtils.getAnnotationsJar(), - javaClassesTempDirectory), - EnvironmentConfigFiles.JVM_CONFIG_FILES); + myEnvironment = KotlinCoreEnvironment.createForTests( + getTestRootDisposable(), + JetTestUtils.compilerConfigurationForTests( + ConfigurationKind.ALL, getTestJdkKind(ktFileFullPath), JetTestUtils.getAnnotationsJar(), javaClassesTempDirectory + ), + EnvironmentConfigFiles.JVM_CONFIG_FILES + ); loadFile(ktFile); blackBox(); @@ -124,7 +142,7 @@ public abstract class AbstractBlackBoxCodegenTest extends CodegenTestCase { }); CompilerConfiguration configuration = JetTestUtils.compilerConfigurationForTests( - ConfigurationKind.ALL, TestJdkKind.FULL_JDK, JetTestUtils.getAnnotationsJar() + ConfigurationKind.ALL, getTestJdkKind(directory), JetTestUtils.getAnnotationsJar() ); addJvmClasspathRoot(configuration, dirFile); myEnvironment = KotlinCoreEnvironment.createForTests(getTestRootDisposable(), configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java index 7c134a59bd4..4aa78e5b6e3 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java @@ -50,11 +50,9 @@ import java.util.regex.Pattern; BlackBoxWithStdlibCodegenTestGenerated.LazyCodegen.class, BlackBoxWithStdlibCodegenTestGenerated.LocalFunInLambda.class, BlackBoxWithStdlibCodegenTestGenerated.MultiDeclForArray.class, - BlackBoxWithStdlibCodegenTestGenerated.Native.class, BlackBoxWithStdlibCodegenTestGenerated.NonLocalReturns.class, BlackBoxWithStdlibCodegenTestGenerated.PlatformNames.class, BlackBoxWithStdlibCodegenTestGenerated.PlatformStatic.class, - BlackBoxWithStdlibCodegenTestGenerated.PlatformTypes.class, BlackBoxWithStdlibCodegenTestGenerated.Ranges.class, BlackBoxWithStdlibCodegenTestGenerated.Reflection.class, BlackBoxWithStdlibCodegenTestGenerated.Regressions.class, @@ -100,12 +98,6 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode doTestWithStdlib(fileName); } - @TestMetadata("jvmFlags.kt") - public void testJvmFlags() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/annotations/jvmFlags.kt"); - doTestWithStdlib(fileName); - } - @TestMetadata("kotlinPropertyFromClassObjectAsParameter.kt") public void testKotlinPropertyFromClassObjectAsParameter() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/annotations/kotlinPropertyFromClassObjectAsParameter.kt"); @@ -1410,6 +1402,8 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode @TestMetadata("compiler/testData/codegen/boxWithStdlib/fullJdk") @TestDataPath("$PROJECT_ROOT") @InnerTestClasses({ + FullJdk.Native.class, + FullJdk.Regressions.class, FullJdk.Synchronized.class, }) @RunWith(JUnit3RunnerWithInners.class) @@ -1448,6 +1442,12 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode doTestWithStdlib(fileName); } + @TestMetadata("jvmAnnotationFlags.kt") + public void testJvmAnnotationFlags() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/fullJdk/jvmAnnotationFlags.kt"); + doTestWithStdlib(fileName); + } + @TestMetadata("kt2423.kt") public void testKt2423() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/fullJdk/kt2423.kt"); @@ -1466,6 +1466,126 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode doTestWithStdlib(fileName); } + @TestMetadata("platformTypeAssertionStackTrace.kt") + public void testPlatformTypeAssertionStackTrace() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/fullJdk/platformTypeAssertionStackTrace.kt"); + doTestWithStdlib(fileName); + } + + @TestMetadata("compiler/testData/codegen/boxWithStdlib/fullJdk/native") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Native extends AbstractBlackBoxCodegenTest { + public void testAllFilesPresentInNative() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxWithStdlib/fullJdk/native"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("default.kt") + public void testDefault() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/fullJdk/native/default.kt"); + doTestWithStdlib(fileName); + } + + @TestMetadata("nativePropertyAccessors.kt") + public void testNativePropertyAccessors() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/fullJdk/native/nativePropertyAccessors.kt"); + doTestWithStdlib(fileName); + } + + @TestMetadata("privateStatic.kt") + public void testPrivateStatic() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/fullJdk/native/privateStatic.kt"); + doTestWithStdlib(fileName); + } + + @TestMetadata("simpleNative.kt") + public void testSimpleNative() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/fullJdk/native/simpleNative.kt"); + doTestWithStdlib(fileName); + } + + @TestMetadata("staticNative.kt") + public void testStaticNative() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/fullJdk/native/staticNative.kt"); + doTestWithStdlib(fileName); + } + + @TestMetadata("topLevel.kt") + public void testTopLevel() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/fullJdk/native/topLevel.kt"); + doTestWithStdlib(fileName); + } + } + + @TestMetadata("compiler/testData/codegen/boxWithStdlib/fullJdk/regressions") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Regressions extends AbstractBlackBoxCodegenTest { + public void testAllFilesPresentInRegressions() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxWithStdlib/fullJdk/regressions"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("collections.kt") + public void testCollections() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/fullJdk/regressions/collections.kt"); + doTestWithStdlib(fileName); + } + + @TestMetadata("kt1202.kt") + public void testKt1202() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/fullJdk/regressions/kt1202.kt"); + doTestWithStdlib(fileName); + } + + @TestMetadata("kt1406.kt") + public void testKt1406() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/fullJdk/regressions/kt1406.kt"); + doTestWithStdlib(fileName); + } + + @TestMetadata("kt1770.kt") + public void testKt1770() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/fullJdk/regressions/kt1770.kt"); + doTestWithStdlib(fileName); + } + + @TestMetadata("kt274.kt") + public void testKt274() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/fullJdk/regressions/kt274.kt"); + doTestWithStdlib(fileName); + } + + @TestMetadata("kt528.kt") + public void testKt528() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/fullJdk/regressions/kt528.kt"); + doTestWithStdlib(fileName); + } + + @TestMetadata("kt529.kt") + public void testKt529() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/fullJdk/regressions/kt529.kt"); + doTestWithStdlib(fileName); + } + + @TestMetadata("kt533.kt") + public void testKt533() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/fullJdk/regressions/kt533.kt"); + doTestWithStdlib(fileName); + } + + @TestMetadata("kt6485.kt") + public void testKt6485() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/fullJdk/regressions/kt6485.kt"); + doTestWithStdlib(fileName); + } + + @TestMetadata("kt864.kt") + public void testKt864() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/fullJdk/regressions/kt864.kt"); + doTestWithStdlib(fileName); + } + } + @TestMetadata("compiler/testData/codegen/boxWithStdlib/fullJdk/synchronized") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -1510,6 +1630,12 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode doTestWithStdlib(fileName); } + @TestMetadata("nonLocalReturn.kt") + public void testNonLocalReturn() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/fullJdk/synchronized/nonLocalReturn.kt"); + doTestWithStdlib(fileName); + } + @TestMetadata("objectValue.kt") public void testObjectValue() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/fullJdk/synchronized/objectValue.kt"); @@ -1975,51 +2101,6 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode } } - @TestMetadata("compiler/testData/codegen/boxWithStdlib/native") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Native extends AbstractBlackBoxCodegenTest { - public void testAllFilesPresentInNative() throws Exception { - JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxWithStdlib/native"), Pattern.compile("^(.+)\\.kt$"), true); - } - - @TestMetadata("default.kt") - public void testDefault() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/native/default.kt"); - doTestWithStdlib(fileName); - } - - @TestMetadata("nativePropertyAccessors.kt") - public void testNativePropertyAccessors() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/native/nativePropertyAccessors.kt"); - doTestWithStdlib(fileName); - } - - @TestMetadata("privateStatic.kt") - public void testPrivateStatic() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/native/privateStatic.kt"); - doTestWithStdlib(fileName); - } - - @TestMetadata("simpleNative.kt") - public void testSimpleNative() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/native/simpleNative.kt"); - doTestWithStdlib(fileName); - } - - @TestMetadata("staticNative.kt") - public void testStaticNative() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/native/staticNative.kt"); - doTestWithStdlib(fileName); - } - - @TestMetadata("topLevel.kt") - public void testTopLevel() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/native/topLevel.kt"); - doTestWithStdlib(fileName); - } - } - @TestMetadata("compiler/testData/codegen/boxWithStdlib/nonLocalReturns") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -2028,12 +2109,6 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxWithStdlib/nonLocalReturns"), Pattern.compile("^(.+)\\.kt$"), true); } - @TestMetadata("synchronized.kt") - public void testSynchronized() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/nonLocalReturns/synchronized.kt"); - doTestWithStdlib(fileName); - } - @TestMetadata("use.kt") public void testUse() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/nonLocalReturns/use.kt"); @@ -2173,21 +2248,6 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode } } - @TestMetadata("compiler/testData/codegen/boxWithStdlib/platformTypes") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class PlatformTypes extends AbstractBlackBoxCodegenTest { - public void testAllFilesPresentInPlatformTypes() throws Exception { - JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxWithStdlib/platformTypes"), Pattern.compile("^(.+)\\.kt$"), true); - } - - @TestMetadata("assertionStackTrace.kt") - public void testAssertionStackTrace() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/platformTypes/assertionStackTrace.kt"); - doTestWithStdlib(fileName); - } - } - @TestMetadata("compiler/testData/codegen/boxWithStdlib/ranges") @TestDataPath("$PROJECT_ROOT") @InnerTestClasses({ @@ -2994,12 +3054,6 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxWithStdlib/regressions"), Pattern.compile("^(.+)\\.kt$"), true); } - @TestMetadata("collections.kt") - public void testCollections() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/regressions/collections.kt"); - doTestWithStdlib(fileName); - } - @TestMetadata("generic.kt") public void testGeneric() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/regressions/generic.kt"); @@ -3024,18 +3078,6 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode doTestWithStdlib(fileName); } - @TestMetadata("kt1202.kt") - public void testKt1202() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/regressions/kt1202.kt"); - doTestWithStdlib(fileName); - } - - @TestMetadata("kt1406.kt") - public void testKt1406() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/regressions/kt1406.kt"); - doTestWithStdlib(fileName); - } - @TestMetadata("kt1568.kt") public void testKt1568() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/regressions/kt1568.kt"); @@ -3048,12 +3090,6 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode doTestWithStdlib(fileName); } - @TestMetadata("kt1770.kt") - public void testKt1770() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/regressions/kt1770.kt"); - doTestWithStdlib(fileName); - } - @TestMetadata("kt1779.kt") public void testKt1779() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/regressions/kt1779.kt"); @@ -3108,12 +3144,6 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode doTestWithStdlib(fileName); } - @TestMetadata("kt274.kt") - public void testKt274() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/regressions/kt274.kt"); - doTestWithStdlib(fileName); - } - @TestMetadata("kt3046.kt") public void testKt3046() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/regressions/kt3046.kt"); @@ -3156,24 +3186,6 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode doTestWithStdlib(fileName); } - @TestMetadata("kt528.kt") - public void testKt528() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/regressions/kt528.kt"); - doTestWithStdlib(fileName); - } - - @TestMetadata("kt529.kt") - public void testKt529() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/regressions/kt529.kt"); - doTestWithStdlib(fileName); - } - - @TestMetadata("kt533.kt") - public void testKt533() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/regressions/kt533.kt"); - doTestWithStdlib(fileName); - } - @TestMetadata("kt5395.kt") public void testKt5395() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/regressions/kt5395.kt"); @@ -3210,12 +3222,6 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode doTestWithStdlib(fileName); } - @TestMetadata("kt864.kt") - public void testKt864() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/regressions/kt864.kt"); - doTestWithStdlib(fileName); - } - @TestMetadata("kt998.kt") public void testKt998() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/regressions/kt998.kt"); @@ -3315,12 +3321,6 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode doTestWithStdlib(fileName); } - @TestMetadata("kt6485.kt") - public void testKt6485() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reified/kt6485.kt"); - doTestWithStdlib(fileName); - } - @TestMetadata("nestedReified.kt") public void testNestedReified() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reified/nestedReified.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/jvm/runtime/AbstractJvmRuntimeDescriptorLoaderTest.kt b/compiler/tests/org/jetbrains/kotlin/jvm/runtime/AbstractJvmRuntimeDescriptorLoaderTest.kt index b4f8eba9b3e..cd08a10f5ea 100644 --- a/compiler/tests/org/jetbrains/kotlin/jvm/runtime/AbstractJvmRuntimeDescriptorLoaderTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/jvm/runtime/AbstractJvmRuntimeDescriptorLoaderTest.kt @@ -81,14 +81,18 @@ public abstract class AbstractJvmRuntimeDescriptorLoaderTest : TestCaseWithTmpdi if (InTextDirectivesUtils.isDirectiveDefined(text, "SKIP_IN_RUNTIME_TEST")) return - compileFile(file, text) + val jdkKind = + if (InTextDirectivesUtils.isDirectiveDefined(text, "FULL_JDK")) TestJdkKind.FULL_JDK + else TestJdkKind.MOCK_JDK + + compileFile(file, text, jdkKind) val classLoader = URLClassLoader(array(tmpdir.toURI().toURL()), ForTestCompileRuntime.runtimeJarClassLoader()) val actual = createReflectedPackageView(classLoader) val expected = LoadDescriptorUtil.loadTestPackageAndBindingContextFromJavaRoot( - tmpdir, getTestRootDisposable(), TestJdkKind.FULL_JDK, ConfigurationKind.ALL + tmpdir, getTestRootDisposable(), jdkKind, ConfigurationKind.ALL ).first val comparatorConfiguration = Configuration( @@ -104,7 +108,7 @@ public abstract class AbstractJvmRuntimeDescriptorLoaderTest : TestCaseWithTmpdi RecursiveDescriptorComparator.validateAndCompareDescriptors(expected, actual, comparatorConfiguration, null) } - private fun compileFile(file: File, text: String) { + private fun compileFile(file: File, text: String, jdkKind: TestJdkKind) { val fileName = file.getName() when { fileName.endsWith(".java") -> { @@ -118,7 +122,9 @@ public abstract class AbstractJvmRuntimeDescriptorLoaderTest : TestCaseWithTmpdi LoadDescriptorUtil.compileJavaWithAnnotationsJar(sources, tmpdir) } fileName.endsWith(".kt") -> { - val environment = JetTestUtils.createEnvironmentWithFullJdk(myTestRootDisposable) + val environment = JetTestUtils.createEnvironmentWithJdkAndNullabilityAnnotationsFromIdea( + myTestRootDisposable, ConfigurationKind.ALL, jdkKind + ) val jetFile = JetTestUtils.createFile(file.getPath(), addRuntimeRetentionToKotlinSource(text), environment.project) GenerationUtils.compileFileGetClassFileFactoryForTest(jetFile).writeAllTo(tmpdir) } diff --git a/compiler/tests/org/jetbrains/kotlin/repl/AbstractReplInterpreterTest.kt b/compiler/tests/org/jetbrains/kotlin/repl/AbstractReplInterpreterTest.kt index ec86f13e84c..dd6b57e5708 100644 --- a/compiler/tests/org/jetbrains/kotlin/repl/AbstractReplInterpreterTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/repl/AbstractReplInterpreterTest.kt @@ -18,15 +18,15 @@ package org.jetbrains.kotlin.repl import com.intellij.openapi.util.text.StringUtil import com.intellij.testFramework.UsefulTestCase +import org.jetbrains.kotlin.cli.jvm.repl.ReplInterpreter import org.jetbrains.kotlin.test.ConfigurationKind import org.jetbrains.kotlin.test.JetTestUtils import org.jetbrains.kotlin.test.TestJdkKind -import org.jetbrains.kotlin.cli.jvm.repl.ReplInterpreter +import org.junit.Assert import java.io.File import java.util.ArrayDeque import java.util.ArrayList import java.util.regex.Pattern -import org.junit.Assert private val START_PATTERN = Pattern.compile(">>>( *)(.*)$") private val INCOMPLETE_PATTERN = Pattern.compile("\\.\\.\\.( *)(.*)$") @@ -76,7 +76,7 @@ public abstract class AbstractReplInterpreterTest : UsefulTestCase() { } protected fun doTest(path: String) { - val configuration = JetTestUtils.compilerConfigurationForTests(ConfigurationKind.ALL, TestJdkKind.FULL_JDK) + val configuration = JetTestUtils.compilerConfigurationForTests(ConfigurationKind.ALL, TestJdkKind.MOCK_JDK) val repl = ReplInterpreter(getTestRootDisposable()!!, configuration) for ((code, expected) in loadLines(File(path))) { diff --git a/compiler/tests/org/jetbrains/kotlin/serialization/builtins/LoadBuiltinsTest.java b/compiler/tests/org/jetbrains/kotlin/serialization/builtins/LoadBuiltinsTest.java index 0f2106dd178..fd6c3349d67 100644 --- a/compiler/tests/org/jetbrains/kotlin/serialization/builtins/LoadBuiltinsTest.java +++ b/compiler/tests/org/jetbrains/kotlin/serialization/builtins/LoadBuiltinsTest.java @@ -41,7 +41,7 @@ import java.util.regex.Pattern; public class LoadBuiltinsTest extends KotlinTestWithEnvironment { @Override protected KotlinCoreEnvironment createEnvironment() { - return createEnvironmentWithJdk(ConfigurationKind.JDK_AND_ANNOTATIONS, TestJdkKind.FULL_JDK); + return createEnvironmentWithJdk(ConfigurationKind.JDK_AND_ANNOTATIONS, TestJdkKind.MOCK_JDK); } public void testBuiltIns() throws Exception { diff --git a/compiler/tests/org/jetbrains/kotlin/test/JetTestUtils.java b/compiler/tests/org/jetbrains/kotlin/test/JetTestUtils.java index df62a21f8a5..fb19b3e5b41 100644 --- a/compiler/tests/org/jetbrains/kotlin/test/JetTestUtils.java +++ b/compiler/tests/org/jetbrains/kotlin/test/JetTestUtils.java @@ -250,12 +250,6 @@ public class JetTestUtils { return JvmResolveUtil.analyzeOneFileWithJavaIntegration(file); } - @NotNull - public static KotlinCoreEnvironment createEnvironmentWithFullJdk(Disposable disposable) { - return createEnvironmentWithJdkAndNullabilityAnnotationsFromIdea(disposable, - ConfigurationKind.ALL, TestJdkKind.FULL_JDK); - } - @NotNull public static KotlinCoreEnvironment createEnvironmentWithMockJdkAndIdeaAnnotations(Disposable disposable) { return createEnvironmentWithMockJdkAndIdeaAnnotations(disposable, ConfigurationKind.ALL);