diff --git a/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/services/RuntimeClasspathProvider.kt b/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/services/RuntimeClasspathProvider.kt new file mode 100644 index 00000000000..f477bdf0f0c --- /dev/null +++ b/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/services/RuntimeClasspathProvider.kt @@ -0,0 +1,18 @@ +/* + * 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.services + +import java.io.File + +abstract class RuntimeClasspathProvider { + abstract fun runtimeClassPaths(): List +} + +class RuntimeClasspathProviderHolder(val providers: List) : TestService + +private val TestServices.runtimeClasspathProviderHolder: RuntimeClasspathProviderHolder by TestServices.testServiceAccessor() +val TestServices.runtimeClasspathProviders: List + get() = runtimeClasspathProviderHolder.providers diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/JvmBoxRunner.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/JvmBoxRunner.kt index 71adfcc9a0d..8328472dd0f 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/JvmBoxRunner.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/JvmBoxRunner.kt @@ -16,10 +16,8 @@ import org.jetbrains.kotlin.test.directives.CodegenTestDirectives import org.jetbrains.kotlin.test.model.BinaryArtifacts import org.jetbrains.kotlin.test.model.DependencyKind import org.jetbrains.kotlin.test.model.TestModule -import org.jetbrains.kotlin.test.services.TestServices -import org.jetbrains.kotlin.test.services.compilerConfigurationProvider +import org.jetbrains.kotlin.test.services.* import org.jetbrains.kotlin.test.services.configuration.JvmEnvironmentConfigurator.Companion.TEST_CONFIGURATION_KIND_KEY -import org.jetbrains.kotlin.test.services.dependencyProvider import org.jetbrains.kotlin.test.services.jvm.compiledClassesManager import org.jetbrains.kotlin.utils.addIfNotNull import org.jetbrains.kotlin.utils.addToStdlib.runIf @@ -195,6 +193,7 @@ class JvmBoxRunner(testServices: TestServices) : JvmBinaryArtifactHandler(testSe } computeClasspath(rootModule, true) + testServices.runtimeClasspathProviders.flatMapTo(result) { it.runtimeClassPaths() } return result } diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/builders/TestConfigurationBuilder.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/builders/TestConfigurationBuilder.kt index e158afa4955..a2fbaf1865d 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/builders/TestConfigurationBuilder.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/builders/TestConfigurationBuilder.kt @@ -46,6 +46,7 @@ class TestConfigurationBuilder { private val additionalServices: MutableList = mutableListOf() private var compilerConfigurationProvider: ((Disposable, List) -> CompilerConfigurationProvider)? = null + private var runtimeClasspathProviders: MutableList> = mutableListOf() lateinit var testInfo: KotlinTestInfo @@ -154,6 +155,10 @@ class TestConfigurationBuilder { compilerConfigurationProvider = provider } + fun useCustomRuntimeClasspathProvider(provider: Constructor) { + runtimeClasspathProviders += provider + } + fun useMetaTestConfigurators(vararg configurators: Constructor) { metaTestConfigurators += configurators } @@ -199,6 +204,7 @@ class TestConfigurationBuilder { metaTestConfigurators, afterAnalysisCheckers, compilerConfigurationProvider, + runtimeClasspathProviders, metaInfoHandlerEnabled, directives, defaultRegisteredDirectivesBuilder.build(), diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/impl/TestConfigurationImpl.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/impl/TestConfigurationImpl.kt index ad260d286ea..c1979cdf789 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/impl/TestConfigurationImpl.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/impl/TestConfigurationImpl.kt @@ -39,6 +39,7 @@ class TestConfigurationImpl( afterAnalysisCheckers: List>, compilerConfigurationProvider: ((Disposable, List) -> CompilerConfigurationProvider)?, + runtimeClasspathProviders: List>, override val metaInfoHandlerEnabled: Boolean, @@ -51,6 +52,8 @@ class TestConfigurationImpl( init { testServices.register(KotlinTestInfo::class, testInfo) + val runtimeClassPathProviders = runtimeClasspathProviders.map { it.invoke(testServices) } + testServices.register(RuntimeClasspathProviderHolder::class, RuntimeClasspathProviderHolder(runtimeClassPathProviders)) additionalServices.forEach { testServices.register(it) } }