diff --git a/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/project/structure/KtCodeFragmentModuleFactory.kt b/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/project/structure/KtCodeFragmentModuleFactory.kt index 4fc40c86da5..1d28ade6806 100644 --- a/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/project/structure/KtCodeFragmentModuleFactory.kt +++ b/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/project/structure/KtCodeFragmentModuleFactory.kt @@ -32,7 +32,7 @@ object KtCodeFragmentModuleFactory : KtModuleFactory { override fun createModule( testModule: TestModule, contextModule: KtTestModule?, - dependencyPaths: Collection, + dependencyBinaryRoots: Collection, testServices: TestServices, project: Project, ): KtTestModule { diff --git a/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/project/structure/KtLibraryBinaryModuleFactoryBase.kt b/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/project/structure/KtLibraryBinaryModuleFactoryBase.kt index 64e1f11dd67..5f5c2379030 100644 --- a/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/project/structure/KtLibraryBinaryModuleFactoryBase.kt +++ b/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/project/structure/KtLibraryBinaryModuleFactoryBase.kt @@ -23,11 +23,11 @@ abstract class KtLibraryBinaryModuleFactoryBase : KtModuleFactory { override fun createModule( testModule: TestModule, contextModule: KtTestModule?, + dependencyBinaryRoots: Collection, testServices: TestServices, project: Project, - dependencyPaths: Collection, ): KtTestModule { - val binaryRoot = testServices.compiledLibraryProvider.compileToLibrary(testModule).artifact + val binaryRoot = testServices.compiledLibraryProvider.compileToLibrary(testModule, dependencyBinaryRoots).artifact val decompiledFiles = decompileToPsiFiles(binaryRoot, testServices, project) return KtTestModule( diff --git a/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/project/structure/KtLibrarySourceModuleFactory.kt b/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/project/structure/KtLibrarySourceModuleFactory.kt index 0302ab1958a..b310998be84 100644 --- a/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/project/structure/KtLibrarySourceModuleFactory.kt +++ b/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/project/structure/KtLibrarySourceModuleFactory.kt @@ -25,13 +25,13 @@ object KtLibrarySourceModuleFactory : KtModuleFactory { override fun createModule( testModule: TestModule, contextModule: KtTestModule?, - dependencyPaths: Collection, + dependencyBinaryRoots: Collection, testServices: TestServices, project: Project, ): KtTestModule { Assume.assumeFalse("Compilation of multi-platform libraries is not supported", testModule.targetPlatform.isMultiPlatform()) - val (libraryJar, librarySourcesJar) = testServices.compiledLibraryProvider.compileToLibrary(testModule) + val (libraryJar, librarySourcesJar) = testServices.compiledLibraryProvider.compileToLibrary(testModule, dependencyBinaryRoots) require(librarySourcesJar != null) diff --git a/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/project/structure/KtModuleFactory.kt b/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/project/structure/KtModuleFactory.kt index 9bb2ae25818..5ba616c0782 100644 --- a/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/project/structure/KtModuleFactory.kt +++ b/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/project/structure/KtModuleFactory.kt @@ -20,13 +20,13 @@ fun interface KtModuleFactory : TestService { * @param contextModule a module to use as a context module. Some kinds of modules (such as dangling file modules) require a * context module. Modules representing code fragments also require a context element. That is why the [KtTestModule] is passed * instead of a plain [KtModule][org.jetbrains.kotlin.analysis.project.structure.KtModule]. - * @param dependencyPaths The binary roots of [testModule]'s binary library dependencies. This allows avoiding unresolved symbol issues - * when compiling test binary libraries that depend on other test binary libraries. + * @param dependencyBinaryRoots The binary roots of [testModule]'s binary library dependencies. This allows avoiding unresolved symbol + * issues when compiling test binary libraries that depend on other test binary libraries. */ fun createModule( testModule: TestModule, contextModule: KtTestModule?, - dependencyPaths: Collection, + dependencyBinaryRoots: Collection, testServices: TestServices, project: Project, ): KtTestModule diff --git a/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/project/structure/KtScriptModuleFactory.kt b/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/project/structure/KtScriptModuleFactory.kt index 83ec4fdb302..136b34d7ca9 100644 --- a/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/project/structure/KtScriptModuleFactory.kt +++ b/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/project/structure/KtScriptModuleFactory.kt @@ -19,7 +19,7 @@ object KtScriptModuleFactory : KtModuleFactory { override fun createModule( testModule: TestModule, contextModule: KtTestModule?, - dependencyPaths: Collection, + dependencyBinaryRoots: Collection, testServices: TestServices, project: Project, ): KtTestModule { diff --git a/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/project/structure/KtSourceModuleFactory.kt b/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/project/structure/KtSourceModuleFactory.kt index 83b492a3637..ef23812b42e 100644 --- a/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/project/structure/KtSourceModuleFactory.kt +++ b/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/project/structure/KtSourceModuleFactory.kt @@ -19,7 +19,7 @@ object KtSourceModuleFactory : KtModuleFactory { override fun createModule( testModule: TestModule, contextModule: KtTestModule?, - dependencyPaths: Collection, + dependencyBinaryRoots: Collection, testServices: TestServices, project: Project, ): KtTestModule { diff --git a/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/services/libraries/CliTestModuleCompilers.kt b/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/services/libraries/CliTestModuleCompilers.kt index e5d9df499c7..463b183013e 100644 --- a/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/services/libraries/CliTestModuleCompilers.kt +++ b/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/services/libraries/CliTestModuleCompilers.kt @@ -40,15 +40,15 @@ abstract class CliTestModuleCompiler : TestModuleCompiler() { override fun compile( tmpDir: Path, module: TestModule, + dependencyBinaryRoots: Collection, testServices: TestServices, - dependencyPaths: Collection, ): Path = CompilerExecutor.compileLibrary( compilerKind, tmpDir, buildCompilerOptions(module, testServices), compilationErrorExpected = Directives.COMPILATION_ERRORS in module.directives, libraryName = module.name, - extraClasspath = buildExtraClasspath(module, testServices) + dependencyPaths.map { it.pathString }, + extraClasspath = buildExtraClasspath(module, dependencyBinaryRoots, testServices), ) override fun compileTestModuleToLibrarySources(module: TestModule, testServices: TestServices): Path { @@ -65,8 +65,13 @@ abstract class CliTestModuleCompiler : TestModuleCompiler() { return librarySourcesPath } - private fun buildExtraClasspath(module: TestModule, testServices: TestServices): List = buildList { + private fun buildExtraClasspath( + module: TestModule, + dependencyBinaryRoots: Collection, + testServices: TestServices, + ): List = buildList { addAll(buildPlatformExtraClasspath(module, testServices)) + dependencyBinaryRoots.mapTo(this) { it.pathString } } protected open fun buildPlatformExtraClasspath(module: TestModule, testServices: TestServices): List = emptyList() @@ -151,8 +156,8 @@ class DispatchingTestModuleCompiler : TestModuleCompiler() { CompilerExecutor.CompilerKind.JS to JsKlibTestModuleCompiler(), ) - override fun compile(tmpDir: Path, module: TestModule, testServices: TestServices, dependencyPaths: Collection): Path { - return getCompiler(module).compileTestModuleToLibrary(module, testServices, dependencyPaths) + override fun compile(tmpDir: Path, module: TestModule, dependencyBinaryRoots: Collection, testServices: TestServices): Path { + return getCompiler(module).compileTestModuleToLibrary(module, dependencyBinaryRoots, testServices) } override fun compileTestModuleToLibrarySources(module: TestModule, testServices: TestServices): Path { diff --git a/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/services/libraries/CompiledLibraryProvider.kt b/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/services/libraries/CompiledLibraryProvider.kt index dcfe776612d..7e79e737832 100644 --- a/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/services/libraries/CompiledLibraryProvider.kt +++ b/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/services/libraries/CompiledLibraryProvider.kt @@ -13,11 +13,11 @@ import java.nio.file.Path class CompiledLibraryProvider(private val testServices: TestServices) : TestService { private val libraries = mutableMapOf() - fun compileToLibrary(module: TestModule, dependencyPaths: Collection = emptyList()): CompiledLibrary { + fun compileToLibrary(module: TestModule, dependencyBinaryRoots: Collection): CompiledLibrary { if (module.name in libraries) { error("Library for module ${module.name} is already compiled") } - val libraryJar = testServices.testModuleCompiler.compileTestModuleToLibrary(module, testServices, dependencyPaths) + val libraryJar = testServices.testModuleCompiler.compileTestModuleToLibrary(module, dependencyBinaryRoots, testServices) val librarySourcesJar = testServices.testModuleCompiler.compileTestModuleToLibrarySources(module, testServices) return CompiledLibrary(libraryJar, librarySourcesJar).also { libraries[module.name] = it } diff --git a/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/services/libraries/TestModuleCompiler.kt b/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/services/libraries/TestModuleCompiler.kt index 65505d6a9d3..45e2d924f75 100644 --- a/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/services/libraries/TestModuleCompiler.kt +++ b/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/services/libraries/TestModuleCompiler.kt @@ -18,7 +18,7 @@ import kotlin.io.path.div import kotlin.io.path.writeText abstract class TestModuleCompiler : TestService { - fun compileTestModuleToLibrary(module: TestModule, testServices: TestServices, dependencyPaths: Collection = emptyList()): Path { + fun compileTestModuleToLibrary(module: TestModule, dependencyBinaryRoots: Collection, testServices: TestServices): Path { val tmpDir = KtTestUtil.tmpDir("testSourcesToCompile").toPath() for (testFile in module.files) { val text = testServices.sourceFileProvider.getContentOfSourceFile(testFile) @@ -28,14 +28,14 @@ abstract class TestModuleCompiler : TestService { val tmpSourceFile = filePath.createFile() tmpSourceFile.writeText(text) } - return compile(tmpDir, module, testServices, dependencyPaths) + return compile(tmpDir, module, dependencyBinaryRoots, testServices) } abstract fun compile( tmpDir: Path, module: TestModule, + dependencyBinaryRoots: Collection, testServices: TestServices, - dependencyPaths: Collection = emptyList(), ): Path abstract fun compileTestModuleToLibrarySources(module: TestModule, testServices: TestServices): Path? diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/test/configurators/AnalysisApiFirOutOfContentRootTestConfigurator.kt b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/test/configurators/AnalysisApiFirOutOfContentRootTestConfigurator.kt index 3822d6a42b4..fabe9d1101b 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/test/configurators/AnalysisApiFirOutOfContentRootTestConfigurator.kt +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/test/configurators/AnalysisApiFirOutOfContentRootTestConfigurator.kt @@ -68,7 +68,7 @@ private object KtOutOfContentRootModuleFactory : KtModuleFactory { override fun createModule( testModule: TestModule, contextModule: KtTestModule?, - dependencyPaths: Collection, + dependencyBinaryRoots: Collection, testServices: TestServices, project: Project, ): KtTestModule { diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/test/configurators/AnalysisApiFirStdlibSourceTestConfigurator.kt b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/test/configurators/AnalysisApiFirStdlibSourceTestConfigurator.kt index e5e3effae71..1ad2dbd80f4 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/test/configurators/AnalysisApiFirStdlibSourceTestConfigurator.kt +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/test/configurators/AnalysisApiFirStdlibSourceTestConfigurator.kt @@ -29,7 +29,7 @@ private object KtStdlibSourceModuleFactory : KtModuleFactory { override fun createModule( testModule: TestModule, contextModule: KtTestModule?, - dependencyPaths: Collection, + dependencyBinaryRoots: Collection, testServices: TestServices, project: Project, ): KtTestModule {