[Tests] Introduce reversible source file preprocessor
This commit is contained in:
+2
-2
@@ -19292,13 +19292,13 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
|||||||
@Test
|
@Test
|
||||||
@TestMetadata("boxResultInlineClassOfConstructorCall.kt")
|
@TestMetadata("boxResultInlineClassOfConstructorCall.kt")
|
||||||
public void testBoxResultInlineClassOfConstructorCall() throws Exception {
|
public void testBoxResultInlineClassOfConstructorCall() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/inlineClasses/boxResultInlineClassOfConstructorCall.kt", TransformersFunctions::replaceOptionalJvmInlineAnnotationWithReal);
|
runTest("compiler/testData/codegen/box/inlineClasses/boxResultInlineClassOfConstructorCall.kt", TransformersFunctions.getReplaceOptionalJvmInlineAnnotationWithReal());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("boxResultInlineClassOfConstructorCall.kt")
|
@TestMetadata("boxResultInlineClassOfConstructorCall.kt")
|
||||||
public void testBoxResultInlineClassOfConstructorCall_valueClasses() throws Exception {
|
public void testBoxResultInlineClassOfConstructorCall_valueClasses() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/inlineClasses/boxResultInlineClassOfConstructorCall.kt", TransformersFunctions::removeOptionalJvmInlineAnnotation);
|
runTest("compiler/testData/codegen/box/inlineClasses/boxResultInlineClassOfConstructorCall.kt", TransformersFunctions.getRemoveOptionalJvmInlineAnnotation());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -24,13 +24,9 @@ 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(
|
fun runTest(@TestDataFile testDataFileName: String, beforeDispose: (TestConfiguration) -> Unit = {}) {
|
||||||
@TestDataFile testDataFileName: String,
|
|
||||||
expectedFileTransformer: ((String) -> String)? = null,
|
|
||||||
beforeDispose: (TestConfiguration) -> Unit = {},
|
|
||||||
) {
|
|
||||||
try {
|
try {
|
||||||
runTestImpl(testDataFileName, expectedFileTransformer)
|
runTestImpl(testDataFileName)
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
testConfiguration.testServices.temporaryDirectoryManager.cleanupTemporaryDirectories()
|
testConfiguration.testServices.temporaryDirectoryManager.cleanupTemporaryDirectories()
|
||||||
@@ -42,7 +38,7 @@ class TestRunner(private val testConfiguration: TestConfiguration) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun runTestImpl(@TestDataFile testDataFileName: String, expectedFileTransformer: ((String) -> String)?) {
|
private fun runTestImpl(@TestDataFile testDataFileName: String) {
|
||||||
val services = testConfiguration.testServices
|
val services = testConfiguration.testServices
|
||||||
|
|
||||||
@Suppress("NAME_SHADOWING")
|
@Suppress("NAME_SHADOWING")
|
||||||
@@ -70,14 +66,10 @@ class TestRunner(private val testConfiguration: TestConfiguration) {
|
|||||||
if (it.shouldSkipTest()) return
|
if (it.shouldSkipTest()) return
|
||||||
}
|
}
|
||||||
|
|
||||||
runTestPipeline(moduleStructure, services, expectedFileTransformer)
|
runTestPipeline(moduleStructure, services)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun runTestPipeline(
|
fun runTestPipeline(moduleStructure: TestModuleStructure, services: TestServices) {
|
||||||
moduleStructure: TestModuleStructure,
|
|
||||||
services: TestServices,
|
|
||||||
expectedFileTransformer: ((String) -> String)?,
|
|
||||||
) {
|
|
||||||
val globalMetadataInfoHandler = testConfiguration.testServices.globalMetadataInfoHandler
|
val globalMetadataInfoHandler = testConfiguration.testServices.globalMetadataInfoHandler
|
||||||
globalMetadataInfoHandler.parseExistingMetadataInfosFromAllSources()
|
globalMetadataInfoHandler.parseExistingMetadataInfosFromAllSources()
|
||||||
|
|
||||||
@@ -105,7 +97,7 @@ class TestRunner(private val testConfiguration: TestConfiguration) {
|
|||||||
}
|
}
|
||||||
if (testConfiguration.metaInfoHandlerEnabled) {
|
if (testConfiguration.metaInfoHandlerEnabled) {
|
||||||
withAssertionCatching(WrappedException::FromMetaInfoHandler) {
|
withAssertionCatching(WrappedException::FromMetaInfoHandler) {
|
||||||
globalMetadataInfoHandler.compareAllMetaDataInfos(expectedFileTransformer)
|
globalMetadataInfoHandler.compareAllMetaDataInfos()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+6
-1
@@ -15,6 +15,10 @@ abstract class SourceFilePreprocessor(val testServices: TestServices) {
|
|||||||
abstract fun process(file: TestFile, content: String): String
|
abstract fun process(file: TestFile, content: String): String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
abstract class ReversibleSourceFilePreprocessor(testServices: TestServices) : SourceFilePreprocessor(testServices) {
|
||||||
|
abstract fun revert(file: TestFile, actualContent: String): String
|
||||||
|
}
|
||||||
|
|
||||||
abstract class SourceFileProvider : TestService {
|
abstract class SourceFileProvider : TestService {
|
||||||
abstract val kotlinSourceDirectory: File
|
abstract val kotlinSourceDirectory: File
|
||||||
abstract val javaSourceDirectory: File
|
abstract val javaSourceDirectory: File
|
||||||
@@ -23,11 +27,12 @@ abstract class SourceFileProvider : TestService {
|
|||||||
abstract fun getContentOfSourceFile(testFile: TestFile): String
|
abstract fun getContentOfSourceFile(testFile: TestFile): String
|
||||||
abstract fun getRealFileForSourceFile(testFile: TestFile): File
|
abstract fun getRealFileForSourceFile(testFile: TestFile): File
|
||||||
abstract fun getRealFileForBinaryFile(testFile: TestFile): File
|
abstract fun getRealFileForBinaryFile(testFile: TestFile): File
|
||||||
|
abstract val preprocessors: List<SourceFilePreprocessor>
|
||||||
}
|
}
|
||||||
|
|
||||||
val TestServices.sourceFileProvider: SourceFileProvider by TestServices.testServiceAccessor()
|
val TestServices.sourceFileProvider: SourceFileProvider by TestServices.testServiceAccessor()
|
||||||
|
|
||||||
class SourceFileProviderImpl(val testServices: TestServices, val preprocessors: List<SourceFilePreprocessor>) : SourceFileProvider() {
|
class SourceFileProviderImpl(val testServices: TestServices, override val preprocessors: List<SourceFilePreprocessor>) : SourceFileProvider() {
|
||||||
override val kotlinSourceDirectory: File = testServices.getOrCreateTempDirectory("kotlin-files")
|
override val kotlinSourceDirectory: File = testServices.getOrCreateTempDirectory("kotlin-files")
|
||||||
override val javaSourceDirectory: File = testServices.getOrCreateTempDirectory("java-files")
|
override val javaSourceDirectory: File = testServices.getOrCreateTempDirectory("java-files")
|
||||||
override val javaBinaryDirectory: File = testServices.getOrCreateTempDirectory("java-binary-files")
|
override val javaBinaryDirectory: File = testServices.getOrCreateTempDirectory("java-binary-files")
|
||||||
|
|||||||
+1
-1
@@ -18908,7 +18908,7 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
@Test
|
@Test
|
||||||
@TestMetadata("boxResultInlineClassOfConstructorCall.kt")
|
@TestMetadata("boxResultInlineClassOfConstructorCall.kt")
|
||||||
public void testBoxResultInlineClassOfConstructorCall() throws Exception {
|
public void testBoxResultInlineClassOfConstructorCall() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/inlineClasses/boxResultInlineClassOfConstructorCall.kt", TransformersFunctions::replaceOptionalJvmInlineAnnotationWithReal);
|
runTest("compiler/testData/codegen/box/inlineClasses/boxResultInlineClassOfConstructorCall.kt", TransformersFunctions.getReplaceOptionalJvmInlineAnnotationWithReal());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
+2
-2
@@ -19292,13 +19292,13 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
@Test
|
@Test
|
||||||
@TestMetadata("boxResultInlineClassOfConstructorCall.kt")
|
@TestMetadata("boxResultInlineClassOfConstructorCall.kt")
|
||||||
public void testBoxResultInlineClassOfConstructorCall() throws Exception {
|
public void testBoxResultInlineClassOfConstructorCall() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/inlineClasses/boxResultInlineClassOfConstructorCall.kt", TransformersFunctions::replaceOptionalJvmInlineAnnotationWithReal);
|
runTest("compiler/testData/codegen/box/inlineClasses/boxResultInlineClassOfConstructorCall.kt", TransformersFunctions.getReplaceOptionalJvmInlineAnnotationWithReal());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("boxResultInlineClassOfConstructorCall.kt")
|
@TestMetadata("boxResultInlineClassOfConstructorCall.kt")
|
||||||
public void testBoxResultInlineClassOfConstructorCall_valueClasses() throws Exception {
|
public void testBoxResultInlineClassOfConstructorCall_valueClasses() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/inlineClasses/boxResultInlineClassOfConstructorCall.kt", TransformersFunctions::removeOptionalJvmInlineAnnotation);
|
runTest("compiler/testData/codegen/box/inlineClasses/boxResultInlineClassOfConstructorCall.kt", TransformersFunctions.getRemoveOptionalJvmInlineAnnotation());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
+3
-7
@@ -9,18 +9,14 @@ import java.io.File
|
|||||||
|
|
||||||
object TransformersFunctions {
|
object TransformersFunctions {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun replaceOptionalJvmInlineAnnotationWithReal(source: String): String {
|
val replaceOptionalJvmInlineAnnotationWithReal = ReplacingSourceTransformer("OPTIONAL_JVM_INLINE_ANNOTATION", "@JvmInline")
|
||||||
return source.replace("OPTIONAL_JVM_INLINE_ANNOTATION", "@JvmInline")
|
|
||||||
}
|
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun removeOptionalJvmInlineAnnotation(source: String): String {
|
val removeOptionalJvmInlineAnnotation = ReplacingSourceTransformer("OPTIONAL_JVM_INLINE_ANNOTATION", "")
|
||||||
return source.replace("OPTIONAL_JVM_INLINE_ANNOTATION", "")
|
|
||||||
}
|
|
||||||
|
|
||||||
object Android {
|
object Android {
|
||||||
val forAll: List<(String) -> String> = listOf(
|
val forAll: List<(String) -> String> = listOf(
|
||||||
TransformersFunctions::replaceOptionalJvmInlineAnnotationWithReal,
|
replaceOptionalJvmInlineAnnotationWithReal,
|
||||||
)
|
)
|
||||||
val forSpecificFile: Map<File, (String) -> String> = mapOf(
|
val forSpecificFile: Map<File, (String) -> String> = mapOf(
|
||||||
)
|
)
|
||||||
|
|||||||
+1
-1
@@ -15781,7 +15781,7 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
|
|
||||||
@TestMetadata("boxResultInlineClassOfConstructorCall.kt")
|
@TestMetadata("boxResultInlineClassOfConstructorCall.kt")
|
||||||
public void testBoxResultInlineClassOfConstructorCall() throws Exception {
|
public void testBoxResultInlineClassOfConstructorCall() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/inlineClasses/boxResultInlineClassOfConstructorCall.kt", TransformersFunctions::replaceOptionalJvmInlineAnnotationWithReal);
|
runTest("compiler/testData/codegen/box/inlineClasses/boxResultInlineClassOfConstructorCall.kt", TransformersFunctions.getReplaceOptionalJvmInlineAnnotationWithReal());
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("boxUnboxInlineClassesWithOperatorsGetSet.kt")
|
@TestMetadata("boxUnboxInlineClassesWithOperatorsGetSet.kt")
|
||||||
|
|||||||
+2
-2
@@ -11,8 +11,8 @@ class WithoutJvmInlineTestMethodModel(
|
|||||||
withPostfix: Boolean,
|
withPostfix: Boolean,
|
||||||
) : TransformingTestMethodModel(
|
) : TransformingTestMethodModel(
|
||||||
source,
|
source,
|
||||||
transformer = "TransformersFunctions::" +
|
transformer = "TransformersFunctions.get" +
|
||||||
if (withAnnotation) "replaceOptionalJvmInlineAnnotationWithReal" else "removeOptionalJvmInlineAnnotation"
|
if (withAnnotation) "ReplaceOptionalJvmInlineAnnotationWithReal()" else "RemoveOptionalJvmInlineAnnotation()"
|
||||||
) {
|
) {
|
||||||
override val name: String = source.name + if (withPostfix) "_valueClasses" else ""
|
override val name: String = source.name + if (withPostfix) "_valueClasses" else ""
|
||||||
}
|
}
|
||||||
+1
-1
@@ -14842,7 +14842,7 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
|||||||
@Test
|
@Test
|
||||||
@TestMetadata("boxResultInlineClassOfConstructorCall.kt")
|
@TestMetadata("boxResultInlineClassOfConstructorCall.kt")
|
||||||
public void testBoxResultInlineClassOfConstructorCall() throws Exception {
|
public void testBoxResultInlineClassOfConstructorCall() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/inlineClasses/boxResultInlineClassOfConstructorCall.kt", TransformersFunctions::removeOptionalJvmInlineAnnotation);
|
runTest("compiler/testData/codegen/box/inlineClasses/boxResultInlineClassOfConstructorCall.kt", TransformersFunctions.getRemoveOptionalJvmInlineAnnotation());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
+1
-1
@@ -14806,7 +14806,7 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
|||||||
@Test
|
@Test
|
||||||
@TestMetadata("boxResultInlineClassOfConstructorCall.kt")
|
@TestMetadata("boxResultInlineClassOfConstructorCall.kt")
|
||||||
public void testBoxResultInlineClassOfConstructorCall() throws Exception {
|
public void testBoxResultInlineClassOfConstructorCall() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/inlineClasses/boxResultInlineClassOfConstructorCall.kt", TransformersFunctions::removeOptionalJvmInlineAnnotation);
|
runTest("compiler/testData/codegen/box/inlineClasses/boxResultInlineClassOfConstructorCall.kt", TransformersFunctions.getRemoveOptionalJvmInlineAnnotation());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
+1
-1
@@ -12473,7 +12473,7 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
|||||||
|
|
||||||
@TestMetadata("boxResultInlineClassOfConstructorCall.kt")
|
@TestMetadata("boxResultInlineClassOfConstructorCall.kt")
|
||||||
public void testBoxResultInlineClassOfConstructorCall() throws Exception {
|
public void testBoxResultInlineClassOfConstructorCall() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/inlineClasses/boxResultInlineClassOfConstructorCall.kt", TransformersFunctions::removeOptionalJvmInlineAnnotation);
|
runTest("compiler/testData/codegen/box/inlineClasses/boxResultInlineClassOfConstructorCall.kt", TransformersFunctions.getRemoveOptionalJvmInlineAnnotation());
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("boxUnboxInlineClassesWithOperatorsGetSet.kt")
|
@TestMetadata("boxUnboxInlineClassesWithOperatorsGetSet.kt")
|
||||||
|
|||||||
+2
-2
@@ -15646,7 +15646,7 @@ public class NativeExtBlackBoxTestGenerated extends AbstractNativeBlackBoxTest {
|
|||||||
@NativeBlackBoxTestCaseGroupProvider(ExtTestCaseGroupProvider.class)
|
@NativeBlackBoxTestCaseGroupProvider(ExtTestCaseGroupProvider.class)
|
||||||
public class InlineClasses {
|
public class InlineClasses {
|
||||||
public InlineClasses() {
|
public InlineClasses() {
|
||||||
register("compiler/testData/codegen/box/inlineClasses/boxResultInlineClassOfConstructorCall.kt", TransformersFunctions::removeOptionalJvmInlineAnnotation);
|
register("compiler/testData/codegen/box/inlineClasses/boxResultInlineClassOfConstructorCall.kt", TransformersFunctions.getRemoveOptionalJvmInlineAnnotation());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -15705,7 +15705,7 @@ public class NativeExtBlackBoxTestGenerated extends AbstractNativeBlackBoxTest {
|
|||||||
@Test
|
@Test
|
||||||
@TestMetadata("boxResultInlineClassOfConstructorCall.kt")
|
@TestMetadata("boxResultInlineClassOfConstructorCall.kt")
|
||||||
public void testBoxResultInlineClassOfConstructorCall() throws Exception {
|
public void testBoxResultInlineClassOfConstructorCall() throws Exception {
|
||||||
// There is a registered source transformer for the testcase: TransformersFunctions::removeOptionalJvmInlineAnnotation
|
// There is a registered source transformer for the testcase: TransformersFunctions.getRemoveOptionalJvmInlineAnnotation()
|
||||||
runTest("compiler/testData/codegen/box/inlineClasses/boxResultInlineClassOfConstructorCall.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/boxResultInlineClassOfConstructorCall.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user