Added support for reflection tests on android
This commit is contained in:
+10
-2
@@ -26,9 +26,11 @@ import org.jetbrains.kotlin.backend.common.output.OutputFileCollection;
|
|||||||
import org.jetbrains.kotlin.cli.common.output.outputUtils.OutputUtilsKt;
|
import org.jetbrains.kotlin.cli.common.output.outputUtils.OutputUtilsKt;
|
||||||
import org.jetbrains.kotlin.cli.jvm.compiler.JvmPackagePartProvider;
|
import org.jetbrains.kotlin.cli.jvm.compiler.JvmPackagePartProvider;
|
||||||
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment;
|
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment;
|
||||||
|
import org.jetbrains.kotlin.cli.jvm.config.JVMConfigurationKeys;
|
||||||
import org.jetbrains.kotlin.codegen.CodegenTestFiles;
|
import org.jetbrains.kotlin.codegen.CodegenTestFiles;
|
||||||
import org.jetbrains.kotlin.codegen.GenerationUtils;
|
import org.jetbrains.kotlin.codegen.GenerationUtils;
|
||||||
import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime;
|
import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime;
|
||||||
|
import org.jetbrains.kotlin.config.CompilerConfiguration;
|
||||||
import org.jetbrains.kotlin.idea.KotlinFileType;
|
import org.jetbrains.kotlin.idea.KotlinFileType;
|
||||||
import org.jetbrains.kotlin.load.java.JvmAbi;
|
import org.jetbrains.kotlin.load.java.JvmAbi;
|
||||||
import org.jetbrains.kotlin.name.FqName;
|
import org.jetbrains.kotlin.name.FqName;
|
||||||
@@ -54,6 +56,8 @@ public class CodegenTestsOnAndroidGenerator extends UsefulTestCase {
|
|||||||
private static final String baseTestClassName = "AbstractCodegenTestCaseOnAndroid";
|
private static final String baseTestClassName = "AbstractCodegenTestCaseOnAndroid";
|
||||||
private static final String generatorName = "CodegenTestsOnAndroidGenerator";
|
private static final String generatorName = "CodegenTestsOnAndroidGenerator";
|
||||||
|
|
||||||
|
private static int MODULE_INDEX = 1;
|
||||||
|
|
||||||
private final List<String> generatedTestNames = Lists.newArrayList();
|
private final List<String> generatedTestNames = Lists.newArrayList();
|
||||||
|
|
||||||
public static void generate(PathManager pathManager) throws Throwable {
|
public static void generate(PathManager pathManager) throws Throwable {
|
||||||
@@ -149,7 +153,7 @@ public class CodegenTestsOnAndroidGenerator extends UsefulTestCase {
|
|||||||
return isFullJdkAndRuntime ?
|
return isFullJdkAndRuntime ?
|
||||||
KotlinTestUtils.createEnvironmentWithJdkAndNullabilityAnnotationsFromIdea(
|
KotlinTestUtils.createEnvironmentWithJdkAndNullabilityAnnotationsFromIdea(
|
||||||
myTestRootDisposable, ConfigurationKind.ALL, TestJdkKind.FULL_JDK
|
myTestRootDisposable, ConfigurationKind.ALL, TestJdkKind.FULL_JDK
|
||||||
) :
|
) :
|
||||||
KotlinTestUtils.createEnvironmentWithMockJdkAndIdeaAnnotations(myTestRootDisposable, ConfigurationKind.JDK_ONLY);
|
KotlinTestUtils.createEnvironmentWithMockJdkAndIdeaAnnotations(myTestRootDisposable, ConfigurationKind.JDK_ONLY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,11 +188,15 @@ public class CodegenTestsOnAndroidGenerator extends UsefulTestCase {
|
|||||||
? " (full jdk and runtime)" : "") + "...");
|
? " (full jdk and runtime)" : "") + "...");
|
||||||
OutputFileCollection outputFiles;
|
OutputFileCollection outputFiles;
|
||||||
try {
|
try {
|
||||||
|
//hack to pass module name
|
||||||
|
CompilerConfiguration configuration = environment.getConfiguration().copy();
|
||||||
|
configuration.put(JVMConfigurationKeys.MODULE_NAME, "android-module-" + MODULE_INDEX++);
|
||||||
|
configuration.setReadOnly(true);
|
||||||
outputFiles = GenerationUtils.compileManyFilesGetGenerationStateForTest(
|
outputFiles = GenerationUtils.compileManyFilesGetGenerationStateForTest(
|
||||||
filesToCompile.iterator().next().getProject(),
|
filesToCompile.iterator().next().getProject(),
|
||||||
filesToCompile,
|
filesToCompile,
|
||||||
new JvmPackagePartProvider(environment),
|
new JvmPackagePartProvider(environment),
|
||||||
null
|
configuration
|
||||||
).getFactory();
|
).getFactory();
|
||||||
}
|
}
|
||||||
catch (Throwable e) {
|
catch (Throwable e) {
|
||||||
|
|||||||
@@ -36,7 +36,10 @@ public class SpecialFiles {
|
|||||||
private static void fillExcludedFiles() {
|
private static void fillExcludedFiles() {
|
||||||
excludedFiles.add("native"); // Reflection is used to check full class name
|
excludedFiles.add("native"); // Reflection is used to check full class name
|
||||||
|
|
||||||
excludedFiles.add("reflection");
|
excludedFiles.add("enclosing"); //reflection tests
|
||||||
|
excludedFiles.add("noReflectAtRuntime"); //reflection tests
|
||||||
|
excludedFiles.add("methodsFromAny"); //reflection tests
|
||||||
|
|
||||||
excludedFiles.add("kt3238.kt"); // Reflection
|
excludedFiles.add("kt3238.kt"); // Reflection
|
||||||
excludedFiles.add("kt1482_2279.kt"); // Reflection
|
excludedFiles.add("kt1482_2279.kt"); // Reflection
|
||||||
excludedFiles.add("extensionMethod.kt"); // Reflection loadClass
|
excludedFiles.add("extensionMethod.kt"); // Reflection loadClass
|
||||||
@@ -61,11 +64,18 @@ public class SpecialFiles {
|
|||||||
excludedFiles.add("kt6990.kt"); // Cannot change package name
|
excludedFiles.add("kt6990.kt"); // Cannot change package name
|
||||||
excludedFiles.add("mainInFiles.kt"); // Cannot change package name
|
excludedFiles.add("mainInFiles.kt"); // Cannot change package name
|
||||||
excludedFiles.add("noClassForSimpleEnum.kt"); // Cannot change package name
|
excludedFiles.add("noClassForSimpleEnum.kt"); // Cannot change package name
|
||||||
|
excludedFiles.add("simpleClassLiteral.kt"); // Cannot change package name
|
||||||
|
excludedFiles.add("jvmName.kt"); // Cannot change package name
|
||||||
|
excludedFiles.add("qualifiedName.kt"); // Cannot change package name
|
||||||
|
excludedFiles.add("topLevelProperty.kt"); // Cannot change package name
|
||||||
|
excludedFiles.add("typeParameters.kt"); // Cannot change package name
|
||||||
|
|
||||||
excludedFiles.add("kt684.kt"); // StackOverflow with StringBuilder (escape())
|
excludedFiles.add("kt684.kt"); // StackOverflow with StringBuilder (escape())
|
||||||
|
|
||||||
excludedFiles.add("genericBackingFieldSignature.kt"); // Wrong signature after package renaming
|
excludedFiles.add("genericBackingFieldSignature.kt"); // Wrong signature after package renaming
|
||||||
excludedFiles.add("genericMethodSignature.kt"); // Wrong signature after package renaming
|
excludedFiles.add("genericMethodSignature.kt"); // Wrong signature after package renaming
|
||||||
|
excludedFiles.add("kt11121.kt"); // Wrong signature after package renaming
|
||||||
|
excludedFiles.add("kt5112.kt"); // Wrong signature after package renaming
|
||||||
|
|
||||||
excludedFiles.add("classpath.kt"); // Some classes are not visible on android
|
excludedFiles.add("classpath.kt"); // Some classes are not visible on android
|
||||||
|
|
||||||
@@ -76,6 +86,10 @@ public class SpecialFiles {
|
|||||||
excludedFiles.add("enclosingInfo"); // Wrong enclosing info after package renaming
|
excludedFiles.add("enclosingInfo"); // Wrong enclosing info after package renaming
|
||||||
excludedFiles.add("signature"); // Wrong signature after package renaming
|
excludedFiles.add("signature"); // Wrong signature after package renaming
|
||||||
|
|
||||||
|
excludedFiles.add("functionNtoStringNoReflect.kt"); // disabled cause test executed with reflection
|
||||||
|
|
||||||
|
excludedFiles.add("nestedClasses.kt"); // additional nested class in 'Thread' class on Android
|
||||||
|
|
||||||
//excludedFiles.add("simpleThrow.kt"); // jack and jill fail
|
//excludedFiles.add("simpleThrow.kt"); // jack and jill fail
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import org.jetbrains.kotlin.codegen.state.GenerationState;
|
|||||||
import org.jetbrains.kotlin.config.CompilerConfiguration;
|
import org.jetbrains.kotlin.config.CompilerConfiguration;
|
||||||
import org.jetbrains.kotlin.config.CompilerConfigurationKey;
|
import org.jetbrains.kotlin.config.CompilerConfigurationKey;
|
||||||
import org.jetbrains.kotlin.descriptors.PackagePartProvider;
|
import org.jetbrains.kotlin.descriptors.PackagePartProvider;
|
||||||
|
import org.jetbrains.kotlin.name.FqName;
|
||||||
import org.jetbrains.kotlin.psi.KtFile;
|
import org.jetbrains.kotlin.psi.KtFile;
|
||||||
import org.jetbrains.kotlin.resolve.lazy.JvmResolveUtil;
|
import org.jetbrains.kotlin.resolve.lazy.JvmResolveUtil;
|
||||||
|
|
||||||
@@ -102,7 +103,11 @@ public class GenerationUtils {
|
|||||||
getConfigurationValueOrDefault(configuration, JVMConfigurationKeys.DISABLE_INLINE, false),
|
getConfigurationValueOrDefault(configuration, JVMConfigurationKeys.DISABLE_INLINE, false),
|
||||||
getConfigurationValueOrDefault(configuration, JVMConfigurationKeys.DISABLE_OPTIMIZATION, false),
|
getConfigurationValueOrDefault(configuration, JVMConfigurationKeys.DISABLE_OPTIMIZATION, false),
|
||||||
useTypeTableInSerializer,
|
useTypeTableInSerializer,
|
||||||
getConfigurationValueOrDefault(configuration, JVMConfigurationKeys.INHERIT_MULTIFILE_PARTS, false)
|
getConfigurationValueOrDefault(configuration, JVMConfigurationKeys.INHERIT_MULTIFILE_PARTS, false),
|
||||||
|
Collections.<FqName>emptySet(),
|
||||||
|
Collections.<FqName>emptySet(),
|
||||||
|
null,
|
||||||
|
configuration == null ? null : configuration.get(JVMConfigurationKeys.MODULE_NAME)
|
||||||
);
|
);
|
||||||
KotlinCodegenFacade.compileCorrectFiles(state, CompilationErrorHandler.THROW_EXCEPTION);
|
KotlinCodegenFacade.compileCorrectFiles(state, CompilationErrorHandler.THROW_EXCEPTION);
|
||||||
return state;
|
return state;
|
||||||
|
|||||||
Reference in New Issue
Block a user