[FIR Native] KT-58549: Get rid of the builtin provider
According to `FirNativeCodegenBoxTestGenerated.testNestedClassesInAnnotations`, the annotation `kotlin.internal.PlatformDependent` is unresolved reference. ^KT-58549 Fixed
This commit is contained in:
committed by
Space Team
parent
5af4230f46
commit
70605c84df
+7
-7
@@ -12,7 +12,7 @@ import org.jetbrains.kotlin.analyzer.ModuleInfo
|
||||
import org.jetbrains.kotlin.analyzer.common.CommonDependenciesContainer
|
||||
import org.jetbrains.kotlin.analyzer.common.CommonPlatformAnalyzerServices
|
||||
import org.jetbrains.kotlin.analyzer.common.CommonResolverForModuleFactory
|
||||
import org.jetbrains.kotlin.backend.common.CommonJsKLibResolver
|
||||
import org.jetbrains.kotlin.backend.common.CommonKLibResolver
|
||||
import org.jetbrains.kotlin.builtins.DefaultBuiltIns
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.builtins.jvm.JvmBuiltIns
|
||||
@@ -75,7 +75,7 @@ import org.jetbrains.kotlin.test.model.FrontendKinds
|
||||
import org.jetbrains.kotlin.test.model.TestModule
|
||||
import org.jetbrains.kotlin.test.services.*
|
||||
import org.jetbrains.kotlin.test.services.configuration.JsEnvironmentConfigurator
|
||||
import org.jetbrains.kotlin.test.services.configuration.WasmEnvironmentConfigurator
|
||||
import org.jetbrains.kotlin.test.services.configuration.getDependencies
|
||||
import org.jetbrains.kotlin.test.util.KtTestUtil
|
||||
import org.jetbrains.kotlin.types.typeUtil.closure
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.runIf
|
||||
@@ -273,7 +273,7 @@ class ClassicFrontendFacade(
|
||||
}
|
||||
|
||||
private fun loadKlib(names: List<String>, configuration: CompilerConfiguration): List<ModuleDescriptor> {
|
||||
val resolvedLibraries = CommonJsKLibResolver.resolve(
|
||||
val resolvedLibraries = CommonKLibResolver.resolve(
|
||||
names,
|
||||
configuration.resolverLogger
|
||||
).getFullResolvedList()
|
||||
@@ -315,8 +315,8 @@ class ClassicFrontendFacade(
|
||||
): AnalysisResult {
|
||||
val runtimeKlibsNames = JsEnvironmentConfigurator.getRuntimePathsForModule(module, testServices)
|
||||
val runtimeKlibs = loadKlib(runtimeKlibsNames, configuration)
|
||||
val transitiveLibraries = JsEnvironmentConfigurator.getDependencies(module, testServices, DependencyRelation.RegularDependency)
|
||||
val friendLibraries = JsEnvironmentConfigurator.getDependencies(module, testServices, DependencyRelation.FriendDependency)
|
||||
val transitiveLibraries = getDependencies(module, testServices, DependencyRelation.RegularDependency)
|
||||
val friendLibraries = getDependencies(module, testServices, DependencyRelation.FriendDependency)
|
||||
val allDependencies = runtimeKlibs + dependencyDescriptors + friendLibraries + friendsDescriptors + transitiveLibraries
|
||||
|
||||
val analyzer = AnalyzerWithCompilerReport(configuration)
|
||||
@@ -357,8 +357,8 @@ class ClassicFrontendFacade(
|
||||
}
|
||||
|
||||
val runtimeKlibs = loadKlib(runtimeKlibsNames, configuration)
|
||||
val transitiveLibraries = WasmEnvironmentConfigurator.getDependencies(module, testServices, DependencyRelation.RegularDependency)
|
||||
val friendLibraries = WasmEnvironmentConfigurator.getDependencies(module, testServices, DependencyRelation.FriendDependency)
|
||||
val transitiveLibraries = getDependencies(module, testServices, DependencyRelation.RegularDependency)
|
||||
val friendLibraries = getDependencies(module, testServices, DependencyRelation.FriendDependency)
|
||||
val allDependencies = runtimeKlibs + dependencyDescriptors + friendLibraries + friendsDescriptors + transitiveLibraries
|
||||
|
||||
val builtInModuleDescriptor = allDependencies.firstNotNullOfOrNull { it.builtIns }?.builtInsModule
|
||||
|
||||
+1
-1
@@ -167,7 +167,7 @@ fun AbstractFirAnalyzerFacade.convertToJsIr(
|
||||
): Fir2IrResult {
|
||||
this as FirAnalyzerFacade
|
||||
// TODO: consider avoiding repeated libraries resolution
|
||||
val libraries = resolveJsLibraries(module, testServices, configuration)
|
||||
val libraries = resolveLibraries(configuration, getAllJsDependenciesPaths(module, testServices))
|
||||
val (dependencies, builtIns) = loadResolvedLibraries(libraries, configuration.languageVersionSettings, testServices)
|
||||
|
||||
val fir2IrConfiguration = Fir2IrConfiguration(
|
||||
|
||||
+16
-5
@@ -35,6 +35,7 @@ import org.jetbrains.kotlin.fir.session.FirJvmSessionFactory
|
||||
import org.jetbrains.kotlin.fir.session.FirNativeSessionFactory
|
||||
import org.jetbrains.kotlin.fir.session.FirSessionConfigurator
|
||||
import org.jetbrains.kotlin.fir.session.environment.AbstractProjectEnvironment
|
||||
import org.jetbrains.kotlin.test.services.configuration.NativeEnvironmentConfigurator
|
||||
import org.jetbrains.kotlin.load.kotlin.PackageAndMetadataPartProvider
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.platform.TargetPlatform
|
||||
@@ -44,7 +45,6 @@ import org.jetbrains.kotlin.platform.jvm.isJvm
|
||||
import org.jetbrains.kotlin.platform.konan.isNative
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.test.FirParser
|
||||
import org.jetbrains.kotlin.test.TargetBackend
|
||||
import org.jetbrains.kotlin.test.directives.FirDiagnosticsDirectives
|
||||
import org.jetbrains.kotlin.test.directives.model.DirectivesContainer
|
||||
import org.jetbrains.kotlin.test.directives.model.singleValue
|
||||
@@ -54,6 +54,7 @@ import org.jetbrains.kotlin.test.model.FrontendKinds
|
||||
import org.jetbrains.kotlin.test.model.TestModule
|
||||
import org.jetbrains.kotlin.test.runners.lightTreeSyntaxDiagnosticsReporterHolder
|
||||
import org.jetbrains.kotlin.test.services.*
|
||||
import org.jetbrains.kotlin.test.services.configuration.JsEnvironmentConfigurator
|
||||
import java.nio.file.Paths
|
||||
|
||||
open class FirFrontendFacade(
|
||||
@@ -170,13 +171,21 @@ open class FirFrontendFacade(
|
||||
): DependencyListForCliModule {
|
||||
return DependencyListForCliModule.build(binaryModuleData) {
|
||||
when {
|
||||
targetPlatform.isCommon() || targetPlatform.isJvm() || targetPlatform.isNative() -> {
|
||||
targetPlatform.isCommon() || targetPlatform.isJvm() -> {
|
||||
dependencies(configuration.jvmModularRoots.map { it.toPath() })
|
||||
dependencies(configuration.jvmClasspathRoots.map { it.toPath() })
|
||||
friendDependencies(configuration[JVMConfigurationKeys.FRIEND_PATHS] ?: emptyList())
|
||||
}
|
||||
targetPlatform.isJs() -> {
|
||||
val (runtimeKlibsPaths, transitiveLibraries, friendLibraries) = getJsDependencies(mainModule, testServices)
|
||||
val runtimeKlibsPaths = JsEnvironmentConfigurator.getRuntimePathsForModule(mainModule, testServices)
|
||||
val (transitiveLibraries, friendLibraries) = getTransitivesAndFriends(mainModule, testServices)
|
||||
dependencies(runtimeKlibsPaths.map { Paths.get(it).toAbsolutePath() })
|
||||
dependencies(transitiveLibraries.map { it.toPath().toAbsolutePath() })
|
||||
friendDependencies(friendLibraries.map { it.toPath().toAbsolutePath() })
|
||||
}
|
||||
targetPlatform.isNative() -> {
|
||||
val runtimeKlibsPaths = NativeEnvironmentConfigurator.getRuntimePathsForModule(mainModule, testServices)
|
||||
val (transitiveLibraries, friendLibraries) = getTransitivesAndFriends(mainModule, testServices)
|
||||
dependencies(runtimeKlibsPaths.map { Paths.get(it).toAbsolutePath() })
|
||||
dependencies(transitiveLibraries.map { it.toPath().toAbsolutePath() })
|
||||
friendDependencies(friendLibraries.map { it.toPath().toAbsolutePath() })
|
||||
@@ -251,11 +260,13 @@ open class FirFrontendFacade(
|
||||
}
|
||||
module.targetPlatform.isNative() -> {
|
||||
projectEnvironment = null
|
||||
FirNativeSessionFactory.createLibrarySession(
|
||||
TestFirNativeSessionFactory.createLibrarySession(
|
||||
moduleName,
|
||||
listOf(),
|
||||
module,
|
||||
testServices,
|
||||
sessionProvider,
|
||||
moduleDataProvider,
|
||||
configuration,
|
||||
extensionRegistrars,
|
||||
languageVersionSettings,
|
||||
registerExtraComponents = ::registerExtraComponents,
|
||||
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright 2010-2023 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.frontend.fir
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.CommonKLibResolver
|
||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||
import org.jetbrains.kotlin.ir.backend.js.resolverLogger
|
||||
import org.jetbrains.kotlin.library.metadata.resolver.KotlinResolvedLibrary
|
||||
import org.jetbrains.kotlin.test.model.DependencyRelation
|
||||
import org.jetbrains.kotlin.test.model.TestModule
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
import org.jetbrains.kotlin.test.services.configuration.getKlibDependencies
|
||||
import java.io.File
|
||||
|
||||
fun resolveLibraries(configuration: CompilerConfiguration, paths: List<String>): List<KotlinResolvedLibrary> {
|
||||
return CommonKLibResolver.resolve(paths, configuration.resolverLogger).getFullResolvedList()
|
||||
}
|
||||
|
||||
fun getTransitivesAndFriendsPaths(module: TestModule, testServices: TestServices): List<String> {
|
||||
return getTransitivesAndFriends(module, testServices).toList().flatten().map { it.path }
|
||||
}
|
||||
|
||||
fun getTransitivesAndFriends(module: TestModule, testServices: TestServices): Pair<List<File>, List<File>> {
|
||||
val transitiveLibraries = getKlibDependencies(module, testServices, DependencyRelation.RegularDependency)
|
||||
val friendLibraries = getKlibDependencies(module, testServices, DependencyRelation.FriendDependency)
|
||||
return transitiveLibraries to friendLibraries
|
||||
}
|
||||
+3
-29
@@ -5,7 +5,6 @@
|
||||
|
||||
package org.jetbrains.kotlin.test.frontend.fir
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.CommonJsKLibResolver
|
||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.fir.FirModuleData
|
||||
@@ -16,14 +15,10 @@ import org.jetbrains.kotlin.fir.java.FirProjectSessionProvider
|
||||
import org.jetbrains.kotlin.fir.session.FirJsSessionFactory
|
||||
import org.jetbrains.kotlin.fir.session.FirSessionConfigurator
|
||||
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
||||
import org.jetbrains.kotlin.ir.backend.js.resolverLogger
|
||||
import org.jetbrains.kotlin.library.metadata.resolver.KotlinResolvedLibrary
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.test.model.DependencyRelation
|
||||
import org.jetbrains.kotlin.test.model.TestModule
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
import org.jetbrains.kotlin.test.services.configuration.JsEnvironmentConfigurator
|
||||
import java.io.File
|
||||
|
||||
object TestFirJsSessionFactory {
|
||||
fun createLibrarySession(
|
||||
@@ -37,9 +32,7 @@ object TestFirJsSessionFactory {
|
||||
languageVersionSettings: LanguageVersionSettings,
|
||||
registerExtraComponents: ((FirSession) -> Unit),
|
||||
): FirSession {
|
||||
val logger = configuration.resolverLogger
|
||||
val libraries = getAllJsDependenciesPaths(module, testServices)
|
||||
val resolvedLibraries = CommonJsKLibResolver.resolve(libraries, logger).getFullResolvedList()
|
||||
val resolvedLibraries = resolveLibraries(configuration, getAllJsDependenciesPaths(module, testServices))
|
||||
|
||||
return FirJsSessionFactory.createLibrarySession(
|
||||
mainModuleName,
|
||||
@@ -70,24 +63,5 @@ object TestFirJsSessionFactory {
|
||||
)
|
||||
}
|
||||
|
||||
fun resolveJsLibraries(
|
||||
module: TestModule,
|
||||
testServices: TestServices,
|
||||
configuration: CompilerConfiguration
|
||||
): List<KotlinResolvedLibrary> {
|
||||
val paths = getAllJsDependenciesPaths(module, testServices)
|
||||
val logger = configuration.resolverLogger
|
||||
return CommonJsKLibResolver.resolve(paths, logger).getFullResolvedList()
|
||||
}
|
||||
|
||||
fun getAllJsDependenciesPaths(module: TestModule, testServices: TestServices): List<String> {
|
||||
val (runtimeKlibsPaths, transitiveLibraries, friendLibraries) = getJsDependencies(module, testServices)
|
||||
return runtimeKlibsPaths + transitiveLibraries.map { it.path } + friendLibraries.map { it.path }
|
||||
}
|
||||
|
||||
fun getJsDependencies(module: TestModule, testServices: TestServices): Triple<List<String>, List<File>, List<File>> {
|
||||
val runtimeKlibsPaths = JsEnvironmentConfigurator.getRuntimePathsForModule(module, testServices)
|
||||
val transitiveLibraries = JsEnvironmentConfigurator.getKlibDependencies(module, testServices, DependencyRelation.RegularDependency)
|
||||
val friendLibraries = JsEnvironmentConfigurator.getKlibDependencies(module, testServices, DependencyRelation.FriendDependency)
|
||||
return Triple(runtimeKlibsPaths, transitiveLibraries, friendLibraries)
|
||||
}
|
||||
fun getAllJsDependenciesPaths(module: TestModule, testServices: TestServices) =
|
||||
JsEnvironmentConfigurator.getRuntimePathsForModule(module, testServices) + getTransitivesAndFriendsPaths(module, testServices)
|
||||
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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.frontend.fir
|
||||
|
||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.deserialization.ModuleDataProvider
|
||||
import org.jetbrains.kotlin.fir.extensions.FirExtensionRegistrar
|
||||
import org.jetbrains.kotlin.fir.java.FirProjectSessionProvider
|
||||
import org.jetbrains.kotlin.fir.session.FirNativeSessionFactory
|
||||
import org.jetbrains.kotlin.test.services.configuration.NativeEnvironmentConfigurator
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.test.model.TestModule
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
|
||||
object TestFirNativeSessionFactory {
|
||||
fun createLibrarySession(
|
||||
mainModuleName: Name,
|
||||
module: TestModule,
|
||||
testServices: TestServices,
|
||||
sessionProvider: FirProjectSessionProvider,
|
||||
moduleDataProvider: ModuleDataProvider,
|
||||
configuration: CompilerConfiguration,
|
||||
extensionRegistrars: List<FirExtensionRegistrar>,
|
||||
languageVersionSettings: LanguageVersionSettings,
|
||||
registerExtraComponents: (FirSession) -> Unit = {},
|
||||
): FirSession {
|
||||
val resolvedLibraries = resolveLibraries(configuration, getAllNativeDependenciesPaths(module, testServices))
|
||||
|
||||
return FirNativeSessionFactory.createLibrarySession(
|
||||
mainModuleName,
|
||||
resolvedLibraries,
|
||||
sessionProvider,
|
||||
moduleDataProvider,
|
||||
extensionRegistrars,
|
||||
languageVersionSettings,
|
||||
registerExtraComponents,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun getAllNativeDependenciesPaths(module: TestModule, testServices: TestServices) =
|
||||
NativeEnvironmentConfigurator.getRuntimePathsForModule(module, testServices) + getTransitivesAndFriendsPaths(module, testServices)
|
||||
-125
@@ -1,125 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2020 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
|
||||
|
||||
import org.jetbrains.kotlin.platform.konan.NativePlatforms
|
||||
import org.jetbrains.kotlin.test.Constructor
|
||||
import org.jetbrains.kotlin.test.FirParser
|
||||
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
|
||||
import org.jetbrains.kotlin.test.builders.classicFrontendHandlersStep
|
||||
import org.jetbrains.kotlin.test.builders.firHandlersStep
|
||||
import org.jetbrains.kotlin.test.directives.*
|
||||
import org.jetbrains.kotlin.test.frontend.classic.ClassicFrontendFacade
|
||||
import org.jetbrains.kotlin.test.frontend.classic.ClassicFrontendOutputArtifact
|
||||
import org.jetbrains.kotlin.test.frontend.classic.handlers.ClassicDiagnosticsHandler
|
||||
import org.jetbrains.kotlin.test.frontend.classic.handlers.DeclarationsDumpHandler
|
||||
import org.jetbrains.kotlin.test.frontend.classic.handlers.OldNewInferenceMetaInfoProcessor
|
||||
import org.jetbrains.kotlin.test.frontend.fir.FirFrontendFacade
|
||||
import org.jetbrains.kotlin.test.frontend.fir.FirOutputArtifact
|
||||
import org.jetbrains.kotlin.test.frontend.fir.handlers.*
|
||||
import org.jetbrains.kotlin.test.model.*
|
||||
import org.jetbrains.kotlin.test.services.configuration.CommonEnvironmentConfigurator
|
||||
import org.jetbrains.kotlin.test.services.sourceProviders.AdditionalDiagnosticsSourceFilesProvider
|
||||
import org.jetbrains.kotlin.test.services.sourceProviders.CoroutineHelpersSourceFilesProvider
|
||||
|
||||
abstract class AbstractDiagnosticsNativeTestBase<R : ResultingArtifact.FrontendOutput<R>> : AbstractKotlinCompilerTest() {
|
||||
abstract val targetFrontend: FrontendKind<R>
|
||||
abstract val frontend: Constructor<FrontendFacade<R>>
|
||||
abstract fun handlersSetup(builder: TestConfigurationBuilder)
|
||||
|
||||
override fun TestConfigurationBuilder.configuration() {
|
||||
globalDefaults {
|
||||
frontend = targetFrontend
|
||||
targetPlatform = NativePlatforms.unspecifiedNativePlatform
|
||||
dependencyKind = DependencyKind.Source
|
||||
}
|
||||
|
||||
defaultDirectives {
|
||||
+JvmEnvironmentConfigurationDirectives.USE_PSI_CLASS_FILES_READING
|
||||
}
|
||||
|
||||
enableMetaInfoHandler()
|
||||
|
||||
useConfigurators(::CommonEnvironmentConfigurator)
|
||||
|
||||
useMetaInfoProcessors(::OldNewInferenceMetaInfoProcessor)
|
||||
useAdditionalSourceProviders(
|
||||
::AdditionalDiagnosticsSourceFilesProvider,
|
||||
::CoroutineHelpersSourceFilesProvider,
|
||||
)
|
||||
|
||||
facadeStep(frontend)
|
||||
|
||||
handlersSetup(this)
|
||||
|
||||
forTestsMatching("testData/diagnostics/nativeTests/*") {
|
||||
defaultDirectives {
|
||||
+LanguageSettingsDirectives.ALLOW_KOTLIN_PACKAGE
|
||||
+ConfigurationDirectives.WITH_STDLIB
|
||||
}
|
||||
}
|
||||
forTestsMatching("testData/diagnostics/nativeTests/testsWithStdLib/*") {
|
||||
defaultDirectives {
|
||||
+ConfigurationDirectives.WITH_STDLIB
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
abstract class AbstractDiagnosticsNativeTest : AbstractDiagnosticsNativeTestBase<ClassicFrontendOutputArtifact>() {
|
||||
override val targetFrontend: FrontendKind<ClassicFrontendOutputArtifact>
|
||||
get() = FrontendKinds.ClassicFrontend
|
||||
|
||||
override val frontend: Constructor<FrontendFacade<ClassicFrontendOutputArtifact>>
|
||||
get() = ::ClassicFrontendFacade
|
||||
|
||||
override fun handlersSetup(builder: TestConfigurationBuilder) {
|
||||
builder.classicFrontendHandlersStep {
|
||||
useHandlers(
|
||||
::DeclarationsDumpHandler,
|
||||
::ClassicDiagnosticsHandler,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
abstract class AbstractFirNativeDiagnosticsTestBase(val parser: FirParser) : AbstractDiagnosticsNativeTestBase<FirOutputArtifact>() {
|
||||
override val targetFrontend: FrontendKind<FirOutputArtifact>
|
||||
get() = FrontendKinds.FIR
|
||||
|
||||
override val frontend: Constructor<FrontendFacade<FirOutputArtifact>>
|
||||
get() = ::FirFrontendFacade
|
||||
|
||||
override fun handlersSetup(builder: TestConfigurationBuilder) {
|
||||
builder.firHandlersStep {
|
||||
useHandlers(
|
||||
::FirDiagnosticsHandler,
|
||||
::FirDumpHandler,
|
||||
::FirCfgDumpHandler,
|
||||
::FirCfgConsistencyHandler,
|
||||
::FirResolvedTypesVerifier,
|
||||
::FirScopeDumpHandler,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun configure(builder: TestConfigurationBuilder) {
|
||||
super.configure(builder)
|
||||
with(builder) {
|
||||
configureFirParser(parser)
|
||||
enableLazyResolvePhaseChecking()
|
||||
|
||||
forTestsMatching("compiler/testData/diagnostics/*") {
|
||||
configurationForClassicAndFirTestsAlongside()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
abstract class AbstractFirPsiNativeDiagnosticsTest : AbstractFirNativeDiagnosticsTestBase(FirParser.Psi)
|
||||
abstract class AbstractFirLightTreeNativeDiagnosticsTest : AbstractFirNativeDiagnosticsTestBase(FirParser.LightTree)
|
||||
|
||||
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright 2010-2023 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.services.configuration
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.test.model.ArtifactKinds
|
||||
import org.jetbrains.kotlin.test.model.DependencyKind
|
||||
import org.jetbrains.kotlin.test.model.DependencyRelation
|
||||
import org.jetbrains.kotlin.test.model.TestModule
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
import org.jetbrains.kotlin.test.services.dependencyProvider
|
||||
import org.jetbrains.kotlin.test.services.jsLibraryProvider
|
||||
import java.io.File
|
||||
|
||||
fun getKlibDependencies(module: TestModule, testServices: TestServices, kind: DependencyRelation): List<File> {
|
||||
val visited = mutableSetOf<TestModule>()
|
||||
fun getRecursive(module: TestModule, relation: DependencyRelation) {
|
||||
val dependencies = if (relation == DependencyRelation.FriendDependency) {
|
||||
module.friendDependencies
|
||||
} else {
|
||||
module.regularDependencies
|
||||
}
|
||||
dependencies
|
||||
// See: `dependencyKind =` in AbstractJsBlackBoxCodegenTestBase.kt
|
||||
.filter { it.kind != DependencyKind.Source }
|
||||
.map { testServices.dependencyProvider.getTestModule(it.moduleName) }.forEach {
|
||||
if (it !in visited) {
|
||||
visited += it
|
||||
getRecursive(it, relation)
|
||||
}
|
||||
}
|
||||
}
|
||||
getRecursive(module, kind)
|
||||
return visited.map { testServices.dependencyProvider.getArtifact(it, ArtifactKinds.KLib).outputFile }
|
||||
}
|
||||
|
||||
fun getDependencies(module: TestModule, testServices: TestServices, kind: DependencyRelation): List<ModuleDescriptor> {
|
||||
return getKlibDependencies(module, testServices, kind)
|
||||
.map { testServices.jsLibraryProvider.getDescriptorByPath(it.absolutePath) }
|
||||
}
|
||||
-34
@@ -161,33 +161,6 @@ class JsEnvironmentConfigurator(testServices: TestServices) : EnvironmentConfigu
|
||||
return result
|
||||
}
|
||||
|
||||
fun getKlibDependencies(module: TestModule, testServices: TestServices, kind: DependencyRelation): List<File> {
|
||||
val visited = mutableSetOf<TestModule>()
|
||||
fun getRecursive(module: TestModule, relation: DependencyRelation) {
|
||||
val dependencies = if (relation == DependencyRelation.FriendDependency) {
|
||||
module.friendDependencies
|
||||
} else {
|
||||
module.regularDependencies
|
||||
}
|
||||
dependencies
|
||||
// See: `dependencyKind =` in AbstractJsBlackBoxCodegenTestBase.kt
|
||||
.filter { it.kind != DependencyKind.Source }
|
||||
.map { testServices.dependencyProvider.getTestModule(it.moduleName) }.forEach {
|
||||
if (it !in visited) {
|
||||
visited += it
|
||||
getRecursive(it, relation)
|
||||
}
|
||||
}
|
||||
}
|
||||
getRecursive(module, kind)
|
||||
return visited.map { testServices.dependencyProvider.getArtifact(it, ArtifactKinds.KLib).outputFile }
|
||||
}
|
||||
|
||||
fun getDependencies(module: TestModule, testServices: TestServices, kind: DependencyRelation): List<ModuleDescriptor> {
|
||||
return getKlibDependencies(module, testServices, kind)
|
||||
.map { testServices.jsLibraryProvider.getDescriptorByPath(it.absolutePath) }
|
||||
}
|
||||
|
||||
fun getMainCallParametersForModule(module: TestModule): MainCallParameters {
|
||||
return when (JsEnvironmentConfigurationDirectives.CALL_MAIN) {
|
||||
in module.directives -> MainCallParameters.mainWithArguments(listOf())
|
||||
@@ -235,13 +208,6 @@ class JsEnvironmentConfigurator(testServices: TestServices) : EnvironmentConfigu
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun TestModule.allTransitiveDependencies(): Set<DependencyDescription> {
|
||||
val modules = testServices.moduleStructure.modules
|
||||
return regularDependencies.toSet() +
|
||||
regularDependencies.flatMap { modules.single { module -> module.name == it.moduleName }.allTransitiveDependencies() }
|
||||
}
|
||||
|
||||
override fun provideAdditionalAnalysisFlags(
|
||||
directives: RegisteredDirectives,
|
||||
languageVersion: LanguageVersion
|
||||
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2010-2023 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.services.configuration
|
||||
|
||||
import org.jetbrains.kotlin.test.directives.ConfigurationDirectives
|
||||
import org.jetbrains.kotlin.test.model.TestModule
|
||||
import org.jetbrains.kotlin.test.services.EnvironmentConfigurator
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
import org.jetbrains.kotlin.test.services.runtimeClasspathProviders
|
||||
import java.io.File
|
||||
|
||||
class NativeEnvironmentConfigurator(testServices: TestServices) : EnvironmentConfigurator(testServices) {
|
||||
companion object {
|
||||
private val nativeHome
|
||||
get() = System.getProperty("kotlin.internal.native.test.nativeHome")
|
||||
?: error("No nativeHome provided. Are you sure the test are executed within :native:native.tests?")
|
||||
|
||||
fun getRuntimePathsForModule(module: TestModule, testServices: TestServices): List<String> {
|
||||
val result = mutableListOf<String>()
|
||||
|
||||
if (ConfigurationDirectives.WITH_STDLIB in module.directives) {
|
||||
result += File("$nativeHome/klib/common/stdlib").absolutePath
|
||||
}
|
||||
|
||||
testServices.runtimeClasspathProviders
|
||||
.flatMap { it.runtimeClassPaths(module) }
|
||||
.mapTo(result) { it.absolutePath }
|
||||
|
||||
return result
|
||||
}
|
||||
}
|
||||
}
|
||||
-31
@@ -34,37 +34,6 @@ class WasmEnvironmentConfigurator(testServices: TestServices) : EnvironmentConfi
|
||||
override val directiveContainers: List<DirectivesContainer>
|
||||
get() = listOf(JsEnvironmentConfigurationDirectives)
|
||||
|
||||
companion object {
|
||||
private fun getKlibDependencies(module: TestModule, testServices: TestServices, kind: DependencyRelation): List<File> {
|
||||
val visited = mutableSetOf<TestModule>()
|
||||
fun getRecursive(module: TestModule, relation: DependencyRelation) {
|
||||
val dependencies = if (relation == DependencyRelation.FriendDependency) {
|
||||
module.friendDependencies
|
||||
} else {
|
||||
module.regularDependencies
|
||||
}
|
||||
dependencies
|
||||
// See: `dependencyKind =` in AbstractJsBlackBoxCodegenTestBase.kt
|
||||
.filter { it.kind != DependencyKind.Source }
|
||||
.map { testServices.dependencyProvider.getTestModule(it.moduleName) }.forEach {
|
||||
if (it !in visited) {
|
||||
visited += it
|
||||
getRecursive(it, relation)
|
||||
}
|
||||
}
|
||||
}
|
||||
getRecursive(module, kind)
|
||||
return visited.map { testServices.dependencyProvider.getArtifact(it, ArtifactKinds.KLib).outputFile }
|
||||
}
|
||||
|
||||
fun getDependencies(module: TestModule, testServices: TestServices, kind: DependencyRelation): List<ModuleDescriptor> {
|
||||
return getKlibDependencies(module, testServices, kind)
|
||||
.map { testServices.jsLibraryProvider.getDescriptorByPath(it.absolutePath) }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
override fun provideAdditionalAnalysisFlags(
|
||||
directives: RegisteredDirectives,
|
||||
languageVersion: LanguageVersion
|
||||
|
||||
Reference in New Issue
Block a user