[Test] Add ability to specify main class in Box tests

Also slightly refactor some existing services to make them more idiomatic
This commit is contained in:
Dmitriy Novozhilov
2021-10-06 15:03:48 +03:00
committed by TeamCityServer
parent aab8870903
commit a68c4ec7be
9 changed files with 86 additions and 31 deletions
@@ -5,14 +5,15 @@
package org.jetbrains.kotlin.test.services
import org.jetbrains.kotlin.test.model.TestModule
import java.io.File
abstract class RuntimeClasspathProvider {
abstract fun runtimeClassPaths(): List<File>
abstract class RuntimeClasspathProvider(val testServices: TestServices) {
abstract fun runtimeClassPaths(module: TestModule): List<File>
}
class RuntimeClasspathProviderHolder(val providers: List<RuntimeClasspathProvider>) : TestService
class RuntimeClasspathProvidersContainer(val providers: List<RuntimeClasspathProvider>) : TestService
private val TestServices.runtimeClasspathProviderHolder: RuntimeClasspathProviderHolder by TestServices.testServiceAccessor()
private val TestServices.runtimeClasspathProviderContainer: RuntimeClasspathProvidersContainer by TestServices.testServiceAccessor()
val TestServices.runtimeClasspathProviders: List<RuntimeClasspathProvider>
get() = runtimeClasspathProviderHolder.providers
get() = runtimeClasspathProviderContainer.providers
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.test.services
import org.jetbrains.kotlin.fir.utils.ArrayMapAccessor
import org.jetbrains.kotlin.fir.utils.ComponentArrayOwner
import org.jetbrains.kotlin.fir.utils.NullableArrayMapAccessor
import org.jetbrains.kotlin.fir.utils.TypeRegistry
import kotlin.reflect.KClass
@@ -31,6 +32,10 @@ class TestServices : ComponentArrayOwner<TestService, TestService>(){
inline fun <reified T : TestService> testServiceAccessor(): ArrayMapAccessor<TestService, TestService, T> {
return generateAccessor(T::class)
}
inline fun <reified T : TestService> nullableTestServiceAccessor(): NullableArrayMapAccessor<TestService, TestService, T> {
return generateNullableAccessor(T::class)
}
}
fun register(data: ServiceRegistrationData) {