Revert "[K2/N] KT-57026, KT-57208: Adjust Native & JS test infrastructures for MPP testing"

This reverts commit 6964121c15.
This commit is contained in:
Nikolay Krasko
2023-03-10 11:58:03 +01:00
committed by teamcity
parent aed6272107
commit c0c692844e
51 changed files with 106 additions and 187 deletions
@@ -81,7 +81,7 @@ fun compileModuleToAnalyzedFir(
val resolvedLibraries = moduleStructure.fullResolvedLibraries val resolvedLibraries = moduleStructure.fullResolvedLibraries
val sessionsWithSources = prepareJsSessions( val sessionsWithSources = prepareJsSessions(
ktFiles, moduleStructure.compilerConfiguration, escapedMainModuleName, ktFiles, moduleStructure.compilerConfiguration, escapedMainModuleName.asString(),
resolvedLibraries, dependencyList, extensionRegistrars, isCommonSourceForPsi, fileBelongsToModuleForPsi resolvedLibraries, dependencyList, extensionRegistrars, isCommonSourceForPsi, fileBelongsToModuleForPsi
) )
@@ -55,7 +55,7 @@ fun <F> prepareJvmSessions(
files: List<F>, files: List<F>,
configuration: CompilerConfiguration, configuration: CompilerConfiguration,
projectEnvironment: AbstractProjectEnvironment, projectEnvironment: AbstractProjectEnvironment,
rootModuleName: Name, rootModuleName: String,
extensionRegistrars: List<FirExtensionRegistrar>, extensionRegistrars: List<FirExtensionRegistrar>,
librariesScope: AbstractProjectFileSearchScope, librariesScope: AbstractProjectFileSearchScope,
libraryList: DependencyListForCliModule, libraryList: DependencyListForCliModule,
@@ -70,7 +70,7 @@ fun <F> prepareJvmSessions(
JvmPlatformAnalyzerServices, libraryList, isCommonSource, fileBelongsToModule, JvmPlatformAnalyzerServices, libraryList, isCommonSource, fileBelongsToModule,
createLibrarySession = { sessionProvider -> createLibrarySession = { sessionProvider ->
FirJvmSessionFactory.createLibrarySession( FirJvmSessionFactory.createLibrarySession(
rootModuleName, Name.identifier(rootModuleName),
sessionProvider, sessionProvider,
libraryList.moduleDataProvider, libraryList.moduleDataProvider,
projectEnvironment, projectEnvironment,
@@ -109,7 +109,7 @@ fun <F> prepareJvmSessions(
fun <F> prepareJsSessions( fun <F> prepareJsSessions(
files: List<F>, files: List<F>,
configuration: CompilerConfiguration, configuration: CompilerConfiguration,
rootModuleName: Name, rootModuleName: String,
resolvedLibraries: List<KotlinResolvedLibrary>, resolvedLibraries: List<KotlinResolvedLibrary>,
libraryList: DependencyListForCliModule, libraryList: DependencyListForCliModule,
extensionRegistrars: List<FirExtensionRegistrar>, extensionRegistrars: List<FirExtensionRegistrar>,
@@ -121,7 +121,7 @@ fun <F> prepareJsSessions(
libraryList, isCommonSource, fileBelongsToModule, libraryList, isCommonSource, fileBelongsToModule,
createLibrarySession = { sessionProvider -> createLibrarySession = { sessionProvider ->
FirJsSessionFactory.createLibrarySession( FirJsSessionFactory.createLibrarySession(
rootModuleName, Name.identifier(rootModuleName),
resolvedLibraries, resolvedLibraries,
sessionProvider, sessionProvider,
libraryList.moduleDataProvider, libraryList.moduleDataProvider,
@@ -152,7 +152,7 @@ fun <F> prepareJsSessions(
fun <F> prepareNativeSessions( fun <F> prepareNativeSessions(
files: List<F>, files: List<F>,
configuration: CompilerConfiguration, configuration: CompilerConfiguration,
rootModuleName: Name, rootModuleName: String,
resolvedLibraries: List<KotlinResolvedLibrary>, resolvedLibraries: List<KotlinResolvedLibrary>,
libraryList: DependencyListForCliModule, libraryList: DependencyListForCliModule,
extensionRegistrars: List<FirExtensionRegistrar>, extensionRegistrars: List<FirExtensionRegistrar>,
@@ -163,7 +163,7 @@ fun <F> prepareNativeSessions(
files, configuration, rootModuleName, NativePlatforms.unspecifiedNativePlatform, NativePlatformAnalyzerServices, files, configuration, rootModuleName, NativePlatforms.unspecifiedNativePlatform, NativePlatformAnalyzerServices,
libraryList, isCommonSource, fileBelongsToModule, createLibrarySession = { sessionProvider -> libraryList, isCommonSource, fileBelongsToModule, createLibrarySession = { sessionProvider ->
FirNativeSessionFactory.createLibrarySession( FirNativeSessionFactory.createLibrarySession(
rootModuleName, Name.identifier(rootModuleName),
resolvedLibraries, resolvedLibraries,
sessionProvider, sessionProvider,
libraryList.moduleDataProvider, libraryList.moduleDataProvider,
@@ -193,7 +193,7 @@ fun <F> prepareCommonSessions(
files: List<F>, files: List<F>,
configuration: CompilerConfiguration, configuration: CompilerConfiguration,
projectEnvironment: AbstractProjectEnvironment, projectEnvironment: AbstractProjectEnvironment,
rootModuleName: Name, rootModuleName: String,
extensionRegistrars: List<FirExtensionRegistrar>, extensionRegistrars: List<FirExtensionRegistrar>,
librariesScope: AbstractProjectFileSearchScope, librariesScope: AbstractProjectFileSearchScope,
libraryList: DependencyListForCliModule, libraryList: DependencyListForCliModule,
@@ -206,7 +206,7 @@ fun <F> prepareCommonSessions(
files, configuration, rootModuleName, CommonPlatforms.defaultCommonPlatform, CommonPlatformAnalyzerServices, files, configuration, rootModuleName, CommonPlatforms.defaultCommonPlatform, CommonPlatformAnalyzerServices,
libraryList, isCommonSource, fileBelongsToModule, createLibrarySession = { sessionProvider -> libraryList, isCommonSource, fileBelongsToModule, createLibrarySession = { sessionProvider ->
FirCommonSessionFactory.createLibrarySession( FirCommonSessionFactory.createLibrarySession(
rootModuleName, Name.identifier(rootModuleName),
sessionProvider, sessionProvider,
libraryList.moduleDataProvider, libraryList.moduleDataProvider,
projectEnvironment, projectEnvironment,
@@ -240,7 +240,7 @@ private typealias FirSessionProducer<F> = (List<F>, FirModuleData, FirProjectSes
private inline fun <F> prepareSessions( private inline fun <F> prepareSessions(
files: List<F>, files: List<F>,
configuration: CompilerConfiguration, configuration: CompilerConfiguration,
rootModuleName: Name, rootModuleName: String,
targetPlatform: TargetPlatform, targetPlatform: TargetPlatform,
analyzerServices: PlatformDependentAnalyzerServices, analyzerServices: PlatformDependentAnalyzerServices,
libraryList: DependencyListForCliModule, libraryList: DependencyListForCliModule,
@@ -277,7 +277,7 @@ private inline fun <F> prepareSessions(
) )
else -> createSessionsForHmppProject( else -> createSessionsForHmppProject(
files, rootModuleName, hmppModuleStructure, libraryList, targetPlatform, analyzerServices, files, hmppModuleStructure, libraryList, targetPlatform, analyzerServices,
sessionProvider, sessionConfigurator, fileBelongsToModule, createSourceSession sessionProvider, sessionConfigurator, fileBelongsToModule, createSourceSession
) )
} }
@@ -285,7 +285,7 @@ private inline fun <F> prepareSessions(
private inline fun <F> createSessionForNonMppProject( private inline fun <F> createSessionForNonMppProject(
files: List<F>, files: List<F>,
rootModuleName: Name, rootModuleName: String,
libraryList: DependencyListForCliModule, libraryList: DependencyListForCliModule,
targetPlatform: TargetPlatform, targetPlatform: TargetPlatform,
analyzerServices: PlatformDependentAnalyzerServices, analyzerServices: PlatformDependentAnalyzerServices,
@@ -294,7 +294,7 @@ private inline fun <F> createSessionForNonMppProject(
createFirSession: FirSessionProducer<F>, createFirSession: FirSessionProducer<F>,
): SessionWithSources<F> { ): SessionWithSources<F> {
val platformModuleData = FirModuleDataImpl( val platformModuleData = FirModuleDataImpl(
rootModuleName, Name.identifier(rootModuleName),
libraryList.regularDependencies, libraryList.regularDependencies,
dependsOnDependencies = emptyList(), dependsOnDependencies = emptyList(),
libraryList.friendsDependencies, libraryList.friendsDependencies,
@@ -308,7 +308,7 @@ private inline fun <F> createSessionForNonMppProject(
private inline fun <F> createSessionsForLegacyMppProject( private inline fun <F> createSessionsForLegacyMppProject(
files: List<F>, files: List<F>,
rootModuleName: Name, rootModuleName: String,
libraryList: DependencyListForCliModule, libraryList: DependencyListForCliModule,
targetPlatform: TargetPlatform, targetPlatform: TargetPlatform,
analyzerServices: PlatformDependentAnalyzerServices, analyzerServices: PlatformDependentAnalyzerServices,
@@ -318,7 +318,7 @@ private inline fun <F> createSessionsForLegacyMppProject(
createFirSession: FirSessionProducer<F>, createFirSession: FirSessionProducer<F>,
): List<SessionWithSources<F>> { ): List<SessionWithSources<F>> {
val commonModuleData = FirModuleDataImpl( val commonModuleData = FirModuleDataImpl(
Name.identifier("${rootModuleName.asString()}-common"), Name.identifier("${rootModuleName}-common"),
libraryList.regularDependencies, libraryList.regularDependencies,
listOf(), listOf(),
libraryList.friendsDependencies, libraryList.friendsDependencies,
@@ -327,7 +327,7 @@ private inline fun <F> createSessionsForLegacyMppProject(
) )
val platformModuleData = FirModuleDataImpl( val platformModuleData = FirModuleDataImpl(
rootModuleName, Name.identifier(rootModuleName),
libraryList.regularDependencies, libraryList.regularDependencies,
listOf(commonModuleData), listOf(commonModuleData),
libraryList.friendsDependencies, libraryList.friendsDependencies,
@@ -352,7 +352,6 @@ private inline fun <F> createSessionsForLegacyMppProject(
private inline fun <F> createSessionsForHmppProject( private inline fun <F> createSessionsForHmppProject(
files: List<F>, files: List<F>,
rootModuleName: Name,
hmppModuleStructure: HmppCliModuleStructure, hmppModuleStructure: HmppCliModuleStructure,
libraryList: DependencyListForCliModule, libraryList: DependencyListForCliModule,
targetPlatform: TargetPlatform, targetPlatform: TargetPlatform,
@@ -369,7 +368,7 @@ private inline fun <F> createSessionsForHmppProject(
?.map { moduleDataForHmppModule.getValue(it) } ?.map { moduleDataForHmppModule.getValue(it) }
.orEmpty() .orEmpty()
val moduleData = FirModuleDataImpl( val moduleData = FirModuleDataImpl(
rootModuleName, Name.identifier(module.name),
libraryList.regularDependencies, libraryList.regularDependencies,
dependsOnDependencies = dependencies, dependsOnDependencies = dependencies,
libraryList.friendsDependencies, libraryList.friendsDependencies,
@@ -44,7 +44,6 @@ import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCompil
import org.jetbrains.kotlin.modules.Module import org.jetbrains.kotlin.modules.Module
import org.jetbrains.kotlin.modules.TargetId import org.jetbrains.kotlin.modules.TargetId
import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.progress.ProgressIndicatorAndCompilationCanceledStatus import org.jetbrains.kotlin.progress.ProgressIndicatorAndCompilationCanceledStatus
import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.resolve.multiplatform.hmppModuleName import org.jetbrains.kotlin.resolve.multiplatform.hmppModuleName
@@ -201,7 +200,7 @@ object FirKotlinToJvmBytecodeCompiler {
val rootModuleName = module.getModuleName() val rootModuleName = module.getModuleName()
val libraryList = createLibraryListForJvm(rootModuleName, moduleConfiguration, module.getFriendPaths()) val libraryList = createLibraryListForJvm(rootModuleName, moduleConfiguration, module.getFriendPaths())
val sessionsWithSources = prepareJvmSessions( val sessionsWithSources = prepareJvmSessions(
ktFiles, moduleConfiguration, projectEnvironment, Name.identifier(rootModuleName), ktFiles, moduleConfiguration, projectEnvironment, rootModuleName,
extensionRegistrars, librariesScope, libraryList, extensionRegistrars, librariesScope, libraryList,
isCommonSource = { it.isCommonSource == true }, isCommonSource = { it.isCommonSource == true },
fileBelongsToModule = { file, moduleName -> file.hmppModuleName == moduleName }, fileBelongsToModule = { file, moduleName -> file.hmppModuleName == moduleName },
@@ -65,7 +65,6 @@ import org.jetbrains.kotlin.load.kotlin.incremental.IncrementalPackagePartProvid
import org.jetbrains.kotlin.modules.Module import org.jetbrains.kotlin.modules.Module
import org.jetbrains.kotlin.modules.TargetId import org.jetbrains.kotlin.modules.TargetId
import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.platform.CommonPlatforms import org.jetbrains.kotlin.platform.CommonPlatforms
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
import org.jetbrains.kotlin.progress.ProgressIndicatorAndCompilationCanceledStatus import org.jetbrains.kotlin.progress.ProgressIndicatorAndCompilationCanceledStatus
@@ -327,7 +326,7 @@ fun compileModuleToAnalyzedFir(
// TODO: handle friends paths // TODO: handle friends paths
val libraryList = createLibraryListForJvm(rootModuleName, moduleConfiguration, friendPaths = emptyList()) val libraryList = createLibraryListForJvm(rootModuleName, moduleConfiguration, friendPaths = emptyList())
val sessionWithSources = prepareJvmSessions( val sessionWithSources = prepareJvmSessions(
allSources, moduleConfiguration, projectEnvironment, Name.identifier(rootModuleName), allSources, moduleConfiguration, projectEnvironment, rootModuleName,
extensionRegistrars, librariesScope, libraryList, extensionRegistrars, librariesScope, libraryList,
isCommonSource = input.groupedSources.isCommonSourceForLt, isCommonSource = input.groupedSources.isCommonSourceForLt,
fileBelongsToModule = input.groupedSources.fileBelongsToModuleForLt, fileBelongsToModule = input.groupedSources.fileBelongsToModuleForLt,
@@ -57,11 +57,12 @@ internal class FirMetadataSerializer(
val configuration = environment.configuration val configuration = environment.configuration
val messageCollector = configuration.getNotNull(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY) val messageCollector = configuration.getNotNull(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY)
val rootModuleName = Name.special("<${configuration.getNotNull(CommonConfigurationKeys.MODULE_NAME)}>") val moduleName = Name.special("<${configuration.getNotNull(CommonConfigurationKeys.MODULE_NAME)}>")
val isLightTree = configuration.getBoolean(CommonConfigurationKeys.USE_LIGHT_TREE) val isLightTree = configuration.getBoolean(CommonConfigurationKeys.USE_LIGHT_TREE)
val rootModuleName = moduleName.asString()
val binaryModuleData = BinaryModuleData.initialize( val binaryModuleData = BinaryModuleData.initialize(
rootModuleName, Name.identifier(rootModuleName),
CommonPlatforms.defaultCommonPlatform, CommonPlatforms.defaultCommonPlatform,
CommonPlatformAnalyzerServices CommonPlatformAnalyzerServices
) )
@@ -1,3 +1,4 @@
// IGNORE_BACKEND: NATIVE
// !LANGUAGE: +MultiPlatformProjects // !LANGUAGE: +MultiPlatformProjects
// IGNORE_BACKEND_K1: ANY // IGNORE_BACKEND_K1: ANY
// IGNORE_BACKEND_MULTI_MODULE: ANY // IGNORE_BACKEND_MULTI_MODULE: ANY
@@ -1,6 +1,7 @@
// !LANGUAGE: +MultiPlatformProjects // !LANGUAGE: +MultiPlatformProjects
// WITH_STDLIB // WITH_STDLIB
// IGNORE_BACKEND_K1: ANY // IGNORE_BACKEND_K1: ANY
// IGNORE_BACKEND_K2: NATIVE
// MODULE: common // MODULE: common
// FILE: common.kt // FILE: common.kt
@@ -1,10 +1,8 @@
// !LANGUAGE: +MultiPlatformProjects // !LANGUAGE: +MultiPlatformProjects
// !OPT_IN: kotlin.ExperimentalMultiplatform // !OPT_IN: kotlin.ExperimentalMultiplatform
// IGNORE_BACKEND: WASM // IGNORE_BACKEND: NATIVE, WASM
// IGNORE_BACKEND_K1: JVM, JVM_IR, JS, JS_IR, JS_IR_ES6, NATIVE // IGNORE_BACKEND_K1: JVM, JVM_IR, JS, JS_IR, JS_IR_ES6
// IGNORE_BACKEND_K2: JS_IR // IGNORE_BACKEND_K2: JS_IR
// KT-57181
// IGNORE_BACKEND_K2: NATIVE
// WITH_STDLIB // WITH_STDLIB
// MODULE: common // MODULE: common
@@ -1,4 +1,5 @@
// !LANGUAGE: +MultiPlatformProjects // !LANGUAGE: +MultiPlatformProjects
// IGNORE_BACKEND: NATIVE
// IGNORE_BACKEND_K1: JVM, JVM_IR, JS, JS_IR, JS_IR_ES6 // IGNORE_BACKEND_K1: JVM, JVM_IR, JS, JS_IR, JS_IR_ES6
// MODULE: common // MODULE: common
@@ -1,5 +1,6 @@
// !LANGUAGE: +MultiPlatformProjects // !LANGUAGE: +MultiPlatformProjects
// IGNORE_BACKEND_K1: JVM, JVM_IR, JS, JS_IR, JS_IR_ES6, NATIVE // IGNORE_BACKEND: NATIVE
// IGNORE_BACKEND_K1: JVM, JVM_IR, JS, JS_IR, JS_IR_ES6
// MODULE: common // MODULE: common
// FILE: common.kt // FILE: common.kt
@@ -1,5 +1,6 @@
// !LANGUAGE: +MultiPlatformProjects // !LANGUAGE: +MultiPlatformProjects
// IGNORE_BACKEND_K1: JVM, JVM_IR, JS, JS_IR, JS_IR_ES6, NATIVE // IGNORE_BACKEND: NATIVE
// IGNORE_BACKEND_K1: JVM, JVM_IR, JS, JS_IR, JS_IR_ES6
// MODULE: common // MODULE: common
// FILE: common.kt // FILE: common.kt
@@ -1,4 +1,5 @@
// !LANGUAGE: +MultiPlatformProjects // !LANGUAGE: +MultiPlatformProjects
// IGNORE_BACKEND: NATIVE
// IGNORE_BACKEND_K1: JVM, JVM_IR, JS, JS_IR, JS_IR_ES6 // IGNORE_BACKEND_K1: JVM, JVM_IR, JS, JS_IR, JS_IR_ES6
// WITH_STDLIB // WITH_STDLIB
@@ -1,4 +1,5 @@
// !LANGUAGE: +MultiPlatformProjects // !LANGUAGE: +MultiPlatformProjects
// IGNORE_BACKEND: NATIVE
// IGNORE_BACKEND_K1: JVM, JVM_IR, JS, JS_IR, JS_IR_ES6 // IGNORE_BACKEND_K1: JVM, JVM_IR, JS, JS_IR, JS_IR_ES6
// MODULE: common // MODULE: common
@@ -1,7 +1,5 @@
// IGNORE_BACKEND: JS_IR, JS_IR_ES6, WASM // IGNORE_BACKEND: JS_IR, JS_IR_ES6, NATIVE, WASM
// IGNORE_BACKEND_K1: JVM, JVM_IR, JS, NATIVE // IGNORE_BACKEND_K1: JVM, JVM_IR, JS
// KT-57181
// IGNORE_BACKEND_K2: NATIVE
// WASM_MUTE_REASON: EXPECT_DEFAULT_PARAMETERS // WASM_MUTE_REASON: EXPECT_DEFAULT_PARAMETERS
// !LANGUAGE: +MultiPlatformProjects // !LANGUAGE: +MultiPlatformProjects
// ISSUE: KT-41901 // ISSUE: KT-41901
@@ -1,4 +1,5 @@
// !LANGUAGE: +MultiPlatformProjects // !LANGUAGE: +MultiPlatformProjects
// IGNORE_BACKEND: NATIVE
// IGNORE_BACKEND_K1: JVM, JVM_IR, JS, JS_IR, JS_IR_ES6 // IGNORE_BACKEND_K1: JVM, JVM_IR, JS, JS_IR, JS_IR_ES6
// MODULE: common // MODULE: common
@@ -1,4 +1,5 @@
// !LANGUAGE: +MultiPlatformProjects // !LANGUAGE: +MultiPlatformProjects
// IGNORE_BACKEND: NATIVE
// IGNORE_BACKEND_K1: JVM, JVM_IR, JS, JS_IR, JS_IR_ES6 // IGNORE_BACKEND_K1: JVM, JVM_IR, JS, JS_IR, JS_IR_ES6
// WITH_STDLIB // WITH_STDLIB
@@ -1,7 +1,6 @@
// !LANGUAGE: +MultiPlatformProjects // !LANGUAGE: +MultiPlatformProjects
// IGNORE_BACKEND_K1: JVM, JVM_IR, JS, JS_IR, JS_IR_ES6, NATIVE // IGNORE_BACKEND: NATIVE
// KT-57181 // IGNORE_BACKEND_K1: JVM, JVM_IR, JS, JS_IR, JS_IR_ES6
// IGNORE_BACKEND_K2: NATIVE
// WITH_STDLIB // WITH_STDLIB
// MODULE: common // MODULE: common
@@ -1,4 +1,5 @@
// !LANGUAGE: +MultiPlatformProjects // !LANGUAGE: +MultiPlatformProjects
// IGNORE_BACKEND: NATIVE
// IGNORE_BACKEND_K1: JVM, JVM_IR, JS, JS_IR, JS_IR_ES6 // IGNORE_BACKEND_K1: JVM, JVM_IR, JS, JS_IR, JS_IR_ES6
// WITH_STDLIB // WITH_STDLIB
@@ -1,4 +1,5 @@
// !LANGUAGE: +MultiPlatformProjects // !LANGUAGE: +MultiPlatformProjects
// IGNORE_BACKEND: NATIVE
// IGNORE_BACKEND_K1: JVM, JVM_IR, JS, JS_IR, JS_IR_ES6 // IGNORE_BACKEND_K1: JVM, JVM_IR, JS, JS_IR, JS_IR_ES6
// WITH_STDLIB // WITH_STDLIB
@@ -1,4 +1,5 @@
// !LANGUAGE: +MultiPlatformProjects // !LANGUAGE: +MultiPlatformProjects
// IGNORE_BACKEND: NATIVE
// IGNORE_BACKEND_K1: JVM, JVM_IR, JS, JS_IR, JS_IR_ES6 // IGNORE_BACKEND_K1: JVM, JVM_IR, JS, JS_IR, JS_IR_ES6
// MODULE: common // MODULE: common
@@ -1,4 +1,5 @@
// !LANGUAGE: +MultiPlatformProjects // !LANGUAGE: +MultiPlatformProjects
// IGNORE_BACKEND: NATIVE
// IGNORE_BACKEND_K1: JVM, JVM_IR, JS, JS_IR, JS_IR_ES6 // IGNORE_BACKEND_K1: JVM, JVM_IR, JS, JS_IR, JS_IR_ES6
// WITH_STDLIB // WITH_STDLIB
@@ -1,4 +1,5 @@
// !LANGUAGE: +MultiPlatformProjects // !LANGUAGE: +MultiPlatformProjects
// IGNORE_BACKEND: NATIVE
// IGNORE_BACKEND_K1: JVM, JVM_IR, JS, JS_IR, JS_IR_ES6 // IGNORE_BACKEND_K1: JVM, JVM_IR, JS, JS_IR, JS_IR_ES6
// WITH_STDLIB // WITH_STDLIB
@@ -1,4 +1,5 @@
// !LANGUAGE: +MultiPlatformProjects // !LANGUAGE: +MultiPlatformProjects
// IGNORE_BACKEND: NATIVE
// IGNORE_BACKEND_K1: JVM, JVM_IR, JS, JS_IR, JS_IR_ES6 // IGNORE_BACKEND_K1: JVM, JVM_IR, JS, JS_IR, JS_IR_ES6
// MODULE: common // MODULE: common
@@ -1,4 +1,5 @@
// !LANGUAGE: +MultiPlatformProjects // !LANGUAGE: +MultiPlatformProjects
// IGNORE_BACKEND: NATIVE
// IGNORE_BACKEND_K1: JVM, JVM_IR, JS, JS_IR, JS_IR_ES6 // IGNORE_BACKEND_K1: JVM, JVM_IR, JS, JS_IR, JS_IR_ES6
// WITH_STDLIB // WITH_STDLIB
@@ -1,4 +1,5 @@
// !LANGUAGE: +MultiPlatformProjects // !LANGUAGE: +MultiPlatformProjects
// IGNORE_BACKEND: NATIVE
// IGNORE_BACKEND_K1: JVM, JVM_IR, JS, JS_IR, JS_IR_ES6 // IGNORE_BACKEND_K1: JVM, JVM_IR, JS, JS_IR, JS_IR_ES6
// WITH_STDLIB // WITH_STDLIB
@@ -1,4 +1,5 @@
// !LANGUAGE: +MultiPlatformProjects // !LANGUAGE: +MultiPlatformProjects
// IGNORE_BACKEND: NATIVE
// IGNORE_BACKEND_K1: JVM, JVM_IR, JS, JS_IR, JS_IR_ES6 // IGNORE_BACKEND_K1: JVM, JVM_IR, JS, JS_IR, JS_IR_ES6
// MODULE: common // MODULE: common
@@ -1,4 +1,5 @@
// !LANGUAGE: +MultiPlatformProjects // !LANGUAGE: +MultiPlatformProjects
// IGNORE_BACKEND: NATIVE
// IGNORE_BACKEND_K1: JVM, JVM_IR, JS, JS_IR, JS_IR_ES6 // IGNORE_BACKEND_K1: JVM, JVM_IR, JS, JS_IR, JS_IR_ES6
// MODULE: common // MODULE: common
@@ -1,5 +1,6 @@
// !LANGUAGE: +MultiPlatformProjects // !LANGUAGE: +MultiPlatformProjects
// IGNORE_BACKEND_K1: JVM, JVM_IR, JS, JS_IR, JS_IR_ES6, NATIVE // IGNORE_BACKEND: NATIVE
// IGNORE_BACKEND_K1: JVM, JVM_IR, JS, JS_IR, JS_IR_ES6
// WITH_STDLIB // WITH_STDLIB
// WITH_COROUTINES // WITH_COROUTINES
@@ -1,4 +1,5 @@
// !LANGUAGE: +MultiPlatformProjects // !LANGUAGE: +MultiPlatformProjects
// IGNORE_BACKEND: NATIVE
// IGNORE_BACKEND_K1: JVM, JVM_IR, JS, JS_IR, JS_IR_ES6 // IGNORE_BACKEND_K1: JVM, JVM_IR, JS, JS_IR, JS_IR_ES6
// WITH_STDLIB // WITH_STDLIB
@@ -1,9 +1,7 @@
// !LANGUAGE: +MultiPlatformProjects // !LANGUAGE: +MultiPlatformProjects
// IGNORE_BACKEND: WASM // IGNORE_BACKEND: NATIVE, WASM
// IGNORE_BACKEND_K1: JVM, JVM_IR, JS, JS_IR, JS_IR_ES6, NATIVE // IGNORE_BACKEND_K1: JVM, JVM_IR, JS, JS_IR, JS_IR_ES6
// IGNORE_BACKEND_K2: JS_IR // IGNORE_BACKEND_K2: JS_IR
// KT-57181
// IGNORE_BACKEND_K2: NATIVE
// WITH_STDLIB // WITH_STDLIB
// MODULE: common // MODULE: common
@@ -4,7 +4,6 @@
*/ */
package org.jetbrains.kotlin.checkers package org.jetbrains.kotlin.checkers
import org.jetbrains.kotlin.ObsoleteTestInfrastructure
import org.jetbrains.kotlin.cli.common.config.addKotlinSourceRoot import org.jetbrains.kotlin.cli.common.config.addKotlinSourceRoot
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
@@ -119,7 +118,6 @@ abstract class KotlinMultiFileTestWithJava<M : KotlinBaseTest.TestModule, F : Ko
protected abstract fun createTestFile(module: M?, fileName: String, text: String, directives: Directives): F protected abstract fun createTestFile(module: M?, fileName: String, text: String, directives: Directives): F
@OptIn(ObsoleteTestInfrastructure::class)
protected open fun createTestFiles( protected open fun createTestFiles(
file: File, file: File,
expectedText: String, expectedText: String,
@@ -141,7 +139,7 @@ abstract class KotlinMultiFileTestWithJava<M : KotlinBaseTest.TestModule, F : Ko
return createTestFile(module, fileName, text, directives) return createTestFile(module, fileName, text, directives)
} }
override fun createModule(name: String, dependencies: List<String>, friends: List<String>, dependsOn: List<String>): M? { override fun createModule(name: String, dependencies: List<String>, friends: List<String>, abiVersions: List<Int>): M? {
val module = createTestModule(name, dependencies, friends) val module = createTestModule(name, dependencies, friends)
val oldValue = modules.put(name, ModuleAndDependencies(module, dependencies, friends)) val oldValue = modules.put(name, ModuleAndDependencies(module, dependencies, friends))
assert(oldValue == null) { "Module $name declared more than once" } assert(oldValue == null) { "Module $name declared more than once" }
@@ -5,7 +5,6 @@
package org.jetbrains.kotlin.compatibility.binary package org.jetbrains.kotlin.compatibility.binary
import org.jetbrains.kotlin.ObsoleteTestInfrastructure
import org.jetbrains.kotlin.test.* import org.jetbrains.kotlin.test.*
import org.jetbrains.kotlin.test.util.KtTestUtil import org.jetbrains.kotlin.test.util.KtTestUtil
import org.jetbrains.kotlin.utils.DFS import org.jetbrains.kotlin.utils.DFS
@@ -72,7 +71,6 @@ abstract class AbstractKlibBinaryCompatibilityTest : KotlinTestWithEnvironment()
const val TEST_FUNCTION = "box" const val TEST_FUNCTION = "box"
const val DEFAULT_MODULE = "main" const val DEFAULT_MODULE = "main"
@OptIn(ObsoleteTestInfrastructure::class)
fun doTest( fun doTest(
filePath: String, filePath: String,
expectedResult: String, expectedResult: String,
@@ -91,7 +89,7 @@ abstract class AbstractKlibBinaryCompatibilityTest : KotlinTestWithEnvironment()
TestFile(module, fileName, text, directives) TestFile(module, fileName, text, directives)
} ?: error("Expected a module for $fileName in $filePath") } ?: error("Expected a module for $fileName in $filePath")
override fun createModule(name: String, dependencies: List<String>, friends: List<String>, dependsOn: List<String>) = override fun createModule(name: String, dependencies: List<String>, friends: List<String>, abiVersions: List<Int>) =
TestModule(name, dependencies, friends) TestModule(name, dependencies, friends)
}, },
@@ -108,13 +108,11 @@ abstract class KotlinBaseTest<F : KotlinBaseTest.TestFile> : KtUsefulTestCase()
open class TestModule( open class TestModule(
@JvmField val name: String, @JvmField val name: String,
@JvmField val dependenciesSymbols: List<String>, @JvmField val dependenciesSymbols: List<String>,
@JvmField val friendsSymbols: List<String>, @JvmField val friendsSymbols: List<String>
@JvmField val dependsOnSymbols: List<String> = listOf(), // mimics the name from ModuleStructureExtractorImpl, thought later converted to `-Xfragment-refines` parameter
) : Comparable<TestModule> { ) : Comparable<TestModule> {
val dependencies: MutableList<TestModule> = arrayListOf() val dependencies: MutableList<TestModule> = arrayListOf()
val friends: MutableList<TestModule> = arrayListOf() val friends: MutableList<TestModule> = arrayListOf()
val dependsOn: MutableList<TestModule> = arrayListOf()
override fun compareTo(other: TestModule): Int = name.compareTo(other.name) override fun compareTo(other: TestModule): Int = name.compareTo(other.name)
@@ -6,10 +6,8 @@
package org.jetbrains.kotlin.test; package org.jetbrains.kotlin.test;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import kotlin.text.StringsKt;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.ObsoleteTestInfrastructure;
import org.jetbrains.kotlin.TestHelperGeneratorKt; import org.jetbrains.kotlin.TestHelperGeneratorKt;
import java.util.*; import java.util.*;
@@ -20,12 +18,11 @@ import java.util.stream.Collectors;
import static org.jetbrains.kotlin.test.InTextDirectivesUtils.isDirectiveDefined; import static org.jetbrains.kotlin.test.InTextDirectivesUtils.isDirectiveDefined;
import static org.jetbrains.kotlin.test.KotlinTestUtils.parseDirectives; import static org.jetbrains.kotlin.test.KotlinTestUtils.parseDirectives;
@ObsoleteTestInfrastructure // THIS TEST PARSER IS OUTDATED/DEPRECATED. PLEASE USE ModuleStructureExtractor INSTEAD
public class TestFiles { public class TestFiles {
/** /**
* Syntax: * Syntax:
* *
* // MODULE: name(dependency1, dependency2, ...)(friend1, friend2, ...)(dependsOn1, dependsOn2, ...) * // MODULE: name(dependency1, dependency2, ...)
* *
* // FILE: name * // FILE: name
* *
@@ -33,11 +30,7 @@ public class TestFiles {
*/ */
private static final String MODULE_DELIMITER = ",\\s*"; private static final String MODULE_DELIMITER = ",\\s*";
private static final Pattern MODULE_PREFIX_PATTERN = Pattern.compile("//\\s*MODULE:.*\n"); private static final Pattern MODULE_PATTERN = Pattern.compile("//\\s*MODULE:\\s*([^()\\n]+)(?:\\(([^()]+(?:" + MODULE_DELIMITER + "[^()]+)*)\\))?\\s*(?:\\(([^()]+(?:" + MODULE_DELIMITER + "[^()]+)*)\\))?\\s*(?:\\((\\d+(?:" + MODULE_DELIMITER + "\\d+)*)\\))?\n");
private static final Pattern MODULE_PATTERN = Pattern.compile("//\\s*MODULE:\\s*([^()\\n]+)" + // name
"(?:\\(([^()]*(?:" + MODULE_DELIMITER + "[^()]+)*)\\))?\\s*" + // dependencies
"(?:\\(([^()]*(?:" + MODULE_DELIMITER + "[^()]+)*)\\))?\\s*" + // friends
"(?:\\(([^()]*(?:" + MODULE_DELIMITER + "[^()]+)*)\\))?\n"); // dependsOn
private static final Pattern FILE_PATTERN = Pattern.compile("//\\s*FILE:\\s*(.*)\n"); private static final Pattern FILE_PATTERN = Pattern.compile("//\\s*FILE:\\s*(.*)\n");
private static final Pattern LINE_SEPARATOR_PATTERN = Pattern.compile("\\r\\n|\\r|\\n"); private static final Pattern LINE_SEPARATOR_PATTERN = Pattern.compile("\\r\\n|\\r|\\n");
@@ -60,15 +53,11 @@ public class TestFiles {
List<F> testFiles = Lists.newArrayList(); List<F> testFiles = Lists.newArrayList();
Matcher fileMatcher = FILE_PATTERN.matcher(expectedText); Matcher fileMatcher = FILE_PATTERN.matcher(expectedText);
Matcher moduleMatcher = MODULE_PATTERN.matcher(expectedText); Matcher moduleMatcher = MODULE_PATTERN.matcher(expectedText);
Matcher modulePrefixMatcher = MODULE_PREFIX_PATTERN.matcher(expectedText);
boolean hasModules = false; boolean hasModules = false;
String commonPrefixOrWholeFile; String commonPrefixOrWholeFile;
boolean fileFound = fileMatcher.find(); boolean fileFound = fileMatcher.find();
boolean moduleFound = moduleMatcher.find(); boolean moduleFound = moduleMatcher.find();
boolean modulePrefixFound = modulePrefixMatcher.find();
assert moduleFound == modulePrefixFound : "First MODULE directive doesn't match to the expected pattern in:\n" + expectedText;
if (!fileFound && !moduleFound) { if (!fileFound && !moduleFound) {
assert testFileName != null : "testFileName should not be null if no FILE directive defined"; assert testFileName != null : "testFileName should not be null if no FILE directive defined";
// One file // One file
@@ -96,20 +85,17 @@ public class TestFiles {
String moduleName = moduleMatcher.group(1); String moduleName = moduleMatcher.group(1);
String moduleDependencies = moduleMatcher.group(2); String moduleDependencies = moduleMatcher.group(2);
String moduleFriends = moduleMatcher.group(3); String moduleFriends = moduleMatcher.group(3);
String moduleDependsOn = moduleMatcher.group(4); String abiVersions = moduleMatcher.group(4);
if (moduleName != null) { if (moduleName != null) {
moduleName = moduleName.trim(); moduleName = moduleName.trim();
hasModules = true; hasModules = true;
module = factory.createModule(moduleName, parseModuleList(moduleDependencies), parseModuleList(moduleFriends), parseModuleList(moduleDependsOn)); module = factory.createModule(moduleName, parseModuleList(moduleDependencies), parseModuleList(moduleFriends), parseAbiVersionsList(abiVersions));
M oldValue = modules.put(moduleName, module); M oldValue = modules.put(moduleName, module);
assert oldValue == null : "Module with name " + moduleName + " already present in file"; assert oldValue == null : "Module with name " + moduleName + " already present in file";
} }
} }
boolean nextModuleExists = moduleMatcher.find(); boolean nextModuleExists = moduleMatcher.find();
boolean nextModulePrefixExists = modulePrefixMatcher.find();
assert nextModuleExists == nextModulePrefixExists : "Continuation MODULE directive doesn't match to the expected pattern in:\n" + expectedText;
moduleFound = nextModuleExists; moduleFound = nextModuleExists;
while (true) { while (true) {
String fileName = fileMatcher.group(1); String fileName = fileMatcher.group(1);
@@ -170,26 +156,19 @@ public class TestFiles {
for (M module : modules.values()) { for (M module : modules.values()) {
if (module != null) { if (module != null) {
module.getDependencies().addAll(module.dependenciesSymbols.stream().map(name -> { module.getDependencies().addAll(module.dependenciesSymbols.stream()
M dep = modules.get(name); .map(modules::get)
assert dep != null : "Dependency not found: " + name + " for module " + module.name + " in:\n" + expectedText; .filter(Objects::nonNull)
return dep; .collect(Collectors.toList()));
}).collect(Collectors.toList()));
module.getFriends().addAll(module.friendsSymbols.stream().map(name -> { module.getFriends().addAll(module.friendsSymbols.stream()
M dep = modules.get(name); .map(modules::get)
assert dep != null : "Dependency not found: " + name + " for module " + module.name + " in:\n" + expectedText; .filter(Objects::nonNull)
return dep; .collect(Collectors.toList()));
}).collect(Collectors.toList()));
module.getDependsOn().addAll(module.dependsOnSymbols.stream().map(name -> {
M dep = modules.get(name);
assert dep != null : "Dependency not found: " + name + " for module " + module.name + " in:\n" + expectedText;
return dep;
}).collect(Collectors.toList()));
} }
} }
return testFiles; return testFiles;
} }
@@ -214,13 +193,23 @@ public class TestFiles {
} }
private static List<String> parseModuleList(@Nullable String dependencies) { private static List<String> parseModuleList(@Nullable String dependencies) {
if (dependencies == null || StringsKt.isBlank(dependencies)) return Collections.emptyList(); if (dependencies == null) return Collections.emptyList();
return StringsKt.split(dependencies, Pattern.compile(MODULE_DELIMITER), 0); return kotlin.text.StringsKt.split(dependencies, Pattern.compile(MODULE_DELIMITER), 0);
}
private static List<Integer> parseAbiVersionsList(@Nullable String versions) {
if (versions == null) return Collections.emptyList();
List<String> splitted = kotlin.text.StringsKt.split(versions, Pattern.compile(MODULE_DELIMITER), 0);
List<Integer> result = new ArrayList<>(splitted.size());
for (String s : splitted) {
result.add(Integer.parseInt(s));
}
return result;
} }
public interface TestFileFactory<M, F> { public interface TestFileFactory<M, F> {
F createFile(@Nullable M module, @NotNull String fileName, @NotNull String text, @NotNull Directives directives); F createFile(@Nullable M module, @NotNull String fileName, @NotNull String text, @NotNull Directives directives);
M createModule(@NotNull String name, @NotNull List<String> dependencies, @NotNull List<String> friends, @NotNull List<String> dependsOn); M createModule(@NotNull String name, @NotNull List<String> dependencies, @NotNull List<String> friends, @NotNull List<Integer> abiVersions);
} }
public static abstract class TestFileFactoryNoModules<F> implements TestFileFactory<KotlinBaseTest.TestModule, F> { public static abstract class TestFileFactoryNoModules<F> implements TestFileFactory<KotlinBaseTest.TestModule, F> {
@@ -238,7 +227,7 @@ public class TestFiles {
public abstract F create(@NotNull String fileName, @NotNull String text, @NotNull Directives directives); public abstract F create(@NotNull String fileName, @NotNull String text, @NotNull Directives directives);
@Override @Override
public KotlinBaseTest.TestModule createModule(@NotNull String name, @NotNull List<String> dependencies, @NotNull List<String> friends, @NotNull List<String> dependsOn) { public KotlinBaseTest.TestModule createModule(@NotNull String name, @NotNull List<String> dependencies, @NotNull List<String> friends, @NotNull List<Integer> abiVersions) {
return null; return null;
} }
} }
@@ -7,7 +7,6 @@ package org.jetbrains.kotlin.jvm.runtime
import com.intellij.openapi.diagnostic.Logger import com.intellij.openapi.diagnostic.Logger
import com.intellij.openapi.util.io.FileUtil import com.intellij.openapi.util.io.FileUtil
import org.jetbrains.kotlin.ObsoleteTestInfrastructure
import org.jetbrains.kotlin.checkers.KotlinMultiFileTestWithJava import org.jetbrains.kotlin.checkers.KotlinMultiFileTestWithJava
import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
import org.jetbrains.kotlin.codegen.GenerationUtils import org.jetbrains.kotlin.codegen.GenerationUtils
@@ -112,7 +111,6 @@ abstract class AbstractJvmRuntimeDescriptorLoaderTest : TestCaseWithTmpdir() {
containingDeclaration is JavaClassDescriptor && containingDeclaration is JavaClassDescriptor &&
containingDeclaration.kind == ClassKind.ANNOTATION_CLASS containingDeclaration.kind == ClassKind.ANNOTATION_CLASS
@OptIn(ObsoleteTestInfrastructure::class)
private fun compileFile(file: File, text: String, jdkKind: TestJdkKind) { private fun compileFile(file: File, text: String, jdkKind: TestJdkKind) {
val fileName = file.name val fileName = file.name
when { when {
@@ -71,9 +71,6 @@ internal fun PhaseContext.fir2Ir(
).also { ).also {
(it.irModuleFragment.descriptor as? FirModuleDescriptor)?.let { it.allDependencyModules = librariesDescriptors } (it.irModuleFragment.descriptor as? FirModuleDescriptor)?.let { it.allDependencyModules = librariesDescriptors }
} }
assert(fir2irResult.irModuleFragment.name.isSpecial) {
"`${fir2irResult.irModuleFragment.name}` must be Name.special, since it's required by KlibMetadataModuleDescriptorFactoryImpl.createDescriptorOptionalBuiltIns()"
}
val symbols = createKonanSymbols(fir2irResult) val symbols = createKonanSymbols(fir2irResult)
// TODO KT-55580 Invoke CopyDefaultValuesToActualPhase, same as PsiToir phase does. // TODO KT-55580 Invoke CopyDefaultValuesToActualPhase, same as PsiToir phase does.
@@ -42,7 +42,7 @@ internal fun PhaseContext.firFrontend(input: KotlinCoreEnvironment): FirOutput {
val resolvedLibraries: List<KotlinResolvedLibrary> = config.resolvedLibraries.getFullResolvedList() val resolvedLibraries: List<KotlinResolvedLibrary> = config.resolvedLibraries.getFullResolvedList()
val sessionsWithSources = prepareNativeSessions( val sessionsWithSources = prepareNativeSessions(
ktFiles, configuration, mainModuleName, resolvedLibraries, dependencyList, ktFiles, configuration, mainModuleName.asString(), resolvedLibraries, dependencyList,
extensionRegistrars, isCommonSourceForPsi, fileBelongsToModuleForPsi extensionRegistrars, isCommonSourceForPsi, fileBelongsToModuleForPsi
) )
@@ -32,7 +32,7 @@ abstract class AbstractNativeCInteropBaseTest : AbstractNativeSimpleTest() {
internal fun generateCInteropTestCaseWithSingleDef(defFile: File, extraArgs: List<String>): TestCase { internal fun generateCInteropTestCaseWithSingleDef(defFile: File, extraArgs: List<String>): TestCase {
val moduleName: String = defFile.name val moduleName: String = defFile.name
val module = TestModule.Exclusive(moduleName, emptySet(), emptySet(), emptySet()) val module = TestModule.Exclusive(moduleName, emptySet(), emptySet())
module.files += TestFile.createCommitted(defFile, module) module.files += TestFile.createCommitted(defFile, module)
return TestCase( return TestCase(
@@ -56,7 +56,7 @@ abstract class AbstractNativeCInteropKT39120Test : AbstractNativeCInteropBaseTes
val ktFile = testPathFull.resolve(DEFAULT_FILE_NAME) val ktFile = testPathFull.resolve(DEFAULT_FILE_NAME)
if (ktFile.exists()) { if (ktFile.exists()) {
// Just compile "main.kt" with klib1 and klib2, without running resulting executable // Just compile "main.kt" with klib1 and klib2, without running resulting executable
val module = TestModule.Exclusive(DEFAULT_MODULE_NAME, emptySet(), emptySet(), emptySet()).apply { val module = TestModule.Exclusive(DEFAULT_MODULE_NAME, emptySet(), emptySet()).apply {
files += TestFile.createCommitted(ktFile, this) files += TestFile.createCommitted(ktFile, this)
} }
val compilationResult = compileToExecutable( val compilationResult = compileToExecutable(
@@ -107,7 +107,6 @@ abstract class AbstractNativeKlibABITest : AbstractNativeSimpleTest() {
settings = testRunSettings, settings = testRunSettings,
freeCompilerArgs = COMPILER_ARGS_FOR_STATIC_CACHE_AND_EXECUTABLE, freeCompilerArgs = COMPILER_ARGS_FOR_STATIC_CACHE_AND_EXECUTABLE,
options = StaticCacheCompilation.Options.Regular, options = StaticCacheCompilation.Options.Regular,
pipelineType = testRunSettings.get(),
dependencies = createLibraryCacheDependencies(moduleDependencies) + klibArtifact.toDependency(), dependencies = createLibraryCacheDependencies(moduleDependencies) + klibArtifact.toDependency(),
expectedArtifact = klibArtifact.toStaticCacheArtifact() expectedArtifact = klibArtifact.toStaticCacheArtifact()
) )
@@ -119,8 +118,7 @@ abstract class AbstractNativeKlibABITest : AbstractNativeSimpleTest() {
name = moduleName, name = moduleName,
directDependencySymbols = emptySet(), /* Don't need to pass any dependency symbols here. directDependencySymbols = emptySet(), /* Don't need to pass any dependency symbols here.
Dependencies are already handled by the AbstractKlibABITestCase class. */ Dependencies are already handled by the AbstractKlibABITestCase class. */
directFriendSymbols = emptySet(), directFriendSymbols = emptySet()
directDependsOnSymbols = emptySet(),
) )
private fun createTestCase(module: TestModule.Exclusive, compilerArgs: TestCompilerArgs) = TestCase( private fun createTestCase(module: TestModule.Exclusive, compilerArgs: TestCompilerArgs) = TestCase(
@@ -127,7 +127,6 @@ abstract class AbstractNativeKlibBinaryCompatibilityTest : AbstractNativeSimpleT
settings = testRunSettings, settings = testRunSettings,
freeCompilerArgs = COMPILER_ARGS_FOR_STATIC_CACHE_AND_EXECUTABLE, freeCompilerArgs = COMPILER_ARGS_FOR_STATIC_CACHE_AND_EXECUTABLE,
options = StaticCacheCompilation.Options.Regular, options = StaticCacheCompilation.Options.Regular,
pipelineType = testRunSettings.get(),
dependencies = moduleDependencies.map { dependencies = moduleDependencies.map {
it.klibFile.toStaticCacheArtifact().toDependency() it.klibFile.toStaticCacheArtifact().toDependency()
} + klib.toKlib().toDependency(), } + klib.toKlib().toDependency(),
@@ -143,8 +142,7 @@ abstract class AbstractNativeKlibBinaryCompatibilityTest : AbstractNativeSimpleT
val module: TestModule.Exclusive = TestModule.Exclusive( val module: TestModule.Exclusive = TestModule.Exclusive(
name = name, name = name,
directDependencySymbols = emptySet(), directDependencySymbols = emptySet(),
directFriendSymbols = emptySet(), directFriendSymbols = emptySet()
directDependsOnSymbols = emptySet(),
) )
val localBuildDir: File = val localBuildDir: File =
@@ -39,7 +39,7 @@ abstract class AbstractNativeKlibContentsTest : AbstractNativeSimpleTest() {
private fun generateTestCaseWithSingleSource(source: File, extraArgs: List<String>): TestCase { private fun generateTestCaseWithSingleSource(source: File, extraArgs: List<String>): TestCase {
val moduleName: String = source.name val moduleName: String = source.name
val module = TestModule.Exclusive(moduleName, emptySet(), emptySet(), emptySet()) val module = TestModule.Exclusive(moduleName, emptySet(), emptySet())
module.files += TestFile.createCommitted(source, module) module.files += TestFile.createCommitted(source, module)
return TestCase( return TestCase(
@@ -80,7 +80,6 @@ internal fun AbstractNativeSimpleTest.compileToStaticCache(
settings = testRunSettings, settings = testRunSettings,
freeCompilerArgs = TestCompilerArgs.EMPTY, freeCompilerArgs = TestCompilerArgs.EMPTY,
StaticCacheCompilation.Options.Regular, StaticCacheCompilation.Options.Regular,
pipelineType = testRunSettings.get(),
dependencies = listOf(klib.asLibraryDependency()), dependencies = listOf(klib.asLibraryDependency()),
expectedArtifact = TestCompilationArtifact.KLIBStaticCache(cacheDir, klib) expectedArtifact = TestCompilationArtifact.KLIBStaticCache(cacheDir, klib)
) )
@@ -92,7 +91,7 @@ internal fun AbstractNativeSimpleTest.generateTestCaseWithSingleModule(
freeCompilerArgs: TestCompilerArgs = TestCompilerArgs.EMPTY freeCompilerArgs: TestCompilerArgs = TestCompilerArgs.EMPTY
): TestCase { ): TestCase {
val moduleName: String = moduleDir?.name ?: LAUNCHER_MODULE_NAME val moduleName: String = moduleDir?.name ?: LAUNCHER_MODULE_NAME
val module = TestModule.Exclusive(moduleName, emptySet(), emptySet(), emptySet()) val module = TestModule.Exclusive(moduleName, emptySet(), emptySet())
moduleDir?.walkTopDown() moduleDir?.walkTopDown()
?.filter { it.isFile && it.extension == "kt" } ?.filter { it.isFile && it.extension == "kt" }
@@ -9,7 +9,6 @@ package org.jetbrains.kotlin.konan.blackboxtest.support
import org.jetbrains.kotlin.konan.blackboxtest.support.TestCase.WithTestRunnerExtras import org.jetbrains.kotlin.konan.blackboxtest.support.TestCase.WithTestRunnerExtras
import org.jetbrains.kotlin.konan.blackboxtest.support.TestModule.Companion.allDependencies import org.jetbrains.kotlin.konan.blackboxtest.support.TestModule.Companion.allDependencies
import org.jetbrains.kotlin.konan.blackboxtest.support.TestModule.Companion.allDependsOn
import org.jetbrains.kotlin.konan.blackboxtest.support.runner.TestRunChecks import org.jetbrains.kotlin.konan.blackboxtest.support.runner.TestRunChecks
import org.jetbrains.kotlin.konan.blackboxtest.support.util.* import org.jetbrains.kotlin.konan.blackboxtest.support.util.*
import org.jetbrains.kotlin.storage.LockBasedStorageManager import org.jetbrains.kotlin.storage.LockBasedStorageManager
@@ -86,19 +85,16 @@ internal sealed class TestModule {
data class Exclusive( data class Exclusive(
override val name: String, override val name: String,
val directDependencySymbols: Set<String>, val directDependencySymbols: Set<String>,
val directFriendSymbols: Set<String>, val directFriendSymbols: Set<String>
val directDependsOnSymbols: Set<String>, // mimics the name from ModuleStructureExtractorImpl, thought later converted to `-Xfragment-refines` parameter
) : TestModule() { ) : TestModule() {
override val files: FailOnDuplicatesSet<TestFile<Exclusive>> = FailOnDuplicatesSet() override val files: FailOnDuplicatesSet<TestFile<Exclusive>> = FailOnDuplicatesSet()
lateinit var directDependencies: Set<TestModule> lateinit var directDependencies: Set<TestModule>
lateinit var directFriends: Set<TestModule> lateinit var directFriends: Set<TestModule>
lateinit var directDependsOn: Set<TestModule>
// N.B. The following two properties throw an exception on attempt to resolve cyclic dependencies. // N.B. The following two properties throw an exception on attempt to resolve cyclic dependencies.
val allDependencies: Set<TestModule> by SM.lazyNeighbors({ directDependencies }, { it.allDependencies }) val allDependencies: Set<TestModule> by SM.lazyNeighbors({ directDependencies }, { it.allDependencies })
val allFriends: Set<TestModule> by SM.lazyNeighbors({ directFriends }, { it.allFriends }) val allFriends: Set<TestModule> by SM.lazyNeighbors({ directFriends }, { it.allFriends })
val allDependsOn: Set<TestModule> by SM.lazyNeighbors({ directDependsOn }, { it.allDependsOn })
lateinit var testCase: TestCase lateinit var testCase: TestCase
@@ -107,9 +103,7 @@ internal sealed class TestModule {
} }
fun haveSameSymbols(other: Exclusive) = fun haveSameSymbols(other: Exclusive) =
other.directDependencySymbols == directDependencySymbols && other.directDependencySymbols == directDependencySymbols && other.directFriendSymbols == directFriendSymbols
other.directFriendSymbols == directFriendSymbols &&
other.directDependsOnSymbols == directDependsOnSymbols
} }
data class Shared(override val name: String) : TestModule() { data class Shared(override val name: String) : TestModule() {
@@ -128,7 +122,7 @@ internal sealed class TestModule {
final override fun toString() = "${javaClass.canonicalName}[name=$name]" final override fun toString() = "${javaClass.canonicalName}[name=$name]"
companion object { companion object {
fun newDefaultModule() = Exclusive(DEFAULT_MODULE_NAME, emptySet(), emptySet(), emptySet()) fun newDefaultModule() = Exclusive(DEFAULT_MODULE_NAME, emptySet(), emptySet())
val TestModule.allDependencies: Set<TestModule> val TestModule.allDependencies: Set<TestModule>
get() = when (this) { get() = when (this) {
@@ -142,12 +136,6 @@ internal sealed class TestModule {
is Shared, is Given -> emptySet() is Shared, is Given -> emptySet()
} }
val TestModule.allDependsOn: Set<TestModule>
get() = when (this) {
is Exclusive -> allDependsOn
is Shared, is Given -> emptySet()
}
private val SM = LockBasedStorageManager(TestModule::class.java.name) private val SM = LockBasedStorageManager(TestModule::class.java.name)
} }
} }
@@ -210,13 +198,11 @@ internal class TestCase(
modules.forEach { module -> modules.forEach { module ->
allModules += module allModules += module
allModules += module.allDependencies allModules += module.allDependencies
allModules += module.allDependsOn
} }
val rootModules = allModules.toHashSet() val rootModules = allModules.toHashSet()
allModules.forEach { module -> allModules.forEach { module ->
rootModules -= module.allDependencies rootModules -= module.allDependencies
rootModules -= module.allDependsOn
} }
assertTrue(rootModules.isNotEmpty()) { "$id: No root modules in test case." } assertTrue(rootModules.isNotEmpty()) { "$id: No root modules in test case." }
@@ -271,7 +257,6 @@ internal class TestCase(
} }
module.directFriends = module.directFriendSymbols.mapToSet(::findModule) module.directFriends = module.directFriendSymbols.mapToSet(::findModule)
module.directDependsOn = module.directDependsOnSymbols.mapToSet(::findModule)
} }
} }
} }
@@ -242,14 +242,13 @@ internal fun parseModule(parsedDirective: RegisteredDirectivesParser.ParsedDirec
val name = match.groupValues[1] val name = match.groupValues[1]
val directDependencySymbols = match.groupValues[3].split(',').filter(String::isNotEmpty).toSet() val directDependencySymbols = match.groupValues[3].split(',').filter(String::isNotEmpty).toSet()
val directFriendSymbols = match.groupValues[5].split(',').filter(String::isNotEmpty).toSet() val directFriendSymbols = match.groupValues[5].split(',').filter(String::isNotEmpty).toSet()
val directDependsOnSymbols = match.groupValues[7].split(',').filter(String::isNotEmpty).toSet()
val friendsThatAreNotDependencies = directFriendSymbols - directDependencySymbols val friendsThatAreNotDependencies = directFriendSymbols - directDependencySymbols
assertTrue(friendsThatAreNotDependencies.isEmpty()) { assertTrue(friendsThatAreNotDependencies.isEmpty()) {
"$location: Found friends that are not dependencies: $friendsThatAreNotDependencies" "$location: Found friends that are not dependencies: $friendsThatAreNotDependencies"
} }
TestModule.Exclusive(name, directDependencySymbols, directFriendSymbols, directDependsOnSymbols) TestModule.Exclusive(name, directDependencySymbols, directFriendSymbols)
} }
return module ?: fail { return module ?: fail {
@@ -260,11 +259,7 @@ internal fun parseModule(parsedDirective: RegisteredDirectivesParser.ParsedDirec
} }
} }
private val TEST_MODULE_REGEX = Regex("^([a-zA-Z0-9_]+)(" + // name private val TEST_MODULE_REGEX = Regex("^([a-zA-Z0-9_]+)(\\(([a-zA-Z0-9_,]*)\\)(\\(([a-zA-Z0-9_,]*)\\))?)?$")
"\\(([a-zA-Z0-9_,]*)\\)" + // dependencies
"(\\(([a-zA-Z0-9_,]*)\\))?" + // friends
"(\\(([a-zA-Z0-9_,]*)\\))?" + // dependsOn
")?$")
internal fun parseFileName(parsedDirective: RegisteredDirectivesParser.ParsedDirective, location: Location): String { internal fun parseFileName(parsedDirective: RegisteredDirectivesParser.ParsedDirective, location: Location): String {
val fileName = parsedDirective.values.singleOrNull()?.toString() val fileName = parsedDirective.values.singleOrNull()?.toString()
@@ -8,7 +8,6 @@ package org.jetbrains.kotlin.konan.blackboxtest.support.compilation
import org.jetbrains.kotlin.cli.common.ExitCode import org.jetbrains.kotlin.cli.common.ExitCode
import org.jetbrains.kotlin.konan.blackboxtest.support.* import org.jetbrains.kotlin.konan.blackboxtest.support.*
import org.jetbrains.kotlin.konan.blackboxtest.support.TestCase.* import org.jetbrains.kotlin.konan.blackboxtest.support.TestCase.*
import org.jetbrains.kotlin.konan.blackboxtest.support.TestModule.Companion.allDependsOn
import org.jetbrains.kotlin.konan.blackboxtest.support.compilation.ExecutableCompilation.Companion.applyTestRunnerSpecificArgs import org.jetbrains.kotlin.konan.blackboxtest.support.compilation.ExecutableCompilation.Companion.applyTestRunnerSpecificArgs
import org.jetbrains.kotlin.konan.blackboxtest.support.compilation.ExecutableCompilation.Companion.assertTestDumpFileNotEmptyIfExists import org.jetbrains.kotlin.konan.blackboxtest.support.compilation.ExecutableCompilation.Companion.assertTestDumpFileNotEmptyIfExists
import org.jetbrains.kotlin.konan.blackboxtest.support.compilation.TestCompilationArtifact.* import org.jetbrains.kotlin.konan.blackboxtest.support.compilation.TestCompilationArtifact.*
@@ -155,7 +154,6 @@ internal abstract class SourceBasedCompilation<A : TestCompilationArtifact>(
gcType.compilerFlag?.let { compilerFlag -> add(compilerFlag) } gcType.compilerFlag?.let { compilerFlag -> add(compilerFlag) }
gcScheduler.compilerFlag?.let { compilerFlag -> add(compilerFlag) } gcScheduler.compilerFlag?.let { compilerFlag -> add(compilerFlag) }
pipelineType.compilerFlags.forEach { compilerFlag -> add(compilerFlag) } pipelineType.compilerFlags.forEach { compilerFlag -> add(compilerFlag) }
applyK2MPPArgs(this)
} }
override fun applyDependencies(argsBuilder: ArgsBuilder): Unit = with(argsBuilder) { override fun applyDependencies(argsBuilder: ArgsBuilder): Unit = with(argsBuilder) {
@@ -165,17 +163,6 @@ internal abstract class SourceBasedCompilation<A : TestCompilationArtifact>(
} }
add(dependencies.includedLibraries) { include -> "-Xinclude=${include.path}" } add(dependencies.includedLibraries) { include -> "-Xinclude=${include.path}" }
} }
private fun applyK2MPPArgs(argsBuilder: ArgsBuilder): Unit = with(argsBuilder) {
if (pipelineType == PipelineType.K2 && freeCompilerArgs.compilerArgs.any { it == "-XXLanguage:+MultiPlatformProjects" }) {
sourceModules.mapToSet { "-Xfragments=${it.name}" }
.sorted().forEach { add(it) }
sourceModules.flatMapToSet { module -> module.allDependsOn.map { "-Xfragment-refines=${module.name}:${it.name}" } }
.sorted().forEach { add(it) }
sourceModules.flatMapToSet { module -> module.files.map { "-Xfragment-sources=${module.name}:${it.location.path}" } }
.sorted().forEach { add(it) }
}
}
} }
internal class LibraryCompilation( internal class LibraryCompilation(
@@ -351,7 +338,6 @@ internal class StaticCacheCompilation(
settings: Settings, settings: Settings,
freeCompilerArgs: TestCompilerArgs, freeCompilerArgs: TestCompilerArgs,
private val options: Options, private val options: Options,
private val pipelineType: PipelineType,
dependencies: Iterable<TestCompilationDependency<*>>, dependencies: Iterable<TestCompilationDependency<*>>,
expectedArtifact: KLIBStaticCache expectedArtifact: KLIBStaticCache
) : BasicCompilation<KLIBStaticCache>( ) : BasicCompilation<KLIBStaticCache>(
@@ -381,7 +367,6 @@ internal class StaticCacheCompilation(
override fun applySpecificArgs(argsBuilder: ArgsBuilder): Unit = with(argsBuilder) { override fun applySpecificArgs(argsBuilder: ArgsBuilder): Unit = with(argsBuilder) {
add("-produce", "static_cache") add("-produce", "static_cache")
pipelineType.compilerFlags.forEach { compilerFlag -> add(compilerFlag) }
when (options) { when (options) {
is Options.Regular -> Unit /* Nothing to do. */ is Options.Regular -> Unit /* Nothing to do. */
@@ -15,7 +15,6 @@ import org.jetbrains.kotlin.konan.blackboxtest.support.compilation.TestCompilati
* [Library] - the [TestCompilation]s (modules) that should yield KLIBs to be consumed as dependency libraries in the current compilation. * [Library] - the [TestCompilation]s (modules) that should yield KLIBs to be consumed as dependency libraries in the current compilation.
* [FriendLibrary] - similarly but friend modules (-friend-modules). * [FriendLibrary] - similarly but friend modules (-friend-modules).
* [IncludedLibrary] - similarly but included modules (-Xinclude). * [IncludedLibrary] - similarly but included modules (-Xinclude).
* Note: there cannot be DependsOnLibrary type, since `dependsOn` dependency works only within a KLIB, not between KLIBs.
*/ */
internal sealed class TestCompilationDependencyType<A : TestCompilationArtifact>(private val artifactClass: Class<A>) { internal sealed class TestCompilationDependencyType<A : TestCompilationArtifact>(private val artifactClass: Class<A>) {
object Library : TestCompilationDependencyType<KLIB>(KLIB::class.java) object Library : TestCompilationDependencyType<KLIB>(KLIB::class.java)
@@ -11,7 +11,6 @@ import org.jetbrains.kotlin.konan.blackboxtest.support.TestCase.*
import org.jetbrains.kotlin.konan.blackboxtest.support.TestCompilerArgs import org.jetbrains.kotlin.konan.blackboxtest.support.TestCompilerArgs
import org.jetbrains.kotlin.konan.blackboxtest.support.TestModule import org.jetbrains.kotlin.konan.blackboxtest.support.TestModule
import org.jetbrains.kotlin.konan.blackboxtest.support.TestModule.Companion.allDependencies import org.jetbrains.kotlin.konan.blackboxtest.support.TestModule.Companion.allDependencies
import org.jetbrains.kotlin.konan.blackboxtest.support.TestModule.Companion.allDependsOn
import org.jetbrains.kotlin.konan.blackboxtest.support.TestModule.Companion.allFriends import org.jetbrains.kotlin.konan.blackboxtest.support.TestModule.Companion.allFriends
import org.jetbrains.kotlin.konan.blackboxtest.support.compilation.TestCompilationArtifact.* import org.jetbrains.kotlin.konan.blackboxtest.support.compilation.TestCompilationArtifact.*
import org.jetbrains.kotlin.konan.blackboxtest.support.compilation.TestCompilationDependencyType.* import org.jetbrains.kotlin.konan.blackboxtest.support.compilation.TestCompilationDependencyType.*
@@ -159,7 +158,7 @@ internal class TestCompilationFactory {
LibraryCompilation( LibraryCompilation(
settings = settings, settings = settings,
freeCompilerArgs = freeCompilerArgs, freeCompilerArgs = freeCompilerArgs,
sourceModules = sourceModules.flatMapToSet { sortDependsOnTopologically(it) }, sourceModules = sourceModules,
dependencies = dependencies.forKlib(), dependencies = dependencies.forKlib(),
expectedArtifact = klibArtifact expectedArtifact = klibArtifact
) )
@@ -170,7 +169,6 @@ internal class TestCompilationFactory {
settings = settings, settings = settings,
freeCompilerArgs = freeCompilerArgs, freeCompilerArgs = freeCompilerArgs,
options = staticCacheOptions, options = staticCacheOptions,
pipelineType = settings.get(),
dependencies = dependencies.forStaticCache(klibCompilation.asKlibDependency(type = /* does not matter in fact*/ Library)), dependencies = dependencies.forStaticCache(klibCompilation.asKlibDependency(type = /* does not matter in fact*/ Library)),
expectedArtifact = staticCacheArtifact expectedArtifact = staticCacheArtifact
) )
@@ -205,23 +203,6 @@ internal class TestCompilationFactory {
return CompilationDependencies(klibDependencies, staticCacheDependencies) return CompilationDependencies(klibDependencies, staticCacheDependencies)
} }
// mimics FirFrontendFacade.sortDependsOnTopologically(org.jetbrains.kotlin.test.model.TestModule)
private fun sortDependsOnTopologically(module: TestModule): List<TestModule> {
val sortedModules = mutableListOf<TestModule>()
val visitedModules = mutableSetOf<TestModule>()
val modulesQueue = ArrayDeque<TestModule>()
modulesQueue.add(module)
while (modulesQueue.isNotEmpty()) {
val currentModule = modulesQueue.removeFirst()
if (!visitedModules.add(currentModule)) continue
sortedModules.add(currentModule)
modulesQueue += currentModule.allDependsOn
}
return sortedModules.reversed()
}
companion object { companion object {
private fun Set<TestModule>.allDependencies() = if (size == 1) first().allDependencies else flatMapToSet { it.allDependencies } private fun Set<TestModule>.allDependencies() = if (size == 1) first().allDependencies else flatMapToSet { it.allDependencies }
private fun Set<TestModule>.allFriends() = if (size == 1) first().allFriends else flatMapToSet { it.allFriends } private fun Set<TestModule>.allFriends() = if (size == 1) first().allFriends else flatMapToSet { it.allFriends }
@@ -12,7 +12,6 @@ import com.intellij.pom.PomModel
import com.intellij.pom.core.impl.PomModelImpl import com.intellij.pom.core.impl.PomModelImpl
import com.intellij.pom.tree.TreeAspect import com.intellij.pom.tree.TreeAspect
import com.intellij.psi.impl.source.tree.TreeCopyHandler import com.intellij.psi.impl.source.tree.TreeCopyHandler
import org.jetbrains.kotlin.ObsoleteTestInfrastructure
import org.jetbrains.kotlin.builtins.StandardNames import org.jetbrains.kotlin.builtins.StandardNames
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
@@ -658,8 +657,7 @@ private class ExtTestDataFileStructureFactory(parentDisposable: Disposable) : Te
destination = TestModule.Exclusive( destination = TestModule.Exclusive(
name = extTestModule.name, name = extTestModule.name,
directDependencySymbols = extTestModule.dependencies.mapToSet(::transformDependency), directDependencySymbols = extTestModule.dependencies.mapToSet(::transformDependency),
directFriendSymbols = extTestModule.friends.mapToSet(::transformDependency), directFriendSymbols = extTestModule.friends.mapToSet(::transformDependency)
directDependsOnSymbols = extTestModule.dependsOn.mapToSet(::transformDependency),
), ),
baseDir = testCaseDir baseDir = testCaseDir
) { module, file -> module.files += file } ) { module, file -> module.files += file }
@@ -706,15 +704,11 @@ private class ExtTestDataFileStructureFactory(parentDisposable: Disposable) : Te
private fun checkModulesConsistency() { private fun checkModulesConsistency() {
filesAndModules.modules.values.forEach { module -> filesAndModules.modules.values.forEach { module ->
val unknownFriends = (module.friendsSymbols + module.friends.map { it.name }).toSet() - filesAndModules.modules.keys val unknownFriends = (module.friendsSymbols + module.friends.map { it.name }).toSet() - filesAndModules.modules.keys
assertTrue(unknownFriends.isEmpty()) { "Module $module has unknown friends: $unknownFriends" }
val unknownDependencies = val unknownDependencies =
(module.dependenciesSymbols + module.dependencies.map { it.name }).toSet() - filesAndModules.modules.keys (module.dependenciesSymbols + module.dependencies.map { it.name }).toSet() - filesAndModules.modules.keys
assertTrue(unknownDependencies.isEmpty()) { "Module $module has unknown dependencies: $unknownDependencies" }
val unknownDependsOn =
(module.dependsOnSymbols + module.dependsOn.map { it.name }).toSet() - filesAndModules.modules.keys
val unknownAllDependencies = unknownDependencies + unknownFriends + unknownDependsOn
assertTrue(unknownAllDependencies.isEmpty()) { "Module $module has unknown dependencies: $unknownAllDependencies" }
assertTrue(module.files.isNotEmpty()) { "Module $module has no files" } assertTrue(module.files.isNotEmpty()) { "Module $module has no files" }
} }
@@ -724,9 +718,8 @@ private class ExtTestDataFileStructureFactory(parentDisposable: Disposable) : Te
private class ExtTestModule( private class ExtTestModule(
name: String, name: String,
dependencies: List<String>, dependencies: List<String>,
friends: List<String>, friends: List<String>
dependsOn: List<String>, // mimics the name from ModuleStructureExtractorImpl, thought later converted to `-Xfragment-refines` parameter ) : KotlinBaseTest.TestModule(name, dependencies, friends) {
) : KotlinBaseTest.TestModule(name, dependencies, friends, dependsOn) {
val files = mutableListOf<ExtTestFile>() val files = mutableListOf<ExtTestFile>()
val isSupport get() = name == SUPPORT_MODULE_NAME val isSupport get() = name == SUPPORT_MODULE_NAME
@@ -753,7 +746,6 @@ private class ExtTestDataFileStructureFactory(parentDisposable: Disposable) : Te
override fun hashCode() = name.hashCode() * 31 + module.hashCode() override fun hashCode() = name.hashCode() * 31 + module.hashCode()
} }
@OptIn(ObsoleteTestInfrastructure::class)
private class ExtTestFileFactory : TestFiles.TestFileFactory<ExtTestModule, ExtTestFile> { private class ExtTestFileFactory : TestFiles.TestFileFactory<ExtTestModule, ExtTestFile> {
private val defaultModule by lazy { createModule(DEFAULT_MODULE_NAME, emptyList(), emptyList(), emptyList()) } private val defaultModule by lazy { createModule(DEFAULT_MODULE_NAME, emptyList(), emptyList(), emptyList()) }
private val supportModule by lazy { createModule(SUPPORT_MODULE_NAME, emptyList(), emptyList(), emptyList()) } private val supportModule by lazy { createModule(SUPPORT_MODULE_NAME, emptyList(), emptyList(), emptyList()) }
@@ -772,14 +764,13 @@ private class ExtTestDataFileStructureFactory(parentDisposable: Disposable) : Te
) )
} }
override fun createModule(name: String, dependencies: List<String>, friends: List<String>, dependsOn: List<String>): ExtTestModule = override fun createModule(name: String, dependencies: List<String>, friends: List<String>, abiVersions: List<Int>): ExtTestModule =
ExtTestModule(name, dependencies, friends, dependsOn) ExtTestModule(name, dependencies, friends)
} }
private inner class FilesAndModules(originalTestDataFile: File, sourceTransformers: ExternalSourceTransformers) { private inner class FilesAndModules(originalTestDataFile: File, sourceTransformers: ExternalSourceTransformers) {
private val testFileFactory = ExtTestFileFactory() private val testFileFactory = ExtTestFileFactory()
@OptIn(ObsoleteTestInfrastructure::class)
private val generatedFiles = TestFiles.createTestFiles( private val generatedFiles = TestFiles.createTestFiles(
/* testFileName = */ DEFAULT_FILE_NAME, /* testFileName = */ DEFAULT_FILE_NAME,
/* expectedText = */ originalTestDataFile.readText(), /* expectedText = */ originalTestDataFile.readText(),
@@ -49,8 +49,7 @@ internal class PredefinedTestCaseGroupProvider(annotation: PredefinedTestCases)
val module = TestModule.Exclusive( val module = TestModule.Exclusive(
name = testCaseId.uniqueName, name = testCaseId.uniqueName,
directDependencySymbols = emptySet(), directDependencySymbols = emptySet(),
directFriendSymbols = emptySet(), directFriendSymbols = emptySet()
directDependsOnSymbols = emptySet(),
) )
val ignoredFiles = predefinedTestCase.ignoredFiles.map { it.absoluteNormalizedFile() } val ignoredFiles = predefinedTestCase.ignoredFiles.map { it.absoluteNormalizedFile() }
@@ -29,7 +29,6 @@ import org.jetbrains.kotlin.fir.extensions.FirExtensionRegistrar
import org.jetbrains.kotlin.fir.pipeline.* import org.jetbrains.kotlin.fir.pipeline.*
import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmProtoBufUtil import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmProtoBufUtil
import org.jetbrains.kotlin.modules.TargetId import org.jetbrains.kotlin.modules.TargetId
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.platform.CommonPlatforms import org.jetbrains.kotlin.platform.CommonPlatforms
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.psi.KtFile
@@ -357,7 +356,7 @@ private fun doCompileWithK2(
friendPaths = emptyList() friendPaths = emptyList()
) )
val session = prepareJvmSessions( val session = prepareJvmSessions(
sourceFiles, kotlinCompilerConfiguration, projectEnvironment, Name.identifier(rootModuleName), extensionRegistrars, sourceFiles, kotlinCompilerConfiguration, projectEnvironment, rootModuleName, extensionRegistrars,
librariesScope, libraryList, isCommonSourceForPsi, fileBelongsToModuleForPsi, librariesScope, libraryList, isCommonSourceForPsi, fileBelongsToModuleForPsi,
createProviderAndScopeForIncrementalCompilation = { files -> createProviderAndScopeForIncrementalCompilation = { files ->
createContextForIncrementalCompilation( createContextForIncrementalCompilation(