[Tests] Regenerate tests with correct postfix

This commit is contained in:
Evgeniy.Zhelenskiy
2021-12-06 21:19:39 +03:00
parent 2874462e3a
commit cd1d77e760
9 changed files with 20 additions and 19 deletions
@@ -293,6 +293,6 @@ object NewTestGeneratorImpl : TestGenerator(METHOD_GENERATORS) {
private fun TestClassModel.predefinedNativeTransformers(recursive: Boolean): List<Pair<String, String>> =
methods.mapNotNull { method ->
(method as? TransformingTestMethodModel)?.takeIf { it.isNative }?.let { it.source.file.path to it.transformer }
(method as? TransformingTestMethodModel)?.takeIf { it.registerInConstructor }?.let { it.source.file.path to it.transformer }
} + if (recursive) innerTestClasses.flatMap { it.predefinedNativeTransformers(recursive) } else listOf()
}
@@ -24,8 +24,8 @@ object TransformingTestMethodGenerator : MethodGenerator<TransformingTestMethodM
override fun generateBody(method: TransformingTestMethodModel, p: Printer) {
with(method) {
val filePath = KtTestUtil.getFilePath(source.file) + if (source.file.isDirectory) "/" else ""
p.println("${RunTestMethodModel.METHOD_NAME}(\"$filePath\"${if (isNative) "" else ", $transformer"});")
if (isNative) {
p.println("${RunTestMethodModel.METHOD_NAME}(\"$filePath\"${if (registerInConstructor) "" else ", $transformer"});")
if (registerInConstructor) {
p.println("/*")
p.println(" There is a registered source transformer for the testcase:")
transformer.lines().forEach { p.println(" $it") }
@@ -21,8 +21,7 @@ abstract class TransformingTestMethodModel(val source: SimpleTestMethodModel, va
override fun imports(): Collection<Class<*>> = super.imports() + TransformerFunctionsClassPlaceHolder::class.java
internal val isNative
get() = source.targetBackend in listOf(TargetBackend.NATIVE, TargetBackend.ANY)
internal val registerInConstructor
get() = source.targetBackend == TargetBackend.NATIVE
// Native tests load sources before runTest call if more than 1 test is called, so we need to register it before.
// Existing native tests specify target backend as ANY, setting it to NATIVE removes some previously generated tests.
}
@@ -7,11 +7,12 @@ package org.jetbrains.kotlin.generators.model
class WithoutJvmInlineTestMethodModel(
source: SimpleTestMethodModel,
val withAnnotation: Boolean
withAnnotation: Boolean,
withPostfix: Boolean,
) : TransformingTestMethodModel(
source,
transformer = "TransformersFunctions::" +
if (withAnnotation) "replaceOptionalJvmInlineAnnotationWithReal" else "removeOptionalJvmInlineAnnotation"
) {
override val name: String = source.name + if (withAnnotation) "" else "_valueClasses"
override val name: String = source.name + if (withPostfix) "_valueClasses" else ""
}
@@ -37,11 +37,11 @@ fun methodModelLocator(
tags
).let { methodModel ->
if (methodModel.containsWithoutJvmInline()) {
val isWithoutAnnotations = when {
targetBackend.isRecursivelyCompatibleWith(TargetBackend.JVM_IR) -> listOf(true, false)
targetBackend.isRecursivelyCompatibleWith(TargetBackend.JVM) -> listOf(true)
else -> listOf(false)
val isWithAnnotationAndIsWithPostfix = when {
targetBackend.isRecursivelyCompatibleWith(TargetBackend.JVM_IR) -> listOf(true to false, false to true)
targetBackend.isRecursivelyCompatibleWith(TargetBackend.JVM) -> listOf(true to false)
else -> listOf(false to false)
}
isWithoutAnnotations.map { WithoutJvmInlineTestMethodModel(methodModel, it) }
isWithAnnotationAndIsWithPostfix.map { (ann, post) -> WithoutJvmInlineTestMethodModel(methodModel, ann, post) }
} else listOf(methodModel)
}
@@ -14841,7 +14841,7 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
@Test
@TestMetadata("boxResultInlineClassOfConstructorCall.kt")
public void testBoxResultInlineClassOfConstructorCall_valueClasses() throws Exception {
public void testBoxResultInlineClassOfConstructorCall() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/boxResultInlineClassOfConstructorCall.kt", TransformersFunctions::removeOptionalJvmInlineAnnotation);
}
@@ -14805,7 +14805,7 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
@Test
@TestMetadata("boxResultInlineClassOfConstructorCall.kt")
public void testBoxResultInlineClassOfConstructorCall_valueClasses() throws Exception {
public void testBoxResultInlineClassOfConstructorCall() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/boxResultInlineClassOfConstructorCall.kt", TransformersFunctions::removeOptionalJvmInlineAnnotation);
}
@@ -12472,7 +12472,7 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
}
@TestMetadata("boxResultInlineClassOfConstructorCall.kt")
public void testBoxResultInlineClassOfConstructorCall_valueClasses() throws Exception {
public void testBoxResultInlineClassOfConstructorCall() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/boxResultInlineClassOfConstructorCall.kt", TransformersFunctions::removeOptionalJvmInlineAnnotation);
}
@@ -10,6 +10,7 @@ import org.jetbrains.kotlin.test.util.KtTestUtil;
import org.jetbrains.kotlin.konan.blackboxtest.support.group.NativeBlackBoxTestCaseGroupProvider;
import org.jetbrains.kotlin.konan.blackboxtest.support.group.ExtTestCaseGroupProvider;
import org.jetbrains.kotlin.test.TargetBackend;
import org.jetbrains.kotlin.test.runners.TransformersFunctions;
import org.jetbrains.kotlin.test.TestMetadata;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
@@ -15645,7 +15646,7 @@ public class NativeExtBlackBoxTestGenerated extends AbstractNativeBlackBoxTest {
@NativeBlackBoxTestCaseGroupProvider(ExtTestCaseGroupProvider.class)
public class InlineClasses {
public InlineClasses() {
register("compiler/testData/codegen/box/inlineClasses/boxResultInlineClassOfConstructorCall.kt", s -> s.replaceAll("OPTIONAL_JVM_INLINE_ANNOTATION", ""));
register("compiler/testData/codegen/box/inlineClasses/boxResultInlineClassOfConstructorCall.kt", TransformersFunctions::removeOptionalJvmInlineAnnotation);
}
@Test
@@ -15703,11 +15704,11 @@ public class NativeExtBlackBoxTestGenerated extends AbstractNativeBlackBoxTest {
@Test
@TestMetadata("boxResultInlineClassOfConstructorCall.kt")
public void testBoxResultInlineClassOfConstructorCall_valueClasses() throws Exception {
public void testBoxResultInlineClassOfConstructorCall() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/boxResultInlineClassOfConstructorCall.kt");
/*
There is a registered source transformer for the testcase:
s -> s.replaceAll("OPTIONAL_JVM_INLINE_ANNOTATION", "")
TransformersFunctions::removeOptionalJvmInlineAnnotation
*/
}