[Test] Migrate all jvm tests runners for boxInline tests

This commit is contained in:
Dmitriy Novozhilov
2021-01-27 12:07:06 +03:00
parent 8973e3f362
commit 3a0eee64b8
25 changed files with 7119 additions and 3499 deletions
@@ -42,3 +42,8 @@ abstract class TestConfiguration {
abstract fun getAllHandlers(): List<AnalysisHandler<*>> abstract fun getAllHandlers(): List<AnalysisHandler<*>>
} }
// ---------------------------- Utils ----------------------------
fun <T, R> ((TestServices, T) -> R).bind(value: T): Constructor<R> {
return { this.invoke(it, value) }
}
@@ -35,11 +35,17 @@ class TestRunner(private val testConfiguration: TestConfiguration) {
configurator.transformTestDataPath(fileName) configurator.transformTestDataPath(fileName)
} }
val moduleStructure = testConfiguration.moduleStructureExtractor.splitTestDataByModules( val moduleStructure = try {
testDataFileName, testConfiguration.moduleStructureExtractor.splitTestDataByModules(
testConfiguration.directives, testDataFileName,
).also { testConfiguration.directives,
services.register(TestModuleStructure::class, it) ).also {
services.register(TestModuleStructure::class, it)
}
} catch (e: ExceptionFromModuleStructureTransformer) {
services.register(TestModuleStructure::class, e.alreadyParsedModuleStructure)
val exception = filterFailedExceptions(listOf(e.cause)).singleOrNull() ?: return
throw exception
} }
testConfiguration.metaTestConfigurators.forEach { testConfiguration.metaTestConfigurators.forEach {
@@ -84,15 +90,17 @@ class TestRunner(private val testConfiguration: TestConfiguration) {
} }
} }
val filteredFailedAssertions = testConfiguration.afterAnalysisCheckers val filteredFailedAssertions = filterFailedExceptions(failedAssertions)
.fold<AfterAnalysisChecker, List<Throwable>>(failedAssertions) { assertions, checker ->
checker.suppressIfNeeded(assertions)
}
.map { if (it is ExceptionFromTestError) it.cause else it }
services.assertions.assertAll(filteredFailedAssertions) services.assertions.assertAll(filteredFailedAssertions)
} }
private fun filterFailedExceptions(failedExceptions: List<Throwable>): List<Throwable> = testConfiguration.afterAnalysisCheckers
.fold(failedExceptions) { assertions, checker ->
checker.suppressIfNeeded(assertions)
}
.map { if (it is ExceptionFromTestError) it.cause else it }
private fun processModule( private fun processModule(
services: TestServices, services: TestServices,
module: TestModule, module: TestModule,
@@ -11,3 +11,8 @@ import org.jetbrains.kotlin.test.TestInfrastructureInternals
abstract class ModuleStructureTransformer { abstract class ModuleStructureTransformer {
abstract fun transformModuleStructure(moduleStructure: TestModuleStructure): TestModuleStructure abstract fun transformModuleStructure(moduleStructure: TestModuleStructure): TestModuleStructure
} }
class ExceptionFromModuleStructureTransformer(
override val cause: Throwable,
val alreadyParsedModuleStructure: TestModuleStructure
) : Exception(cause)
@@ -13,23 +13,32 @@ import org.jetbrains.kotlin.test.directives.model.DirectivesContainer
import org.jetbrains.kotlin.test.directives.model.ValueDirective import org.jetbrains.kotlin.test.directives.model.ValueDirective
import org.jetbrains.kotlin.test.model.AfterAnalysisChecker import org.jetbrains.kotlin.test.model.AfterAnalysisChecker
import org.jetbrains.kotlin.test.model.FrontendKinds import org.jetbrains.kotlin.test.model.FrontendKinds
import org.jetbrains.kotlin.test.services.TestModuleStructure import org.jetbrains.kotlin.test.services.*
import org.jetbrains.kotlin.test.services.TestServices
import org.jetbrains.kotlin.test.services.moduleStructure
import org.jetbrains.kotlin.test.util.joinToArrayString import org.jetbrains.kotlin.test.util.joinToArrayString
class BlackBoxCodegenSuppressor(testServices: TestServices) : AfterAnalysisChecker(testServices) { class BlackBoxCodegenSuppressor(
testServices: TestServices,
val customIgnoreDirective: ValueDirective<TargetBackend>? = null
) : AfterAnalysisChecker(testServices) {
override val directives: List<DirectivesContainer> override val directives: List<DirectivesContainer>
get() = listOf(CodegenTestDirectives) get() = listOf(CodegenTestDirectives)
@OptIn(ExperimentalStdlibApi::class)
override fun suppressIfNeeded(failedAssertions: List<Throwable>): List<Throwable> { override fun suppressIfNeeded(failedAssertions: List<Throwable>): List<Throwable> {
val moduleStructure = testServices.moduleStructure val moduleStructure = testServices.moduleStructure
val targetBackends = moduleStructure.modules.mapNotNull { it.targetBackend } val targetBackends = buildList {
return when (moduleStructure.modules.map { it.frontendKind }.first()) { testServices.defaultsProvider.defaultTargetBackend?.let {
FrontendKinds.ClassicFrontend -> processIgnoreBackend(moduleStructure, IGNORE_BACKEND, targetBackends, failedAssertions) add(it)
FrontendKinds.FIR -> processIgnoreBackend(moduleStructure, IGNORE_BACKEND_FIR, targetBackends, failedAssertions) return@buildList
else -> failedAssertions }
moduleStructure.modules.mapNotNullTo(this) { it.targetBackend }
} }
val ignoreDirective = when (moduleStructure.modules.map { it.frontendKind }.first()) {
FrontendKinds.ClassicFrontend -> customIgnoreDirective ?: IGNORE_BACKEND
FrontendKinds.FIR -> IGNORE_BACKEND_FIR
else -> return failedAssertions
}
return processIgnoreBackend(moduleStructure, ignoreDirective, targetBackends, failedAssertions)
} }
private fun processIgnoreBackend( private fun processIgnoreBackend(
@@ -6,27 +6,34 @@
package org.jetbrains.kotlin.test.backend.handlers package org.jetbrains.kotlin.test.backend.handlers
import org.jetbrains.kotlin.codegen.InlineTestUtil import org.jetbrains.kotlin.codegen.InlineTestUtil
import org.jetbrains.kotlin.codegen.filterClassFiles
import org.jetbrains.kotlin.codegen.getClassFiles import org.jetbrains.kotlin.codegen.getClassFiles
import org.jetbrains.kotlin.test.directives.CodegenTestDirectives import org.jetbrains.kotlin.test.directives.CodegenTestDirectives
import org.jetbrains.kotlin.test.directives.CodegenTestDirectives.NO_CHECK_LAMBDA_INLINING import org.jetbrains.kotlin.test.directives.CodegenTestDirectives.NO_CHECK_LAMBDA_INLINING
import org.jetbrains.kotlin.test.directives.CodegenTestDirectives.SKIP_INLINE_CHECK_IN import org.jetbrains.kotlin.test.directives.CodegenTestDirectives.SKIP_INLINE_CHECK_IN
import org.jetbrains.kotlin.test.directives.model.DirectivesContainer import org.jetbrains.kotlin.test.directives.model.DirectivesContainer
import org.jetbrains.kotlin.test.model.ArtifactKinds
import org.jetbrains.kotlin.test.model.BinaryArtifacts import org.jetbrains.kotlin.test.model.BinaryArtifacts
import org.jetbrains.kotlin.test.model.TestModule import org.jetbrains.kotlin.test.model.TestModule
import org.jetbrains.kotlin.test.services.TestServices import org.jetbrains.kotlin.test.services.TestServices
import org.jetbrains.kotlin.test.services.dependencyProvider
import org.jetbrains.kotlin.test.services.moduleStructure
class BytecodeInliningHandler(testServices: TestServices) : JvmBinaryArtifactHandler(testServices) { class BytecodeInliningHandler(testServices: TestServices) : JvmBinaryArtifactHandler(testServices) {
override val directivesContainers: List<DirectivesContainer> override val directivesContainers: List<DirectivesContainer>
get() = listOf(CodegenTestDirectives) get() = listOf(CodegenTestDirectives)
override fun processModule(module: TestModule, info: BinaryArtifacts.Jvm) { override fun processModule(module: TestModule, info: BinaryArtifacts.Jvm) {}
InlineTestUtil.checkNoCallsToInline(
info.classFileFactory.getClassFiles(),
skipParameterCheckingInDirectives = NO_CHECK_LAMBDA_INLINING in module.directives,
skippedMethods = module.directives[SKIP_INLINE_CHECK_IN].toSet()
)
}
override fun processAfterAllModules(someAssertionWasFailed: Boolean) {} override fun processAfterAllModules(someAssertionWasFailed: Boolean) {
val classFiles = testServices.moduleStructure.modules.flatMap {
testServices.dependencyProvider.getArtifact(it, ArtifactKinds.Jvm).classFileFactory.getClassFiles()
}
val allDirectives = testServices.moduleStructure.allDirectives
InlineTestUtil.checkNoCallsToInline(
classFiles,
skipParameterCheckingInDirectives = NO_CHECK_LAMBDA_INLINING in allDirectives,
skippedMethods = allDirectives[SKIP_INLINE_CHECK_IN].toSet()
)
}
} }
@@ -6,6 +6,7 @@
package org.jetbrains.kotlin.test.backend.handlers package org.jetbrains.kotlin.test.backend.handlers
import org.jetbrains.kotlin.codegen.CommonSMAPTestUtil import org.jetbrains.kotlin.codegen.CommonSMAPTestUtil
import org.jetbrains.kotlin.codegen.getClassFiles
import org.jetbrains.kotlin.codegen.inline.GENERATE_SMAP import org.jetbrains.kotlin.codegen.inline.GENERATE_SMAP
import org.jetbrains.kotlin.test.directives.CodegenTestDirectives import org.jetbrains.kotlin.test.directives.CodegenTestDirectives
import org.jetbrains.kotlin.test.directives.CodegenTestDirectives.DUMP_SMAP import org.jetbrains.kotlin.test.directives.CodegenTestDirectives.DUMP_SMAP
@@ -34,7 +35,7 @@ class SMAPDumpHandler(testServices: TestServices) : JvmBinaryArtifactHandler(tes
if (!GENERATE_SMAP) return if (!GENERATE_SMAP) return
if (DUMP_SMAP !in module.directives) return if (DUMP_SMAP !in module.directives) return
val compiledSmaps = CommonSMAPTestUtil.extractSMAPFromClasses(info.classFileFactory.currentOutput) val compiledSmaps = CommonSMAPTestUtil.extractSMAPFromClasses(info.classFileFactory.getClassFiles())
CommonSMAPTestUtil.checkNoConflictMappings(compiledSmaps, assertions) CommonSMAPTestUtil.checkNoConflictMappings(compiledSmaps, assertions)
@@ -54,6 +55,8 @@ class SMAPDumpHandler(testServices: TestServices) : JvmBinaryArtifactHandler(tes
} }
override fun processAfterAllModules(someAssertionWasFailed: Boolean) { override fun processAfterAllModules(someAssertionWasFailed: Boolean) {
if (dumper.isEmpty()) return
val separateDumpEnabled = separateDumpsEnabled() val separateDumpEnabled = separateDumpsEnabled()
val isSeparateCompilation = isSeparateCompilation() val isSeparateCompilation = isSeparateCompilation()
@@ -23,6 +23,11 @@ object CodegenTestDirectives : SimpleDirectivesContainer() {
applicability = Global applicability = Global
) )
val IGNORE_BACKEND_MULTI_MODULE by enumDirective<TargetBackend>(
description = "Ignore failures of multimodule test on target backend",
applicability = Global
)
val JAVAC_OPTIONS by stringDirective( val JAVAC_OPTIONS by stringDirective(
description = "Specify javac options to compile java files" description = "Specify javac options to compile java files"
) )
@@ -0,0 +1,29 @@
/*
* 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.test.runners.codegen
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
open class AbstractBlackBoxInlineCodegenTest : AbstractBlackBoxCodegenTest() {
override fun configure(builder: TestConfigurationBuilder) {
super.configure(builder)
builder.useInlineHandlers()
}
}
open class AbstractIrBlackBoxInlineCodegenTest : AbstractIrBlackBoxCodegenTest() {
override fun configure(builder: TestConfigurationBuilder) {
super.configure(builder)
builder.useInlineHandlers()
}
}
open class AbstractFirBlackBoxInlineCodegenTest : AbstractFirBlackBoxCodegenTest() {
override fun configure(builder: TestConfigurationBuilder) {
super.configure(builder)
builder.useInlineHandlers()
}
}
@@ -0,0 +1,67 @@
/*
* 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.test.runners.codegen
import org.jetbrains.kotlin.test.Constructor
import org.jetbrains.kotlin.test.TargetBackend
import org.jetbrains.kotlin.test.TestInfrastructureInternals
import org.jetbrains.kotlin.test.backend.BlackBoxCodegenSuppressor
import org.jetbrains.kotlin.test.backend.classic.ClassicBackendInput
import org.jetbrains.kotlin.test.backend.classic.ClassicJvmBackendFacade
import org.jetbrains.kotlin.test.backend.ir.IrBackendInput
import org.jetbrains.kotlin.test.backend.ir.JvmIrBackendFacade
import org.jetbrains.kotlin.test.bind
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
import org.jetbrains.kotlin.test.directives.CodegenTestDirectives.IGNORE_BACKEND_MULTI_MODULE
import org.jetbrains.kotlin.test.frontend.classic.ClassicFrontend2ClassicBackendConverter
import org.jetbrains.kotlin.test.frontend.classic.ClassicFrontend2IrConverter
import org.jetbrains.kotlin.test.frontend.classic.ClassicFrontendFacade
import org.jetbrains.kotlin.test.frontend.classic.ClassicFrontendOutputArtifact
import org.jetbrains.kotlin.test.model.*
import org.jetbrains.kotlin.test.runners.AbstractKotlinCompilerWithTargetBackendTest
import org.jetbrains.kotlin.test.services.ModuleTransformerForTwoFilesBoxTests
@OptIn(TestInfrastructureInternals::class)
abstract class AbstractCompileKotlinAgainstInlineKotlinTestBase<I : ResultingArtifact.BackendInput<I>>(
targetBackend: TargetBackend
) : AbstractKotlinCompilerWithTargetBackendTest(targetBackend) {
abstract val frontendToBackendConverter: Constructor<Frontend2BackendConverter<ClassicFrontendOutputArtifact, I>>
abstract val backendFacade: Constructor<BackendFacade<I, BinaryArtifacts.Jvm>>
override fun TestConfigurationBuilder.configuration() {
commonConfigurationForCodegenTest(
FrontendKinds.ClassicFrontend,
::ClassicFrontendFacade,
frontendToBackendConverter,
backendFacade
)
useInlineHandlers()
commonHandlersForCodegenTest()
useModuleStructureTransformers(
ModuleTransformerForTwoFilesBoxTests()
)
useAfterAnalysisCheckers(::BlackBoxCodegenSuppressor.bind(IGNORE_BACKEND_MULTI_MODULE))
}
}
open class AbstractCompileKotlinAgainstInlineKotlinTest :
AbstractCompileKotlinAgainstInlineKotlinTestBase<ClassicBackendInput>(TargetBackend.JVM) {
override val frontendToBackendConverter: Constructor<Frontend2BackendConverter<ClassicFrontendOutputArtifact, ClassicBackendInput>>
get() = ::ClassicFrontend2ClassicBackendConverter
override val backendFacade: Constructor<BackendFacade<ClassicBackendInput, BinaryArtifacts.Jvm>>
get() = ::ClassicJvmBackendFacade
}
open class AbstractIrCompileKotlinAgainstInlineKotlinTest :
AbstractCompileKotlinAgainstInlineKotlinTestBase<IrBackendInput>(TargetBackend.JVM_IR) {
override val frontendToBackendConverter: Constructor<Frontend2BackendConverter<ClassicFrontendOutputArtifact, IrBackendInput>>
get() = ::ClassicFrontend2IrConverter
override val backendFacade: Constructor<BackendFacade<IrBackendInput, BinaryArtifacts.Jvm>>
get() = ::JvmIrBackendFacade
}
@@ -8,7 +8,7 @@ package org.jetbrains.kotlin.test.runners.codegen
import org.jetbrains.kotlin.test.Constructor import org.jetbrains.kotlin.test.Constructor
import org.jetbrains.kotlin.test.TargetBackend import org.jetbrains.kotlin.test.TargetBackend
import org.jetbrains.kotlin.test.backend.BlackBoxCodegenSuppressor import org.jetbrains.kotlin.test.backend.BlackBoxCodegenSuppressor
import org.jetbrains.kotlin.test.backend.handlers.* import org.jetbrains.kotlin.test.backend.handlers.BytecodeListingHandler
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
import org.jetbrains.kotlin.test.model.* import org.jetbrains.kotlin.test.model.*
import org.jetbrains.kotlin.test.runners.AbstractKotlinCompilerWithTargetBackendTest import org.jetbrains.kotlin.test.runners.AbstractKotlinCompilerWithTargetBackendTest
@@ -23,19 +23,8 @@ abstract class AbstractJvmBlackBoxCodegenTestBase<R : ResultingArtifact.Frontend
override fun TestConfigurationBuilder.configuration() { override fun TestConfigurationBuilder.configuration() {
commonConfigurationForCodegenTest(targetFrontend, frontendFacade, frontendToBackendConverter, backendFacade) commonConfigurationForCodegenTest(targetFrontend, frontendFacade, frontendToBackendConverter, backendFacade)
commonHandlersForCodegenTest()
useFrontendHandlers( useArtifactsHandlers(::BytecodeListingHandler)
::NoCompilationErrorsHandler,
::NoFirCompilationErrorsHandler,
)
useArtifactsHandlers(
::JvmBoxRunner,
::NoJvmSpecificCompilationErrorsHandler,
::BytecodeListingHandler,
::DxCheckerHandler,
)
useAfterAnalysisCheckers(::BlackBoxCodegenSuppressor) useAfterAnalysisCheckers(::BlackBoxCodegenSuppressor)
} }
} }
@@ -0,0 +1,62 @@
/*
* 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.test.runners.codegen
import org.jetbrains.kotlin.test.TargetBackend
import org.jetbrains.kotlin.test.TestInfrastructureInternals
import org.jetbrains.kotlin.test.backend.BlackBoxCodegenSuppressor
import org.jetbrains.kotlin.test.backend.classic.ClassicJvmBackendFacade
import org.jetbrains.kotlin.test.backend.ir.JvmIrBackendFacade
import org.jetbrains.kotlin.test.bind
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
import org.jetbrains.kotlin.test.directives.CodegenTestDirectives
import org.jetbrains.kotlin.test.frontend.classic.ClassicFrontend2ClassicBackendConverter
import org.jetbrains.kotlin.test.frontend.classic.ClassicFrontend2IrConverter
import org.jetbrains.kotlin.test.frontend.classic.ClassicFrontendFacade
import org.jetbrains.kotlin.test.model.FrontendKinds
import org.jetbrains.kotlin.test.runners.AbstractKotlinCompilerWithTargetBackendTest
import org.jetbrains.kotlin.test.services.ModuleTransformerForSwitchingBackend
import org.jetbrains.kotlin.test.services.ModuleTransformerForTwoFilesBoxTests
@OptIn(TestInfrastructureInternals::class)
open class AbstractBackendAgainstBackendBoxTestBase(
targetBackend: TargetBackend,
val backendForLib: TargetBackend,
val backendForMain: TargetBackend
) : AbstractKotlinCompilerWithTargetBackendTest(targetBackend) {
override fun TestConfigurationBuilder.configuration() {
commonConfigurationForCodegenTest(
FrontendKinds.ClassicFrontend,
::ClassicFrontendFacade,
::ClassicFrontend2ClassicBackendConverter,
::ClassicJvmBackendFacade
)
useFrontend2BackendConverters(::ClassicFrontend2IrConverter)
useBackendFacades(::JvmIrBackendFacade)
commonHandlersForCodegenTest()
useInlineHandlers()
useAfterAnalysisCheckers(::BlackBoxCodegenSuppressor.bind(CodegenTestDirectives.IGNORE_BACKEND_MULTI_MODULE))
useModuleStructureTransformers(
ModuleTransformerForTwoFilesBoxTests(),
ModuleTransformerForSwitchingBackend(backendForLib, backendForMain)
)
}
}
open class AbstractJvmIrAgainstOldBoxInlineTest : AbstractBackendAgainstBackendBoxTestBase(
targetBackend = TargetBackend.JVM_MULTI_MODULE_IR_AGAINST_OLD,
backendForLib = TargetBackend.JVM,
backendForMain = TargetBackend.JVM_IR
)
open class AbstractJvmOldAgainstIrBoxInlineTest : AbstractBackendAgainstBackendBoxTestBase(
targetBackend = TargetBackend.JVM_MULTI_MODULE_OLD_AGAINST_IR,
backendForLib = TargetBackend.JVM_IR,
backendForMain = TargetBackend.JVM_OLD
)
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.test.runners.codegen
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
import org.jetbrains.kotlin.test.Constructor import org.jetbrains.kotlin.test.Constructor
import org.jetbrains.kotlin.test.backend.handlers.*
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
import org.jetbrains.kotlin.test.directives.CodegenTestDirectives.RUN_DEX_CHECKER import org.jetbrains.kotlin.test.directives.CodegenTestDirectives.RUN_DEX_CHECKER
import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirectives.USE_PSI_CLASS_FILES_READING import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirectives.USE_PSI_CLASS_FILES_READING
@@ -49,3 +50,22 @@ fun <R : ResultingArtifact.FrontendOutput<R>> TestConfigurationBuilder.commonCon
useFrontend2BackendConverters(frontendToBackendConverter) useFrontend2BackendConverters(frontendToBackendConverter)
useBackendFacades(backendFacade) useBackendFacades(backendFacade)
} }
fun TestConfigurationBuilder.commonHandlersForCodegenTest() {
useFrontendHandlers(
::NoCompilationErrorsHandler,
::NoFirCompilationErrorsHandler,
)
useArtifactsHandlers(
::JvmBoxRunner,
::NoJvmSpecificCompilationErrorsHandler,
::DxCheckerHandler,
)
}
fun TestConfigurationBuilder.useInlineHandlers() {
useArtifactsHandlers(
::BytecodeInliningHandler
)
}
@@ -47,8 +47,8 @@ class ModuleTransformerForTwoFilesBoxTests : ModuleStructureTransformer() {
module.frontendKind, module.frontendKind,
module.binaryKind, module.binaryKind,
files = listOf(second) + additionalFiles, files = listOf(second) + additionalFiles,
dependencies = listOf(DependencyDescription("lib", DependencyKind.Binary, DependencyRelation.Dependency)), dependencies = emptyList(),
friends = emptyList(), friends = listOf(DependencyDescription("lib", DependencyKind.Binary, DependencyRelation.Dependency)),
module.directives, module.directives,
module.languageVersionSettings module.languageVersionSettings
) )
@@ -62,7 +62,11 @@ class ModuleStructureExtractorImpl(
val extractor = ModuleStructureExtractorWorker(listOf(testDataFile), directivesContainer) val extractor = ModuleStructureExtractorWorker(listOf(testDataFile), directivesContainer)
var result = extractor.splitTestDataByModules() var result = extractor.splitTestDataByModules()
for (transformer in moduleStructureTransformers) { for (transformer in moduleStructureTransformers) {
result = transformer.transformModuleStructure(result) result = try {
transformer.transformModuleStructure(result)
} catch (e: Throwable) {
throw ExceptionFromModuleStructureTransformer(e, result)
}
} }
return result return result
} }
@@ -1,46 +0,0 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.kotlin.codegen
import org.jetbrains.kotlin.test.InTextDirectivesUtils
import java.io.File
abstract class AbstractCompileKotlinAgainstInlineKotlinTest : AbstractCompileKotlinAgainstKotlinTest() {
override fun doMultiFileTest(wholeFile: File, files: List<TestFile>) {
val isIgnored = InTextDirectivesUtils.isIgnoredTarget(backend, wholeFile, ignoreBackendDirectivePrefix)
val (factory1, factory2) = doTwoFileTest(
files.filter { it.name.endsWith(".kt") },
!isIgnored
)
try {
val allGeneratedFiles = factory1.asList() + factory2.asList()
InlineTestUtil.checkNoCallsToInline(
allGeneratedFiles.filterClassFiles(),
skipParameterCheckingInDirectives = files.any { "NO_CHECK_LAMBDA_INLINING" in it.directives },
skippedMethods = files.flatMapTo(mutableSetOf()) { it.directives.listValues("SKIP_INLINE_CHECK_IN") ?: emptyList() }
)
SMAPTestUtil.checkSMAP(files, allGeneratedFiles.filterClassFiles(), true)
} catch (e: Throwable) {
if (!isIgnored) {
println("FIRST:\n\n${factory1.createText()}\n\nSECOND:\n\n${factory2.createText()}")
}
throw e
}
}
override fun getIgnoreBackendDirectivePrefix(): String = "// IGNORE_BACKEND_MULTI_MODULE: "
}
@@ -1,27 +0,0 @@
/*
* Copyright 2010-2019 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.codegen.ir
import org.jetbrains.kotlin.codegen.AbstractCompileKotlinAgainstInlineKotlinTest
import org.jetbrains.kotlin.test.TargetBackend
abstract class AbstractIrCompileKotlinAgainstInlineKotlinTest : AbstractCompileKotlinAgainstInlineKotlinTest() {
override val backend: TargetBackend get() = TargetBackend.JVM_IR
}
abstract class AbstractJvmIrAgainstOldBoxInlineTest : AbstractIrCompileKotlinAgainstInlineKotlinTest() {
override val backend: TargetBackend get() = TargetBackend.JVM_MULTI_MODULE_IR_AGAINST_OLD
override fun getBackendA(): TargetBackend = TargetBackend.JVM
override fun getBackendB(): TargetBackend = TargetBackend.JVM_IR
}
abstract class AbstractJvmOldAgainstIrBoxInlineTest : AbstractIrCompileKotlinAgainstInlineKotlinTest() {
override val backend: TargetBackend get() = TargetBackend.JVM_MULTI_MODULE_OLD_AGAINST_IR
override fun getBackendA(): TargetBackend = TargetBackend.JVM_IR
override fun getBackendB(): TargetBackend = TargetBackend.JVM
}
@@ -113,10 +113,6 @@ fun generateJUnit3CompilerTests(args: Array<String>) {
model("codegen/asmLike", targetBackend = TargetBackend.JVM) model("codegen/asmLike", targetBackend = TargetBackend.JVM)
} }
testClass<AbstractBlackBoxInlineCodegenTest> {
model("codegen/boxInline", targetBackend = TargetBackend.JVM)
}
testClass<AbstractBlackBoxAgainstJavaCodegenTest> { testClass<AbstractBlackBoxAgainstJavaCodegenTest> {
model("codegen/boxAgainstJava") model("codegen/boxAgainstJava")
} }
@@ -474,10 +470,6 @@ fun generateJUnit3CompilerTests(args: Array<String>) {
model("debug/localVariables", targetBackend = TargetBackend.JVM_IR) model("debug/localVariables", targetBackend = TargetBackend.JVM_IR)
} }
testClass<AbstractIrBlackBoxInlineCodegenTest> {
model("codegen/boxInline", targetBackend = TargetBackend.JVM_IR)
}
testClass<AbstractIrAsmLikeInstructionListingTest> { testClass<AbstractIrAsmLikeInstructionListingTest> {
model("codegen/asmLike", targetBackend = TargetBackend.JVM_IR) model("codegen/asmLike", targetBackend = TargetBackend.JVM_IR)
} }
@@ -492,37 +484,11 @@ fun generateJUnit3CompilerTests(args: Array<String>) {
testRunnerMethodName = "runTestWithCustomIgnoreDirective", testRunnerMethodName = "runTestWithCustomIgnoreDirective",
additionalRunnerArguments = listOf("\"// IGNORE_BACKEND_FIR: \"") additionalRunnerArguments = listOf("\"// IGNORE_BACKEND_FIR: \"")
) { ) {
testClass<AbstractFirBlackBoxInlineCodegenTest> {
model("codegen/boxInline", targetBackend = TargetBackend.JVM_IR, excludeDirs = listOf("oldLanguageVersions"))
}
testClass<AbstractFirBlackBoxAgainstJavaCodegenTest> { testClass<AbstractFirBlackBoxAgainstJavaCodegenTest> {
model("codegen/boxAgainstJava", targetBackend = TargetBackend.JVM_IR, excludeDirs = listOf("oldLanguageVersions")) model("codegen/boxAgainstJava", targetBackend = TargetBackend.JVM_IR, excludeDirs = listOf("oldLanguageVersions"))
} }
} }
testGroup(
"compiler/tests-gen", "compiler/testData",
testRunnerMethodName = "runTestWithCustomIgnoreDirective",
additionalRunnerArguments = listOf("\"// IGNORE_BACKEND_MULTI_MODULE: \"")
) {
testClass<AbstractCompileKotlinAgainstInlineKotlinTest> {
model("codegen/boxInline", targetBackend = TargetBackend.JVM)
}
testClass<AbstractIrCompileKotlinAgainstInlineKotlinTest> {
model("codegen/boxInline", targetBackend = TargetBackend.JVM_IR)
}
testClass<AbstractJvmIrAgainstOldBoxInlineTest> {
model("codegen/boxInline", targetBackend = TargetBackend.JVM_MULTI_MODULE_IR_AGAINST_OLD)
}
testClass<AbstractJvmOldAgainstIrBoxInlineTest> {
model(
"codegen/boxInline",
targetBackend = TargetBackend.JVM_MULTI_MODULE_OLD_AGAINST_IR
)
}
}
testGroup("compiler/fir/raw-fir/psi2fir/tests-gen", "compiler/fir/raw-fir/psi2fir/testData") { testGroup("compiler/fir/raw-fir/psi2fir/tests-gen", "compiler/fir/raw-fir/psi2fir/testData") {
testClass<AbstractRawFirBuilderTestCase> { testClass<AbstractRawFirBuilderTestCase> {
model("rawBuilder", testMethod = "doRawFirTest") model("rawBuilder", testMethod = "doRawFirTest")
@@ -79,6 +79,30 @@ fun generateJUnit5CompilerTests(args: Array<String>) {
testClass<AbstractIrBytecodeTextTest> { testClass<AbstractIrBytecodeTextTest> {
model("codegen/bytecodeText", excludeDirs = listOf("oldLanguageVersions")) model("codegen/bytecodeText", excludeDirs = listOf("oldLanguageVersions"))
} }
testClass<AbstractBlackBoxInlineCodegenTest> {
model("codegen/boxInline")
}
testClass<AbstractIrBlackBoxInlineCodegenTest> {
model("codegen/boxInline")
}
testClass<AbstractCompileKotlinAgainstInlineKotlinTest> {
model("codegen/boxInline")
}
testClass<AbstractIrCompileKotlinAgainstInlineKotlinTest> {
model("codegen/boxInline")
}
testClass<AbstractJvmIrAgainstOldBoxInlineTest> {
model("codegen/boxInline")
}
testClass<AbstractJvmOldAgainstIrBoxInlineTest> {
model("codegen/boxInline")
}
} }
// ---------------------------------------------- FIR tests ---------------------------------------------- // ---------------------------------------------- FIR tests ----------------------------------------------
@@ -92,6 +116,10 @@ fun generateJUnit5CompilerTests(args: Array<String>) {
testClass<AbstractFirBlackBoxCodegenTest> { testClass<AbstractFirBlackBoxCodegenTest> {
model("codegen/box", excludeDirs = listOf("oldLanguageVersions")) model("codegen/box", excludeDirs = listOf("oldLanguageVersions"))
} }
testClass<AbstractFirBlackBoxInlineCodegenTest> {
model("codegen/boxInline", excludeDirs = listOf("oldLanguageVersions"))
}
} }
testGroup("compiler/fir/analysis-tests/tests-gen", "compiler/fir/analysis-tests/testData") { testGroup("compiler/fir/analysis-tests/tests-gen", "compiler/fir/analysis-tests/testData") {