[K/N][test] Fix cache mode selection for test targets without cache

Execution of tests without cache support should be restricted. Such runs
should use default cache mode (without).
This commit is contained in:
Pavel Punegov
2023-10-04 13:32:30 +02:00
committed by Space Team
parent cd4c241fa3
commit a72eafc92b
@@ -262,10 +262,11 @@ private object NativeTestSupport {
kotlinNativeTargets: KotlinNativeTargets, kotlinNativeTargets: KotlinNativeTargets,
optimizationMode: OptimizationMode optimizationMode: OptimizationMode
): CacheMode { ): CacheMode {
val defaultCache = CacheMode.defaultForTestTarget(distribution, kotlinNativeTargets)
val cacheMode = ClassLevelProperty.CACHE_MODE.readValue( val cacheMode = ClassLevelProperty.CACHE_MODE.readValue(
enforcedProperties, enforcedProperties,
CacheMode.Alias.values(), CacheMode.Alias.values(),
default = CacheMode.defaultForTestTarget(distribution, kotlinNativeTargets) default = defaultCache
) )
val useStaticCacheForUserLibraries = when (cacheMode) { val useStaticCacheForUserLibraries = when (cacheMode) {
CacheMode.Alias.NO -> return CacheMode.WithoutCache CacheMode.Alias.NO -> return CacheMode.WithoutCache
@@ -275,7 +276,9 @@ private object NativeTestSupport {
} }
val makePerFileCaches = cacheMode == CacheMode.Alias.STATIC_PER_FILE_EVERYWHERE val makePerFileCaches = cacheMode == CacheMode.Alias.STATIC_PER_FILE_EVERYWHERE
return CacheMode.WithStaticCache( return if (defaultCache == CacheMode.Alias.NO)
CacheMode.WithoutCache
else CacheMode.WithStaticCache(
distribution, distribution,
kotlinNativeTargets, kotlinNativeTargets,
optimizationMode, optimizationMode,