[Native][tests] Don't use non-default runtime assertions mode with cache

^KT-53032
This commit is contained in:
Dmitriy Dolovov
2022-07-19 13:54:26 +02:00
committed by Space
parent d094a2dcaf
commit 8adb0528d7
@@ -36,6 +36,7 @@ internal abstract class BasicCompilation<A : TestCompilationArtifact>(
protected val expectedArtifact: A protected val expectedArtifact: A
) : TestCompilation<A>() { ) : TestCompilation<A>() {
protected abstract val sourceModules: Collection<TestModule> protected abstract val sourceModules: Collection<TestModule>
protected abstract val binaryOptions: Map<String, String>
// Runs the compiler and memorizes the result on property access. // Runs the compiler and memorizes the result on property access.
final override val result: TestCompilationResult<out A> by lazy { final override val result: TestCompilationResult<out A> by lazy {
@@ -52,9 +53,9 @@ internal abstract class BasicCompilation<A : TestCompilationArtifact>(
add( add(
"-enable-assertions", "-enable-assertions",
"-Xskip-prerelease-check", "-Xskip-prerelease-check",
"-Xverify-ir", "-Xverify-ir"
"-Xbinary=runtimeAssertionsMode=panic"
) )
addFlattened(binaryOptions.entries) { (name, value) -> listOf("-Xbinary=$name=$value") }
} }
protected abstract fun applySpecificArgs(argsBuilder: ArgsBuilder) protected abstract fun applySpecificArgs(argsBuilder: ArgsBuilder)
@@ -170,6 +171,8 @@ internal class LibraryCompilation(
dependencies = CategorizedDependencies(dependencies), dependencies = CategorizedDependencies(dependencies),
expectedArtifact = expectedArtifact expectedArtifact = expectedArtifact
) { ) {
override val binaryOptions get() = BinaryOptions.RuntimeAssertionsMode.defaultForTesting
override fun applySpecificArgs(argsBuilder: ArgsBuilder) = with(argsBuilder) { override fun applySpecificArgs(argsBuilder: ArgsBuilder) = with(argsBuilder) {
add( add(
"-produce", "library", "-produce", "library",
@@ -201,6 +204,7 @@ internal class ExecutableCompilation(
expectedArtifact = expectedArtifact expectedArtifact = expectedArtifact
) { ) {
private val cacheMode: CacheMode = settings.get() private val cacheMode: CacheMode = settings.get()
override val binaryOptions = BinaryOptions.RuntimeAssertionsMode.chooseFor(cacheMode)
override fun applySpecificArgs(argsBuilder: ArgsBuilder): Unit = with(argsBuilder) { override fun applySpecificArgs(argsBuilder: ArgsBuilder): Unit = with(argsBuilder) {
add( add(
@@ -281,6 +285,7 @@ internal class StaticCacheCompilation(
} }
override val sourceModules get() = emptyList<TestModule>() override val sourceModules get() = emptyList<TestModule>()
override val binaryOptions get() = BinaryOptions.RuntimeAssertionsMode.forUseWithCache
private val cacheRootDir: File = run { private val cacheRootDir: File = run {
val cacheMode = settings.get<CacheMode>() val cacheMode = settings.get<CacheMode>()
@@ -356,3 +361,13 @@ internal class CategorizedDependencies(uncategorizedDependencies: Iterable<TestC
return mapNotNull { dependency -> if (dependencyTypeMatcher(dependency.type)) dependency.artifact as A else null } return mapNotNull { dependency -> 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<String, String> = mapOf("runtimeAssertionsMode" to "panic")
val forUseWithCache: Map<String, String> = mapOf("runtimeAssertionsMode" to "ignore")
fun chooseFor(cacheMode: CacheMode) = if (cacheMode.staticCacheRootDir != null) forUseWithCache else defaultForTesting
}
}