[TEST-GEN] Extract run of TestGenerator to top of test generation DSL
This commit is contained in:
+2
-2
@@ -6,13 +6,13 @@
|
||||
package org.jetbrains.kotlin.generators.tests
|
||||
|
||||
import org.jetbrains.kotlin.codegen.ir.AbstractCompileKotlinAgainstKlibTest
|
||||
import org.jetbrains.kotlin.generators.tests.generator.testGroupSuite
|
||||
import org.jetbrains.kotlin.generators.tests.generator.generateTestGroupSuite
|
||||
import org.jetbrains.kotlin.test.TargetBackend
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
System.setProperty("java.awt.headless", "true")
|
||||
|
||||
testGroupSuite(args) {
|
||||
generateTestGroupSuite(args) {
|
||||
testGroup("compiler/tests-against-klib/tests", "compiler/testData") {
|
||||
testClass<AbstractCompileKotlinAgainstKlibTest> {
|
||||
model("codegen/boxKlib", targetBackend = TargetBackend.JVM_IR)
|
||||
|
||||
+2
-2
@@ -21,7 +21,7 @@ import org.jetbrains.kotlin.checkers.AbstractForeignJava8AnnotationsNoAnnotation
|
||||
import org.jetbrains.kotlin.checkers.AbstractForeignJava8AnnotationsTest
|
||||
import org.jetbrains.kotlin.checkers.AbstractJspecifyAnnotationsTest
|
||||
import org.jetbrains.kotlin.checkers.javac.AbstractJavacForeignJava8AnnotationsTest
|
||||
import org.jetbrains.kotlin.generators.tests.generator.testGroupSuite
|
||||
import org.jetbrains.kotlin.generators.tests.generator.generateTestGroupSuite
|
||||
import org.jetbrains.kotlin.jvm.compiler.AbstractLoadJava8Test
|
||||
import org.jetbrains.kotlin.jvm.compiler.AbstractLoadJava8WithPsiClassReadingTest
|
||||
import org.jetbrains.kotlin.jvm.compiler.javac.AbstractLoadJava8UsingJavacTest
|
||||
@@ -30,7 +30,7 @@ import org.jetbrains.kotlin.resolve.calls.AbstractEnhancedSignaturesResolvedCall
|
||||
fun main(args: Array<String>) {
|
||||
System.setProperty("java.awt.headless", "true")
|
||||
|
||||
testGroupSuite(args) {
|
||||
generateTestGroupSuite(args) {
|
||||
testGroup("compiler/tests-java8/tests", "compiler/testData") {
|
||||
testClass<AbstractForeignJava8AnnotationsTest> {
|
||||
model("foreignAnnotationsJava8/tests", excludeDirs = listOf("jspecify"))
|
||||
|
||||
+2
-2
@@ -5,7 +5,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.spec.utils.tasks
|
||||
|
||||
import org.jetbrains.kotlin.generators.tests.generator.testGroupSuite
|
||||
import org.jetbrains.kotlin.generators.tests.generator.generateTestGroupSuite
|
||||
import org.jetbrains.kotlin.spec.checkers.AbstractDiagnosticsTestSpec
|
||||
import org.jetbrains.kotlin.spec.checkers.AbstractFirDiagnosticsTestSpec
|
||||
import org.jetbrains.kotlin.spec.codegen.AbstractBlackBoxCodegenTestSpec
|
||||
@@ -39,7 +39,7 @@ fun detectDirsWithTestsMapFileOnly(dirName: String): List<String> {
|
||||
fun generateTests() {
|
||||
val excludedFirTestdataPattern = "^(.+)\\.fir\\.kts?\$"
|
||||
|
||||
testGroupSuite {
|
||||
generateTestGroupSuite {
|
||||
testGroup(SPEC_TEST_PATH, SPEC_TESTDATA_PATH) {
|
||||
testClass<AbstractDiagnosticsTestSpec> {
|
||||
model(
|
||||
|
||||
@@ -30,7 +30,7 @@ import org.jetbrains.kotlin.fir.java.AbstractFirOldFrontendLightClassesTest
|
||||
import org.jetbrains.kotlin.fir.java.AbstractFirTypeEnhancementTest
|
||||
import org.jetbrains.kotlin.fir.java.AbstractOwnFirTypeEnhancementTest
|
||||
import org.jetbrains.kotlin.fir.lightTree.AbstractLightTree2FirConverterTestCase
|
||||
import org.jetbrains.kotlin.generators.tests.generator.testGroupSuite
|
||||
import org.jetbrains.kotlin.generators.tests.generator.generateTestGroupSuite
|
||||
import org.jetbrains.kotlin.generators.util.KT_OR_KTS_WITHOUT_DOTS_IN_NAME
|
||||
import org.jetbrains.kotlin.generators.util.KT_WITHOUT_DOTS_IN_NAME
|
||||
import org.jetbrains.kotlin.integration.AbstractAntTaskTest
|
||||
@@ -68,7 +68,7 @@ fun main(args: Array<String>) {
|
||||
|
||||
val excludedFirTestdataPattern = "^(.+)\\.fir\\.kts?\$"
|
||||
|
||||
testGroupSuite(args) {
|
||||
generateTestGroupSuite(args) {
|
||||
testGroup("compiler/tests-gen", "compiler/testData") {
|
||||
testClass<AbstractDiagnosticsTestWithFirValidation>(suiteTestClassName = "DiagnosticsTestGenerated") {
|
||||
model("diagnostics/tests", pattern = "^(.*)\\.kts?$", excludedPattern = excludedFirTestdataPattern)
|
||||
|
||||
+2
-2
@@ -16,14 +16,14 @@
|
||||
|
||||
package org.jetbrains.kotlin.generators.tests
|
||||
|
||||
import org.jetbrains.kotlin.generators.tests.generator.testGroupSuite
|
||||
import org.jetbrains.kotlin.generators.tests.generator.generateTestGroupSuite
|
||||
import org.jetbrains.kotlin.jvm.runtime.AbstractJvm8RuntimeDescriptorLoaderTest
|
||||
import org.jetbrains.kotlin.jvm.runtime.AbstractJvmRuntimeDescriptorLoaderTest
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
System.setProperty("java.awt.headless", "true")
|
||||
|
||||
testGroupSuite(args) {
|
||||
generateTestGroupSuite(args) {
|
||||
testGroup("core/descriptors.runtime/tests", "compiler/testData") {
|
||||
testClass<AbstractJvmRuntimeDescriptorLoaderTest> {
|
||||
model("loadJava/compiledKotlin")
|
||||
|
||||
+29
-14
@@ -8,7 +8,6 @@ package org.jetbrains.kotlin.generators.tests.generator
|
||||
import junit.framework.TestCase
|
||||
import org.jetbrains.kotlin.generators.tests.generator.InconsistencyChecker.Companion.hasDryRunArg
|
||||
import org.jetbrains.kotlin.generators.tests.generator.InconsistencyChecker.Companion.inconsistencyChecker
|
||||
import org.jetbrains.kotlin.generators.tests.generator.generators.TestGenerator
|
||||
import org.jetbrains.kotlin.generators.tests.generator.generators.impl.*
|
||||
import org.jetbrains.kotlin.test.TargetBackend
|
||||
import java.io.File
|
||||
@@ -21,8 +20,11 @@ class TestGroup(
|
||||
val testRunnerMethodName: String,
|
||||
val additionalRunnerArguments: List<String> = emptyList(),
|
||||
val annotations: List<AnnotationModel> = emptyList(),
|
||||
private val dryRun: Boolean = false
|
||||
) {
|
||||
private val _testClasses: MutableList<TestClass> = mutableListOf()
|
||||
val testClasses: List<TestClass>
|
||||
get() = _testClasses
|
||||
|
||||
inline fun <reified T : TestCase> testClass(
|
||||
suiteTestClassName: String = getDefaultSuiteTestClassName(T::class.java.simpleName),
|
||||
useJunit4: Boolean = false,
|
||||
@@ -39,11 +41,7 @@ class TestGroup(
|
||||
annotations: List<AnnotationModel> = emptyList(),
|
||||
init: TestClass.() -> Unit
|
||||
) {
|
||||
val testClass = TestClass(baseTestClassName, suiteTestClassName, useJunit4, annotations).apply(init)
|
||||
val (changed, testSourceFilePath) = TestGeneratorImpl.generateAndSave(testClass, dryRun)
|
||||
if (changed) {
|
||||
inconsistencyChecker(dryRun).add(testSourceFilePath)
|
||||
}
|
||||
_testClasses += TestClass(baseTestClassName, suiteTestClassName, useJunit4, annotations).apply(init)
|
||||
}
|
||||
|
||||
inner class TestClass(
|
||||
@@ -99,20 +97,38 @@ class TestGroup(
|
||||
}
|
||||
|
||||
fun testGroupSuite(
|
||||
init: TestGroupSuite.() -> Unit
|
||||
): TestGroupSuite {
|
||||
return TestGroupSuite().apply(init)
|
||||
}
|
||||
|
||||
fun generateTestGroupSuite(
|
||||
args: Array<String>,
|
||||
init: TestGroupSuite.() -> Unit
|
||||
) {
|
||||
testGroupSuite(hasDryRunArg(args), init)
|
||||
generateTestGroupSuite(hasDryRunArg(args), init)
|
||||
}
|
||||
|
||||
fun testGroupSuite(
|
||||
fun generateTestGroupSuite(
|
||||
dryRun: Boolean = false,
|
||||
init: TestGroupSuite.() -> Unit
|
||||
) {
|
||||
TestGroupSuite(dryRun).init()
|
||||
val suite = testGroupSuite(init)
|
||||
for (testGroup in suite.testGroups) {
|
||||
for (testClass in testGroup.testClasses) {
|
||||
val (changed, testSourceFilePath) = TestGeneratorImpl.generateAndSave(testClass, dryRun)
|
||||
if (changed) {
|
||||
inconsistencyChecker(dryRun).add(testSourceFilePath)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class TestGroupSuite(private val dryRun: Boolean) {
|
||||
class TestGroupSuite {
|
||||
private val _testGroups = mutableListOf<TestGroup>()
|
||||
val testGroups: List<TestGroup>
|
||||
get() = _testGroups
|
||||
|
||||
fun testGroup(
|
||||
testsRoot: String,
|
||||
testDataRoot: String,
|
||||
@@ -120,13 +136,12 @@ class TestGroupSuite(private val dryRun: Boolean) {
|
||||
additionalRunnerArguments: List<String> = emptyList(),
|
||||
init: TestGroup.() -> Unit
|
||||
) {
|
||||
TestGroup(
|
||||
_testGroups += TestGroup(
|
||||
testsRoot,
|
||||
testDataRoot,
|
||||
testRunnerMethodName,
|
||||
additionalRunnerArguments,
|
||||
dryRun = dryRun
|
||||
).init()
|
||||
).apply(init)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.jetbrains.kotlin.formatter.AbstractFormatterTest
|
||||
import org.jetbrains.kotlin.formatter.AbstractTypingIndentationTestBase
|
||||
import org.jetbrains.kotlin.generators.tests.generator.TestGroup
|
||||
import org.jetbrains.kotlin.generators.tests.generator.muteExtraSuffix
|
||||
import org.jetbrains.kotlin.generators.tests.generator.testGroupSuite
|
||||
import org.jetbrains.kotlin.generators.tests.generator.generateTestGroupSuite
|
||||
import org.jetbrains.kotlin.generators.util.KT_OR_KTS
|
||||
import org.jetbrains.kotlin.generators.util.KT_OR_KTS_WITHOUT_DOTS_IN_NAME
|
||||
import org.jetbrains.kotlin.generators.util.KT_WITHOUT_DOTS_IN_NAME
|
||||
@@ -195,7 +195,7 @@ import org.jetbrains.kotlinx.serialization.AbstractSerializationPluginDiagnostic
|
||||
fun main(args: Array<String>) {
|
||||
System.setProperty("java.awt.headless", "true")
|
||||
|
||||
testGroupSuite(args) {
|
||||
generateTestGroupSuite(args) {
|
||||
testGroup("idea/jvm-debugger/jvm-debugger-test/test", "idea/jvm-debugger/jvm-debugger-test/testData") {
|
||||
testClass<AbstractKotlinSteppingTest> {
|
||||
model(
|
||||
|
||||
@@ -31,7 +31,7 @@ import org.jetbrains.kotlin.formatter.AbstractFormatterTest
|
||||
import org.jetbrains.kotlin.formatter.AbstractTypingIndentationTestBase
|
||||
import org.jetbrains.kotlin.generators.tests.generator.TestGroup
|
||||
import org.jetbrains.kotlin.generators.tests.generator.muteExtraSuffix
|
||||
import org.jetbrains.kotlin.generators.tests.generator.testGroupSuite
|
||||
import org.jetbrains.kotlin.generators.tests.generator.generateTestGroupSuite
|
||||
import org.jetbrains.kotlin.generators.util.KT_OR_KTS
|
||||
import org.jetbrains.kotlin.generators.util.KT_OR_KTS_WITHOUT_DOTS_IN_NAME
|
||||
import org.jetbrains.kotlin.generators.util.KT_WITHOUT_DOTS_IN_NAME
|
||||
@@ -167,7 +167,7 @@ import org.jetbrains.kotlinx.serialization.AbstractSerializationIrBytecodeListin
|
||||
fun main(args: Array<String>) {
|
||||
System.setProperty("java.awt.headless", "true")
|
||||
|
||||
testGroupSuite(args) {
|
||||
generateTestGroupSuite(args) {
|
||||
testGroup("idea/jvm-debugger/jvm-debugger-test/test", "idea/jvm-debugger/jvm-debugger-test/testData") {
|
||||
testClass<AbstractKotlinSteppingTest> {
|
||||
model(
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.generators.tests
|
||||
|
||||
import org.jetbrains.kotlin.generators.tests.generator.testGroupSuite
|
||||
import org.jetbrains.kotlin.generators.tests.generator.generateTestGroupSuite
|
||||
import org.jetbrains.kotlin.js.test.AbstractDceTest
|
||||
import org.jetbrains.kotlin.js.test.AbstractJsLineNumberTest
|
||||
import org.jetbrains.kotlin.js.test.es6.semantics.*
|
||||
@@ -20,7 +20,7 @@ fun main(args: Array<String>) {
|
||||
// TODO: repair these tests
|
||||
//generateTestDataForReservedWords()
|
||||
|
||||
testGroupSuite(args) {
|
||||
generateTestGroupSuite(args) {
|
||||
testGroup("js/js.tests/tests-gen", "js/js.translator/testData", testRunnerMethodName = "runTest0") {
|
||||
testClass<AbstractBoxJsTest> {
|
||||
model("box/", pattern = "^([^_](.+))\\.kt$", targetBackend = TargetBackend.JS)
|
||||
|
||||
+2
-2
@@ -5,12 +5,12 @@
|
||||
|
||||
package org.jetbrains.kotlin.kotlinp.test
|
||||
|
||||
import org.jetbrains.kotlin.generators.tests.generator.testGroupSuite
|
||||
import org.jetbrains.kotlin.generators.tests.generator.generateTestGroupSuite
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
System.setProperty("java.awt.headless", "true")
|
||||
|
||||
testGroupSuite(args) {
|
||||
generateTestGroupSuite(args) {
|
||||
testGroup("libraries/tools/kotlinp/test", "libraries/tools/kotlinp/testData") {
|
||||
testClass<AbstractKotlinpTest> {
|
||||
model("")
|
||||
|
||||
Reference in New Issue
Block a user