[AllOpen] Migrate AllOpen tests to new test infrastructure

This commit is contained in:
Dmitriy Novozhilov
2022-05-13 14:19:28 +03:00
committed by teamcity
parent 9e9c9530e7
commit 01664da0a3
22 changed files with 157 additions and 78 deletions
+10 -4
View File
@@ -1,4 +1,3 @@
description = "Kotlin AllOpen Compiler Plugin"
plugins {
@@ -15,15 +14,21 @@ dependencies {
testApi(project(":compiler:backend"))
testApi(project(":compiler:cli"))
testApi(projectTests(":compiler:tests-common"))
testApi(commonDependency("junit:junit"))
testApi(intellijCore())
testApiJUnit5()
testApi(projectTests(":compiler:tests-common-new"))
testApi(projectTests(":compiler:test-infrastructure"))
testApi(projectTests(":compiler:test-infrastructure-utils"))
}
sourceSets {
"main" { projectDefault() }
"test" { projectDefault() }
"test" {
projectDefault()
generatedTestDir()
}
}
runtimeJar()
@@ -36,4 +41,5 @@ testsJar()
projectTest(parallel = true) {
workingDir = rootDir
useJUnitPlatform()
}
@@ -16,25 +16,52 @@
package org.jetbrains.kotlin.allopen
import org.jetbrains.kotlin.ObsoleteTestInfrastructure
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.Constructor
import org.jetbrains.kotlin.test.TargetBackend
import org.jetbrains.kotlin.test.backend.classic.ClassicBackendInput
import org.jetbrains.kotlin.test.backend.classic.ClassicJvmBackendFacade
import org.jetbrains.kotlin.test.backend.ir.IrBackendInput
import org.jetbrains.kotlin.test.backend.ir.JvmIrBackendFacade
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
import org.jetbrains.kotlin.test.frontend.classic.ClassicFrontend2ClassicBackendConverter
import org.jetbrains.kotlin.test.frontend.classic.ClassicFrontend2IrConverter
import org.jetbrains.kotlin.test.frontend.classic.ClassicFrontendFacade
import org.jetbrains.kotlin.test.frontend.classic.ClassicFrontendOutputArtifact
import org.jetbrains.kotlin.test.model.*
import org.jetbrains.kotlin.test.runners.codegen.AbstractBytecodeListingTestBase
@OptIn(ObsoleteTestInfrastructure::class)
abstract class AbstractBytecodeListingTestForAllOpen : AbstractBytecodeListingTest() {
override fun setupEnvironment(environment: KotlinCoreEnvironment) {
val annotations = AbstractAllOpenDeclarationAttributeAltererExtension.ANNOTATIONS_FOR_TESTS +
AllOpenCommandLineProcessor.SUPPORTED_PRESETS.flatMap { it.value }
DeclarationAttributeAltererExtension.registerExtension(
environment.project,
CliAllOpenDeclarationAttributeAltererExtension(annotations)
)
abstract class AbstractBytecodeListingTestForAllOpenBase<R : ResultingArtifact.FrontendOutput<R>, I : ResultingArtifact.BackendInput<I>>(
targetBackend: TargetBackend,
targetFrontend: FrontendKind<R>
) : AbstractBytecodeListingTestBase<R, I>(targetBackend, targetFrontend){
override fun configure(builder: TestConfigurationBuilder) {
super.configure(builder)
builder.apply {
useConfigurators(::AllOpenEnvironmentConfigurator)
}
}
}
abstract class AbstractIrBytecodeListingTestForAllOpen : AbstractBytecodeListingTestForAllOpen() {
override val backend = TargetBackend.JVM_IR
open class AbstractBytecodeListingTestForAllOpen :
AbstractBytecodeListingTestForAllOpenBase<ClassicFrontendOutputArtifact, ClassicBackendInput>(
TargetBackend.JVM, FrontendKinds.ClassicFrontend
) {
override val frontendFacade: Constructor<FrontendFacade<ClassicFrontendOutputArtifact>>
get() = ::ClassicFrontendFacade
override val frontendToBackendConverter: Constructor<Frontend2BackendConverter<ClassicFrontendOutputArtifact, ClassicBackendInput>>
get() = ::ClassicFrontend2ClassicBackendConverter
override val backendFacade: Constructor<BackendFacade<ClassicBackendInput, BinaryArtifacts.Jvm>>
get() = ::ClassicJvmBackendFacade
}
open class AbstractIrBytecodeListingTestForAllOpen :
AbstractBytecodeListingTestForAllOpenBase<ClassicFrontendOutputArtifact, IrBackendInput>(
TargetBackend.JVM_IR, FrontendKinds.ClassicFrontend
) {
override val frontendFacade: Constructor<FrontendFacade<ClassicFrontendOutputArtifact>>
get() = ::ClassicFrontendFacade
override val frontendToBackendConverter: Constructor<Frontend2BackendConverter<ClassicFrontendOutputArtifact, IrBackendInput>>
get() = ::ClassicFrontend2IrConverter
override val backendFacade: Constructor<BackendFacade<IrBackendInput, BinaryArtifacts.Jvm>>
get() = ::JvmIrBackendFacade
}
@@ -0,0 +1,25 @@
/*
* Copyright 2010-2022 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.openapi.project.Project
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.extensions.DeclarationAttributeAltererExtension
import org.jetbrains.kotlin.test.model.TestModule
import org.jetbrains.kotlin.test.services.EnvironmentConfigurator
import org.jetbrains.kotlin.test.services.TestServices
class AllOpenEnvironmentConfigurator(testServices: TestServices) : EnvironmentConfigurator(testServices) {
override fun registerCompilerExtensions(project: Project, module: TestModule, configuration: CompilerConfiguration) {
val annotations = AbstractAllOpenDeclarationAttributeAltererExtension.ANNOTATIONS_FOR_TESTS +
AllOpenCommandLineProcessor.SUPPORTED_PRESETS.flatMap { it.value }
DeclarationAttributeAltererExtension.registerExtension(
project,
CliAllOpenDeclarationAttributeAltererExtension(annotations)
)
}
}
@@ -1,5 +1,5 @@
@AllOpen
@java.lang.annotation.Retention
@java.lang.annotation.Retention(value=RUNTIME)
@kotlin.Metadata
public annotation class AllOpen {
// source: 'allOpenOnNotClasses.kt'
@@ -1,5 +1,5 @@
@AllOpen
@java.lang.annotation.Retention
@java.lang.annotation.Retention(value=RUNTIME)
@kotlin.Metadata
public annotation class AllOpen {
// source: 'allOpenOnNotClasses.kt'
@@ -1,4 +1,4 @@
@java.lang.annotation.Retention
@java.lang.annotation.Retention(value=RUNTIME)
@kotlin.Metadata
public annotation class AllOpen {
// source: 'alreadyOpen.kt'
@@ -1,4 +1,4 @@
@java.lang.annotation.Retention
@java.lang.annotation.Retention(value=RUNTIME)
@kotlin.Metadata
public annotation class AllOpen {
// source: 'annotationMembers.kt'
@@ -18,7 +18,7 @@ public final class MyComponent$Companion {
}
@AllOpen
@java.lang.annotation.Retention
@java.lang.annotation.Retention(value=RUNTIME)
@kotlin.Metadata
public annotation class MyComponent {
// source: 'annotationMembers.kt'
@@ -44,7 +44,7 @@ public final class Plain$Companion {
public final inner class Plain$Companion
}
@java.lang.annotation.Retention
@java.lang.annotation.Retention(value=RUNTIME)
@kotlin.Metadata
public annotation class Plain {
// source: 'annotationMembers.kt'
@@ -1,4 +1,4 @@
@java.lang.annotation.Retention
@java.lang.annotation.Retention(value=RUNTIME)
@kotlin.Metadata
public annotation class AllOpen {
// source: 'anonymousObject.kt'
@@ -1,4 +1,4 @@
@java.lang.annotation.Retention
@java.lang.annotation.Retention(value=RUNTIME)
@kotlin.Metadata
public annotation class AllOpen {
// source: 'anonymousObject.kt'
@@ -1,4 +1,4 @@
@java.lang.annotation.Retention
@java.lang.annotation.Retention(value=RUNTIME)
@kotlin.Metadata
public annotation class AllOpen {
// source: 'explicitFinal.kt'
@@ -1,11 +1,11 @@
@java.lang.annotation.Retention
@java.lang.annotation.Retention(value=RUNTIME)
@kotlin.Metadata
public annotation class AllOpen {
// source: 'metaAnnotation.kt'
}
@OtherComponent
@java.lang.annotation.Retention
@java.lang.annotation.Retention(value=RUNTIME)
@kotlin.Metadata
public annotation class AnotherComponent {
// source: 'metaAnnotation.kt'
@@ -19,14 +19,14 @@ public final class ClassWithDocumented {
}
@java.lang.annotation.Documented
@java.lang.annotation.Retention
@java.lang.annotation.Retention(value=RUNTIME)
@kotlin.Metadata
public annotation class Documented {
// source: 'metaAnnotation.kt'
}
@AllOpen
@java.lang.annotation.Retention
@java.lang.annotation.Retention(value=RUNTIME)
@kotlin.Metadata
public annotation class MyComponent {
// source: 'metaAnnotation.kt'
@@ -61,7 +61,7 @@ public class MyComponentImpl_ShouldBeOpen {
}
@MyComponent
@java.lang.annotation.Retention
@java.lang.annotation.Retention(value=RUNTIME)
@kotlin.Metadata
public annotation class OtherComponent {
// source: 'metaAnnotation.kt'
@@ -1,4 +1,4 @@
@java.lang.annotation.Retention
@java.lang.annotation.Retention(value=RUNTIME)
@kotlin.Metadata
public annotation class AllOpen {
// source: 'nestedInner.kt'
@@ -13,10 +13,10 @@ class Test {
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
public @org.jetbrains.annotations.NotNull method getInternalProp$main(): 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
public method internalMethod$main(): void
private method privateMethod(): void
private method privateTailrecMethod(): void
protected method protectedMethod(): void
@@ -13,10 +13,10 @@ class Test {
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
public @org.jetbrains.annotations.NotNull method getInternalProp$main(): 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
public method internalMethod$main(): void
private method privateMethod(): void
private method privateTailrecMethod(): void
protected method protectedMethod(): void
@@ -1,4 +1,4 @@
@java.lang.annotation.Retention
@java.lang.annotation.Retention(value=RUNTIME)
@kotlin.Metadata
public annotation class AllOpen {
// source: 'sealed.kt'
@@ -1,10 +1,10 @@
@java.lang.annotation.Retention
@java.lang.annotation.Retention(value=RUNTIME)
@kotlin.Metadata
public annotation class AllOpen {
// source: 'severalAllOpen.kt'
}
@java.lang.annotation.Retention
@java.lang.annotation.Retention(value=RUNTIME)
@kotlin.Metadata
public annotation class AllOpen2 {
// source: 'severalAllOpen.kt'
@@ -1,4 +1,4 @@
@java.lang.annotation.Retention
@java.lang.annotation.Retention(value=RUNTIME)
@kotlin.Metadata
public annotation class AllOpen {
// source: 'simple.kt'
@@ -1,28 +1,28 @@
@java.lang.annotation.Retention
@java.lang.annotation.Retention(value=RUNTIME)
@kotlin.Metadata
public annotation class org/springframework/boot/test/context/SpringBootTest {
// source: 'springBootTest.kt'
}
@java.lang.annotation.Retention
@java.lang.annotation.Retention(value=RUNTIME)
@kotlin.Metadata
public annotation class org/springframework/cache/annotation/Cacheable {
// source: 'cacheable.kt'
}
@java.lang.annotation.Retention
@java.lang.annotation.Retention(value=RUNTIME)
@kotlin.Metadata
public annotation class org/springframework/scheduling/annotation/Async {
// source: 'async.kt'
}
@java.lang.annotation.Retention
@java.lang.annotation.Retention(value=RUNTIME)
@kotlin.Metadata
public annotation class org/springframework/stereotype/Component {
// source: 'component.kt'
}
@java.lang.annotation.Retention
@java.lang.annotation.Retention(value=RUNTIME)
@kotlin.Metadata
public annotation class org/springframework/transaction/annotation/Transactional {
// source: 'transactional.kt'
@@ -1,4 +1,4 @@
@java.lang.annotation.Retention
@java.lang.annotation.Retention(value=RUNTIME)
@kotlin.Metadata
public annotation class AllOpen {
// source: 'superClassAnnotation.kt'
@@ -6,94 +6,104 @@
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.TargetBackend;
import org.jetbrains.kotlin.test.TestMetadata;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
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 */
/** This class is generated by {@link GenerateNewCompilerTests.kt}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("plugins/allopen/allopen-cli/testData/bytecodeListing")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public class BytecodeListingTestForAllOpenGenerated extends AbstractBytecodeListingTestForAllOpen {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
@Test
public void testAllFilesPresentInBytecodeListing() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/allopen/allopen-cli/testData/bytecodeListing"), Pattern.compile("^(.+)\\.kt$"), null, true);
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/allopen/allopen-cli/testData/bytecodeListing"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), TargetBackend.JVM, true);
}
@Test
@TestMetadata("allOpenOnNotClasses.kt")
public void testAllOpenOnNotClasses() throws Exception {
runTest("plugins/allopen/allopen-cli/testData/bytecodeListing/allOpenOnNotClasses.kt");
}
@Test
@TestMetadata("alreadyOpen.kt")
public void testAlreadyOpen() throws Exception {
runTest("plugins/allopen/allopen-cli/testData/bytecodeListing/alreadyOpen.kt");
}
@Test
@TestMetadata("annotationMembers.kt")
public void testAnnotationMembers() throws Exception {
runTest("plugins/allopen/allopen-cli/testData/bytecodeListing/annotationMembers.kt");
}
@Test
@TestMetadata("anonymousObject.kt")
public void testAnonymousObject() throws Exception {
runTest("plugins/allopen/allopen-cli/testData/bytecodeListing/anonymousObject.kt");
}
@Test
@TestMetadata("explicitFinal.kt")
public void testExplicitFinal() throws Exception {
runTest("plugins/allopen/allopen-cli/testData/bytecodeListing/explicitFinal.kt");
}
@Test
@TestMetadata("metaAnnotation.kt")
public void testMetaAnnotation() throws Exception {
runTest("plugins/allopen/allopen-cli/testData/bytecodeListing/metaAnnotation.kt");
}
@Test
@TestMetadata("nestedInner.kt")
public void testNestedInner() throws Exception {
runTest("plugins/allopen/allopen-cli/testData/bytecodeListing/nestedInner.kt");
}
@Test
@TestMetadata("noAllOpen.kt")
public void testNoAllOpen() throws Exception {
runTest("plugins/allopen/allopen-cli/testData/bytecodeListing/noAllOpen.kt");
}
@Test
@TestMetadata("privateMembers.kt")
public void testPrivateMembers() throws Exception {
runTest("plugins/allopen/allopen-cli/testData/bytecodeListing/privateMembers.kt");
}
@Test
@TestMetadata("sealed.kt")
public void testSealed() throws Exception {
runTest("plugins/allopen/allopen-cli/testData/bytecodeListing/sealed.kt");
}
@Test
@TestMetadata("severalAllOpen.kt")
public void testSeveralAllOpen() throws Exception {
runTest("plugins/allopen/allopen-cli/testData/bytecodeListing/severalAllOpen.kt");
}
@Test
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
runTest("plugins/allopen/allopen-cli/testData/bytecodeListing/simple.kt");
}
@Test
@TestMetadata("springAnnotations.kt")
public void testSpringAnnotations() throws Exception {
runTest("plugins/allopen/allopen-cli/testData/bytecodeListing/springAnnotations.kt");
}
@Test
@TestMetadata("superClassAnnotation.kt")
public void testSuperClassAnnotation() throws Exception {
runTest("plugins/allopen/allopen-cli/testData/bytecodeListing/superClassAnnotation.kt");
@@ -6,94 +6,104 @@
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.TargetBackend;
import org.jetbrains.kotlin.test.TestMetadata;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
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 */
/** This class is generated by {@link GenerateNewCompilerTests.kt}. 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);
}
@Test
public void testAllFilesPresentInBytecodeListing() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/allopen/allopen-cli/testData/bytecodeListing"), Pattern.compile("^(.+)\\.kt$"), null, true);
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/allopen/allopen-cli/testData/bytecodeListing"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("allOpenOnNotClasses.kt")
public void testAllOpenOnNotClasses() throws Exception {
runTest("plugins/allopen/allopen-cli/testData/bytecodeListing/allOpenOnNotClasses.kt");
}
@Test
@TestMetadata("alreadyOpen.kt")
public void testAlreadyOpen() throws Exception {
runTest("plugins/allopen/allopen-cli/testData/bytecodeListing/alreadyOpen.kt");
}
@Test
@TestMetadata("annotationMembers.kt")
public void testAnnotationMembers() throws Exception {
runTest("plugins/allopen/allopen-cli/testData/bytecodeListing/annotationMembers.kt");
}
@Test
@TestMetadata("anonymousObject.kt")
public void testAnonymousObject() throws Exception {
runTest("plugins/allopen/allopen-cli/testData/bytecodeListing/anonymousObject.kt");
}
@Test
@TestMetadata("explicitFinal.kt")
public void testExplicitFinal() throws Exception {
runTest("plugins/allopen/allopen-cli/testData/bytecodeListing/explicitFinal.kt");
}
@Test
@TestMetadata("metaAnnotation.kt")
public void testMetaAnnotation() throws Exception {
runTest("plugins/allopen/allopen-cli/testData/bytecodeListing/metaAnnotation.kt");
}
@Test
@TestMetadata("nestedInner.kt")
public void testNestedInner() throws Exception {
runTest("plugins/allopen/allopen-cli/testData/bytecodeListing/nestedInner.kt");
}
@Test
@TestMetadata("noAllOpen.kt")
public void testNoAllOpen() throws Exception {
runTest("plugins/allopen/allopen-cli/testData/bytecodeListing/noAllOpen.kt");
}
@Test
@TestMetadata("privateMembers.kt")
public void testPrivateMembers() throws Exception {
runTest("plugins/allopen/allopen-cli/testData/bytecodeListing/privateMembers.kt");
}
@Test
@TestMetadata("sealed.kt")
public void testSealed() throws Exception {
runTest("plugins/allopen/allopen-cli/testData/bytecodeListing/sealed.kt");
}
@Test
@TestMetadata("severalAllOpen.kt")
public void testSeveralAllOpen() throws Exception {
runTest("plugins/allopen/allopen-cli/testData/bytecodeListing/severalAllOpen.kt");
}
@Test
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
runTest("plugins/allopen/allopen-cli/testData/bytecodeListing/simple.kt");
}
@Test
@TestMetadata("springAnnotations.kt")
public void testSpringAnnotations() throws Exception {
runTest("plugins/allopen/allopen-cli/testData/bytecodeListing/springAnnotations.kt");
}
@Test
@TestMetadata("superClassAnnotation.kt")
public void testSuperClassAnnotation() throws Exception {
runTest("plugins/allopen/allopen-cli/testData/bytecodeListing/superClassAnnotation.kt");