Add bytecode listing tests for 'allopen' plugin with JVM_IR

This commit is contained in:
Dmitry Petrov
2021-03-18 15:05:38 +03:00
committed by TeamCityServer
parent e4d98d4e39
commit 2fd69a5718
8 changed files with 221 additions and 4 deletions
@@ -9,6 +9,7 @@ import org.jetbrains.kotlin.AbstractDataFlowValueRenderingTest
import org.jetbrains.kotlin.addImport.AbstractAddImportTest
import org.jetbrains.kotlin.addImportAlias.AbstractAddImportAliasTest
import org.jetbrains.kotlin.allopen.AbstractBytecodeListingTestForAllOpen
import org.jetbrains.kotlin.allopen.AbstractIrBytecodeListingTestForAllOpen
import org.jetbrains.kotlin.android.parcel.AbstractParcelBoxTest
import org.jetbrains.kotlin.android.parcel.AbstractParcelBytecodeListingTest
import org.jetbrains.kotlin.android.parcel.AbstractParcelIrBoxTest
@@ -1755,6 +1756,9 @@ fun main(args: Array<String>) {
testClass<AbstractBytecodeListingTestForAllOpen> {
model("bytecodeListing", extension = "kt")
}
testClass<AbstractIrBytecodeListingTestForAllOpen> {
model("bytecodeListing", extension = "kt")
}
}
testGroup("plugins/noarg/noarg-cli/test", "plugins/noarg/noarg-cli/testData") {
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.generators.tests
import org.jetbrains.kotlin.AbstractDataFlowValueRenderingTest
import org.jetbrains.kotlin.addImport.AbstractAddImportTest
import org.jetbrains.kotlin.allopen.AbstractBytecodeListingTestForAllOpen
import org.jetbrains.kotlin.allopen.AbstractIrBytecodeListingTestForAllOpen
import org.jetbrains.kotlin.android.parcel.AbstractParcelBytecodeListingTest
import org.jetbrains.kotlin.android.synthetic.test.AbstractAndroidBoxTest
import org.jetbrains.kotlin.android.synthetic.test.AbstractAndroidBytecodeShapeTest
@@ -1181,6 +1182,9 @@ fun main(args: Array<String>) {
testClass<AbstractBytecodeListingTestForAllOpen> {
model("bytecodeListing", extension = "kt")
}
testClass<AbstractIrBytecodeListingTestForAllOpen> {
model("bytecodeListing", extension = "kt")
}
}
testGroup("plugins/noarg/noarg-cli/test", "plugins/noarg/noarg-cli/testData") {
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.generators.tests
import org.jetbrains.kotlin.AbstractDataFlowValueRenderingTest
import org.jetbrains.kotlin.addImport.AbstractAddImportTest
import org.jetbrains.kotlin.allopen.AbstractBytecodeListingTestForAllOpen
import org.jetbrains.kotlin.allopen.AbstractIrBytecodeListingTestForAllOpen
import org.jetbrains.kotlin.android.parcel.AbstractParcelBytecodeListingTest
import org.jetbrains.kotlin.android.synthetic.test.AbstractAndroidBoxTest
import org.jetbrains.kotlin.android.synthetic.test.AbstractAndroidBytecodeShapeTest
@@ -1109,6 +1110,9 @@ fun main(args: Array<String>) {
testClass<AbstractBytecodeListingTestForAllOpen> {
model("bytecodeListing", extension = "kt")
}
testClass<AbstractIrBytecodeListingTestForAllOpen> {
model("bytecodeListing", extension = "kt")
}
}
testGroup("plugins/noarg/noarg-cli/test", "plugins/noarg/noarg-cli/testData") {
@@ -19,14 +19,20 @@ package org.jetbrains.kotlin.allopen
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
import org.jetbrains.kotlin.codegen.AbstractBytecodeListingTest
import org.jetbrains.kotlin.extensions.DeclarationAttributeAltererExtension
import org.jetbrains.kotlin.test.TargetBackend
abstract class AbstractBytecodeListingTestForAllOpen : AbstractBytecodeListingTest() {
override fun setupEnvironment(environment: KotlinCoreEnvironment) {
val annotations = AbstractAllOpenDeclarationAttributeAltererExtension.ANNOTATIONS_FOR_TESTS +
AllOpenCommandLineProcessor.SUPPORTED_PRESETS.flatMap { it.value }
AllOpenCommandLineProcessor.SUPPORTED_PRESETS.flatMap { it.value }
DeclarationAttributeAltererExtension.registerExtension(
environment.project,
CliAllOpenDeclarationAttributeAltererExtension(annotations))
environment.project,
CliAllOpenDeclarationAttributeAltererExtension(annotations)
)
}
}
}
abstract class AbstractIrBytecodeListingTestForAllOpen : AbstractBytecodeListingTestForAllOpen() {
override val backend = TargetBackend.JVM_IR
}
@@ -0,0 +1,96 @@
/*
* Copyright 2010-2021 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.allopen;
import com.intellij.testFramework.TestDataPath;
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
import org.jetbrains.kotlin.test.KotlinTestUtils;
import org.jetbrains.kotlin.test.util.KtTestUtil;
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")
@TestMetadata("plugins/allopen/allopen-cli/testData/bytecodeListing")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public class IrBytecodeListingTestForAllOpenGenerated extends AbstractIrBytecodeListingTestForAllOpen {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public void testAllFilesPresentInBytecodeListing() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/allopen/allopen-cli/testData/bytecodeListing"), Pattern.compile("^(.+)\\.kt$"), null, true);
}
@TestMetadata("allOpenOnNotClasses.kt")
public void testAllOpenOnNotClasses() throws Exception {
runTest("plugins/allopen/allopen-cli/testData/bytecodeListing/allOpenOnNotClasses.kt");
}
@TestMetadata("alreadyOpen.kt")
public void testAlreadyOpen() throws Exception {
runTest("plugins/allopen/allopen-cli/testData/bytecodeListing/alreadyOpen.kt");
}
@TestMetadata("anonymousObject.kt")
public void testAnonymousObject() throws Exception {
runTest("plugins/allopen/allopen-cli/testData/bytecodeListing/anonymousObject.kt");
}
@TestMetadata("explicitFinal.kt")
public void testExplicitFinal() throws Exception {
runTest("plugins/allopen/allopen-cli/testData/bytecodeListing/explicitFinal.kt");
}
@TestMetadata("metaAnnotation.kt")
public void testMetaAnnotation() throws Exception {
runTest("plugins/allopen/allopen-cli/testData/bytecodeListing/metaAnnotation.kt");
}
@TestMetadata("nestedInner.kt")
public void testNestedInner() throws Exception {
runTest("plugins/allopen/allopen-cli/testData/bytecodeListing/nestedInner.kt");
}
@TestMetadata("noAllOpen.kt")
public void testNoAllOpen() throws Exception {
runTest("plugins/allopen/allopen-cli/testData/bytecodeListing/noAllOpen.kt");
}
@TestMetadata("privateMembers.kt")
public void testPrivateMembers() throws Exception {
runTest("plugins/allopen/allopen-cli/testData/bytecodeListing/privateMembers.kt");
}
@TestMetadata("sealed.kt")
public void testSealed() throws Exception {
runTest("plugins/allopen/allopen-cli/testData/bytecodeListing/sealed.kt");
}
@TestMetadata("severalAllOpen.kt")
public void testSeveralAllOpen() throws Exception {
runTest("plugins/allopen/allopen-cli/testData/bytecodeListing/severalAllOpen.kt");
}
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
runTest("plugins/allopen/allopen-cli/testData/bytecodeListing/simple.kt");
}
@TestMetadata("springAnnotations.kt")
public void testSpringAnnotations() throws Exception {
runTest("plugins/allopen/allopen-cli/testData/bytecodeListing/springAnnotations.kt");
}
@TestMetadata("superClassAnnotation.kt")
public void testSuperClassAnnotation() throws Exception {
runTest("plugins/allopen/allopen-cli/testData/bytecodeListing/superClassAnnotation.kt");
}
}
@@ -0,0 +1,43 @@
@AllOpen
@java.lang.annotation.Retention
@kotlin.Metadata
public annotation class AllOpen {
// source: 'allOpenOnNotClasses.kt'
}
@AllOpen
@kotlin.Metadata
public final enum class Enum {
// source: 'allOpenOnNotClasses.kt'
private synthetic final static field $VALUES: Enum[]
private synthetic final static method $values(): Enum[]
static method <clinit>(): void
private method <init>(p0: java.lang.String, p1: int): void
public static method valueOf(p0: java.lang.String): Enum
public static method values(): Enum[]
}
@AllOpen
@kotlin.Metadata
public interface Intf {
// source: 'allOpenOnNotClasses.kt'
}
@kotlin.Metadata
public final class MyClass {
// source: 'allOpenOnNotClasses.kt'
private @AllOpen @org.jetbrains.annotations.NotNull field prop: java.lang.String
public method <init>(): void
public final @AllOpen @org.jetbrains.annotations.NotNull method getProp(): java.lang.String
public final @AllOpen method method(): void
public final @AllOpen method setProp(@org.jetbrains.annotations.NotNull p0: java.lang.String): void
}
@AllOpen
@kotlin.Metadata
public final class Obj {
// source: 'allOpenOnNotClasses.kt'
public final static @org.jetbrains.annotations.NotNull field INSTANCE: Obj
static method <clinit>(): void
private method <init>(): void
}
@@ -0,0 +1,36 @@
@java.lang.annotation.Retention
@kotlin.Metadata
public annotation class AllOpen {
// source: 'anonymousObject.kt'
}
@kotlin.Metadata
public final class Test$a$1 {
// source: 'anonymousObject.kt'
enclosing method Test.<init>()V
inner (anonymous) class Test$a$1
method <init>(): void
public method run(): void
}
@kotlin.Metadata
public final class Test$b$1 {
// source: 'anonymousObject.kt'
enclosing method Test.b()V
inner (anonymous) class Test$b$1
method <init>(): void
public method run(): void
}
@AllOpen
@kotlin.Metadata
public class Test {
// source: 'anonymousObject.kt'
private final @org.jetbrains.annotations.NotNull field a: java.lang.Runnable
inner (anonymous) class Test$a$1
inner (anonymous) class Test$b$1
public method <init>(): void
private final static method b$lambda-0(): void
public method b(): void
public @org.jetbrains.annotations.NotNull method getA(): java.lang.Runnable
}
@@ -0,0 +1,24 @@
@java.lang.annotation.Retention
@kotlin.Metadata
public annotation class AllOpen {
// source: 'privateMembers.kt'
}
@AllOpen
@kotlin.Metadata
final class Test {
// source: 'privateMembers.kt'
private final @org.jetbrains.annotations.NotNull field internalProp: java.lang.String
private final @org.jetbrains.annotations.NotNull field privateProp: java.lang.String
private final @org.jetbrains.annotations.NotNull field protectedProp: java.lang.String
private final @org.jetbrains.annotations.NotNull field publicProp: java.lang.String
public method <init>(): void
public @org.jetbrains.annotations.NotNull method getInternalProp$test_module(): java.lang.String
protected @org.jetbrains.annotations.NotNull method getProtectedProp(): java.lang.String
public @org.jetbrains.annotations.NotNull method getPublicProp(): java.lang.String
public method internalMethod$test_module(): void
private final method privateMethod(): void
private final method privateTailrecMethod(): void
protected method protectedMethod(): void
public method publicMethod(): void
}