Add an IR version of Android Extensions blackbox tests

This commit is contained in:
pyos
2020-01-14 13:05:50 +01:00
committed by Yan Zhulanow
parent 4094841dc6
commit ca3c1d04c5
5 changed files with 176 additions and 0 deletions
@@ -11,6 +11,7 @@ import org.jetbrains.kotlin.cli.jvm.config.jvmClasspathRoots
import org.jetbrains.kotlin.codegen.AbstractBlackBoxCodegenTest
import org.jetbrains.kotlin.codegen.CodegenTestFiles
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.config.JVMConfigurationKeys
import org.jetbrains.kotlin.test.ConfigurationKind
import org.jetbrains.kotlin.test.KotlinTestUtils
import org.jetbrains.kotlin.test.TestJdkKind
@@ -29,6 +30,7 @@ abstract class AbstractAndroidBoxTest : AbstractBlackBoxCodegenTest() {
}
private fun createEnvironmentForConfiguration(configuration: CompilerConfiguration, path: String) {
configuration.put(JVMConfigurationKeys.IR, backend.isIR);
val layoutPaths = File(path)
.listFiles { file -> file.name.startsWith("layout") && file.isDirectory }!!
.map { "$path${it.name}/" }
@@ -0,0 +1,12 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.android.synthetic.test
import org.jetbrains.kotlin.test.TargetBackend
abstract class AbstractAndroidIrBoxTest : AbstractAndroidBoxTest() {
override fun getBackend() = TargetBackend.JVM_IR
}
@@ -0,0 +1,147 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.android.synthetic.test;
import com.intellij.testFramework.TestDataPath;
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
import org.jetbrains.kotlin.test.KotlinTestUtils;
import org.jetbrains.kotlin.test.TargetBackend;
import org.jetbrains.kotlin.test.TestMetadata;
import org.junit.runner.RunWith;
import java.io.File;
import java.util.regex.Pattern;
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@RunWith(JUnit3RunnerWithInners.class)
public class AndroidIrBoxTestGenerated extends AbstractAndroidIrBoxTest {
@TestMetadata("plugins/android-extensions/android-extensions-compiler/testData/codegen/android")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Android extends AbstractAndroidIrBoxTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doCompileAgainstAndroidSdkTest, TargetBackend.JVM_IR, testDataFilePath);
}
public void testAllFilesPresentInAndroid() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/android-extensions/android-extensions-compiler/testData/codegen/android"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, false);
}
@TestMetadata("androidEntity")
public void testAndroidEntity() throws Exception {
runTest("plugins/android-extensions/android-extensions-compiler/testData/codegen/android/androidEntity/");
}
@TestMetadata("androidEntityInnerClass")
public void testAndroidEntityInnerClass() throws Exception {
runTest("plugins/android-extensions/android-extensions-compiler/testData/codegen/android/androidEntityInnerClass/");
}
@TestMetadata("fqNameInAttr")
public void testFqNameInAttr() throws Exception {
runTest("plugins/android-extensions/android-extensions-compiler/testData/codegen/android/fqNameInAttr/");
}
@TestMetadata("fqNameInTag")
public void testFqNameInTag() throws Exception {
runTest("plugins/android-extensions/android-extensions-compiler/testData/codegen/android/fqNameInTag/");
}
@TestMetadata("fragment")
public void testFragment() throws Exception {
runTest("plugins/android-extensions/android-extensions-compiler/testData/codegen/android/fragment/");
}
@TestMetadata("fragmentNoGetView")
public void testFragmentNoGetView() throws Exception {
runTest("plugins/android-extensions/android-extensions-compiler/testData/codegen/android/fragmentNoGetView/");
}
@TestMetadata("manyWidgets")
public void testManyWidgets() throws Exception {
runTest("plugins/android-extensions/android-extensions-compiler/testData/codegen/android/manyWidgets/");
}
@TestMetadata("multiFile")
public void testMultiFile() throws Exception {
runTest("plugins/android-extensions/android-extensions-compiler/testData/codegen/android/multiFile/");
}
@TestMetadata("singleFile")
public void testSingleFile() throws Exception {
runTest("plugins/android-extensions/android-extensions-compiler/testData/codegen/android/singleFile/");
}
@TestMetadata("view")
public void testView() throws Exception {
runTest("plugins/android-extensions/android-extensions-compiler/testData/codegen/android/view/");
}
}
@TestMetadata("plugins/android-extensions/android-extensions-compiler/testData/codegen/android")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Invoke extends AbstractAndroidIrBoxTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doFakeInvocationTest, TargetBackend.JVM_IR, testDataFilePath);
}
public void testAllFilesPresentInInvoke() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/android-extensions/android-extensions-compiler/testData/codegen/android"), Pattern.compile("^([^\\.]+)$"), null, TargetBackend.JVM_IR, false);
}
@TestMetadata("androidEntity")
public void testAndroidEntity() throws Exception {
runTest("plugins/android-extensions/android-extensions-compiler/testData/codegen/android/androidEntity/");
}
@TestMetadata("androidEntityInnerClass")
public void testAndroidEntityInnerClass() throws Exception {
runTest("plugins/android-extensions/android-extensions-compiler/testData/codegen/android/androidEntityInnerClass/");
}
@TestMetadata("fqNameInAttr")
public void testFqNameInAttr() throws Exception {
runTest("plugins/android-extensions/android-extensions-compiler/testData/codegen/android/fqNameInAttr/");
}
@TestMetadata("fqNameInTag")
public void testFqNameInTag() throws Exception {
runTest("plugins/android-extensions/android-extensions-compiler/testData/codegen/android/fqNameInTag/");
}
@TestMetadata("fragment")
public void testFragment() throws Exception {
runTest("plugins/android-extensions/android-extensions-compiler/testData/codegen/android/fragment/");
}
@TestMetadata("fragmentNoGetView")
public void testFragmentNoGetView() throws Exception {
runTest("plugins/android-extensions/android-extensions-compiler/testData/codegen/android/fragmentNoGetView/");
}
@TestMetadata("manyWidgets")
public void testManyWidgets() throws Exception {
runTest("plugins/android-extensions/android-extensions-compiler/testData/codegen/android/manyWidgets/");
}
@TestMetadata("multiFile")
public void testMultiFile() throws Exception {
runTest("plugins/android-extensions/android-extensions-compiler/testData/codegen/android/multiFile/");
}
@TestMetadata("singleFile")
public void testSingleFile() throws Exception {
runTest("plugins/android-extensions/android-extensions-compiler/testData/codegen/android/singleFile/");
}
@TestMetadata("view")
public void testView() throws Exception {
runTest("plugins/android-extensions/android-extensions-compiler/testData/codegen/android/view/");
}
}
}
@@ -10,11 +10,13 @@ import kotlinx.android.extensions.CacheImplementation
import org.jetbrains.kotlin.android.synthetic.AndroidConfigurationKeys
import org.jetbrains.kotlin.android.synthetic.AndroidExtensionPropertiesComponentContainerContributor
import org.jetbrains.kotlin.android.synthetic.codegen.CliAndroidExtensionsExpressionCodegenExtension
import org.jetbrains.kotlin.android.synthetic.codegen.CliAndroidIrExtension
import org.jetbrains.kotlin.android.synthetic.codegen.CliAndroidOnDestroyClassBuilderInterceptorExtension
import org.jetbrains.kotlin.android.synthetic.res.AndroidLayoutXmlFileManager
import org.jetbrains.kotlin.android.synthetic.res.AndroidVariant
import org.jetbrains.kotlin.android.synthetic.res.CliAndroidLayoutXmlFileManager
import org.jetbrains.kotlin.android.synthetic.res.CliAndroidPackageFragmentProviderExtension
import org.jetbrains.kotlin.backend.common.extensions.IrGenerationExtension
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
import org.jetbrains.kotlin.cli.jvm.config.JvmClasspathRoot
@@ -38,6 +40,7 @@ fun KtUsefulTestCase.createTestEnvironment(configuration: CompilerConfiguration,
project.registerServiceInstance(AndroidLayoutXmlFileManager::class.java, CliAndroidLayoutXmlFileManager(project, "test", variants))
ExpressionCodegenExtension.registerExtension(project, CliAndroidExtensionsExpressionCodegenExtension(true, CacheImplementation.DEFAULT))
IrGenerationExtension.registerExtension(project, CliAndroidIrExtension(true, CacheImplementation.DEFAULT))
StorageComponentContainerContributor.registerExtension(project, AndroidExtensionPropertiesComponentContainerContributor())
ClassBuilderInterceptorExtension.registerExtension(
project, CliAndroidOnDestroyClassBuilderInterceptorExtension(CacheImplementation.DEFAULT)