diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/configuration/JsEnvironmentConfigurator.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/configuration/JsEnvironmentConfigurator.kt index 6be3be199a6..c8b75ba697f 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/configuration/JsEnvironmentConfigurator.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/configuration/JsEnvironmentConfigurator.kt @@ -13,12 +13,9 @@ import org.jetbrains.kotlin.config.AnalysisFlags.allowFullyQualifiedNameInKClass import org.jetbrains.kotlin.config.CommonConfigurationKeys import org.jetbrains.kotlin.config.CompilerConfiguration import org.jetbrains.kotlin.config.LanguageVersion -import org.jetbrains.kotlin.descriptors.ModuleDescriptor -import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl import org.jetbrains.kotlin.ir.backend.js.transformers.irToJs.TranslationMode import org.jetbrains.kotlin.js.config.* import org.jetbrains.kotlin.js.facade.MainCallParameters -import org.jetbrains.kotlin.library.KotlinLibrary import org.jetbrains.kotlin.platform.js.JsPlatforms import org.jetbrains.kotlin.resolve.CompilerEnvironment import org.jetbrains.kotlin.resolve.TargetEnvironment @@ -37,11 +34,9 @@ import org.jetbrains.kotlin.test.directives.JsEnvironmentConfigurationDirectives import org.jetbrains.kotlin.test.directives.JsEnvironmentConfigurationDirectives.TYPED_ARRAYS import org.jetbrains.kotlin.test.directives.model.DirectivesContainer import org.jetbrains.kotlin.test.directives.model.RegisteredDirectives -import org.jetbrains.kotlin.test.frontend.classic.moduleDescriptorProvider import org.jetbrains.kotlin.test.model.* import org.jetbrains.kotlin.test.services.* import org.jetbrains.kotlin.test.util.joinToArrayString -import org.jetbrains.kotlin.util.capitalizeDecapitalize.decapitalizeAsciiOnly import org.jetbrains.kotlin.utils.KotlinJavascriptMetadataUtils import java.io.File @@ -49,7 +44,7 @@ class JsEnvironmentConfigurator(testServices: TestServices) : EnvironmentConfigu override val directiveContainers: List get() = listOf(JsEnvironmentConfigurationDirectives) - companion object { + companion object : KlibBasedEnvironmentConfiguratorUtils { const val TEST_DATA_DIR_PATH = "js/js.translator/testData" const val OLD_MODULE_SUFFIX = "_old" @@ -63,7 +58,6 @@ class JsEnvironmentConfigurator(testServices: TestServices) : EnvironmentConfigu TranslationMode.PER_FILE_PROD_MINIMIZED_NAMES to "outPfMin" ) - private const val OUTPUT_KLIB_DIR_NAME = "outputKlibDir" private const val MINIFICATION_OUTPUT_DIR_NAME = "minOutputDir" object ExceptionThrowingReporter : JsConfig.Reporter() { @@ -81,12 +75,6 @@ class JsEnvironmentConfigurator(testServices: TestServices) : EnvironmentConfigu } } - fun getJsArtifactSimpleName(testServices: TestServices, moduleName: String): String { - val testName = testServices.testInfo.methodName.removePrefix("test").decapitalizeAsciiOnly() - val outputFileSuffix = if (moduleName == ModuleStructureExtractor.DEFAULT_MODULE_NAME) "" else "-$moduleName" - return testName + outputFileSuffix - } - fun getJsModuleArtifactPath(testServices: TestServices, moduleName: String, translationMode: TranslationMode = TranslationMode.FULL_DEV): String { return getJsArtifactsOutputDir(testServices, translationMode).absolutePath + File.separator + getJsModuleArtifactName(testServices, moduleName) } @@ -96,11 +84,7 @@ class JsEnvironmentConfigurator(testServices: TestServices) : EnvironmentConfigu } fun getJsModuleArtifactName(testServices: TestServices, moduleName: String): String { - return getJsArtifactSimpleName(testServices, moduleName) + "_v5" - } - - fun getJsKlibArtifactPath(testServices: TestServices, moduleName: String): String { - return getJsKlibOutputDir(testServices).absolutePath + File.separator + getJsArtifactSimpleName(testServices, moduleName) + return getKlibArtifactSimpleName(testServices, moduleName) + "_v5" } fun getJsArtifactsOutputDir(testServices: TestServices, translationMode: TranslationMode = TranslationMode.FULL_DEV): File { @@ -111,10 +95,6 @@ class JsEnvironmentConfigurator(testServices: TestServices) : EnvironmentConfigu return testServices.temporaryDirectoryManager.getOrCreateTempDirectory(outputDirByMode[translationMode]!! + "-recompiled") } - fun getJsKlibOutputDir(testServices: TestServices): File { - return testServices.temporaryDirectoryManager.getOrCreateTempDirectory(OUTPUT_KLIB_DIR_NAME) - } - fun getMinificationJsArtifactsOutputDir(testServices: TestServices): File { return testServices.temporaryDirectoryManager.getOrCreateTempDirectory(MINIFICATION_OUTPUT_DIR_NAME) } @@ -182,36 +162,6 @@ class JsEnvironmentConfigurator(testServices: TestServices) : EnvironmentConfigu } } - fun getAllRecursiveDependenciesFor(module: TestModule, testServices: TestServices): Set { - val visited = mutableSetOf() - fun getRecursive(descriptor: ModuleDescriptor) { - descriptor.allDependencyModules.forEach { - if (it is ModuleDescriptorImpl && it !in visited) { - visited += it - getRecursive(it) - } - } - } - - getRecursive(testServices.moduleDescriptorProvider.getModuleDescriptor(module)) - return visited - } - - fun getAllRecursiveLibrariesFor(module: TestModule, testServices: TestServices): Map { - val dependencies = getAllRecursiveDependenciesFor(module, testServices) - return dependencies.associateBy { testServices.libraryProvider.getCompiledLibraryByDescriptor(it) } - } - - fun getAllDependenciesMappingFor(module: TestModule, testServices: TestServices): Map> { - val allRecursiveLibraries: Map = getAllRecursiveLibrariesFor(module, testServices) - val m2l = allRecursiveLibraries.map { it.value to it.key }.toMap() - - return allRecursiveLibraries.keys.associateWith { m -> - val descriptor = allRecursiveLibraries[m] ?: error("No descriptor found for library ${m.libraryName}") - descriptor.allDependencyModules.filter { it != descriptor }.map { m2l.getValue(it) } - } - } - fun TestModule.hasFilesToRecompile(): Boolean { return files.any { JsEnvironmentConfigurationDirectives.RECOMPILE in it.directives } } diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/configuration/KlibBasedEnvironmentConfiguratorUtils.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/configuration/KlibBasedEnvironmentConfiguratorUtils.kt new file mode 100644 index 00000000000..10a635b186f --- /dev/null +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/configuration/KlibBasedEnvironmentConfiguratorUtils.kt @@ -0,0 +1,89 @@ +/* + * Copyright 2010-2024 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.descriptors.impl.ModuleDescriptorImpl +import org.jetbrains.kotlin.library.KotlinLibrary +import org.jetbrains.kotlin.test.frontend.classic.moduleDescriptorProvider +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.* +import org.jetbrains.kotlin.util.capitalizeDecapitalize.decapitalizeAsciiOnly +import java.io.File + +interface KlibBasedEnvironmentConfiguratorUtils { + fun getKlibArtifactSimpleName(testServices: TestServices, moduleName: String): String { + val testName = testServices.testInfo.methodName.removePrefix("test").decapitalizeAsciiOnly() + val outputFileSuffix = if (moduleName == ModuleStructureExtractor.DEFAULT_MODULE_NAME) "" else "-$moduleName" + return testName + outputFileSuffix + } + + fun getKlibArtifactFile(testServices: TestServices, moduleName: String): File { + return getKlibOutputDir(testServices).resolve(getKlibArtifactSimpleName(testServices, moduleName)) + } + + fun getKlibOutputDir(testServices: TestServices): File { + return testServices.temporaryDirectoryManager.getOrCreateTempDirectory(OUTPUT_KLIB_DIR_NAME) + } + + fun getAllRecursiveLibrariesFor(module: TestModule, testServices: TestServices): Map { + val dependencies = getAllRecursiveDependenciesFor(module, testServices) + return dependencies.associateBy { testServices.libraryProvider.getCompiledLibraryByDescriptor(it) } + } + + fun getAllRecursiveDependenciesFor(module: TestModule, testServices: TestServices): Set { + val visited = mutableSetOf() + fun getRecursive(descriptor: ModuleDescriptor) { + descriptor.allDependencyModules.forEach { + if (it is ModuleDescriptorImpl && it !in visited) { + visited += it + getRecursive(it) + } + } + } + + getRecursive(testServices.moduleDescriptorProvider.getModuleDescriptor(module)) + return visited + } + + fun getAllDependenciesMappingFor(module: TestModule, testServices: TestServices): Map> { + val allRecursiveLibraries: Map = getAllRecursiveLibrariesFor(module, testServices) + val m2l = allRecursiveLibraries.map { it.value to it.key }.toMap() + + return allRecursiveLibraries.keys.associateWith { m -> + val descriptor = allRecursiveLibraries[m] ?: error("No descriptor found for library ${m.libraryName}") + descriptor.allDependencyModules.filter { it != descriptor }.map { m2l.getValue(it) } + } + } + + fun getKlibDependencies(module: TestModule, testServices: TestServices, kind: DependencyRelation): List { + val visited = mutableSetOf() + fun getRecursive(module: TestModule, relation: DependencyRelation) { + val dependencies = if (relation == DependencyRelation.FriendDependency) { + module.friendDependencies + } else { + module.regularDependencies + } + dependencies + .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 } + } + + companion object { + private const val OUTPUT_KLIB_DIR_NAME = "outputKlibDir" + } +} diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/configuration/NativeEnvironmentConfigurator.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/configuration/NativeEnvironmentConfigurator.kt index bebf9199817..095ac9b8e04 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/configuration/NativeEnvironmentConfigurator.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/configuration/NativeEnvironmentConfigurator.kt @@ -14,7 +14,7 @@ import org.jetbrains.kotlin.test.services.runtimeClasspathProviders import java.io.File class NativeEnvironmentConfigurator(testServices: TestServices) : EnvironmentConfigurator(testServices) { - companion object { + companion object : KlibBasedEnvironmentConfiguratorUtils { 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?") diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/configuration/WasmEnvironmentConfigurator.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/configuration/WasmEnvironmentConfigurator.kt index 4150ffbbb39..3f454e76124 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/configuration/WasmEnvironmentConfigurator.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/configuration/WasmEnvironmentConfigurator.kt @@ -11,11 +11,9 @@ import org.jetbrains.kotlin.config.CommonConfigurationKeys import org.jetbrains.kotlin.config.CompilerConfiguration import org.jetbrains.kotlin.config.LanguageVersion import org.jetbrains.kotlin.descriptors.ModuleDescriptor -import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl import org.jetbrains.kotlin.js.config.JSConfigurationKeys import org.jetbrains.kotlin.js.config.SourceMapSourceEmbedding import org.jetbrains.kotlin.js.config.WasmTarget -import org.jetbrains.kotlin.library.KotlinLibrary import org.jetbrains.kotlin.serialization.js.ModuleKind import org.jetbrains.kotlin.test.directives.JsEnvironmentConfigurationDirectives.INFER_MAIN_MODULE import org.jetbrains.kotlin.test.directives.JsEnvironmentConfigurationDirectives.PROPERTY_LAZY_INITIALIZATION @@ -24,7 +22,6 @@ import org.jetbrains.kotlin.test.directives.WasmEnvironmentConfigurationDirectiv import org.jetbrains.kotlin.test.directives.WasmEnvironmentConfigurationDirectives.DISABLE_WASM_EXCEPTION_HANDLING import org.jetbrains.kotlin.test.directives.model.DirectivesContainer import org.jetbrains.kotlin.test.directives.model.RegisteredDirectives -import org.jetbrains.kotlin.test.frontend.classic.moduleDescriptorProvider import org.jetbrains.kotlin.test.model.ArtifactKinds import org.jetbrains.kotlin.test.model.DependencyKind import org.jetbrains.kotlin.test.model.DependencyRelation @@ -50,9 +47,7 @@ abstract class WasmEnvironmentConfigurator(testServices: TestServices) : Environ override val directiveContainers: List get() = listOf(WasmEnvironmentConfigurationDirectives) - companion object { - private const val OUTPUT_KLIB_DIR_NAME = "outputKlibDir" - + companion object : KlibBasedEnvironmentConfiguratorUtils { fun getRuntimePathsForModule(target: WasmTarget): List { val suffix = when (target) { WasmTarget.JS -> "-js" @@ -62,75 +57,6 @@ abstract class WasmEnvironmentConfigurator(testServices: TestServices) : Environ return listOf(System.getProperty("kotlin.wasm$suffix.stdlib.path")!!, System.getProperty("kotlin.wasm$suffix.kotlin.test.path")!!) } - fun getKlibDependencies(module: TestModule, testServices: TestServices, kind: DependencyRelation): List { - val visited = mutableSetOf() - fun getRecursive(module: TestModule, relation: DependencyRelation) { - val dependencies = if (relation == DependencyRelation.FriendDependency) { - module.friendDependencies - } else { - module.regularDependencies - } - dependencies - .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 { - return getKlibDependencies(module, testServices, kind) - .map { testServices.libraryProvider.getDescriptorByPath(it.absolutePath) } - } - - - fun getWasmKlibArtifactPath(testServices: TestServices, moduleName: String): String { - return getWasmKlibOutputDir(testServices).absolutePath + File.separator + JsEnvironmentConfigurator.getJsArtifactSimpleName( - testServices, - moduleName - ) - } - - fun getWasmKlibOutputDir(testServices: TestServices): File { - return testServices.temporaryDirectoryManager.getOrCreateTempDirectory(OUTPUT_KLIB_DIR_NAME) - } - - fun getAllRecursiveDependenciesFor(module: TestModule, testServices: TestServices): Set { - val visited = mutableSetOf() - fun getRecursive(descriptor: ModuleDescriptor) { - descriptor.allDependencyModules.forEach { - if (it is ModuleDescriptorImpl && it !in visited) { - visited += it - getRecursive(it) - } - } - } - - getRecursive(testServices.moduleDescriptorProvider.getModuleDescriptor(module)) - return visited - } - - fun getAllRecursiveLibrariesFor(module: TestModule, testServices: TestServices): Map { - val dependencies = getAllRecursiveDependenciesFor(module, testServices) - return dependencies.associateBy { testServices.libraryProvider.getCompiledLibraryByDescriptor(it) } - } - - fun getAllDependenciesMappingFor(module: TestModule, testServices: TestServices): Map> { - val allRecursiveLibraries: Map = - getAllRecursiveLibrariesFor(module, testServices) - val m2l = allRecursiveLibraries.map { it.value to it.key }.toMap() - - return allRecursiveLibraries.keys.associateWith { m -> - val descriptor = allRecursiveLibraries[m] ?: error("No descriptor found for library ${m.libraryName}") - descriptor.allDependencyModules.filter { it != descriptor }.map { m2l.getValue(it) } - } - } - fun getMainModule(testServices: TestServices): TestModule { val modules = testServices.moduleStructure.modules val inferMainModule = INFER_MAIN_MODULE in testServices.moduleStructure.allDirectives diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/converters/FirJsKlibBackendFacade.kt b/js/js.tests/test/org/jetbrains/kotlin/js/test/converters/FirJsKlibBackendFacade.kt index fb9f051349c..b2774d5303a 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/converters/FirJsKlibBackendFacade.kt +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/converters/FirJsKlibBackendFacade.kt @@ -29,7 +29,6 @@ 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.utils.addToStdlib.safeAs -import java.io.File class FirJsKlibBackendFacade( testServices: TestServices, @@ -51,7 +50,7 @@ class FirJsKlibBackendFacade( } val configuration = testServices.compilerConfigurationProvider.getCompilerConfiguration(module) - val outputFile = JsEnvironmentConfigurator.getJsKlibArtifactPath(testServices, module.name) + val outputFile = JsEnvironmentConfigurator.getKlibArtifactFile(testServices, module.name) // TODO: consider avoiding repeated libraries resolution val libraries = resolveLibraries(configuration, getAllJsDependenciesPaths(module, testServices)) @@ -62,7 +61,7 @@ class FirJsKlibBackendFacade( configuration, inputArtifact.diagnosticReporter, inputArtifact.metadataSerializer, - klibPath = outputFile, + klibPath = outputFile.path, libraries.map { it.library }, inputArtifact.irModuleFragment, cleanFiles = inputArtifact.icData, @@ -76,7 +75,7 @@ class FirJsKlibBackendFacade( // TODO: consider avoiding repeated libraries resolution val lib = CommonKLibResolver.resolve( - getAllJsDependenciesPaths(module, testServices) + listOf(outputFile), + getAllJsDependenciesPaths(module, testServices) + listOf(outputFile.path), configuration.getLogger(treatWarningsAsErrors = true) ).getFullResolvedList().last().library @@ -97,8 +96,8 @@ class FirJsKlibBackendFacade( if (JsEnvironmentConfigurator.incrementalEnabled(testServices)) { testServices.jsIrIncrementalDataProvider.recordIncrementalData(module, lib) } - testServices.libraryProvider.setDescriptorAndLibraryByName(outputFile, moduleDescriptor, lib) + testServices.libraryProvider.setDescriptorAndLibraryByName(outputFile.path, moduleDescriptor, lib) - return BinaryArtifacts.KLib(File(outputFile), inputArtifact.diagnosticReporter) + return BinaryArtifacts.KLib(outputFile, inputArtifact.diagnosticReporter) } } diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/converters/JsIrBackendFacade.kt b/js/js.tests/test/org/jetbrains/kotlin/js/test/converters/JsIrBackendFacade.kt index c1c4671bf48..a6079f19fc4 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/converters/JsIrBackendFacade.kt +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/converters/JsIrBackendFacade.kt @@ -42,7 +42,7 @@ import org.jetbrains.kotlin.test.model.* import org.jetbrains.kotlin.test.services.TestServices import org.jetbrains.kotlin.test.services.compilerConfigurationProvider import org.jetbrains.kotlin.test.services.configuration.JsEnvironmentConfigurator -import org.jetbrains.kotlin.test.services.configuration.JsEnvironmentConfigurator.Companion.getJsArtifactSimpleName +import org.jetbrains.kotlin.test.services.configuration.JsEnvironmentConfigurator.Companion.getJsModuleArtifactName import org.jetbrains.kotlin.test.services.configuration.getDependencies import org.jetbrains.kotlin.test.services.libraryProvider import org.jetbrains.kotlin.utils.addToStdlib.ifTrue @@ -127,7 +127,7 @@ class JsIrBackendFacade( val phaseConfig = if (debugMode >= DebugMode.SUPER_DEBUG) { val dumpOutputDir = File( JsEnvironmentConfigurator.getJsArtifactsOutputDir(testServices), - JsEnvironmentConfigurator.getJsArtifactSimpleName(testServices, module.name) + "-irdump" + JsEnvironmentConfigurator.getKlibArtifactSimpleName(testServices, module.name) + "-irdump" ) PhaseConfig( jsPhases, @@ -181,7 +181,7 @@ class JsIrBackendFacade( loweredIr.context, moduleToName = runIf(isEsModules) { loweredIr.allModules.associateWith { - "./${getJsArtifactSimpleName(testServices, it.safeName)}_v5".minifyIfNeed() + "./${getJsModuleArtifactName(testServices, it.safeName)}".minifyIfNeed() } } ?: emptyMap(), shouldReferMainFunction, diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/converters/JsKlibBackendFacade.kt b/js/js.tests/test/org/jetbrains/kotlin/js/test/converters/JsKlibBackendFacade.kt index 65d59ab789b..e8215343b96 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/converters/JsKlibBackendFacade.kt +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/converters/JsKlibBackendFacade.kt @@ -23,7 +23,6 @@ import org.jetbrains.kotlin.test.model.BinaryArtifacts import org.jetbrains.kotlin.test.model.TestModule import org.jetbrains.kotlin.test.services.* import org.jetbrains.kotlin.test.services.configuration.JsEnvironmentConfigurator -import java.io.File class JsKlibBackendFacade( testServices: TestServices, @@ -44,7 +43,7 @@ class JsKlibBackendFacade( } val configuration = testServices.compilerConfigurationProvider.getCompilerConfiguration(module) - val outputFile = JsEnvironmentConfigurator.getJsKlibArtifactPath(testServices, module.name) + val outputFile = JsEnvironmentConfigurator.getKlibArtifactFile(testServices, module.name) if (firstTimeCompilation) { serializeModuleIntoKlib( @@ -52,7 +51,7 @@ class JsKlibBackendFacade( configuration, inputArtifact.diagnosticReporter, inputArtifact.metadataSerializer, - klibPath = outputFile, + klibPath = outputFile.path, JsEnvironmentConfigurator.getAllRecursiveLibrariesFor(module, testServices).keys.toList(), inputArtifact.irModuleFragment, cleanFiles = inputArtifact.icData, @@ -66,7 +65,7 @@ class JsKlibBackendFacade( val dependencies = JsEnvironmentConfigurator.getAllRecursiveDependenciesFor(module, testServices).toList() val lib = CommonKLibResolver.resolve( - dependencies.map { testServices.libraryProvider.getPathByDescriptor(it) } + listOf(outputFile), + dependencies.map { testServices.libraryProvider.getPathByDescriptor(it) } + listOf(outputFile.path), configuration.getLogger(treatWarningsAsErrors = true) ).getFullResolvedList().last().library @@ -84,8 +83,8 @@ class JsKlibBackendFacade( if (JsEnvironmentConfigurator.incrementalEnabled(testServices)) { testServices.jsIrIncrementalDataProvider.recordIncrementalData(module, lib) } - testServices.libraryProvider.setDescriptorAndLibraryByName(outputFile, moduleDescriptor, lib) + testServices.libraryProvider.setDescriptorAndLibraryByName(outputFile.path, moduleDescriptor, lib) - return BinaryArtifacts.KLib(File(outputFile), inputArtifact.diagnosticReporter) + return BinaryArtifacts.KLib(outputFile, inputArtifact.diagnosticReporter) } } diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/utils/JsIrIncrementalDataProvider.kt b/js/js.tests/test/org/jetbrains/kotlin/js/test/utils/JsIrIncrementalDataProvider.kt index 09b3b6930ca..c988ed31d56 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/utils/JsIrIncrementalDataProvider.kt +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/utils/JsIrIncrementalDataProvider.kt @@ -57,8 +57,8 @@ class JsIrIncrementalDataProvider(private val testServices: TestServices) : Test fun getCaches() = icCache.map { it.value.fetchArtifacts() } fun getCacheForModule(module: TestModule): Map { - val path = JsEnvironmentConfigurator.getJsKlibArtifactPath(testServices, module.name) - val canonicalPath = File(path).canonicalPath + val path = JsEnvironmentConfigurator.getKlibArtifactFile(testServices, module.name) + val canonicalPath = path.canonicalPath val moduleCache = icCache[canonicalPath] ?: error("No cache found for $path") val oldBinaryAsts = mutableMapOf() @@ -94,7 +94,7 @@ class JsIrIncrementalDataProvider(private val testServices: TestServices) : Test recordIncrementalDataForRuntimeKlib(module) val dirtyFiles = module.files.map { "/${it.relativePath}" } - val path = JsEnvironmentConfigurator.getJsKlibArtifactPath(testServices, module.name) + val path = JsEnvironmentConfigurator.getKlibArtifactFile(testServices, module.name).path val configuration = testServices.compilerConfigurationProvider.getCompilerConfiguration(module) val mainArguments = JsEnvironmentConfigurator.getMainCallParametersForModule(module) diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/utils/RunnerUtils.kt b/js/js.tests/test/org/jetbrains/kotlin/js/test/utils/RunnerUtils.kt index 9e166590603..fc64786e6ef 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/utils/RunnerUtils.kt +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/utils/RunnerUtils.kt @@ -33,7 +33,7 @@ import java.io.File const val MODULE_EMULATION_FILE = "${JsEnvironmentConfigurator.TEST_DATA_DIR_PATH}/moduleEmulation.js" fun TestModule.getNameFor(filePath: String, testServices: TestServices): String { - return JsEnvironmentConfigurator.getJsArtifactSimpleName(testServices, name) + "-js-" + filePath + return JsEnvironmentConfigurator.getKlibArtifactSimpleName(testServices, name) + "-js-" + filePath } fun TestModule.getNameFor(file: TestFile, testServices: TestServices): String { diff --git a/wasm/wasm.tests/test/org/jetbrains/kotlin/wasm/test/converters/FirWasmKlibBackendFacade.kt b/wasm/wasm.tests/test/org/jetbrains/kotlin/wasm/test/converters/FirWasmKlibBackendFacade.kt index cc37c31f3dc..55d6db97b73 100644 --- a/wasm/wasm.tests/test/org/jetbrains/kotlin/wasm/test/converters/FirWasmKlibBackendFacade.kt +++ b/wasm/wasm.tests/test/org/jetbrains/kotlin/wasm/test/converters/FirWasmKlibBackendFacade.kt @@ -28,7 +28,6 @@ import org.jetbrains.kotlin.test.model.BinaryArtifacts import org.jetbrains.kotlin.test.model.TestModule import org.jetbrains.kotlin.test.services.* import org.jetbrains.kotlin.test.services.configuration.WasmEnvironmentConfigurator -import java.io.File class FirWasmKlibBackendFacade( testServices: TestServices, @@ -50,7 +49,7 @@ class FirWasmKlibBackendFacade( } val configuration = testServices.compilerConfigurationProvider.getCompilerConfiguration(module) - val outputFile = WasmEnvironmentConfigurator.getWasmKlibArtifactPath(testServices, module.name) + val outputFile = WasmEnvironmentConfigurator.getKlibArtifactFile(testServices, module.name) // TODO: consider avoiding repeated libraries resolution val target = configuration.get(JSConfigurationKeys.WASM_TARGET, WasmTarget.JS) @@ -62,7 +61,7 @@ class FirWasmKlibBackendFacade( configuration, inputArtifact.diagnosticReporter, inputArtifact.metadataSerializer, - klibPath = outputFile, + klibPath = outputFile.path, libraries.map { it.library }, inputArtifact.irModuleFragment, cleanFiles = inputArtifact.icData, @@ -76,7 +75,7 @@ class FirWasmKlibBackendFacade( // TODO: consider avoiding repeated libraries resolution val lib = CommonKLibResolver.resolve( - getAllWasmDependenciesPaths(module, testServices, target) + listOf(outputFile), + getAllWasmDependenciesPaths(module, testServices, target) + listOf(outputFile.path), configuration.getLogger(treatWarningsAsErrors = true) ).getFullResolvedList().last().library @@ -94,8 +93,8 @@ class FirWasmKlibBackendFacade( ) testServices.moduleDescriptorProvider.replaceModuleDescriptorForModule(module, moduleDescriptor) - testServices.libraryProvider.setDescriptorAndLibraryByName(outputFile, moduleDescriptor, lib) + testServices.libraryProvider.setDescriptorAndLibraryByName(outputFile.path, moduleDescriptor, lib) - return BinaryArtifacts.KLib(File(outputFile), inputArtifact.diagnosticReporter) + return BinaryArtifacts.KLib(outputFile, inputArtifact.diagnosticReporter) } }