[Test] Extract main compiler test generator to separate project

This is needed because now we have different tests modules with different
  test frameworks (JUnit3 and JUnit5) which has no dependencies between
  each other. So for keeping all test generation config in one place
  we need module which may rely on all independent test modules
This commit is contained in:
Dmitriy Novozhilov
2020-12-18 12:33:40 +03:00
committed by TeamCityServer
parent d753d21dee
commit 1f258c28fc
12 changed files with 70 additions and 29 deletions

View File

@@ -10,12 +10,11 @@
</option>
<option name="taskNames">
<list>
<option value=":compiler:generateTests" />
<option value=":compiler:tests-for-compiler-generator:generateTests" />
<option value=":compiler:tests-java8:generateTests" />
<option value=":compiler:tests-against-klib:generateTests" />
<option value=":js:js.tests:generateTests" />
<option value=":core:descriptors.runtime:generateTests" />
<option value=":compiler:tests-common-new:generateTests" />
</list>
</option>
<option name="vmOptions" value="" />

View File

@@ -99,8 +99,5 @@ projectTest(parallel = true) {
}
val generateTestData by generator("org.jetbrains.kotlin.generators.tests.GenerateCompilerTestDataKt")
val generateTests by generator("org.jetbrains.kotlin.generators.tests.GenerateCompilerTestsKt") {
dependsOn(generateTestData)
}
testsJar()

View File

