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