From a276d059174ddd0678ddde28583c18336d66f0ad Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Fri, 18 Dec 2020 13:00:18 +0300 Subject: [PATCH] [Test] Generate FIR tests with new infrastructure in :analysis-tests module --- build.gradle.kts | 1 + compiler/fir/analysis-tests/build.gradle.kts | 98 +++++++++++++++++++ .../runners/FirDiagnosticTestGenerated.java | 0 ...DiagnosticsWithLightTreeTestGenerated.java | 0 ...irOldFrontendDiagnosticsTestGenerated.java | 0 .../generators/GenerateJUnit5CompilerTests.kt | 18 ++-- settings.gradle | 1 + 7 files changed, 111 insertions(+), 7 deletions(-) create mode 100644 compiler/fir/analysis-tests/build.gradle.kts rename compiler/{tests-common-new => fir/analysis-tests}/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java (100%) rename compiler/{tests-common-new => fir/analysis-tests}/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java (100%) rename compiler/{tests-common-new => fir/analysis-tests}/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java (100%) diff --git a/build.gradle.kts b/build.gradle.kts index 32021802f0e..b9449be6128 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -292,6 +292,7 @@ extra["compilerModules"] = arrayOf( ":compiler:fir:jvm", ":compiler:fir:checkers", ":compiler:fir:entrypoint", + ":compiler:fir:analysis-tests", ":compiler:fir:analysis-tests:legacy-fir-tests", ":wasm:wasm.ir" ) diff --git a/compiler/fir/analysis-tests/build.gradle.kts b/compiler/fir/analysis-tests/build.gradle.kts new file mode 100644 index 00000000000..bcc22c88270 --- /dev/null +++ b/compiler/fir/analysis-tests/build.gradle.kts @@ -0,0 +1,98 @@ +import org.jetbrains.kotlin.ideaExt.idea + +/* + * Copyright 2000-2018 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. + */ + +plugins { + kotlin("jvm") + id("jps-compatible") +} + +dependencies { + compileOnly(intellijCoreDep()) { includeJars("intellij-core", "guava", rootProject = rootProject) } + + testApi(intellijDep()) + testApi(projectTests(":compiler:test-infrastructure")) + testApi(projectTests(":compiler:test-infrastructure-utils")) + testApi(projectTests(":compiler:tests-compiler-utils")) + testApi(projectTests(":compiler:tests-common-new")) + testApi(project(":compiler:cli")) + testApi(project(":compiler:fir:checkers")) + testApi(project(":compiler:fir:entrypoint")) + testApi(project(":compiler:frontend")) + + 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") + + testCompileOnly(project(":kotlin-reflect-api")) + testRuntimeOnly(project(":kotlin-reflect")) + testRuntimeOnly(project(":core:descriptors.runtime")) + + testImplementation(intellijCoreDep()) { includeJars("intellij-core") } + testImplementation(intellijDep()) { + // This dependency is needed only for FileComparisonFailure + includeJars("idea_rt", rootProject = rootProject) + isTransitive = false + } + + // This is needed only for using FileComparisonFailure, which relies on JUnit 3 classes + testRuntimeOnly(commonDep("junit:junit")) + testRuntimeOnly(intellijDep()) { + includeJars( + "jps-model", + "extensions", + "util", + "platform-api", + "platform-impl", + "idea", + "guava", + "trove4j", + "asm-all", + "log4j", + "jdom", + "streamex", + "bootstrap", + "jna", + rootProject = rootProject + ) + } + + Platform[202] { + testRuntimeOnly(intellijDep()) { includeJars("intellij-deps-fastutil-8.3.1-1") } + } + Platform[203].orHigher { + testRuntimeOnly(intellijDep()) { includeJars("intellij-deps-fastutil-8.3.1-3") } + } + testRuntimeOnly(toolsJar()) +} + +val generationRoot = projectDir.resolve("tests-gen") + +sourceSets { + "main" { none() } + "test" { + projectDefault() + this.java.srcDir(generationRoot.name) + } +} + +if (kotlinBuildProperties.isInJpsBuildIdeaSync) { + apply(plugin = "idea") + idea { + this.module.generatedSourceDirs.add(generationRoot) + } +} + +projectTest(parallel = true, jUnit5Enabled = true) { + dependsOn(":dist") + workingDir = rootDir + jvmArgs!!.removeIf { it.contains("-Xmx") } + maxHeapSize = "3g" + + useJUnitPlatform() +} + +testsJar() diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java similarity index 100% rename from compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java rename to compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java similarity index 100% rename from compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java rename to compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java similarity index 100% rename from compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java rename to compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java 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 793b2f7f652..edf1353435e 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 @@ -13,7 +13,7 @@ fun generateJUnit5CompilerTests(args: Array) { val excludedFirTestdataPattern = "^(.+)\\.fir\\.kts?\$" generateTestGroupSuiteWithJUnit5(args) { - testGroup("compiler/tests-common-new/tests-gen", "compiler/testData") { + testGroup(testsRoot = "compiler/tests-common-new/tests-gen", testDataRoot = "compiler/testData") { testClass { model("diagnostics/tests", pattern = "^(.*)\\.kts?$", excludedPattern = excludedFirTestdataPattern) model("diagnostics/testsWithStdLib", excludedPattern = excludedFirTestdataPattern) @@ -23,11 +23,6 @@ fun generateJUnit5CompilerTests(args: Array) { model("diagnostics/tests/javac", pattern = "^(.*)\\.kts?$", excludedPattern = excludedFirTestdataPattern) } - testClass(suiteTestClassName = "FirOldFrontendDiagnosticsTestGenerated") { - model("diagnostics/tests", excludedPattern = excludedFirTestdataPattern) - model("diagnostics/testsWithStdLib", excludedPattern = excludedFirTestdataPattern) - } - testClass { model("diagnostics/testsWithJsStdLib") } @@ -45,7 +40,16 @@ fun generateJUnit5CompilerTests(args: Array) { } } - testGroup("compiler/tests-common-new/tests-gen", "compiler/fir/analysis-tests/testData") { + // ---------------------------------------------- FIR tests ---------------------------------------------- + + testGroup(testsRoot = "compiler/fir/analysis-tests/tests-gen", testDataRoot = "compiler/testData") { + testClass(suiteTestClassName = "FirOldFrontendDiagnosticsTestGenerated") { + model("diagnostics/tests", excludedPattern = excludedFirTestdataPattern) + model("diagnostics/testsWithStdLib", excludedPattern = excludedFirTestdataPattern) + } + } + + testGroup("compiler/fir/analysis-tests/tests-gen", "compiler/fir/analysis-tests/testData") { testClass { model("resolve", pattern = TestGeneratorUtil.KT_WITHOUT_DOTS_IN_NAME) model("resolveWithStdlib", pattern = TestGeneratorUtil.KT_WITHOUT_DOTS_IN_NAME) diff --git a/settings.gradle b/settings.gradle index bc291dbcc65..761b6d7ab2d 100644 --- a/settings.gradle +++ b/settings.gradle @@ -327,6 +327,7 @@ include ":compiler:fir:cones", ":compiler:fir:checkers", ":compiler:fir:checkers:checkers-component-generator", ":compiler:fir:entrypoint", + ":compiler:fir:analysis-tests", ":compiler:fir:analysis-tests:legacy-fir-tests" include ":compiler:test-infrastructure",