[IR][tests] Make ABI compatibility tests less verbose, part 2

This commit is contained in:
Dmitriy Dolovov
2022-08-23 15:00:26 +02:00
parent db1c8cc7a7
commit 24d8ac97cd
24 changed files with 173 additions and 1242 deletions
+7 -38
View File
@@ -1,39 +1,8 @@
fun test1(): String {
return try {
qux(true)
} catch(e: Throwable) {
e.checkLinkageError("function exp_foo can not be called")
}
}
fun test2(): String = qux(false)
fun test3(): String {
return try {
qux2(true)
} catch(e: Throwable) {
e.checkLinkageError("function exp_foo can not be called")
}
}
fun test4(): String = qux2(false)
fun box() = checkResults(test1(), test2(), test3(), test4())
private fun Throwable.checkLinkageError(prefix: String): String {
if (this::class.simpleName != "IrLinkageError") return "Unexpected throwable: ${this::class}"
val expectedMessagePrefix = "$prefix because it uses unlinked symbols"
val actualMessage = message.orEmpty()
return if (actualMessage.startsWith(expectedMessagePrefix))
"OK"
else
"EXPECTED: $expectedMessagePrefix, ACTUAL: $actualMessage"
}
private fun checkResults(vararg results: String): String = when {
results.isEmpty() -> "no results to check"
results.all { it == "OK" } -> "OK"
else -> results.joinToString("\n")
import abitestutils.abiTest
fun box() = abiTest {
expectFailure(prefixed("function exp_foo can not be called")) { qux(true) }
expectSuccess { qux(false) }
expectFailure(prefixed("function exp_foo can not be called")) { qux2(true) }
expectSuccess { qux2(false) }
}