From 4ac38e5f292f26388ab028b8141fe8795ee844fb Mon Sep 17 00:00:00 2001 From: Ivan Kylchik Date: Thu, 4 Feb 2021 20:23:04 +0300 Subject: [PATCH] Rewrite compiler visualizer tests using new test infrastructure --- .../generators/GenerateJUnit3CompilerTests.kt | 20 --- .../generators/GenerateJUnit5CompilerTests.kt | 22 ++++ compiler/visualizer/build.gradle.kts | 20 ++- .../FirVisualizerForRawFirDataGenerated.java | 118 ++++++++++++------ ...irVisualizerForUncommonCasesGenerated.java | 22 ++-- .../PsiVisualizerForRawFirDataGenerated.java | 118 ++++++++++++------ ...siVisualizerForUncommonCasesGenerated.java | 22 ++-- .../kotlin/visualizer/AbstractVisualizer.kt | 84 ++++++++----- .../visualizer/fir/AbstractFirVisualizer.kt | 79 +++++------- .../visualizer/psi/AbstractPsiVisualizer.kt | 34 +++-- 10 files changed, 326 insertions(+), 213 deletions(-) diff --git a/compiler/tests-for-compiler-generator/tests/org/jetbrains/kotlin/test/generators/GenerateJUnit3CompilerTests.kt b/compiler/tests-for-compiler-generator/tests/org/jetbrains/kotlin/test/generators/GenerateJUnit3CompilerTests.kt index 59cb06b003b..eb008af25c0 100644 --- a/compiler/tests-for-compiler-generator/tests/org/jetbrains/kotlin/test/generators/GenerateJUnit3CompilerTests.kt +++ b/compiler/tests-for-compiler-generator/tests/org/jetbrains/kotlin/test/generators/GenerateJUnit3CompilerTests.kt @@ -516,25 +516,5 @@ fun generateJUnit3CompilerTests(args: Array) { model("lightClasses") } } - - testGroup("compiler/visualizer/tests-gen", "compiler/fir/raw-fir/psi2fir/testData") { - testClass("PsiVisualizerForRawFirDataGenerated") { - model("rawBuilder", testMethod = "doFirBuilderDataTest") - } - - testClass("FirVisualizerForRawFirDataGenerated") { - model("rawBuilder", testMethod = "doFirBuilderDataTest") - } - } - - testGroup("compiler/visualizer/tests-gen", "compiler/visualizer/testData") { - testClass("PsiVisualizerForUncommonCasesGenerated") { - model("uncommonCases/testFiles", testMethod = "doUncommonCasesTest") - } - - testClass("FirVisualizerForUncommonCasesGenerated") { - model("uncommonCases/testFiles", testMethod = "doUncommonCasesTest") - } - } } } diff --git a/compiler/tests-for-compiler-generator/tests/org/jetbrains/kotlin/test/generators/GenerateJUnit5CompilerTests.kt b/compiler/tests-for-compiler-generator/tests/org/jetbrains/kotlin/test/generators/GenerateJUnit5CompilerTests.kt index 5efc4bfc47c..c476205aa2f 100644 --- a/compiler/tests-for-compiler-generator/tests/org/jetbrains/kotlin/test/generators/GenerateJUnit5CompilerTests.kt +++ b/compiler/tests-for-compiler-generator/tests/org/jetbrains/kotlin/test/generators/GenerateJUnit5CompilerTests.kt @@ -12,6 +12,8 @@ import org.jetbrains.kotlin.test.runners.* import org.jetbrains.kotlin.test.runners.codegen.* import org.jetbrains.kotlin.test.runners.ir.AbstractFir2IrTextTest import org.jetbrains.kotlin.test.runners.ir.AbstractIrTextTest +import org.jetbrains.kotlin.visualizer.fir.AbstractFirVisualizer +import org.jetbrains.kotlin.visualizer.psi.AbstractPsiVisualizer import org.junit.jupiter.api.parallel.Execution import org.junit.jupiter.api.parallel.ExecutionMode @@ -155,5 +157,25 @@ fun generateJUnit5CompilerTests(args: Array) { model("codegen/bytecodeText") } } + + testGroup("compiler/visualizer/tests-gen", "compiler/fir/raw-fir/psi2fir/testData") { + testClass("PsiVisualizerForRawFirDataGenerated") { + model("rawBuilder") + } + + testClass("FirVisualizerForRawFirDataGenerated") { + model("rawBuilder") + } + } + + testGroup("compiler/visualizer/tests-gen", "compiler/visualizer/testData") { + testClass("PsiVisualizerForUncommonCasesGenerated") { + model("uncommonCases/testFiles") + } + + testClass("FirVisualizerForUncommonCasesGenerated") { + model("uncommonCases/testFiles") + } + } } } diff --git a/compiler/visualizer/build.gradle.kts b/compiler/visualizer/build.gradle.kts index 612da8d9f25..19bf8102006 100644 --- a/compiler/visualizer/build.gradle.kts +++ b/compiler/visualizer/build.gradle.kts @@ -11,12 +11,18 @@ dependencies { testCompileOnly(project(":compiler:fir:raw-fir:psi2fir")) - testCompileOnly(project(":compiler:visualizer:render-psi")) - testCompileOnly(project(":compiler:visualizer:render-fir")) + testImplementation(project(":compiler:visualizer:render-psi")) + testImplementation(project(":compiler:visualizer:render-fir")) - testCompile(commonDep("junit:junit")) - testCompile(projectTests(":compiler:tests-common")) - testCompile(projectTests(":compiler:fir:analysis-tests:legacy-fir-tests")) + testApi(platform("org.junit:junit-bom:5.7.0")) + testApi("org.junit.jupiter:junit-jupiter") + testApi("org.junit.platform:junit-platform-commons:1.7.0") + testApi("org.junit.platform:junit-platform-launcher:1.7.0") + + testImplementation(projectTests(":compiler:tests-common")) + testImplementation(projectTests(":compiler:tests-common-new")) + testImplementation(projectTests(":compiler:test-infrastructure")) + testImplementation(projectTests(":compiler:fir:analysis-tests:legacy-fir-tests")) } val generationRoot = projectDir.resolve("tests-gen") @@ -36,8 +42,10 @@ if (kotlinBuildProperties.isInJpsBuildIdeaSync) { } } -projectTest { +projectTest(parallel = true, jUnit5Enabled = true) { workingDir = rootDir + + useJUnitPlatform() } testsJar() diff --git a/compiler/visualizer/tests-gen/org/jetbrains/kotlin/visualizer/fir/FirVisualizerForRawFirDataGenerated.java b/compiler/visualizer/tests-gen/org/jetbrains/kotlin/visualizer/fir/FirVisualizerForRawFirDataGenerated.java index 53a4a1a5964..fd6ead63aaa 100644 --- a/compiler/visualizer/tests-gen/org/jetbrains/kotlin/visualizer/fir/FirVisualizerForRawFirDataGenerated.java +++ b/compiler/visualizer/tests-gen/org/jetbrains/kotlin/visualizer/fir/FirVisualizerForRawFirDataGenerated.java @@ -6,223 +6,236 @@ package org.jetbrains.kotlin.visualizer.fir; 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 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("compiler/fir/raw-fir/psi2fir/testData/rawBuilder") @TestDataPath("$PROJECT_ROOT") -@RunWith(JUnit3RunnerWithInners.class) public class FirVisualizerForRawFirDataGenerated extends AbstractFirVisualizer { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doFirBuilderDataTest, this, testDataFilePath); - } - + @Test public void testAllFilesPresentInRawBuilder() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/raw-fir/psi2fir/testData/rawBuilder"), Pattern.compile("^(.+)\\.kt$"), null, true); } + @Nested @TestMetadata("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations") @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Declarations extends AbstractFirVisualizer { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doFirBuilderDataTest, this, testDataFilePath); - } - + public class Declarations extends AbstractFirVisualizer { + @Test public void testAllFilesPresentInDeclarations() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations"), Pattern.compile("^(.+)\\.kt$"), null, true); } + @Test @TestMetadata("annotation.kt") public void testAnnotation() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/annotation.kt"); } + @Test @TestMetadata("complexTypes.kt") public void testComplexTypes() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/complexTypes.kt"); } + @Test @TestMetadata("constructorInObject.kt") public void testConstructorInObject() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/constructorInObject.kt"); } + @Test @TestMetadata("constructorOfAnonymousObject.kt") public void testConstructorOfAnonymousObject() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/constructorOfAnonymousObject.kt"); } + @Test @TestMetadata("delegates.kt") public void testDelegates() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/delegates.kt"); } + @Test @TestMetadata("derivedClass.kt") public void testDerivedClass() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/derivedClass.kt"); } + @Test @TestMetadata("emptyAnonymousObject.kt") public void testEmptyAnonymousObject() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/emptyAnonymousObject.kt"); } + @Test @TestMetadata("enums.kt") public void testEnums() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/enums.kt"); } + @Test @TestMetadata("enums2.kt") public void testEnums2() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/enums2.kt"); } + @Test @TestMetadata("expectActual.kt") public void testExpectActual() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/expectActual.kt"); } + @Test @TestMetadata("external.kt") public void testExternal() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/external.kt"); } + @Test @TestMetadata("F.kt") public void testF() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/F.kt"); } + @Test @TestMetadata("functionTypes.kt") public void testFunctionTypes() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/functionTypes.kt"); } + @Test @TestMetadata("genericFunctions.kt") public void testGenericFunctions() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/genericFunctions.kt"); } + @Test @TestMetadata("genericProperty.kt") public void testGenericProperty() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/genericProperty.kt"); } + @Test @TestMetadata("nestedClass.kt") public void testNestedClass() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/nestedClass.kt"); } + @Test @TestMetadata("NestedOfAliasedType.kt") public void testNestedOfAliasedType() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/NestedOfAliasedType.kt"); } + @Test @TestMetadata("NestedSuperType.kt") public void testNestedSuperType() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/NestedSuperType.kt"); } + @Test @TestMetadata("noPrimaryConstructor.kt") public void testNoPrimaryConstructor() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noPrimaryConstructor.kt"); } + @Test @TestMetadata("simpleClass.kt") public void testSimpleClass() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/simpleClass.kt"); } + @Test @TestMetadata("simpleFun.kt") public void testSimpleFun() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/simpleFun.kt"); } + @Test @TestMetadata("simpleTypeAlias.kt") public void testSimpleTypeAlias() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/simpleTypeAlias.kt"); } + @Test @TestMetadata("typeAliasWithGeneric.kt") public void testTypeAliasWithGeneric() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/typeAliasWithGeneric.kt"); } + @Test @TestMetadata("typeParameterVsNested.kt") public void testTypeParameterVsNested() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/typeParameterVsNested.kt"); } + @Test @TestMetadata("typeParameters.kt") public void testTypeParameters() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/typeParameters.kt"); } + @Test @TestMetadata("where.kt") public void testWhere() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/where.kt"); } + @Nested @TestMetadata("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/contracts") @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Contracts extends AbstractFirVisualizer { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doFirBuilderDataTest, this, testDataFilePath); - } - + public class Contracts extends AbstractFirVisualizer { + @Test public void testAllFilesPresentInContracts() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/contracts"), Pattern.compile("^(.+)\\.kt$"), null, true); } + @Nested @TestMetadata("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/contracts/newSyntax") @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class NewSyntax extends AbstractFirVisualizer { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doFirBuilderDataTest, this, testDataFilePath); - } - + public class NewSyntax extends AbstractFirVisualizer { + @Test public void testAllFilesPresentInNewSyntax() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/contracts/newSyntax"), Pattern.compile("^(.+)\\.kt$"), null, true); } + @Test @TestMetadata("functionWithBothOldAndNewSyntaxContractDescription.kt") public void testFunctionWithBothOldAndNewSyntaxContractDescription() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/contracts/newSyntax/functionWithBothOldAndNewSyntaxContractDescription.kt"); } + @Test @TestMetadata("propertyAccessorsContractDescription.kt") public void testPropertyAccessorsContractDescription() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/contracts/newSyntax/propertyAccessorsContractDescription.kt"); } + @Test @TestMetadata("simpleFunctionsContractDescription.kt") public void testSimpleFunctionsContractDescription() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/contracts/newSyntax/simpleFunctionsContractDescription.kt"); } } + @Nested @TestMetadata("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/contracts/oldSyntax") @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class OldSyntax extends AbstractFirVisualizer { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doFirBuilderDataTest, this, testDataFilePath); - } - + public class OldSyntax extends AbstractFirVisualizer { + @Test public void testAllFilesPresentInOldSyntax() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/contracts/oldSyntax"), Pattern.compile("^(.+)\\.kt$"), null, true); } + @Test @TestMetadata("contractDescription.kt") public void testContractDescription() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/contracts/oldSyntax/contractDescription.kt"); @@ -231,163 +244,190 @@ public class FirVisualizerForRawFirDataGenerated extends AbstractFirVisualizer { } } + @Nested @TestMetadata("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions") @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Expressions extends AbstractFirVisualizer { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doFirBuilderDataTest, this, testDataFilePath); - } - + public class Expressions extends AbstractFirVisualizer { + @Test public void testAllFilesPresentInExpressions() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions"), Pattern.compile("^(.+)\\.kt$"), null, true); } + @Test @TestMetadata("annotated.kt") public void testAnnotated() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/annotated.kt"); } + @Test @TestMetadata("arrayAccess.kt") public void testArrayAccess() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/arrayAccess.kt"); } + @Test @TestMetadata("arrayAssignment.kt") public void testArrayAssignment() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/arrayAssignment.kt"); } + @Test @TestMetadata("branches.kt") public void testBranches() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/branches.kt"); } + @Test @TestMetadata("callableReferences.kt") public void testCallableReferences() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/callableReferences.kt"); } + @Test @TestMetadata("calls.kt") public void testCalls() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/calls.kt"); } + @Test @TestMetadata("classReference.kt") public void testClassReference() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/classReference.kt"); } + @Test @TestMetadata("collectionLiterals.kt") public void testCollectionLiterals() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/collectionLiterals.kt"); } + @Test @TestMetadata("destructuring.kt") public void testDestructuring() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/destructuring.kt"); } + @Test @TestMetadata("for.kt") public void testFor() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/for.kt"); } + @Test @TestMetadata("genericCalls.kt") public void testGenericCalls() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/genericCalls.kt"); } + @Test @TestMetadata("in.kt") public void testIn() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/in.kt"); } + @Test @TestMetadata("inBrackets.kt") public void testInBrackets() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/inBrackets.kt"); } + @Test @TestMetadata("init.kt") public void testInit() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/init.kt"); } + @Test @TestMetadata("labelForInfix.kt") public void testLabelForInfix() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/labelForInfix.kt"); } + @Test @TestMetadata("lambda.kt") public void testLambda() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/lambda.kt"); } + @Test @TestMetadata("lambdaAndAnonymousFunction.kt") public void testLambdaAndAnonymousFunction() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/lambdaAndAnonymousFunction.kt"); } + @Test @TestMetadata("locals.kt") public void testLocals() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/locals.kt"); } + @Test @TestMetadata("modifications.kt") public void testModifications() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/modifications.kt"); } + @Test @TestMetadata("namedArgument.kt") public void testNamedArgument() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/namedArgument.kt"); } + @Test @TestMetadata("nullability.kt") public void testNullability() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/nullability.kt"); } + @Test @TestMetadata("qualifierWithTypeArguments.kt") public void testQualifierWithTypeArguments() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/qualifierWithTypeArguments.kt"); } + @Test @TestMetadata("simpleReturns.kt") public void testSimpleReturns() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/simpleReturns.kt"); } + @Test @TestMetadata("super.kt") public void testSuper() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/super.kt"); } + @Test @TestMetadata("these.kt") public void testThese() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/these.kt"); } + @Test @TestMetadata("try.kt") public void testTry() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/try.kt"); } + @Test @TestMetadata("typeOperators.kt") public void testTypeOperators() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/typeOperators.kt"); } + @Test @TestMetadata("unary.kt") public void testUnary() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/unary.kt"); } + @Test @TestMetadata("variables.kt") public void testVariables() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/variables.kt"); } + @Test @TestMetadata("while.kt") public void testWhile() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/while.kt"); diff --git a/compiler/visualizer/tests-gen/org/jetbrains/kotlin/visualizer/fir/FirVisualizerForUncommonCasesGenerated.java b/compiler/visualizer/tests-gen/org/jetbrains/kotlin/visualizer/fir/FirVisualizerForUncommonCasesGenerated.java index 70901441d49..beb6bfac3d8 100644 --- a/compiler/visualizer/tests-gen/org/jetbrains/kotlin/visualizer/fir/FirVisualizerForUncommonCasesGenerated.java +++ b/compiler/visualizer/tests-gen/org/jetbrains/kotlin/visualizer/fir/FirVisualizerForUncommonCasesGenerated.java @@ -6,69 +6,73 @@ package org.jetbrains.kotlin.visualizer.fir; 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 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("compiler/visualizer/testData/uncommonCases/testFiles") @TestDataPath("$PROJECT_ROOT") -@RunWith(JUnit3RunnerWithInners.class) public class FirVisualizerForUncommonCasesGenerated extends AbstractFirVisualizer { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doUncommonCasesTest, this, testDataFilePath); - } - + @Test public void testAllFilesPresentInTestFiles() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/visualizer/testData/uncommonCases/testFiles"), Pattern.compile("^(.+)\\.kt$"), null, true); } + @Test @TestMetadata("dataClass.kt") public void testDataClass() throws Exception { runTest("compiler/visualizer/testData/uncommonCases/testFiles/dataClass.kt"); } + @Test @TestMetadata("delegation.kt") public void testDelegation() throws Exception { runTest("compiler/visualizer/testData/uncommonCases/testFiles/delegation.kt"); } + @Test @TestMetadata("innerWith.kt") public void testInnerWith() throws Exception { runTest("compiler/visualizer/testData/uncommonCases/testFiles/innerWith.kt"); } + @Test @TestMetadata("lists.kt") public void testLists() throws Exception { runTest("compiler/visualizer/testData/uncommonCases/testFiles/lists.kt"); } + @Test @TestMetadata("properties.kt") public void testProperties() throws Exception { runTest("compiler/visualizer/testData/uncommonCases/testFiles/properties.kt"); } + @Test @TestMetadata("receiver.kt") public void testReceiver() throws Exception { runTest("compiler/visualizer/testData/uncommonCases/testFiles/receiver.kt"); } + @Test @TestMetadata("superTypes.kt") public void testSuperTypes() throws Exception { runTest("compiler/visualizer/testData/uncommonCases/testFiles/superTypes.kt"); } + @Test @TestMetadata("variance.kt") public void testVariance() throws Exception { runTest("compiler/visualizer/testData/uncommonCases/testFiles/variance.kt"); } + @Test @TestMetadata("where.kt") public void testWhere() throws Exception { runTest("compiler/visualizer/testData/uncommonCases/testFiles/where.kt"); diff --git a/compiler/visualizer/tests-gen/org/jetbrains/kotlin/visualizer/psi/PsiVisualizerForRawFirDataGenerated.java b/compiler/visualizer/tests-gen/org/jetbrains/kotlin/visualizer/psi/PsiVisualizerForRawFirDataGenerated.java index 7c5b81ecbeb..db30161d2db 100644 --- a/compiler/visualizer/tests-gen/org/jetbrains/kotlin/visualizer/psi/PsiVisualizerForRawFirDataGenerated.java +++ b/compiler/visualizer/tests-gen/org/jetbrains/kotlin/visualizer/psi/PsiVisualizerForRawFirDataGenerated.java @@ -6,223 +6,236 @@ package org.jetbrains.kotlin.visualizer.psi; 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 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("compiler/fir/raw-fir/psi2fir/testData/rawBuilder") @TestDataPath("$PROJECT_ROOT") -@RunWith(JUnit3RunnerWithInners.class) public class PsiVisualizerForRawFirDataGenerated extends AbstractPsiVisualizer { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doFirBuilderDataTest, this, testDataFilePath); - } - + @Test public void testAllFilesPresentInRawBuilder() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/raw-fir/psi2fir/testData/rawBuilder"), Pattern.compile("^(.+)\\.kt$"), null, true); } + @Nested @TestMetadata("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations") @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Declarations extends AbstractPsiVisualizer { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doFirBuilderDataTest, this, testDataFilePath); - } - + public class Declarations extends AbstractPsiVisualizer { + @Test public void testAllFilesPresentInDeclarations() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations"), Pattern.compile("^(.+)\\.kt$"), null, true); } + @Test @TestMetadata("annotation.kt") public void testAnnotation() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/annotation.kt"); } + @Test @TestMetadata("complexTypes.kt") public void testComplexTypes() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/complexTypes.kt"); } + @Test @TestMetadata("constructorInObject.kt") public void testConstructorInObject() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/constructorInObject.kt"); } + @Test @TestMetadata("constructorOfAnonymousObject.kt") public void testConstructorOfAnonymousObject() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/constructorOfAnonymousObject.kt"); } + @Test @TestMetadata("delegates.kt") public void testDelegates() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/delegates.kt"); } + @Test @TestMetadata("derivedClass.kt") public void testDerivedClass() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/derivedClass.kt"); } + @Test @TestMetadata("emptyAnonymousObject.kt") public void testEmptyAnonymousObject() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/emptyAnonymousObject.kt"); } + @Test @TestMetadata("enums.kt") public void testEnums() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/enums.kt"); } + @Test @TestMetadata("enums2.kt") public void testEnums2() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/enums2.kt"); } + @Test @TestMetadata("expectActual.kt") public void testExpectActual() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/expectActual.kt"); } + @Test @TestMetadata("external.kt") public void testExternal() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/external.kt"); } + @Test @TestMetadata("F.kt") public void testF() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/F.kt"); } + @Test @TestMetadata("functionTypes.kt") public void testFunctionTypes() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/functionTypes.kt"); } + @Test @TestMetadata("genericFunctions.kt") public void testGenericFunctions() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/genericFunctions.kt"); } + @Test @TestMetadata("genericProperty.kt") public void testGenericProperty() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/genericProperty.kt"); } + @Test @TestMetadata("nestedClass.kt") public void testNestedClass() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/nestedClass.kt"); } + @Test @TestMetadata("NestedOfAliasedType.kt") public void testNestedOfAliasedType() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/NestedOfAliasedType.kt"); } + @Test @TestMetadata("NestedSuperType.kt") public void testNestedSuperType() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/NestedSuperType.kt"); } + @Test @TestMetadata("noPrimaryConstructor.kt") public void testNoPrimaryConstructor() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noPrimaryConstructor.kt"); } + @Test @TestMetadata("simpleClass.kt") public void testSimpleClass() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/simpleClass.kt"); } + @Test @TestMetadata("simpleFun.kt") public void testSimpleFun() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/simpleFun.kt"); } + @Test @TestMetadata("simpleTypeAlias.kt") public void testSimpleTypeAlias() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/simpleTypeAlias.kt"); } + @Test @TestMetadata("typeAliasWithGeneric.kt") public void testTypeAliasWithGeneric() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/typeAliasWithGeneric.kt"); } + @Test @TestMetadata("typeParameterVsNested.kt") public void testTypeParameterVsNested() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/typeParameterVsNested.kt"); } + @Test @TestMetadata("typeParameters.kt") public void testTypeParameters() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/typeParameters.kt"); } + @Test @TestMetadata("where.kt") public void testWhere() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/where.kt"); } + @Nested @TestMetadata("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/contracts") @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Contracts extends AbstractPsiVisualizer { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doFirBuilderDataTest, this, testDataFilePath); - } - + public class Contracts extends AbstractPsiVisualizer { + @Test public void testAllFilesPresentInContracts() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/contracts"), Pattern.compile("^(.+)\\.kt$"), null, true); } + @Nested @TestMetadata("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/contracts/newSyntax") @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class NewSyntax extends AbstractPsiVisualizer { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doFirBuilderDataTest, this, testDataFilePath); - } - + public class NewSyntax extends AbstractPsiVisualizer { + @Test public void testAllFilesPresentInNewSyntax() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/contracts/newSyntax"), Pattern.compile("^(.+)\\.kt$"), null, true); } + @Test @TestMetadata("functionWithBothOldAndNewSyntaxContractDescription.kt") public void testFunctionWithBothOldAndNewSyntaxContractDescription() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/contracts/newSyntax/functionWithBothOldAndNewSyntaxContractDescription.kt"); } + @Test @TestMetadata("propertyAccessorsContractDescription.kt") public void testPropertyAccessorsContractDescription() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/contracts/newSyntax/propertyAccessorsContractDescription.kt"); } + @Test @TestMetadata("simpleFunctionsContractDescription.kt") public void testSimpleFunctionsContractDescription() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/contracts/newSyntax/simpleFunctionsContractDescription.kt"); } } + @Nested @TestMetadata("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/contracts/oldSyntax") @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class OldSyntax extends AbstractPsiVisualizer { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doFirBuilderDataTest, this, testDataFilePath); - } - + public class OldSyntax extends AbstractPsiVisualizer { + @Test public void testAllFilesPresentInOldSyntax() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/contracts/oldSyntax"), Pattern.compile("^(.+)\\.kt$"), null, true); } + @Test @TestMetadata("contractDescription.kt") public void testContractDescription() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/contracts/oldSyntax/contractDescription.kt"); @@ -231,163 +244,190 @@ public class PsiVisualizerForRawFirDataGenerated extends AbstractPsiVisualizer { } } + @Nested @TestMetadata("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions") @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Expressions extends AbstractPsiVisualizer { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doFirBuilderDataTest, this, testDataFilePath); - } - + public class Expressions extends AbstractPsiVisualizer { + @Test public void testAllFilesPresentInExpressions() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions"), Pattern.compile("^(.+)\\.kt$"), null, true); } + @Test @TestMetadata("annotated.kt") public void testAnnotated() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/annotated.kt"); } + @Test @TestMetadata("arrayAccess.kt") public void testArrayAccess() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/arrayAccess.kt"); } + @Test @TestMetadata("arrayAssignment.kt") public void testArrayAssignment() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/arrayAssignment.kt"); } + @Test @TestMetadata("branches.kt") public void testBranches() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/branches.kt"); } + @Test @TestMetadata("callableReferences.kt") public void testCallableReferences() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/callableReferences.kt"); } + @Test @TestMetadata("calls.kt") public void testCalls() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/calls.kt"); } + @Test @TestMetadata("classReference.kt") public void testClassReference() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/classReference.kt"); } + @Test @TestMetadata("collectionLiterals.kt") public void testCollectionLiterals() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/collectionLiterals.kt"); } + @Test @TestMetadata("destructuring.kt") public void testDestructuring() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/destructuring.kt"); } + @Test @TestMetadata("for.kt") public void testFor() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/for.kt"); } + @Test @TestMetadata("genericCalls.kt") public void testGenericCalls() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/genericCalls.kt"); } + @Test @TestMetadata("in.kt") public void testIn() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/in.kt"); } + @Test @TestMetadata("inBrackets.kt") public void testInBrackets() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/inBrackets.kt"); } + @Test @TestMetadata("init.kt") public void testInit() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/init.kt"); } + @Test @TestMetadata("labelForInfix.kt") public void testLabelForInfix() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/labelForInfix.kt"); } + @Test @TestMetadata("lambda.kt") public void testLambda() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/lambda.kt"); } + @Test @TestMetadata("lambdaAndAnonymousFunction.kt") public void testLambdaAndAnonymousFunction() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/lambdaAndAnonymousFunction.kt"); } + @Test @TestMetadata("locals.kt") public void testLocals() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/locals.kt"); } + @Test @TestMetadata("modifications.kt") public void testModifications() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/modifications.kt"); } + @Test @TestMetadata("namedArgument.kt") public void testNamedArgument() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/namedArgument.kt"); } + @Test @TestMetadata("nullability.kt") public void testNullability() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/nullability.kt"); } + @Test @TestMetadata("qualifierWithTypeArguments.kt") public void testQualifierWithTypeArguments() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/qualifierWithTypeArguments.kt"); } + @Test @TestMetadata("simpleReturns.kt") public void testSimpleReturns() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/simpleReturns.kt"); } + @Test @TestMetadata("super.kt") public void testSuper() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/super.kt"); } + @Test @TestMetadata("these.kt") public void testThese() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/these.kt"); } + @Test @TestMetadata("try.kt") public void testTry() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/try.kt"); } + @Test @TestMetadata("typeOperators.kt") public void testTypeOperators() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/typeOperators.kt"); } + @Test @TestMetadata("unary.kt") public void testUnary() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/unary.kt"); } + @Test @TestMetadata("variables.kt") public void testVariables() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/variables.kt"); } + @Test @TestMetadata("while.kt") public void testWhile() throws Exception { runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/while.kt"); diff --git a/compiler/visualizer/tests-gen/org/jetbrains/kotlin/visualizer/psi/PsiVisualizerForUncommonCasesGenerated.java b/compiler/visualizer/tests-gen/org/jetbrains/kotlin/visualizer/psi/PsiVisualizerForUncommonCasesGenerated.java index 34c441bde4e..ebc67a59682 100644 --- a/compiler/visualizer/tests-gen/org/jetbrains/kotlin/visualizer/psi/PsiVisualizerForUncommonCasesGenerated.java +++ b/compiler/visualizer/tests-gen/org/jetbrains/kotlin/visualizer/psi/PsiVisualizerForUncommonCasesGenerated.java @@ -6,69 +6,73 @@ package org.jetbrains.kotlin.visualizer.psi; 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 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("compiler/visualizer/testData/uncommonCases/testFiles") @TestDataPath("$PROJECT_ROOT") -@RunWith(JUnit3RunnerWithInners.class) public class PsiVisualizerForUncommonCasesGenerated extends AbstractPsiVisualizer { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doUncommonCasesTest, this, testDataFilePath); - } - + @Test public void testAllFilesPresentInTestFiles() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/visualizer/testData/uncommonCases/testFiles"), Pattern.compile("^(.+)\\.kt$"), null, true); } + @Test @TestMetadata("dataClass.kt") public void testDataClass() throws Exception { runTest("compiler/visualizer/testData/uncommonCases/testFiles/dataClass.kt"); } + @Test @TestMetadata("delegation.kt") public void testDelegation() throws Exception { runTest("compiler/visualizer/testData/uncommonCases/testFiles/delegation.kt"); } + @Test @TestMetadata("innerWith.kt") public void testInnerWith() throws Exception { runTest("compiler/visualizer/testData/uncommonCases/testFiles/innerWith.kt"); } + @Test @TestMetadata("lists.kt") public void testLists() throws Exception { runTest("compiler/visualizer/testData/uncommonCases/testFiles/lists.kt"); } + @Test @TestMetadata("properties.kt") public void testProperties() throws Exception { runTest("compiler/visualizer/testData/uncommonCases/testFiles/properties.kt"); } + @Test @TestMetadata("receiver.kt") public void testReceiver() throws Exception { runTest("compiler/visualizer/testData/uncommonCases/testFiles/receiver.kt"); } + @Test @TestMetadata("superTypes.kt") public void testSuperTypes() throws Exception { runTest("compiler/visualizer/testData/uncommonCases/testFiles/superTypes.kt"); } + @Test @TestMetadata("variance.kt") public void testVariance() throws Exception { runTest("compiler/visualizer/testData/uncommonCases/testFiles/variance.kt"); } + @Test @TestMetadata("where.kt") public void testWhere() throws Exception { runTest("compiler/visualizer/testData/uncommonCases/testFiles/where.kt"); diff --git a/compiler/visualizer/tests/org/jetbrains/kotlin/visualizer/AbstractVisualizer.kt b/compiler/visualizer/tests/org/jetbrains/kotlin/visualizer/AbstractVisualizer.kt index 90fbb0b6f75..ba0d20c2634 100644 --- a/compiler/visualizer/tests/org/jetbrains/kotlin/visualizer/AbstractVisualizer.kt +++ b/compiler/visualizer/tests/org/jetbrains/kotlin/visualizer/AbstractVisualizer.kt @@ -5,44 +5,64 @@ package org.jetbrains.kotlin.visualizer -import org.jetbrains.kotlin.checkers.KotlinMultiFileTestWithJava -import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment -import org.jetbrains.kotlin.test.Directives -import org.jetbrains.kotlin.test.KotlinBaseTest -import java.io.File +import org.jetbrains.kotlin.platform.jvm.JvmPlatforms +import org.jetbrains.kotlin.test.Constructor +import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder +import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirectives +import org.jetbrains.kotlin.test.directives.model.SimpleDirectivesContainer +import org.jetbrains.kotlin.test.model.DependencyKind +import org.jetbrains.kotlin.test.model.FrontendFacade +import org.jetbrains.kotlin.test.model.FrontendKind +import org.jetbrains.kotlin.test.model.FrontendOutputHandler +import org.jetbrains.kotlin.test.runners.AbstractKotlinCompilerTest +import org.jetbrains.kotlin.test.services.configuration.CommonEnvironmentConfigurator +import org.jetbrains.kotlin.test.services.configuration.JvmEnvironmentConfigurator -abstract class AbstractVisualizer : KotlinMultiFileTestWithJava() { - lateinit var replacement: Pair +abstract class AbstractVisualizer : AbstractKotlinCompilerTest() { + abstract val handler: Constructor> + abstract val frontendKind: FrontendKind<*> + abstract val frontendFacade: Constructor> - override fun createTestModule( - name: String, - dependencies: List, - friends: List - ): TestModule? = null + override fun TestConfigurationBuilder.configuration() { + globalDefaults { + frontend = frontendKind + targetPlatform = JvmPlatforms.defaultJvmPlatform + dependencyKind = DependencyKind.Source + } + useConfigurators( + ::CommonEnvironmentConfigurator, + ::JvmEnvironmentConfigurator, + ) + useFrontendFacades(frontendFacade) + useFrontendHandlers(handler) - override fun createTestFile(module: TestModule?, fileName: String, text: String, directives: Directives): TestFile = - TestFile(fileName, text, directives) + defaultDirectives { + +JvmEnvironmentConfigurationDirectives.WITH_STDLIB + } + forTestsMatching("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/*") { + defaultDirectives { + VisualizerDirectives.EXPECTED_FILE_PATH with "compiler/visualizer/testData/rawBuilder/declarations" + } + } - override fun doMultiFileTest(wholeFile: File, files: List) { - val environment = createEnvironment(wholeFile, files) - doVisualizerTest(wholeFile, environment) + forTestsMatching("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/*") { + defaultDirectives { + VisualizerDirectives.EXPECTED_FILE_PATH with "compiler/visualizer/testData/rawBuilder/expressions" + } + } + + forTestsMatching("compiler/visualizer/testData/uncommonCases/*") { + defaultDirectives { + VisualizerDirectives.EXPECTED_FILE_PATH with "compiler/visualizer/testData/uncommonCases/resultFiles" + } + } } +} - abstract fun doVisualizerTest(file: File, environment: KotlinCoreEnvironment) - - override fun isKotlinSourceRootNeeded(): Boolean { - return true - } - - fun doFirBuilderDataTest(filePath: String) { - replacement = "fir${File.separator}psi2fir" to "visualizer" - doTest(filePath) - } - - fun doUncommonCasesTest(filePath: String) { - replacement = "testFiles" to "resultFiles" - doTest(filePath) - } +internal object VisualizerDirectives : SimpleDirectivesContainer() { + val EXPECTED_FILE_PATH by stringDirective( + description = "Specify the path to expected result file" + ) } \ No newline at end of file diff --git a/compiler/visualizer/tests/org/jetbrains/kotlin/visualizer/fir/AbstractFirVisualizer.kt b/compiler/visualizer/tests/org/jetbrains/kotlin/visualizer/fir/AbstractFirVisualizer.kt index 912c1abe28c..71b951b1acb 100644 --- a/compiler/visualizer/tests/org/jetbrains/kotlin/visualizer/fir/AbstractFirVisualizer.kt +++ b/compiler/visualizer/tests/org/jetbrains/kotlin/visualizer/fir/AbstractFirVisualizer.kt @@ -5,66 +5,47 @@ package org.jetbrains.kotlin.visualizer.fir -import com.intellij.psi.PsiElementFinder -import com.intellij.psi.search.GlobalSearchScope -import org.jetbrains.kotlin.asJava.finder.JavaElementFinder -import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment -import org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM import org.jetbrains.kotlin.compiler.visualizer.FirVisualizer -import org.jetbrains.kotlin.fir.builder.RawFirBuilder -import org.jetbrains.kotlin.fir.createSessionForTests -import org.jetbrains.kotlin.fir.render -import org.jetbrains.kotlin.fir.resolve.firProvider -import org.jetbrains.kotlin.fir.resolve.providers.impl.FirProviderImpl -import org.jetbrains.kotlin.fir.resolve.transformers.FirTotalResolveProcessor +import org.jetbrains.kotlin.test.Constructor import org.jetbrains.kotlin.test.KotlinTestUtils +import org.jetbrains.kotlin.test.frontend.fir.FirFrontendFacade +import org.jetbrains.kotlin.test.frontend.fir.FirOutputArtifact +import org.jetbrains.kotlin.test.frontend.fir.handlers.FirAnalysisHandler +import org.jetbrains.kotlin.test.model.* +import org.jetbrains.kotlin.test.services.defaultDirectives import org.jetbrains.kotlin.visualizer.AbstractVisualizer +import org.jetbrains.kotlin.visualizer.VisualizerDirectives import org.junit.Assert import java.io.File abstract class AbstractFirVisualizer : AbstractVisualizer() { - override fun doVisualizerTest(file: File, environment: KotlinCoreEnvironment) { - PsiElementFinder.EP.getPoint(environment.project) - .unregisterExtension(JavaElementFinder::class.java) + override val frontendKind: FrontendKind<*> = FrontendKinds.FIR + override val frontendFacade: Constructor> = { FirFrontendFacade(it) } - val ktFiles = environment.getSourceFiles() - val scope = GlobalSearchScope.filesScope(environment.project, ktFiles.mapNotNull { it.virtualFile }) - .uniteWith(TopDownAnalyzerFacadeForJVM.AllJavaSourcesInProjectScope(environment.project)) - val session = createSessionForTests(environment, scope) + override val handler: Constructor> = { + object : FirAnalysisHandler(it) { + override fun processModule(module: TestModule, info: FirOutputArtifact) { + val renderer = FirVisualizer(info.firFiles.values.first()) + val firRenderResult = renderer.render() - val firProvider = (session.firProvider as FirProviderImpl) - val builder = RawFirBuilder(session, firProvider.kotlinScopeProvider) + val fileName = info.firFiles.keys.first().name + val expectedPath = it.defaultDirectives.get(VisualizerDirectives.EXPECTED_FILE_PATH).first() + "/$fileName" + val expectedText = File(expectedPath).readLines() + if (expectedText[0].startsWith("// FIR_IGNORE")) { + Assert.assertFalse( + "Files are identical, please delete ignore directive", + expectedText.filterIndexed { index, _ -> index > 0 }.joinToString("\n") == firRenderResult + ) + return + } + KotlinTestUtils.assertEqualsToFile(File(expectedPath), firRenderResult) { + return@assertEqualsToFile it.replace("// FIR_IGNORE\n", "") + } + } + + override fun processAfterAllModules(someAssertionWasFailed: Boolean) { - val transformer = FirTotalResolveProcessor(session) - val firFiles = ktFiles.map { - val firFile = builder.buildFirFile(it) - firProvider.recordFile(firFile) - firFile - }.also { - try { - transformer.process(it) - } catch (e: Exception) { - it.forEach { println(it.render()) } - throw e } } - - //compare - val renderer = FirVisualizer(firFiles.first()) - val psiRenderResult = renderer.render() - - val expectedPath = file.absolutePath.replace(replacement.first, replacement.second) - val expectedText = File(expectedPath).readLines() - if (expectedText[0].startsWith("// FIR_IGNORE")) { - Assert.assertFalse( - "Files are identical, please delete ignore directive", - expectedText.filterIndexed { index, _ -> index > 0 }.joinToString("\n") == psiRenderResult - ) - return - } - KotlinTestUtils.assertEqualsToFile(File(expectedPath), psiRenderResult) { - return@assertEqualsToFile it.replace("// FIR_IGNORE\n", "") - } - } } diff --git a/compiler/visualizer/tests/org/jetbrains/kotlin/visualizer/psi/AbstractPsiVisualizer.kt b/compiler/visualizer/tests/org/jetbrains/kotlin/visualizer/psi/AbstractPsiVisualizer.kt index 4efe29d5fe9..737acaae70a 100644 --- a/compiler/visualizer/tests/org/jetbrains/kotlin/visualizer/psi/AbstractPsiVisualizer.kt +++ b/compiler/visualizer/tests/org/jetbrains/kotlin/visualizer/psi/AbstractPsiVisualizer.kt @@ -5,24 +5,38 @@ package org.jetbrains.kotlin.visualizer.psi -import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment import org.jetbrains.kotlin.compiler.visualizer.PsiVisualizer -import org.jetbrains.kotlin.resolve.lazy.JvmResolveUtil +import org.jetbrains.kotlin.test.Constructor import org.jetbrains.kotlin.test.KotlinTestUtils +import org.jetbrains.kotlin.test.frontend.classic.ClassicFrontendFacade +import org.jetbrains.kotlin.test.frontend.classic.ClassicFrontendOutputArtifact +import org.jetbrains.kotlin.test.frontend.classic.handlers.ClassicFrontendAnalysisHandler +import org.jetbrains.kotlin.test.model.* +import org.jetbrains.kotlin.test.services.defaultDirectives import org.jetbrains.kotlin.visualizer.AbstractVisualizer +import org.jetbrains.kotlin.visualizer.VisualizerDirectives import java.io.File abstract class AbstractPsiVisualizer : AbstractVisualizer() { - override fun doVisualizerTest(file: File, environment: KotlinCoreEnvironment) { - val ktFiles = environment.getSourceFiles() - val analysisResult = JvmResolveUtil.analyze(ktFiles, environment) + override val frontendKind: FrontendKind<*> = FrontendKinds.ClassicFrontend + override val frontendFacade: Constructor> = { ClassicFrontendFacade(it) } - val renderer = PsiVisualizer(ktFiles.first(), analysisResult) - val psiRenderResult = renderer.render() + override val handler: Constructor> = { + object : ClassicFrontendAnalysisHandler(it) { + override fun processModule(module: TestModule, info: ClassicFrontendOutputArtifact) { + val renderer = PsiVisualizer(info.ktFiles.values.first(), info.analysisResult) + val psiRenderResult = renderer.render() - val expectedPath = file.absolutePath.replace(replacement.first, replacement.second) - KotlinTestUtils.assertEqualsToFile(File(expectedPath), psiRenderResult) { - return@assertEqualsToFile it.replace("// FIR_IGNORE\n", "") + val fileName = info.ktFiles.keys.first().name + val expectedPath = it.defaultDirectives.get(VisualizerDirectives.EXPECTED_FILE_PATH).first() + "/$fileName" + KotlinTestUtils.assertEqualsToFile(File(expectedPath), psiRenderResult) { + return@assertEqualsToFile it.replace("// FIR_IGNORE\n", "") + } + } + + override fun processAfterAllModules(someAssertionWasFailed: Boolean) { + + } } } }