[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
+1 -2
View File
@@ -10,12 +10,11 @@
</option> </option>
<option name="taskNames"> <option name="taskNames">
<list> <list>
<option value=":compiler:generateTests" /> <option value=":compiler:tests-for-compiler-generator:generateTests" />
<option value=":compiler:tests-java8:generateTests" /> <option value=":compiler:tests-java8:generateTests" />
<option value=":compiler:tests-against-klib:generateTests" /> <option value=":compiler:tests-against-klib:generateTests" />
<option value=":js:js.tests:generateTests" /> <option value=":js:js.tests:generateTests" />
<option value=":core:descriptors.runtime:generateTests" /> <option value=":core:descriptors.runtime:generateTests" />
<option value=":compiler:tests-common-new:generateTests" />
</list> </list>
</option> </option>
<option name="vmOptions" value="" /> <option name="vmOptions" value="" />
-3
View File
@@ -99,8 +99,5 @@ projectTest(parallel = true) {
} }
val generateTestData by generator("org.jetbrains.kotlin.generators.tests.GenerateCompilerTestDataKt") val generateTestData by generator("org.jetbrains.kotlin.generators.tests.GenerateCompilerTestDataKt")
val generateTests by generator("org.jetbrains.kotlin.generators.tests.GenerateCompilerTestsKt") {
dependsOn(generateTestData)
}
testsJar() testsJar()
+3 -5
View File
@@ -17,9 +17,9 @@ dependencies {
testImplementation(projectTests(":generators:test-generator")) testImplementation(projectTests(":generators:test-generator"))
testImplementation(platform("org.junit:junit-bom:5.7.0")) testApi(platform("org.junit:junit-bom:5.7.0"))
testImplementation("org.junit.jupiter:junit-jupiter") testApi("org.junit.jupiter:junit-jupiter")
testImplementation("org.junit.platform:junit-platform-commons:1.7.0") testApi("org.junit.platform:junit-platform-commons:1.7.0")
testApi(projectTests(":compiler:test-infrastructure")) testApi(projectTests(":compiler:test-infrastructure"))
testImplementation(projectTests(":compiler:test-infrastructure-utils")) testImplementation(projectTests(":compiler:test-infrastructure-utils"))
testImplementation(projectTests(":compiler:tests-compiler-utils")) testImplementation(projectTests(":compiler:tests-compiler-utils"))
@@ -88,5 +88,3 @@ projectTest(parallel = true, jUnit5Enabled = true) {
} }
testsJar() testsJar()
val generateTests by generator("org.jetbrains.kotlin.test.generators.GenerateNewCompilerTestsKt")
@@ -9,14 +9,14 @@ import org.jetbrains.kotlin.generators.InconsistencyChecker
import org.jetbrains.kotlin.generators.TestGroupSuite import org.jetbrains.kotlin.generators.TestGroupSuite
import org.jetbrains.kotlin.generators.testGroupSuite import org.jetbrains.kotlin.generators.testGroupSuite
fun generateNewTestGroupSuite( fun generateTestGroupSuiteWithJUnit5(
args: Array<String>, args: Array<String>,
init: TestGroupSuite.() -> Unit init: TestGroupSuite.() -> Unit
) { ) {
generateNewTestGroupSuite(InconsistencyChecker.hasDryRunArg(args), init) generateTestGroupSuiteWithJUnit5(InconsistencyChecker.hasDryRunArg(args), init)
} }
fun generateNewTestGroupSuite( fun generateTestGroupSuiteWithJUnit5(
dryRun: Boolean = false, dryRun: Boolean = false,
init: TestGroupSuite.() -> Unit init: TestGroupSuite.() -> Unit
) { ) {
@@ -22,6 +22,8 @@ import java.io.File
import java.io.IOException import java.io.IOException
import java.util.* import java.util.*
private const val TEST_GENERATOR_NAME = "GenerateNewCompilerTests.kt"
private val METHOD_GENERATORS = listOf( private val METHOD_GENERATORS = listOf(
SimpleTestClassModelTestAllFilesPresentMethodGenerator, SimpleTestClassModelTestAllFilesPresentMethodGenerator,
SimpleTestMethodGenerator, SimpleTestMethodGenerator,
@@ -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()
@@ -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)
}
@@ -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. * 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.asJava.AbstractCompilerLightClassTest
import org.jetbrains.kotlin.cfg.AbstractControlFlowTest 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.fir.AbstractFirVisualizer
import org.jetbrains.kotlin.visualizer.psi.AbstractPsiVisualizer import org.jetbrains.kotlin.visualizer.psi.AbstractPsiVisualizer
fun main(args: Array<String>) { fun generateJUnit3CompilerTests(args: Array<String>) {
System.setProperty("java.awt.headless", "true")
generateTestGroupSuite(args) { generateTestGroupSuite(args) {
testGroup("compiler/tests-gen", "compiler/testData") { testGroup("compiler/tests-gen", "compiler/testData") {
testClass<AbstractDiagnosticsTestWithJsStdLibAndBackendCompilation> { testClass<AbstractDiagnosticsTestWithJsStdLibAndBackendCompilation> {
@@ -5,14 +5,14 @@
package org.jetbrains.kotlin.test.generators 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.TargetBackend
import org.jetbrains.kotlin.test.runners.* import org.jetbrains.kotlin.test.runners.*
fun main(args: Array<String>) { fun generateJUnit5CompilerTests(args: Array<String>) {
val excludedFirTestdataPattern = "^(.+)\\.fir\\.kts?\$" val excludedFirTestdataPattern = "^(.+)\\.fir\\.kts?\$"
generateNewTestGroupSuite(args) { generateTestGroupSuiteWithJUnit5(args) {
testGroup("compiler/tests-common-new/tests-gen", "compiler/testData") { testGroup("compiler/tests-common-new/tests-gen", "compiler/testData") {
testClass<AbstractDiagnosticTest> { testClass<AbstractDiagnosticTest> {
model("diagnostics/tests", pattern = "^(.*)\\.kts?$", excludedPattern = excludedFirTestdataPattern) 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") { testGroup("compiler/tests-common-new/tests-gen", "compiler/fir/analysis-tests/testData") {
testClass<AbstractFirDiagnosticTest> { testClass<AbstractFirDiagnosticTest> {
model("resolve", pattern = KT_WITHOUT_DOTS_IN_NAME) model("resolve", pattern = TestGeneratorUtil.KT_WITHOUT_DOTS_IN_NAME)
model("resolveWithStdlib", pattern = KT_WITHOUT_DOTS_IN_NAME) model("resolveWithStdlib", pattern = TestGeneratorUtil.KT_WITHOUT_DOTS_IN_NAME)
} }
testClass<AbstractFirDiagnosticsWithLightTreeTest> { 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" }
@@ -7,7 +7,7 @@ plugins {
val depenencyProjects = arrayOf( val depenencyProjects = arrayOf(
":generators", ":generators",
":compiler", ":compiler",
":compiler:tests-common-new", ":compiler:tests-for-compiler-generator",
":js:js.tests", ":js:js.tests",
":compiler:tests-java8", ":compiler:tests-java8",
":core:descriptors.runtime" ":core:descriptors.runtime"
@@ -7,14 +7,13 @@ package org.jetbrains.kotlin.pill.generateAllTests;
import org.jetbrains.kotlin.generators.tests.*; import org.jetbrains.kotlin.generators.tests.*;
import org.jetbrains.kotlin.generators.InconsistencyChecker; import org.jetbrains.kotlin.generators.InconsistencyChecker;
import org.jetbrains.kotlin.test.generators.GenerateNewCompilerTestsKt; import org.jetbrains.kotlin.test.generators.GenerateCompilerTestsKt;
import java.util.List; import java.util.List;
public class Main { public class Main {
public static void main(String[] args) { public static void main(String[] args) {
GenerateCompilerTestsKt.main(args); GenerateCompilerTestsKt.main(args);
GenerateNewCompilerTestsKt.main(args);
GenerateTestsKt.main(args); GenerateTestsKt.main(args);
GenerateJsTestsKt.main(args); GenerateJsTestsKt.main(args);
GenerateJava8TestsKt.main(args); GenerateJava8TestsKt.main(args);
+1
View File
@@ -121,6 +121,7 @@ include ":benchmarks",
":compiler:tests-mutes:tc-integration", ":compiler:tests-mutes:tc-integration",
":compiler:tests-common-jvm6", ":compiler:tests-common-jvm6",
":compiler:tests-against-klib", ":compiler:tests-against-klib",
":compiler:tests-for-compiler-generator",
":dukat", ":dukat",
":js:js.ast", ":js:js.ast",
":js:js.serializer", ":js:js.serializer",