Drop ConfigurationKind.JDK_AND_ANNOTATIONS, JetTestUtils.getJdkAnnotationsJar()
This commit is contained in:
committed by
Dmitry Jemerov
parent
448b3f6195
commit
b0a4e812e5
+1
-3
@@ -146,9 +146,7 @@ public class CodegenTestsOnAndroidGenerator extends UsefulTestCase {
|
||||
JetTestUtils.createEnvironmentWithJdkAndNullabilityAnnotationsFromIdea(
|
||||
myTestRootDisposable, ConfigurationKind.ALL, TestJdkKind.FULL_JDK
|
||||
) :
|
||||
JetTestUtils.createEnvironmentWithMockJdkAndIdeaAnnotations(
|
||||
myTestRootDisposable, ConfigurationKind.JDK_AND_ANNOTATIONS
|
||||
);
|
||||
JetTestUtils.createEnvironmentWithMockJdkAndIdeaAnnotations(myTestRootDisposable);
|
||||
}
|
||||
|
||||
public boolean shouldWriteFilesOnDisk() {
|
||||
|
||||
@@ -33,7 +33,7 @@ import org.jetbrains.kotlin.utils.UtilsPackage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -77,10 +77,10 @@ public abstract class KotlinMultiFileTestWithWithJava<M, F> extends JetLiteFixtu
|
||||
@NotNull
|
||||
protected CompilerConfiguration createCompilerConfiguration(File javaFilesDir) {
|
||||
return JetTestUtils.compilerConfigurationForTests(
|
||||
ConfigurationKind.JDK_AND_ANNOTATIONS,
|
||||
ConfigurationKind.JDK_ONLY,
|
||||
TestJdkKind.MOCK_JDK,
|
||||
Arrays.asList(JetTestUtils.getAnnotationsJar()),
|
||||
Arrays.asList(javaFilesDir)
|
||||
Collections.singletonList(JetTestUtils.getAnnotationsJar()),
|
||||
Collections.singletonList(javaFilesDir)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,13 +16,13 @@
|
||||
|
||||
package org.jetbrains.kotlin.codegen
|
||||
|
||||
import org.jetbrains.kotlin.test.ConfigurationKind
|
||||
import junit.framework.TestCase
|
||||
import org.jetbrains.asm4.ClassReader
|
||||
import org.jetbrains.asm4.ClassVisitor
|
||||
import org.jetbrains.asm4.Opcodes
|
||||
import org.jetbrains.asm4.MethodVisitor
|
||||
import org.jetbrains.asm4.Opcodes
|
||||
import org.jetbrains.kotlin.test.ConfigurationKind
|
||||
import java.util.ArrayList
|
||||
import junit.framework.TestCase
|
||||
|
||||
public class MethodOrderTest: CodegenTestCase() {
|
||||
public fun testDelegatedMethod() {
|
||||
@@ -109,7 +109,7 @@ public class MethodOrderTest: CodegenTestCase() {
|
||||
}
|
||||
|
||||
private fun doTest(sourceText: String, classSuffix: String, expectedOrder: List<String>) {
|
||||
createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_AND_ANNOTATIONS)
|
||||
createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY)
|
||||
myFiles = CodegenTestFiles.create("file.kt", sourceText, myEnvironment!!.project)
|
||||
|
||||
val classFileForObject = generateClassesInFile().asList().first { it.relativePath.endsWith("$classSuffix.class") }
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@ import static org.jetbrains.kotlin.load.kotlin.PackageClassUtils.getPackageClass
|
||||
|
||||
public abstract class AbstractBlackBoxCodegenTest extends CodegenTestCase {
|
||||
public void doTest(@NotNull String filename) {
|
||||
createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_AND_ANNOTATIONS);
|
||||
createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY);
|
||||
blackBoxFileByFullPath(filename);
|
||||
}
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir {
|
||||
}
|
||||
|
||||
protected void doTestCompiledKotlin(@NotNull String ktFileName) throws Exception {
|
||||
doTestCompiledKotlin(ktFileName, ConfigurationKind.JDK_AND_ANNOTATIONS);
|
||||
doTestCompiledKotlin(ktFileName, ConfigurationKind.JDK_ONLY);
|
||||
}
|
||||
|
||||
protected void doTestCompiledKotlinWithStdlib(@NotNull String ktFileName) throws Exception {
|
||||
@@ -236,7 +236,8 @@ public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir {
|
||||
});
|
||||
|
||||
JetTestUtils.createEnvironmentWithJdkAndNullabilityAnnotationsFromIdea(
|
||||
getTestRootDisposable(), ConfigurationKind.JDK_AND_ANNOTATIONS, TestJdkKind.MOCK_JDK);
|
||||
getTestRootDisposable(), ConfigurationKind.JDK_ONLY, TestJdkKind.MOCK_JDK
|
||||
);
|
||||
|
||||
Pair<PackageViewDescriptor, BindingContext> javaPackageAndContext = compileJavaAndLoadTestPackageAndBindingContextFromBinary(
|
||||
srcFiles, compiledDir, ConfigurationKind.ALL
|
||||
|
||||
+2
-1
@@ -39,7 +39,8 @@ public class AndroidSdkAnnotationsValidityTest extends AbstractSdkAnnotationsVal
|
||||
@Override
|
||||
protected KotlinCoreEnvironment createEnvironment(Disposable parentDisposable) {
|
||||
CompilerConfiguration configuration = JetTestUtils.compilerConfigurationForTests(
|
||||
ConfigurationKind.JDK_AND_ANNOTATIONS, TestJdkKind.ANDROID_API, JetTestUtils.getAnnotationsJar());
|
||||
ConfigurationKind.JDK_ONLY, TestJdkKind.ANDROID_API, JetTestUtils.getAnnotationsJar()
|
||||
);
|
||||
return KotlinCoreEnvironment.createForTests(parentDisposable, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES);
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,8 @@ public class JdkAnnotationsValidityTest extends AbstractSdkAnnotationsValidityTe
|
||||
|
||||
private static KotlinCoreEnvironment createFullJdkEnvironment(Disposable parentDisposable) {
|
||||
CompilerConfiguration configuration = JetTestUtils.compilerConfigurationForTests(
|
||||
ConfigurationKind.JDK_AND_ANNOTATIONS, TestJdkKind.FULL_JDK, JetTestUtils.getAnnotationsJar());
|
||||
ConfigurationKind.JDK_ONLY, TestJdkKind.FULL_JDK, JetTestUtils.getAnnotationsJar()
|
||||
);
|
||||
configuration.add(JVMConfigurationKeys.ANNOTATIONS_PATH_KEY, new File("ideaSDK/lib/jdkAnnotations.jar"));
|
||||
return KotlinCoreEnvironment.createForTests(parentDisposable, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES);
|
||||
}
|
||||
|
||||
+4
-3
@@ -165,13 +165,14 @@ public class ResolveDescriptorsFromExternalLibraries {
|
||||
if (jar != null) {
|
||||
jetCoreEnvironment = KotlinCoreEnvironment.createForTests(
|
||||
junk,
|
||||
JetTestUtils.compilerConfigurationForTests(ConfigurationKind.JDK_AND_ANNOTATIONS, TestJdkKind.MOCK_JDK,
|
||||
JetTestUtils.getAnnotationsJar(), jar),
|
||||
JetTestUtils.compilerConfigurationForTests(
|
||||
ConfigurationKind.JDK_ONLY, TestJdkKind.MOCK_JDK, JetTestUtils.getAnnotationsJar(), jar
|
||||
),
|
||||
EnvironmentConfigFiles.JVM_CONFIG_FILES);
|
||||
}
|
||||
else {
|
||||
CompilerConfiguration configuration =
|
||||
JetTestUtils.compilerConfigurationForTests(ConfigurationKind.JDK_AND_ANNOTATIONS, TestJdkKind.FULL_JDK);
|
||||
JetTestUtils.compilerConfigurationForTests(ConfigurationKind.JDK_ONLY, TestJdkKind.FULL_JDK);
|
||||
jetCoreEnvironment = KotlinCoreEnvironment.createForTests(junk, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES);
|
||||
if (!findRtJar().equals(jar)) {
|
||||
throw new RuntimeException("rt.jar mismatch: " + jar + ", " + findRtJar());
|
||||
|
||||
@@ -33,7 +33,7 @@ public abstract class ExtensibleResolveTestCase extends JetLiteFixture {
|
||||
|
||||
@Override
|
||||
protected KotlinCoreEnvironment createEnvironment() {
|
||||
return createEnvironmentWithMockJdk(ConfigurationKind.JDK_AND_ANNOTATIONS);
|
||||
return createEnvironmentWithMockJdk(ConfigurationKind.JDK_ONLY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -83,7 +83,7 @@ public class ScriptTest {
|
||||
Disposable rootDisposable = Disposer.newDisposable();
|
||||
try {
|
||||
CompilerConfiguration configuration =
|
||||
JetTestUtils.compilerConfigurationForTests(ConfigurationKind.JDK_AND_ANNOTATIONS, TestJdkKind.FULL_JDK);
|
||||
JetTestUtils.compilerConfigurationForTests(ConfigurationKind.JDK_ONLY, TestJdkKind.FULL_JDK);
|
||||
configuration.put(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, messageCollector);
|
||||
addKotlinSourceRoot(configuration, "compiler/testData/script/" + scriptPath);
|
||||
configuration.addAll(CommonConfigurationKeys.SCRIPT_DEFINITIONS_KEY, scriptDefinitions);
|
||||
|
||||
@@ -59,7 +59,7 @@ import static org.jetbrains.kotlin.builtins.KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_
|
||||
public class LoadBuiltinsTest extends KotlinTestWithEnvironment {
|
||||
@Override
|
||||
protected KotlinCoreEnvironment createEnvironment() {
|
||||
return createEnvironmentWithJdk(ConfigurationKind.JDK_AND_ANNOTATIONS, TestJdkKind.MOCK_JDK);
|
||||
return createEnvironmentWithJdk(ConfigurationKind.JDK_ONLY, TestJdkKind.MOCK_JDK);
|
||||
}
|
||||
|
||||
public void testBuiltIns() throws Exception {
|
||||
|
||||
@@ -92,7 +92,6 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static org.jetbrains.kotlin.cli.jvm.config.ConfigPackage.*;
|
||||
import static org.jetbrains.kotlin.cli.jvm.config.JVMConfigurationKeys.ANNOTATIONS_PATH_KEY;
|
||||
import static org.jetbrains.kotlin.cli.jvm.config.JVMConfigurationKeys.MODULE_NAME;
|
||||
import static org.jetbrains.kotlin.jvm.compiler.LoadDescriptorUtil.compileKotlinToDirAndGetAnalysisResult;
|
||||
import static org.jetbrains.kotlin.psi.PsiPackage.JetPsiFactory;
|
||||
@@ -337,24 +336,6 @@ public class JetTestUtils {
|
||||
return new File(getHomeDirectory(), "compiler/testData/mockJDK/jre/lib/annotations.jar");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static File getJdkAnnotationsJar() {
|
||||
File jdkAnnotations = new File(getHomeDirectory(), "dist/kotlinc/lib/kotlin-jdk-annotations.jar");
|
||||
if (!jdkAnnotations.exists()) {
|
||||
throw new RuntimeException("Kotlin JDK annotations jar not found; please run 'ant dist' to build it");
|
||||
}
|
||||
return jdkAnnotations;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static File getAndroidSdkAnnotationsJar() {
|
||||
File androidSdkAnnotations = new File(getHomeDirectory(), "dist/kotlinc/lib/kotlin-android-sdk-annotations.jar");
|
||||
if (!androidSdkAnnotations.exists()) {
|
||||
throw new RuntimeException("Kotlin Android SDK annotations jar not found; please run 'ant dist' to build it");
|
||||
}
|
||||
return androidSdkAnnotations;
|
||||
}
|
||||
|
||||
public static void mkdirs(File file) throws IOException {
|
||||
if (file.isDirectory()) {
|
||||
return;
|
||||
@@ -471,15 +452,6 @@ public class JetTestUtils {
|
||||
|
||||
addJvmClasspathRoots(configuration, classpath);
|
||||
|
||||
if (configurationKind.getWithJdkAnnotations()) {
|
||||
if (jdkKind == TestJdkKind.ANDROID_API) {
|
||||
configuration.add(ANNOTATIONS_PATH_KEY, getAndroidSdkAnnotationsJar());
|
||||
}
|
||||
else {
|
||||
configuration.add(ANNOTATIONS_PATH_KEY, getJdkAnnotationsJar());
|
||||
}
|
||||
}
|
||||
|
||||
configuration.put(MODULE_NAME, "compilerConfigurationForTests");
|
||||
|
||||
return configuration;
|
||||
|
||||
+13
-2
@@ -41,27 +41,38 @@ public class PluginTestCaseBase {
|
||||
return JetTestUtils.getHomeDirectory() + TEST_DATA_PROJECT_RELATIVE;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Sdk getSdk(String sdkHome) {
|
||||
Sdk sdk = JavaSdk.getInstance().createJdk("JDK", sdkHome, true);
|
||||
SdkModificator modificator = sdk.getSdkModificator();
|
||||
JavaSdkImpl.attachJdkAnnotations(modificator);
|
||||
VirtualFile file = LocalFileSystem.getInstance().findFileByIoFile(JetTestUtils.getJdkAnnotationsJar());
|
||||
VirtualFile file = LocalFileSystem.getInstance().findFileByIoFile(getJdkAnnotationsJar());
|
||||
assert file != null;
|
||||
modificator.addRoot(JarFileSystem.getInstance().getJarRootForLocalFile(file), AnnotationOrderRootType.getInstance());
|
||||
modificator.commitChanges();
|
||||
return sdk;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Sdk mockJdk() {
|
||||
return getSdk("compiler/testData/mockJDK/jre");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Sdk fullJdk() {
|
||||
String javaHome = System.getProperty("java.home");
|
||||
assert new File(javaHome).isDirectory();
|
||||
return getSdk(javaHome);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static File getJdkAnnotationsJar() {
|
||||
File jdkAnnotations = new File(JetTestUtils.getHomeDirectory(), "dist/kotlinc/lib/kotlin-jdk-annotations.jar");
|
||||
if (!jdkAnnotations.exists()) {
|
||||
throw new RuntimeException("Kotlin JDK annotations jar not found; please run 'ant dist' to build it");
|
||||
}
|
||||
return jdkAnnotations;
|
||||
}
|
||||
|
||||
public static boolean isAllFilesPresentTest(@NotNull String testName) {
|
||||
return StringUtil.startsWithIgnoreCase(testName, "allFilesPresentIn");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user