Fix android tests
This commit is contained in:
+23
-2
@@ -35,6 +35,9 @@ import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||
import org.jetbrains.kotlin.extensions.StorageComponentContainerContributor
|
||||
import org.jetbrains.kotlin.resolve.jvm.extensions.PackageFragmentProviderExtension
|
||||
import org.jetbrains.kotlin.test.testFramework.KtUsefulTestCase
|
||||
import org.jetbrains.kotlin.utils.KotlinPaths
|
||||
import org.jetbrains.kotlin.utils.KotlinPathsFromHomeDir
|
||||
import org.jetbrains.kotlin.utils.PathUtil
|
||||
import java.io.File
|
||||
|
||||
fun KtUsefulTestCase.createTestEnvironment(configuration: CompilerConfiguration, resDirectories: List<String>): KotlinCoreEnvironment {
|
||||
@@ -59,11 +62,29 @@ fun KtUsefulTestCase.createTestEnvironment(configuration: CompilerConfiguration,
|
||||
|
||||
fun addAndroidExtensionsRuntimeLibrary(environment: KotlinCoreEnvironment) {
|
||||
environment.apply {
|
||||
val runtimeLibrary = File("out/production/android-extensions-runtime")
|
||||
val runtimeLibrary = File(computeKotlinPaths().libPath, "android-extensions-compiler.jar")
|
||||
updateClasspath(listOf(JvmClasspathRoot(runtimeLibrary)))
|
||||
}
|
||||
}
|
||||
|
||||
fun getResPaths(path: String): List<String> {
|
||||
return File(path).listFiles { it -> it.name.startsWith("res") && it.isDirectory }!!.map { "$path${it.name}/" }
|
||||
}
|
||||
}
|
||||
|
||||
val KOTLIN_HOME_PROPERTY = "kotlin.home"
|
||||
val KOTLIN_HOME_ENV_VAR = "KOTLIN_HOME"
|
||||
|
||||
private fun computeKotlinPaths(): KotlinPaths {
|
||||
val kotlinHomeProperty = System.getProperty(KOTLIN_HOME_PROPERTY)
|
||||
val kotlinHomeEnvVar = System.getenv(KOTLIN_HOME_ENV_VAR)
|
||||
val kotlinHome = when {
|
||||
kotlinHomeProperty != null -> File(kotlinHomeProperty)
|
||||
kotlinHomeEnvVar != null -> File(kotlinHomeEnvVar)
|
||||
else -> null
|
||||
}
|
||||
return when {
|
||||
kotlinHome == null -> PathUtil.kotlinPathsForCompiler
|
||||
kotlinHome.isDirectory -> KotlinPathsFromHomeDir(kotlinHome)
|
||||
else -> throw RuntimeException("Kotlin home does not exist or is not a directory: " + kotlinHome)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user