[Native][tests] Old test infra: fail immediately if static cache not supported for the tested target
This commit is contained in:
@@ -3,7 +3,11 @@ package org.jetbrains.kotlin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.Task
|
||||
import org.gradle.api.tasks.Exec
|
||||
import org.jetbrains.kotlin.konan.properties.resolvablePropertyList
|
||||
import org.jetbrains.kotlin.konan.target.CompilerOutputKind
|
||||
import org.jetbrains.kotlin.konan.target.Distribution
|
||||
import org.jetbrains.kotlin.konan.target.HostManager
|
||||
import org.jetbrains.kotlin.konan.target.KonanTarget
|
||||
import org.jetbrains.kotlin.konan.util.visibleName
|
||||
|
||||
class CacheTesting(val buildCacheTask: Task, val compilerArgs: List<String>, val isDynamic: Boolean)
|
||||
@@ -23,14 +27,27 @@ fun configureCacheTesting(project: Project): CacheTesting? {
|
||||
}
|
||||
|
||||
val target = project.testTarget
|
||||
val dist = project.kotlinNativeDist
|
||||
|
||||
val cacheableTargets = Distribution(dist.absolutePath).properties
|
||||
.resolvablePropertyList("cacheableTargets", HostManager.hostName)
|
||||
.map { KonanTarget.predefinedTargets.getValue(it) }
|
||||
.toSet()
|
||||
|
||||
check(target in cacheableTargets) {
|
||||
"""
|
||||
No cache support for test target $target at host target ${HostManager.host}.
|
||||
$STDLIB_BUILD_CACHE_TASK_NAME Gradle task can't be created.
|
||||
""".trimIndent()
|
||||
|
||||
}
|
||||
|
||||
val cacheDir = project.file("${project.buildDir}/cache")
|
||||
val cacheFile = "$cacheDir/stdlib-cache"
|
||||
val dist = project.kotlinNativeDist
|
||||
val stdlib = "$dist/klib/common/stdlib"
|
||||
val compilerArgs = listOf("-Xcached-library=$stdlib,$cacheFile")
|
||||
|
||||
val buildCacheTask = project.tasks.create("buildStdlibCache", Exec::class.java) {
|
||||
val buildCacheTask = project.tasks.create(STDLIB_BUILD_CACHE_TASK_NAME, Exec::class.java) {
|
||||
doFirst {
|
||||
cacheDir.mkdirs()
|
||||
}
|
||||
@@ -49,4 +66,6 @@ fun configureCacheTesting(project: Project): CacheTesting? {
|
||||
}
|
||||
|
||||
return CacheTesting(buildCacheTask, compilerArgs, isDynamic)
|
||||
}
|
||||
}
|
||||
|
||||
private const val STDLIB_BUILD_CACHE_TASK_NAME = "buildStdlibCache"
|
||||
|
||||
Reference in New Issue
Block a user