[Tests] Generate runTest with transformer parameter + example
This commit is contained in:
+6
@@ -19294,6 +19294,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
|||||||
runTest("compiler/testData/codegen/box/inlineClasses/boxResultInlineClassOfConstructorCall.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/boxResultInlineClassOfConstructorCall.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("boxResultInlineClassOfConstructorCall.kt")
|
||||||
|
public void testBoxResultInlineClassOfConstructorCallWithoutJvmInlineAnnotation() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inlineClasses/boxResultInlineClassOfConstructorCall.kt", s -> s.replaceAll("@(kotlin.jvm.)?JvmInline", ""));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("boxUnboxInlineClassesWithOperatorsGetSet.kt")
|
@TestMetadata("boxUnboxInlineClassesWithOperatorsGetSet.kt")
|
||||||
public void testBoxUnboxInlineClassesWithOperatorsGetSet() throws Exception {
|
public void testBoxUnboxInlineClassesWithOperatorsGetSet() throws Exception {
|
||||||
|
|||||||
@@ -24,9 +24,13 @@ class TestRunner(private val testConfiguration: TestConfiguration) {
|
|||||||
private val allFailedExceptions = mutableListOf<WrappedException>()
|
private val allFailedExceptions = mutableListOf<WrappedException>()
|
||||||
private val allRanHandlers = mutableSetOf<AnalysisHandler<*>>()
|
private val allRanHandlers = mutableSetOf<AnalysisHandler<*>>()
|
||||||
|
|
||||||
fun runTest(@TestDataFile testDataFileName: String, beforeDispose: (TestConfiguration) -> Unit = {}) {
|
fun runTest(
|
||||||
|
@TestDataFile testDataFileName: String,
|
||||||
|
beforeDispose: (TestConfiguration) -> Unit = {},
|
||||||
|
expectedFileTransformer: ((String) -> String)? = null
|
||||||
|
) {
|
||||||
try {
|
try {
|
||||||
runTestImpl(testDataFileName)
|
runTestImpl(testDataFileName, expectedFileTransformer)
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
testConfiguration.testServices.temporaryDirectoryManager.cleanupTemporaryDirectories()
|
testConfiguration.testServices.temporaryDirectoryManager.cleanupTemporaryDirectories()
|
||||||
@@ -38,7 +42,7 @@ class TestRunner(private val testConfiguration: TestConfiguration) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun runTestImpl(@TestDataFile testDataFileName: String) {
|
private fun runTestImpl(@TestDataFile testDataFileName: String, expectedFileTransformer: ((String) -> String)?) {
|
||||||
val services = testConfiguration.testServices
|
val services = testConfiguration.testServices
|
||||||
|
|
||||||
@Suppress("NAME_SHADOWING")
|
@Suppress("NAME_SHADOWING")
|
||||||
@@ -66,12 +70,13 @@ class TestRunner(private val testConfiguration: TestConfiguration) {
|
|||||||
if (it.shouldSkipTest()) return
|
if (it.shouldSkipTest()) return
|
||||||
}
|
}
|
||||||
|
|
||||||
runTestPipeline(moduleStructure, services)
|
runTestPipeline(moduleStructure, services, expectedFileTransformer)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun runTestPipeline(
|
fun runTestPipeline(
|
||||||
moduleStructure: TestModuleStructure,
|
moduleStructure: TestModuleStructure,
|
||||||
services: TestServices
|
services: TestServices,
|
||||||
|
expectedFileTransformer: ((String) -> String)?,
|
||||||
) {
|
) {
|
||||||
val globalMetadataInfoHandler = testConfiguration.testServices.globalMetadataInfoHandler
|
val globalMetadataInfoHandler = testConfiguration.testServices.globalMetadataInfoHandler
|
||||||
globalMetadataInfoHandler.parseExistingMetadataInfosFromAllSources()
|
globalMetadataInfoHandler.parseExistingMetadataInfosFromAllSources()
|
||||||
@@ -100,7 +105,7 @@ class TestRunner(private val testConfiguration: TestConfiguration) {
|
|||||||
}
|
}
|
||||||
if (testConfiguration.metaInfoHandlerEnabled) {
|
if (testConfiguration.metaInfoHandlerEnabled) {
|
||||||
withAssertionCatching(WrappedException::FromMetaInfoHandler) {
|
withAssertionCatching(WrappedException::FromMetaInfoHandler) {
|
||||||
globalMetadataInfoHandler.compareAllMetaDataInfos()
|
globalMetadataInfoHandler.compareAllMetaDataInfos(expectedFileTransformer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+9
-2
@@ -51,7 +51,7 @@ class GlobalMetadataInfoHandler(
|
|||||||
infos += codeMetaInfos
|
infos += codeMetaInfos
|
||||||
}
|
}
|
||||||
|
|
||||||
fun compareAllMetaDataInfos() {
|
fun compareAllMetaDataInfos(expectedTransformer: ((String) -> String)?) {
|
||||||
// TODO: adapt to multiple testdata files
|
// TODO: adapt to multiple testdata files
|
||||||
val moduleStructure = testServices.moduleStructure
|
val moduleStructure = testServices.moduleStructure
|
||||||
val builder = StringBuilder()
|
val builder = StringBuilder()
|
||||||
@@ -70,7 +70,14 @@ class GlobalMetadataInfoHandler(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
val actualText = builder.toString()
|
val actualText = builder.toString()
|
||||||
testServices.assertions.assertEqualsToFile(moduleStructure.originalTestDataFiles.single(), actualText)
|
val expectedFile = moduleStructure.originalTestDataFiles.single()
|
||||||
|
if (expectedTransformer != null) {
|
||||||
|
val expectedContent = expectedFile.readText().let(expectedTransformer)
|
||||||
|
val message = "Actual data differs from transformed content of file $expectedFile"
|
||||||
|
testServices.assertions.assertEquals(expectedContent, actualText) { message }
|
||||||
|
} else {
|
||||||
|
testServices.assertions.assertEqualsToFile(expectedFile, actualText)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun StringBuilder.stripAdditionalEmptyLines(file: TestFile): CharSequence {
|
private fun StringBuilder.stripAdditionalEmptyLines(file: TestFile): CharSequence {
|
||||||
|
|||||||
+1
@@ -1,4 +1,5 @@
|
|||||||
// WITH_STDLIB
|
// WITH_STDLIB
|
||||||
|
// WORKS_WITHOUT_JVM_INLINE
|
||||||
|
|
||||||
@Suppress("OPTIONAL_DECLARATION_USAGE_IN_NON_COMMON_SOURCE")
|
@Suppress("OPTIONAL_DECLARATION_USAGE_IN_NON_COMMON_SOURCE")
|
||||||
@kotlin.jvm.JvmInline
|
@kotlin.jvm.JvmInline
|
||||||
|
|||||||
+6
@@ -19294,6 +19294,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/inlineClasses/boxResultInlineClassOfConstructorCall.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/boxResultInlineClassOfConstructorCall.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("boxResultInlineClassOfConstructorCall.kt")
|
||||||
|
public void testBoxResultInlineClassOfConstructorCallWithoutJvmInlineAnnotation() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inlineClasses/boxResultInlineClassOfConstructorCall.kt", s -> s.replaceAll("@(kotlin.jvm.)?JvmInline", ""));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("boxUnboxInlineClassesWithOperatorsGetSet.kt")
|
@TestMetadata("boxUnboxInlineClassesWithOperatorsGetSet.kt")
|
||||||
public void testBoxUnboxInlineClassesWithOperatorsGetSet() throws Exception {
|
public void testBoxUnboxInlineClassesWithOperatorsGetSet() throws Exception {
|
||||||
|
|||||||
+17
-4
@@ -12,11 +12,9 @@ import org.jetbrains.kotlin.test.builders.testRunner
|
|||||||
import org.jetbrains.kotlin.test.directives.ConfigurationDirectives
|
import org.jetbrains.kotlin.test.directives.ConfigurationDirectives
|
||||||
import org.jetbrains.kotlin.test.directives.LanguageSettingsDirectives
|
import org.jetbrains.kotlin.test.directives.LanguageSettingsDirectives
|
||||||
import org.jetbrains.kotlin.test.model.ResultingArtifact
|
import org.jetbrains.kotlin.test.model.ResultingArtifact
|
||||||
|
import org.jetbrains.kotlin.test.model.TestFile
|
||||||
import org.jetbrains.kotlin.test.preprocessors.MetaInfosCleanupPreprocessor
|
import org.jetbrains.kotlin.test.preprocessors.MetaInfosCleanupPreprocessor
|
||||||
import org.jetbrains.kotlin.test.services.JUnit5Assertions
|
import org.jetbrains.kotlin.test.services.*
|
||||||
import org.jetbrains.kotlin.test.services.KotlinTestInfo
|
|
||||||
import org.jetbrains.kotlin.test.services.SourceFilePreprocessor
|
|
||||||
import org.jetbrains.kotlin.test.services.TemporaryDirectoryManager
|
|
||||||
import org.jetbrains.kotlin.test.services.impl.TemporaryDirectoryManagerImpl
|
import org.jetbrains.kotlin.test.services.impl.TemporaryDirectoryManagerImpl
|
||||||
import org.jetbrains.kotlin.types.AbstractTypeChecker
|
import org.jetbrains.kotlin.types.AbstractTypeChecker
|
||||||
import org.jetbrains.kotlin.types.FlexibleTypeImpl
|
import org.jetbrains.kotlin.types.FlexibleTypeImpl
|
||||||
@@ -82,4 +80,19 @@ abstract class AbstractKotlinCompilerTest {
|
|||||||
open fun runTest(@TestDataFile filePath: String) {
|
open fun runTest(@TestDataFile filePath: String) {
|
||||||
testRunner(filePath, configuration).runTest(filePath)
|
testRunner(filePath, configuration).runTest(filePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JvmOverloads
|
||||||
|
open fun runTest(
|
||||||
|
@TestDataFile filePath: String,
|
||||||
|
actualContentModifier: (String) -> String,
|
||||||
|
expectedContentModifier: ((String) -> String)? = actualContentModifier
|
||||||
|
) {
|
||||||
|
class SourceTransformer(testServices: TestServices) : SourceFilePreprocessor(testServices) {
|
||||||
|
override fun process(file: TestFile, content: String): String = content.let(actualContentModifier)
|
||||||
|
}
|
||||||
|
testRunner(filePath) {
|
||||||
|
configuration.let { it() } // property configuration, not method
|
||||||
|
useSourcePreprocessor({ SourceTransformer(it) })
|
||||||
|
}.runTest(filePath, expectedFileTransformer = expectedContentModifier)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -20,13 +20,13 @@ import org.junit.runner.RunWith
|
|||||||
import org.junit.runners.BlockJUnit4ClassRunner
|
import org.junit.runners.BlockJUnit4ClassRunner
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
private val METHOD_GENERATORS = listOf(
|
private val METHOD_GENERATORS = listOf(
|
||||||
RunTestMethodGenerator,
|
RunTestMethodGenerator,
|
||||||
SimpleTestClassModelTestAllFilesPresentMethodGenerator,
|
SimpleTestClassModelTestAllFilesPresentMethodGenerator,
|
||||||
SimpleTestMethodGenerator,
|
SimpleTestMethodGenerator,
|
||||||
SingleClassTestModelAllFilesPresentedMethodGenerator
|
SingleClassTestModelAllFilesPresentedMethodGenerator,
|
||||||
|
WithoutJvmInlineTestMethodGenerator,
|
||||||
)
|
)
|
||||||
|
|
||||||
object TestGeneratorImpl : TestGenerator(METHOD_GENERATORS) {
|
object TestGeneratorImpl : TestGenerator(METHOD_GENERATORS) {
|
||||||
|
|||||||
+3
-2
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.generators
|
|||||||
import org.jetbrains.kotlin.generators.impl.SimpleTestClassModelTestAllFilesPresentMethodGenerator
|
import org.jetbrains.kotlin.generators.impl.SimpleTestClassModelTestAllFilesPresentMethodGenerator
|
||||||
import org.jetbrains.kotlin.generators.impl.SimpleTestMethodGenerator
|
import org.jetbrains.kotlin.generators.impl.SimpleTestMethodGenerator
|
||||||
import org.jetbrains.kotlin.generators.impl.SingleClassTestModelAllFilesPresentedMethodGenerator
|
import org.jetbrains.kotlin.generators.impl.SingleClassTestModelAllFilesPresentedMethodGenerator
|
||||||
|
import org.jetbrains.kotlin.generators.impl.WithoutJvmInlineTestMethodGenerator
|
||||||
import org.jetbrains.kotlin.generators.model.*
|
import org.jetbrains.kotlin.generators.model.*
|
||||||
import org.jetbrains.kotlin.generators.util.GeneratorsFileUtil
|
import org.jetbrains.kotlin.generators.util.GeneratorsFileUtil
|
||||||
import org.jetbrains.kotlin.test.TestMetadata
|
import org.jetbrains.kotlin.test.TestMetadata
|
||||||
@@ -18,14 +19,14 @@ import org.junit.jupiter.api.Tag
|
|||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
private const val TEST_GENERATOR_NAME = "GenerateNewCompilerTests.kt"
|
private const val TEST_GENERATOR_NAME = "GenerateNewCompilerTests.kt"
|
||||||
|
|
||||||
private val METHOD_GENERATORS = listOf(
|
private val METHOD_GENERATORS = listOf(
|
||||||
SimpleTestClassModelTestAllFilesPresentMethodGenerator,
|
SimpleTestClassModelTestAllFilesPresentMethodGenerator,
|
||||||
SimpleTestMethodGenerator,
|
SimpleTestMethodGenerator,
|
||||||
SingleClassTestModelAllFilesPresentedMethodGenerator
|
SingleClassTestModelAllFilesPresentedMethodGenerator,
|
||||||
|
WithoutJvmInlineTestMethodGenerator,
|
||||||
)
|
)
|
||||||
|
|
||||||
object NewTestGeneratorImpl : TestGenerator(METHOD_GENERATORS) {
|
object NewTestGeneratorImpl : TestGenerator(METHOD_GENERATORS) {
|
||||||
|
|||||||
+30
@@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2021 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.impl
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.generators.MethodGenerator
|
||||||
|
import org.jetbrains.kotlin.generators.model.MethodModel
|
||||||
|
import org.jetbrains.kotlin.generators.model.RunTestMethodModel
|
||||||
|
import org.jetbrains.kotlin.generators.model.WithoutJvmInlineTestMethodModel
|
||||||
|
import org.jetbrains.kotlin.test.util.KtTestUtil
|
||||||
|
import org.jetbrains.kotlin.utils.Printer
|
||||||
|
|
||||||
|
object WithoutJvmInlineTestMethodGenerator : MethodGenerator<WithoutJvmInlineTestMethodModel>() {
|
||||||
|
|
||||||
|
override val kind: MethodModel.Kind
|
||||||
|
get() = WithoutJvmInlineTestMethodModel.Kind
|
||||||
|
|
||||||
|
override fun generateSignature(method: WithoutJvmInlineTestMethodModel, p: Printer) {
|
||||||
|
generateDefaultSignature(method, p)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun generateBody(method: WithoutJvmInlineTestMethodModel, p: Printer) {
|
||||||
|
with(method) {
|
||||||
|
val filePath = KtTestUtil.getFilePath(source.file) + if (source.file.isDirectory) "/" else ""
|
||||||
|
p.println("${RunTestMethodModel.METHOD_NAME}(\"$filePath\", s -> s.replaceAll(\"@(kotlin.jvm.)?JvmInline\", \"\"));")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+11
-13
@@ -8,10 +8,10 @@ import com.intellij.openapi.util.io.FileUtil
|
|||||||
import org.jetbrains.kotlin.generators.util.TestGeneratorUtil.fileNameToJavaIdentifier
|
import org.jetbrains.kotlin.generators.util.TestGeneratorUtil.fileNameToJavaIdentifier
|
||||||
import org.jetbrains.kotlin.generators.util.extractTagsFromDirectory
|
import org.jetbrains.kotlin.generators.util.extractTagsFromDirectory
|
||||||
import org.jetbrains.kotlin.generators.util.extractTagsFromTestFile
|
import org.jetbrains.kotlin.generators.util.extractTagsFromTestFile
|
||||||
|
import org.jetbrains.kotlin.generators.util.methodModelLocator
|
||||||
import org.jetbrains.kotlin.test.TargetBackend
|
import org.jetbrains.kotlin.test.TargetBackend
|
||||||
import org.jetbrains.kotlin.test.util.KtTestUtil
|
import org.jetbrains.kotlin.test.util.KtTestUtil
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.*
|
|
||||||
import java.util.regex.Pattern
|
import java.util.regex.Pattern
|
||||||
|
|
||||||
class SimpleTestClassModel(
|
class SimpleTestClassModel(
|
||||||
@@ -87,16 +87,14 @@ class SimpleTestClassModel(
|
|||||||
|
|
||||||
override val methods: Collection<MethodModel> by lazy {
|
override val methods: Collection<MethodModel> by lazy {
|
||||||
if (!rootFile.isDirectory) {
|
if (!rootFile.isDirectory) {
|
||||||
return@lazy listOf(
|
return@lazy methodModelLocator(
|
||||||
SimpleTestMethodModel(
|
rootFile,
|
||||||
rootFile,
|
rootFile,
|
||||||
rootFile,
|
filenamePattern,
|
||||||
filenamePattern,
|
checkFilenameStartsLowerCase,
|
||||||
checkFilenameStartsLowerCase,
|
targetBackend,
|
||||||
targetBackend,
|
skipIgnored,
|
||||||
skipIgnored,
|
extractTagsFromTestFile(rootFile)
|
||||||
extractTagsFromTestFile(rootFile)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
val result = mutableListOf<MethodModel>()
|
val result = mutableListOf<MethodModel>()
|
||||||
@@ -110,8 +108,8 @@ class SimpleTestClassModel(
|
|||||||
if (file.isDirectory && excludeParentDirs && dirHasSubDirs(file)) {
|
if (file.isDirectory && excludeParentDirs && dirHasSubDirs(file)) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
result.add(
|
result.addAll(
|
||||||
SimpleTestMethodModel(
|
methodModelLocator(
|
||||||
rootFile, file, filenamePattern,
|
rootFile, file, filenamePattern,
|
||||||
checkFilenameStartsLowerCase, targetBackend, skipIgnored, extractTagsFromTestFile(file)
|
checkFilenameStartsLowerCase, targetBackend, skipIgnored, extractTagsFromTestFile(file)
|
||||||
)
|
)
|
||||||
|
|||||||
+3
-5
@@ -5,10 +5,10 @@
|
|||||||
package org.jetbrains.kotlin.generators.model
|
package org.jetbrains.kotlin.generators.model
|
||||||
|
|
||||||
import com.intellij.openapi.util.io.FileUtil
|
import com.intellij.openapi.util.io.FileUtil
|
||||||
|
import org.jetbrains.kotlin.generators.util.methodModelLocator
|
||||||
import org.jetbrains.kotlin.test.TargetBackend
|
import org.jetbrains.kotlin.test.TargetBackend
|
||||||
import org.jetbrains.kotlin.test.util.KtTestUtil
|
import org.jetbrains.kotlin.test.util.KtTestUtil
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.*
|
|
||||||
import java.util.regex.Pattern
|
import java.util.regex.Pattern
|
||||||
|
|
||||||
class SingleClassTestModel(
|
class SingleClassTestModel(
|
||||||
@@ -45,10 +45,8 @@ class SingleClassTestModel(
|
|||||||
get() = emptyList()
|
get() = emptyList()
|
||||||
|
|
||||||
private fun getTestMethodsFromFile(file: File): Collection<MethodModel> {
|
private fun getTestMethodsFromFile(file: File): Collection<MethodModel> {
|
||||||
return listOf(
|
return methodModelLocator(
|
||||||
SimpleTestMethodModel(
|
rootFile, file, filenamePattern, checkFilenameStartsLowerCase, targetBackend, skipIgnored, tags = emptyList()
|
||||||
rootFile, file, filenamePattern, checkFilenameStartsLowerCase, targetBackend, skipIgnored, tags = emptyList()
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+21
@@ -0,0 +1,21 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2021 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.model
|
||||||
|
|
||||||
|
class WithoutJvmInlineTestMethodModel(
|
||||||
|
val source: SimpleTestMethodModel
|
||||||
|
) : MethodModel {
|
||||||
|
object Kind : MethodModel.Kind()
|
||||||
|
|
||||||
|
override val kind: MethodModel.Kind
|
||||||
|
get() = Kind
|
||||||
|
override val name: String
|
||||||
|
get() = "${source.name}WithoutJvmInlineAnnotation"
|
||||||
|
override val dataString: String
|
||||||
|
get() = source.dataString
|
||||||
|
override val tags: List<String>
|
||||||
|
get() = source.tags
|
||||||
|
}
|
||||||
+37
@@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2021 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.util
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.generators.model.*
|
||||||
|
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_WITHOUT_JVM_INLINE\\s*$").matches(it) }
|
||||||
|
else -> false
|
||||||
|
}
|
||||||
|
|
||||||
|
fun methodModelLocator(
|
||||||
|
rootDir: File,
|
||||||
|
file: File,
|
||||||
|
filenamePattern: Pattern,
|
||||||
|
checkFilenameStartsLowerCase: Boolean?,
|
||||||
|
targetBackend: TargetBackend,
|
||||||
|
skipIgnored: Boolean,
|
||||||
|
tags: List<String>
|
||||||
|
): List<MethodModel> = SimpleTestMethodModel(
|
||||||
|
rootDir,
|
||||||
|
file,
|
||||||
|
filenamePattern,
|
||||||
|
checkFilenameStartsLowerCase,
|
||||||
|
targetBackend,
|
||||||
|
skipIgnored,
|
||||||
|
tags
|
||||||
|
).let { methodModel ->
|
||||||
|
listOf(methodModel) + if (methodModel.containsWithoutJvmInline(targetBackend)) listOf(WithoutJvmInlineTestMethodModel(methodModel)) else emptyList()
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user