@@ -17,9 +17,9 @@ dependencies {
testImplementation(projectTests(":generators:test-generator"))
testImplementation(platform("org.junit:junit-bom:5.7.0"))
testImplementation("org.junit.jupiter:junit-jupiter")
testImplementation("org.junit.platform:junit-platform-commons:1.7.0")
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(projectTests(":compiler:test-infrastructure"))
testImplementation(projectTests(":compiler:test-infrastructure-utils"))
testImplementation(projectTests(":compiler:tests-compiler-utils"))
@@ -88,5 +88,3 @@ projectTest(parallel = true, jUnit5Enabled = true) {
}
testsJar()
val generateTests by generator("org.jetbrains.kotlin.test.generators.GenerateNewCompilerTestsKt")

View File

@@ -9,14 +9,14 @@ import org.jetbrains.kotlin.generators.InconsistencyChecker
import org.jetbrains.kotlin.generators.TestGroupSuite
import org.jetbrains.kotlin.generators.testGroupSuite
fun generateNewTestGroupSuite(
fun generateTestGroupSuiteWithJUnit5(
args: Array<String>,
init: TestGroupSuite.() -> Unit
) {
generateNewTestGroupSuite(InconsistencyChecker.hasDryRunArg(args), init)
generateTestGroupSuiteWithJUnit5(InconsistencyChecker.hasDryRunArg(args), init)
}
fun generateNewTestGroupSuite(
fun generateTestGroupSuiteWithJUnit5(
dryRun: Boolean = false,
init: TestGroupSuite.() -> Unit
) {

View File

@@ -22,6 +22,8 @@ import java.io.File
import java.io.IOException
import java.util.*
private const val TEST_GENERATOR_NAME = "GenerateNewCompilerTests.kt"
private val METHOD_GENERATORS = listOf(
SimpleTestClassModelTestAllFilesPresentMethodGenerator,
SimpleTestMethodGenerator,

View File

@@ -0,0 +1,35 @@
plugins {
kotlin("jvm")
id("jps-compatible")
}
dependencies {
testRuntimeOnly(intellijDep()) // Should come before compiler, because of "progarded" stuff needed for tests
testImplementation(kotlinStdlib())
testImplementation(platform("org.junit:junit-bom:5.7.0"))
testImplementation("org.junit.jupiter:junit-jupiter")
testImplementation(projectTests(":compiler:tests-common"))
testImplementation(projectTests(":compiler:tests-common-new"))
testImplementation(projectTests(":compiler:tests-common"))
testImplementation(projectTests(":compiler"))
testImplementation(projectTests(":compiler:fir:raw-fir:psi2fir"))
testImplementation(projectTests(":compiler:fir:raw-fir:light-tree2fir"))
testImplementation(projectTests(":compiler:fir:fir2ir"))
testImplementation(projectTests(":compiler:fir:analysis-tests"))
testImplementation(projectTests(":compiler:visualizer"))
testImplementation(projectTests(":generators:test-generator"))
testCompileOnly(project(":kotlin-reflect-api"))
testRuntimeOnly(project(":kotlin-reflect"))
}
sourceSets {
"main" {}
"test" { projectDefault() }
}
val generateTests by generator("org.jetbrains.kotlin.test.generators.GenerateCompilerTestsKt") {
dependsOn(":compiler:generateTestData")
}
testsJar()

View File

@@ -0,0 +1,13 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.test.generators
fun main(args: Array<String>) {
System.setProperty("java.awt.headless", "true")
generateJUnit3CompilerTests(args)
generateJUnit5CompilerTests(args)
}

View File

@@ -1,9 +1,9 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.generators.tests
package org.jetbrains.kotlin.test.generators
import org.jetbrains.kotlin.asJava.AbstractCompilerLightClassTest
import org.jetbrains.kotlin.cfg.AbstractControlFlowTest
@@ -62,9 +62,7 @@ import org.jetbrains.kotlin.types.AbstractTypeBindingTest
import org.jetbrains.kotlin.visualizer.fir.AbstractFirVisualizer
import org.jetbrains.kotlin.visualizer.psi.AbstractPsiVisualizer
fun main(args: Array<String>) {
System.setProperty("java.awt.headless", "true")
fun generateJUnit3CompilerTests(args: Array<String>) {
generateTestGroupSuite(args) {
testGroup("compiler/tests-gen", "compiler/testData") {
testClass<AbstractDiagnosticsTestWithJsStdLibAndBackendCompilation> {

View File

@@ -5,14 +5,14 @@
package org.jetbrains.kotlin.test.generators
import org.jetbrains.kotlin.generators.util.TestGeneratorUtil.KT_WITHOUT_DOTS_IN_NAME
import org.jetbrains.kotlin.generators.util.TestGeneratorUtil
import org.jetbrains.kotlin.test.TargetBackend
import org.jetbrains.kotlin.test.runners.*
fun main(args: Array<String>) {
fun generateJUnit5CompilerTests(args: Array<String>) {
val excludedFirTestdataPattern = "^(.+)\\.fir\\.kts?\$"
generateNewTestGroupSuite(args) {
generateTestGroupSuiteWithJUnit5(args) {
testGroup("compiler/tests-common-new/tests-gen", "compiler/testData") {
testClass<AbstractDiagnosticTest> {
model("diagnostics/tests", pattern = "^(.*)\\.kts?$", excludedPattern = excludedFirTestdataPattern)
@@ -47,15 +47,14 @@ fun main(args: Array<String>) {
testGroup("compiler/tests-common-new/tests-gen", "compiler/fir/analysis-tests/testData") {
testClass<AbstractFirDiagnosticTest> {
model("resolve", pattern = KT_WITHOUT_DOTS_IN_NAME)
model("resolveWithStdlib", pattern = KT_WITHOUT_DOTS_IN_NAME)
model("resolve", pattern = TestGeneratorUtil.KT_WITHOUT_DOTS_IN_NAME)
model("resolveWithStdlib", pattern = TestGeneratorUtil.KT_WITHOUT_DOTS_IN_NAME)
}
testClass<AbstractFirDiagnosticsWithLightTreeTest> {
model("resolve", pattern = KT_WITHOUT_DOTS_IN_NAME)
model("resolve", pattern = TestGeneratorUtil.KT_WITHOUT_DOTS_IN_NAME)
}
}
}
}
const val TEST_GENERATOR_NAME = "GenerateNewCompilerTests.kt"
}

View File

@@ -7,7 +7,7 @@ plugins {
val depenencyProjects = arrayOf(
":generators",
":compiler",
":compiler:tests-common-new",
":compiler:tests-for-compiler-generator",
":js:js.tests",
":compiler:tests-java8",
":core:descriptors.runtime"

View File

@@ -7,14 +7,13 @@ package org.jetbrains.kotlin.pill.generateAllTests;
import org.jetbrains.kotlin.generators.tests.*;
import org.jetbrains.kotlin.generators.InconsistencyChecker;
import org.jetbrains.kotlin.test.generators.GenerateNewCompilerTestsKt;
import org.jetbrains.kotlin.test.generators.GenerateCompilerTestsKt;
import java.util.List;
public class Main {
public static void main(String[] args) {
GenerateCompilerTestsKt.main(args);
GenerateNewCompilerTestsKt.main(args);
GenerateTestsKt.main(args);
GenerateJsTestsKt.main(args);
GenerateJava8TestsKt.main(args);

View File

@@ -121,6 +121,7 @@ include ":benchmarks",
":compiler:tests-mutes:tc-integration",
":compiler:tests-common-jvm6",
":compiler:tests-against-klib",
":compiler:tests-for-compiler-generator",
":dukat",
":js:js.ast",
":js:js.serializer",