From 8adb0528d7eec625250e1f37eafe29362ff68af4 Mon Sep 17 00:00:00 2001 From: Dmitriy Dolovov Date: Tue, 19 Jul 2022 13:54:26 +0200 Subject: [PATCH] [Native][tests] Don't use non-default runtime assertions mode with cache ^KT-53032 --- .../support/compilation/TestCompilation.kt | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) 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 ec126f6a227..7d7baca6681 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 @@ -36,6 +36,7 @@ internal abstract class BasicCompilation( protected val expectedArtifact: A ) : TestCompilation() { protected abstract val sourceModules: Collection + protected abstract val binaryOptions: Map // Runs the compiler and memorizes the result on property access. final override val result: TestCompilationResult by lazy { @@ -52,9 +53,9 @@ internal abstract class BasicCompilation( add( "-enable-assertions", "-Xskip-prerelease-check", - "-Xverify-ir", - "-Xbinary=runtimeAssertionsMode=panic" + "-Xverify-ir" ) + addFlattened(binaryOptions.entries) { (name, value) -> listOf("-Xbinary=$name=$value") } } protected abstract fun applySpecificArgs(argsBuilder: ArgsBuilder) @@ -170,6 +171,8 @@ internal class LibraryCompilation( dependencies = CategorizedDependencies(dependencies), expectedArtifact = expectedArtifact ) { + override val binaryOptions get() = BinaryOptions.RuntimeAssertionsMode.defaultForTesting + override fun applySpecificArgs(argsBuilder: ArgsBuilder) = with(argsBuilder) { add( "-produce", "library", @@ -201,6 +204,7 @@ internal class ExecutableCompilation( expectedArtifact = expectedArtifact ) { private val cacheMode: CacheMode = settings.get() + override val binaryOptions = BinaryOptions.RuntimeAssertionsMode.chooseFor(cacheMode) override fun applySpecificArgs(argsBuilder: ArgsBuilder): Unit = with(argsBuilder) { add( @@ -281,6 +285,7 @@ internal class StaticCacheCompilation( } override val sourceModules get() = emptyList() + override val binaryOptions get() = BinaryOptions.RuntimeAssertionsMode.forUseWithCache private val cacheRootDir: File = run { val cacheMode = settings.get() @@ -356,3 +361,13 @@ internal class CategorizedDependencies(uncategorizedDependencies: Iterable if (dependencyTypeMatcher(dependency.type)) dependency.artifact as A else null } } } + +private object BinaryOptions { + object RuntimeAssertionsMode { + // Here the 'default' is in the sense the default for testing, not the default for the compiler. + val defaultForTesting: Map = mapOf("runtimeAssertionsMode" to "panic") + val forUseWithCache: Map = mapOf("runtimeAssertionsMode" to "ignore") + + fun chooseFor(cacheMode: CacheMode) = if (cacheMode.staticCacheRootDir != null) forUseWithCache else defaultForTesting + } +}