[Test] Add service to provide additional classpath to box tests
This commit is contained in:
committed by
teamcityserver
parent
a55eacd8db
commit
707e1c7f8d
+18
@@ -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<File>
|
||||||
|
}
|
||||||
|
|
||||||
|
class RuntimeClasspathProviderHolder(val providers: List<RuntimeClasspathProvider>) : TestService
|
||||||
|
|
||||||
|
private val TestServices.runtimeClasspathProviderHolder: RuntimeClasspathProviderHolder by TestServices.testServiceAccessor()
|
||||||
|
val TestServices.runtimeClasspathProviders: List<RuntimeClasspathProvider>
|
||||||
|
get() = runtimeClasspathProviderHolder.providers
|
||||||
+2
-3
@@ -16,10 +16,8 @@ import org.jetbrains.kotlin.test.directives.CodegenTestDirectives
|
|||||||
import org.jetbrains.kotlin.test.model.BinaryArtifacts
|
import org.jetbrains.kotlin.test.model.BinaryArtifacts
|
||||||
import org.jetbrains.kotlin.test.model.DependencyKind
|
import org.jetbrains.kotlin.test.model.DependencyKind
|
||||||
import org.jetbrains.kotlin.test.model.TestModule
|
import org.jetbrains.kotlin.test.model.TestModule
|
||||||
import org.jetbrains.kotlin.test.services.TestServices
|
import org.jetbrains.kotlin.test.services.*
|
||||||
import org.jetbrains.kotlin.test.services.compilerConfigurationProvider
|
|
||||||
import org.jetbrains.kotlin.test.services.configuration.JvmEnvironmentConfigurator.Companion.TEST_CONFIGURATION_KIND_KEY
|
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.test.services.jvm.compiledClassesManager
|
||||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||||
import org.jetbrains.kotlin.utils.addToStdlib.runIf
|
import org.jetbrains.kotlin.utils.addToStdlib.runIf
|
||||||
@@ -195,6 +193,7 @@ class JvmBoxRunner(testServices: TestServices) : JvmBinaryArtifactHandler(testSe
|
|||||||
}
|
}
|
||||||
|
|
||||||
computeClasspath(rootModule, true)
|
computeClasspath(rootModule, true)
|
||||||
|
testServices.runtimeClasspathProviders.flatMapTo(result) { it.runtimeClassPaths() }
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+6
@@ -46,6 +46,7 @@ class TestConfigurationBuilder {
|
|||||||
private val additionalServices: MutableList<ServiceRegistrationData> = mutableListOf()
|
private val additionalServices: MutableList<ServiceRegistrationData> = mutableListOf()
|
||||||
|
|
||||||
private var compilerConfigurationProvider: ((Disposable, List<EnvironmentConfigurator>) -> CompilerConfigurationProvider)? = null
|
private var compilerConfigurationProvider: ((Disposable, List<EnvironmentConfigurator>) -> CompilerConfigurationProvider)? = null
|
||||||
|
private var runtimeClasspathProviders: MutableList<Constructor<RuntimeClasspathProvider>> = mutableListOf()
|
||||||
|
|
||||||
lateinit var testInfo: KotlinTestInfo
|
lateinit var testInfo: KotlinTestInfo
|
||||||
|
|
||||||
@@ -154,6 +155,10 @@ class TestConfigurationBuilder {
|
|||||||
compilerConfigurationProvider = provider
|
compilerConfigurationProvider = provider
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun useCustomRuntimeClasspathProvider(provider: Constructor<RuntimeClasspathProvider>) {
|
||||||
|
runtimeClasspathProviders += provider
|
||||||
|
}
|
||||||
|
|
||||||
fun useMetaTestConfigurators(vararg configurators: Constructor<MetaTestConfigurator>) {
|
fun useMetaTestConfigurators(vararg configurators: Constructor<MetaTestConfigurator>) {
|
||||||
metaTestConfigurators += configurators
|
metaTestConfigurators += configurators
|
||||||
}
|
}
|
||||||
@@ -199,6 +204,7 @@ class TestConfigurationBuilder {
|
|||||||
metaTestConfigurators,
|
metaTestConfigurators,
|
||||||
afterAnalysisCheckers,
|
afterAnalysisCheckers,
|
||||||
compilerConfigurationProvider,
|
compilerConfigurationProvider,
|
||||||
|
runtimeClasspathProviders,
|
||||||
metaInfoHandlerEnabled,
|
metaInfoHandlerEnabled,
|
||||||
directives,
|
directives,
|
||||||
defaultRegisteredDirectivesBuilder.build(),
|
defaultRegisteredDirectivesBuilder.build(),
|
||||||
|
|||||||
+3
@@ -39,6 +39,7 @@ class TestConfigurationImpl(
|
|||||||
afterAnalysisCheckers: List<Constructor<AfterAnalysisChecker>>,
|
afterAnalysisCheckers: List<Constructor<AfterAnalysisChecker>>,
|
||||||
|
|
||||||
compilerConfigurationProvider: ((Disposable, List<EnvironmentConfigurator>) -> CompilerConfigurationProvider)?,
|
compilerConfigurationProvider: ((Disposable, List<EnvironmentConfigurator>) -> CompilerConfigurationProvider)?,
|
||||||
|
runtimeClasspathProviders: List<Constructor<RuntimeClasspathProvider>>,
|
||||||
|
|
||||||
override val metaInfoHandlerEnabled: Boolean,
|
override val metaInfoHandlerEnabled: Boolean,
|
||||||
|
|
||||||
@@ -51,6 +52,8 @@ class TestConfigurationImpl(
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
testServices.register(KotlinTestInfo::class, testInfo)
|
testServices.register(KotlinTestInfo::class, testInfo)
|
||||||
|
val runtimeClassPathProviders = runtimeClasspathProviders.map { it.invoke(testServices) }
|
||||||
|
testServices.register(RuntimeClasspathProviderHolder::class, RuntimeClasspathProviderHolder(runtimeClassPathProviders))
|
||||||
additionalServices.forEach { testServices.register(it) }
|
additionalServices.forEach { testServices.register(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user