diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/CachesAutoBuildTest.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/CachesAutoBuildTest.kt index 794a949acca86..54e23380918e0 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/CachesAutoBuildTest.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/CachesAutoBuildTest.kt @@ -82,6 +82,7 @@ class CachesAutoBuildTest : AbstractNativeSimpleTest() { private fun compileToExecutable(sourcesDir: File, autoCacheFrom: File, cacheDirectories: List, vararg dependencies: KLIB) = compileToExecutable( sourcesDir, + tryPassSystemCacheDirectory = false, // With auto-cache mode, the compiler chooses the system cache directory itself. freeCompilerArgs = TestCompilerArgs( listOf( "-Xauto-cache-from=${autoCacheFrom.absolutePath}", diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/NativeSimpleTestUtils.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/NativeSimpleTestUtils.kt index 58f118857c637..82567b12e6568 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/NativeSimpleTestUtils.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/NativeSimpleTestUtils.kt @@ -78,15 +78,30 @@ internal fun AbstractNativeSimpleTest.cinteropToLibrary( internal fun AbstractNativeSimpleTest.compileToExecutable( sourcesDir: File, + tryPassSystemCacheDirectory: Boolean, freeCompilerArgs: TestCompilerArgs, vararg dependencies: TestCompilationArtifact.KLIB ): TestCompilationResult { val testCase: TestCase = generateTestCaseWithSingleModule(sourcesDir, freeCompilerArgs) - return compileToExecutable(testCase, dependencies.map { it.asLibraryDependency() }) + return compileToExecutable(testCase, tryPassSystemCacheDirectory, dependencies.map { it.asLibraryDependency() }) } -internal fun AbstractNativeSimpleTest.compileToExecutable(testCase: TestCase, vararg dependencies: TestCompilationDependency<*>) = - compileToExecutable(testCase, dependencies.asList()) +internal fun AbstractNativeSimpleTest.compileToExecutable( + sourcesDir: File, + freeCompilerArgs: TestCompilerArgs, + vararg dependencies: TestCompilationArtifact.KLIB +) = compileToExecutable(sourcesDir, true, freeCompilerArgs, *dependencies) + +internal fun AbstractNativeSimpleTest.compileToExecutable( + testCase: TestCase, + tryPassSystemCacheDirectory: Boolean, + vararg dependencies: TestCompilationDependency<*> +) = compileToExecutable(testCase, tryPassSystemCacheDirectory, dependencies.asList()) + +internal fun AbstractNativeSimpleTest.compileToExecutable( + testCase: TestCase, + vararg dependencies: TestCompilationDependency<*> +) = compileToExecutable(testCase, true, dependencies.asList()) internal fun AbstractNativeSimpleTest.compileToStaticCache( klib: TestCompilationArtifact.KLIB, @@ -188,6 +203,7 @@ private fun AbstractNativeSimpleTest.compileToLibrary( private fun AbstractNativeSimpleTest.compileToExecutable( testCase: TestCase, + tryPassSystemCacheDirectory: Boolean, dependencies: List> ): TestCompilationResult { val compilation = ExecutableCompilation( @@ -196,7 +212,8 @@ private fun AbstractNativeSimpleTest.compileToExecutable( sourceModules = testCase.modules, extras = testCase.extras, dependencies = dependencies, - expectedArtifact = getExecutableArtifact() + expectedArtifact = getExecutableArtifact(), + tryPassSystemCacheDirectory = tryPassSystemCacheDirectory ) return compilation.result } 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 fc5d4c69f1182..be5f304ca4ad1 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 @@ -269,7 +269,8 @@ internal class ExecutableCompilation( sourceModules: Collection, private val extras: Extras, dependencies: Iterable>, - expectedArtifact: Executable + expectedArtifact: Executable, + val tryPassSystemCacheDirectory: Boolean = true, ) : SourceBasedCompilation( targets = settings.get(), home = settings.get(), @@ -322,7 +323,9 @@ internal class ExecutableCompilation( override fun applyDependencies(argsBuilder: ArgsBuilder): Unit = with(argsBuilder) { super.applyDependencies(argsBuilder) - cacheMode.staticCacheForDistributionLibrariesRootDir?.let { cacheRootDir -> add("-Xcache-directory=$cacheRootDir") } + cacheMode.staticCacheForDistributionLibrariesRootDir + ?.takeIf { tryPassSystemCacheDirectory } + ?.let { cacheRootDir -> add("-Xcache-directory=$cacheRootDir") } add(dependencies.uniqueCacheDirs) { libraryCacheDir -> "-Xcache-directory=${libraryCacheDir.path}" } }