diff --git a/native/native.tests/build.gradle.kts b/native/native.tests/build.gradle.kts index f749b99b26d..8aeaac075a5 100644 --- a/native/native.tests/build.gradle.kts +++ b/native/native.tests/build.gradle.kts @@ -53,7 +53,8 @@ enum class TestProperty(shortName: String) { MEMORY_MODEL("memoryModel"), USE_THREAD_STATE_CHECKER("useThreadStateChecker"), GC_TYPE("gcType"), - USE_CACHE("useCache"), + USE_CACHE("useCache"), // TODO: legacy, need to remove it + CACHE_MODE("cacheMode"), EXECUTION_TIMEOUT("executionTimeout"); private val propertyName = "kotlin.internal.native.test.$shortName" @@ -119,6 +120,7 @@ fun nativeTest(taskName: String, vararg tags: String) = projectTest(taskName, jU TestProperty.USE_THREAD_STATE_CHECKER.setUpFromGradleProperty(this) TestProperty.GC_TYPE.setUpFromGradleProperty(this) TestProperty.USE_CACHE.setUpFromGradleProperty(this) + TestProperty.CACHE_MODE.setUpFromGradleProperty(this) TestProperty.EXECUTION_TIMEOUT.setUpFromGradleProperty(this) ignoreFailures = true // Don't fail Gradle task if there are failed tests. Let the subsequent tasks to run as well. diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/AbstractNativeKlibABITest.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/AbstractNativeKlibABITest.kt index e404f4b9e67..526909216d3 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/AbstractNativeKlibABITest.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/AbstractNativeKlibABITest.kt @@ -14,7 +14,7 @@ import org.jetbrains.kotlin.konan.blackboxtest.support.compilation.TestCompilati import org.jetbrains.kotlin.konan.blackboxtest.support.compilation.TestCompilationDependencyType.Library import org.jetbrains.kotlin.konan.blackboxtest.support.compilation.TestCompilationResult.Companion.assertSuccess import org.jetbrains.kotlin.konan.blackboxtest.support.runner.TestExecutable -import org.jetbrains.kotlin.konan.blackboxtest.support.settings.CacheKind +import org.jetbrains.kotlin.konan.blackboxtest.support.settings.CacheMode import org.jetbrains.kotlin.konan.blackboxtest.support.settings.KotlinNativeHome import org.jetbrains.kotlin.konan.blackboxtest.support.settings.KotlinNativeTargets import org.jetbrains.kotlin.konan.blackboxtest.support.settings.SimpleTestDirectories @@ -139,7 +139,7 @@ abstract class AbstractNativeKlibABITest : AbstractNativeSimpleTest() { private val buildDir: File get() = testRunSettings.get().testBuildDir private val stdlibFile: File get() = testRunSettings.get().stdlibFile - private val staticCacheRequiredForEveryLibrary: Boolean get() = testRunSettings.get().staticCacheRequiredForEveryLibrary + private val staticCacheRequiredForEveryLibrary: Boolean get() = testRunSettings.get().staticCacheRequiredForEveryLibrary companion object { private val COMPILER_ARGS_FOR_KLIB = TestCompilerArgs( diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/support/NativeTestSupport.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/support/NativeTestSupport.kt index 6d319ca8e21..dc2fe06a105 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/support/NativeTestSupport.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/support/NativeTestSupport.kt @@ -13,7 +13,7 @@ import org.jetbrains.kotlin.konan.blackboxtest.support.group.TestCaseGroupProvid import org.jetbrains.kotlin.konan.blackboxtest.support.runner.SimpleTestRunProvider import org.jetbrains.kotlin.konan.blackboxtest.support.runner.TestRunProvider import org.jetbrains.kotlin.konan.blackboxtest.support.settings.* -import org.jetbrains.kotlin.konan.blackboxtest.support.settings.CacheKind +import org.jetbrains.kotlin.konan.blackboxtest.support.settings.CacheMode import org.jetbrains.kotlin.konan.blackboxtest.support.util.* import org.jetbrains.kotlin.konan.target.Distribution import org.jetbrains.kotlin.konan.target.HostManager @@ -109,7 +109,7 @@ private object NativeTestSupport { memoryModel, threadStateChecker, gcType, - CacheKind::class to computeCacheKind(nativeHome, nativeTargets, optimizationMode), + CacheMode::class to computeCacheMode(nativeHome, nativeTargets, optimizationMode), computeBaseDirs(), computeTimeouts() ) @@ -151,28 +151,28 @@ private object NativeTestSupport { private fun computeGCType(): GCType = enumSystemProperty(GC_TYPE, GCType.values(), default = GCType.UNSPECIFIED) - private fun computeCacheKind( + private fun computeCacheMode( kotlinNativeHome: KotlinNativeHome, kotlinNativeTargets: KotlinNativeTargets, optimizationMode: OptimizationMode - ): CacheKind { - // Compatibility stuff (initially, the property was boolean): + ): CacheMode { + // TODO: legacy, need to remove it val legacyUseCache = System.getProperty(USE_CACHE)?.let(String::toBooleanStrictOrNull) if (legacyUseCache != null) { return if (legacyUseCache) - CacheKind.WithStaticCache(kotlinNativeHome, kotlinNativeTargets, optimizationMode, false) + CacheMode.WithStaticCache(kotlinNativeHome, kotlinNativeTargets, optimizationMode, false) else - CacheKind.WithoutCache + CacheMode.WithoutCache } val staticCacheRequiredForEveryLibrary = - when (enumSystemProperty(USE_CACHE, CacheKind.Alias.values(), default = CacheKind.Alias.ONLY_DIST)) { - CacheKind.Alias.NO -> return CacheKind.WithoutCache - CacheKind.Alias.ONLY_DIST -> false - CacheKind.Alias.EVERYWHERE -> true + when (enumSystemProperty(CACHE_MODE, CacheMode.Alias.values(), default = CacheMode.Alias.STATIC_ONLY_DIST)) { + CacheMode.Alias.NO -> return CacheMode.WithoutCache + CacheMode.Alias.STATIC_ONLY_DIST -> false + CacheMode.Alias.STATIC_EVERYWHERE -> true } - return CacheKind.WithStaticCache(kotlinNativeHome, kotlinNativeTargets, optimizationMode, staticCacheRequiredForEveryLibrary) + return CacheMode.WithStaticCache(kotlinNativeHome, kotlinNativeTargets, optimizationMode, staticCacheRequiredForEveryLibrary) } private fun computeBaseDirs(): BaseDirs { @@ -225,7 +225,8 @@ private object NativeTestSupport { private const val MEMORY_MODEL = "kotlin.internal.native.test.memoryModel" private const val USE_THREAD_STATE_CHECKER = "kotlin.internal.native.test.useThreadStateChecker" private const val GC_TYPE = "kotlin.internal.native.test.gcType" - private const val USE_CACHE = "kotlin.internal.native.test.useCache" + private const val USE_CACHE = "kotlin.internal.native.test.useCache" // TODO: legacy, need to remove it + private const val CACHE_MODE = "kotlin.internal.native.test.cacheMode" private const val EXECUTION_TIMEOUT = "kotlin.internal.native.test.executionTimeout" private const val PROJECT_BUILD_DIR = "PROJECT_BUILD_DIR" diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/support/compilation/TestCompilation.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/support/compilation/TestCompilation.kt index 8ae9eb99179..3d94181730c 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/support/compilation/TestCompilation.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/support/compilation/TestCompilation.kt @@ -226,7 +226,7 @@ internal class ExecutableCompilation( dependencies = dependencies, expectedArtifact = expectedArtifact ) { - private val cacheKind: CacheKind = settings.get() + private val cacheMode: CacheMode = settings.get() override fun applySpecificArgs(argsBuilder: ArgsBuilder): Unit = with(argsBuilder) { add( @@ -249,7 +249,7 @@ internal class ExecutableCompilation( override fun applyDependencies(argsBuilder: ArgsBuilder): Unit = with(argsBuilder) { super.applyDependencies(argsBuilder) - cacheKind.staticCacheRootDir?.let { cacheRootDir -> add("-Xcache-directory=$cacheRootDir") } + cacheMode.staticCacheRootDir?.let { cacheRootDir -> add("-Xcache-directory=$cacheRootDir") } add(dependencies.cachedLibraries.uniqueCacheDirs) { libraryCacheDir -> "-Xcache-directory=${libraryCacheDir.path}" } } } @@ -271,8 +271,8 @@ internal class StaticCacheCompilation( override val sourceModules get() = emptyList() private val cacheRootDir: File = run { - val cacheKind = settings.get() - cacheKind.staticCacheRootDir ?: fail { "No cache root directory found for cache kind $cacheKind" } + val cacheMode = settings.get() + cacheMode.staticCacheRootDir ?: fail { "No cache root directory found for cache mode $cacheMode" } } override fun applySpecificArgs(argsBuilder: ArgsBuilder): Unit = with(argsBuilder) { diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/support/compilation/TestCompilationFactory.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/support/compilation/TestCompilationFactory.kt index f1a3a3af179..5be6001f3f3 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/support/compilation/TestCompilationFactory.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/support/compilation/TestCompilationFactory.kt @@ -14,7 +14,7 @@ import org.jetbrains.kotlin.konan.blackboxtest.support.TestModule.Companion.allF import org.jetbrains.kotlin.konan.blackboxtest.support.compilation.TestCompilationArtifact.* import org.jetbrains.kotlin.konan.blackboxtest.support.compilation.TestCompilationDependencyType.* import org.jetbrains.kotlin.konan.blackboxtest.support.settings.Binaries -import org.jetbrains.kotlin.konan.blackboxtest.support.settings.CacheKind +import org.jetbrains.kotlin.konan.blackboxtest.support.settings.CacheMode import org.jetbrains.kotlin.konan.blackboxtest.support.settings.KotlinNativeTargets import org.jetbrains.kotlin.konan.blackboxtest.support.settings.Settings import org.jetbrains.kotlin.konan.blackboxtest.support.util.* @@ -77,7 +77,7 @@ internal class TestCompilationFactory { val dependencies = collectDependencies(sourceModules, freeCompilerArgs, settings) val klibArtifact = KLIB(settings.artifactFileForKlib(sourceModule, freeCompilerArgs)) - val staticCacheArtifact: KLIBStaticCache? = if (settings.get().staticCacheRequiredForEveryLibrary) + val staticCacheArtifact: KLIBStaticCache? = if (settings.get().staticCacheRequiredForEveryLibrary) KLIBStaticCache(cacheDir = klibArtifact.cacheDirForStaticCache(), klib = klibArtifact) else null // No artifact means no static cache should be compiled. diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/support/settings/TestProcessSettings.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/support/settings/TestProcessSettings.kt index c043b82478d..1173c233d80 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/support/settings/TestProcessSettings.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/support/settings/TestProcessSettings.kt @@ -104,13 +104,13 @@ internal class BaseDirs(val testBuildDir: File) internal class Timeouts(val executionTimeout: Duration) /** - * Used cache kind. + * Used cache mode. */ -internal sealed interface CacheKind { +internal sealed interface CacheMode { val staticCacheRootDir: File? val staticCacheRequiredForEveryLibrary: Boolean - object WithoutCache : CacheKind { + object WithoutCache : CacheMode { override val staticCacheRootDir: File? get() = null override val staticCacheRequiredForEveryLibrary get() = false } @@ -120,7 +120,7 @@ internal sealed interface CacheKind { kotlinNativeTargets: KotlinNativeTargets, optimizationMode: OptimizationMode, override val staticCacheRequiredForEveryLibrary: Boolean - ) : CacheKind { + ) : CacheMode { override val staticCacheRootDir: File? = kotlinNativeHome.dir .resolve("klib/cache") .resolve( @@ -136,7 +136,7 @@ internal sealed interface CacheKind { } } - enum class Alias { NO, ONLY_DIST, EVERYWHERE } + enum class Alias { NO, STATIC_ONLY_DIST, STATIC_EVERYWHERE } companion object { private fun computeCacheDirName(testTarget: KonanTarget, cacheKind: String, debuggable: Boolean) =