[Tests] All tests correct generation
This commit is contained in:
+2
-2
@@ -209,8 +209,8 @@ object NewTestGeneratorImpl : TestGenerator(METHOD_GENERATORS) {
|
||||
var first = true
|
||||
|
||||
for (methodModel in testMethods) {
|
||||
if (methodModel is RunTestMethodModel) continue
|
||||
if (!methodModel.shouldBeGenerated()) continue
|
||||
if (methodModel is RunTestMethodModel) continue // should also skip its imports
|
||||
if (!methodModel.shouldBeGenerated()) continue // should also skip its imports
|
||||
|
||||
if (first) {
|
||||
first = false
|
||||
|
||||
+2
-1
@@ -11,7 +11,8 @@ class RunTestMethodModel(
|
||||
val targetBackend: TargetBackend,
|
||||
val testMethodName: String,
|
||||
val testRunnerMethodName: String,
|
||||
val additionalRunnerArguments: List<String> = emptyList()
|
||||
val additionalRunnerArguments: List<String> = emptyList(),
|
||||
val withTransformer: Boolean = false
|
||||
) : MethodModel {
|
||||
object Kind : MethodModel.Kind()
|
||||
|
||||
|
||||
+5
@@ -117,6 +117,11 @@ class SimpleTestClassModel(
|
||||
}
|
||||
}
|
||||
}
|
||||
if (result.any { it is WithoutJvmInlineTestMethodModel }) {
|
||||
val additionalRunner =
|
||||
RunTestMethodModel(targetBackend, doTestMethodName, testRunnerMethodName, additionalRunnerArguments, withTransformer = true)
|
||||
result.add(additionalRunner)
|
||||
}
|
||||
result.sortWith(BY_NAME)
|
||||
result
|
||||
}
|
||||
|
||||
+5
@@ -38,6 +38,11 @@ class SingleClassTestModel(
|
||||
}
|
||||
true
|
||||
}
|
||||
if (result.any { it is WithoutJvmInlineTestMethodModel }) {
|
||||
val additionalRunner =
|
||||
RunTestMethodModel(targetBackend, doTestMethodName, testRunnerMethodName, additionalRunnerArguments, withTransformer = true)
|
||||
result.add(additionalRunner)
|
||||
}
|
||||
result.sortedWith { o1: MethodModel, o2: MethodModel -> o1.name.compareTo(o2.name, ignoreCase = true) }
|
||||
}
|
||||
|
||||
|
||||
+14
-5
@@ -10,12 +10,15 @@ import org.jetbrains.kotlin.test.TargetBackend
|
||||
import java.io.File
|
||||
import java.util.regex.Pattern
|
||||
|
||||
fun TestEntityModel.containsWithoutJvmInline(backend: TargetBackend): Boolean = backend == TargetBackend.JVM_IR && when (this) {
|
||||
is ClassModel -> methods.any { it.containsWithoutJvmInline(backend) } || innerTestClasses.any { it.containsWithoutJvmInline(backend) }
|
||||
is SimpleTestMethodModel -> file.readLines().any { Regex("^\\s*//\\s*WORKS_WHEN_VALUE_CLASS\\s*$").matches(it) }
|
||||
fun TestEntityModel.containsWithoutJvmInline(): Boolean = when (this) {
|
||||
is ClassModel -> methods.any { it.containsWithoutJvmInline() } || innerTestClasses.any { it.containsWithoutJvmInline() }
|
||||
is SimpleTestMethodModel -> file.isFile && file.readLines().any { Regex("^\\s*//\\s*WORKS_WHEN_VALUE_CLASS\\s*$").matches(it) }
|
||||
else -> false
|
||||
}
|
||||
|
||||
private fun TargetBackend.isRecursivelyCompatibleWith(targetBackend: TargetBackend): Boolean =
|
||||
this == targetBackend || this != TargetBackend.ANY && this.compatibleWith.isRecursivelyCompatibleWith(targetBackend)
|
||||
|
||||
fun methodModelLocator(
|
||||
rootDir: File,
|
||||
file: File,
|
||||
@@ -33,6 +36,12 @@ fun methodModelLocator(
|
||||
skipIgnored,
|
||||
tags
|
||||
).let { methodModel ->
|
||||
if (methodModel.containsWithoutJvmInline(targetBackend)) listOf(true, false).map { WithoutJvmInlineTestMethodModel(methodModel, it) }
|
||||
else listOf(methodModel)
|
||||
if (methodModel.containsWithoutJvmInline()) {
|
||||
val isWithoutAnnotations = when {
|
||||
targetBackend.isRecursivelyCompatibleWith(TargetBackend.JVM_IR) -> listOf(true, false)
|
||||
targetBackend.isRecursivelyCompatibleWith(TargetBackend.JVM) -> listOf(true)
|
||||
else -> listOf(false)
|
||||
}
|
||||
isWithoutAnnotations.map { WithoutJvmInlineTestMethodModel(methodModel, it) }
|
||||
} else listOf(methodModel)
|
||||
}
|
||||
Reference in New Issue
Block a user