diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/TestExceptionsComparator.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/TestExceptionsComparator.kt index 8d8a7475519..7a0c3cf4471 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/TestExceptionsComparator.kt +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/TestExceptionsComparator.kt @@ -63,14 +63,22 @@ class TestExceptionsComparator(wholeFile: File) { Pattern.compile("""Exception while analyzing expression at \((?\d+),(?\d+)\) in /(?.*?)$""") ) private val ls = System.lineSeparator() + + private const val BYTECODE_ADDRESS = """\d{7}""" + private val bytecodeAddressRegex = Regex(BYTECODE_ADDRESS) + private val bytecodeAddressListRegex = Regex("""Bytecode:\s+($BYTECODE_ADDRESS:\s*([0-9a-f]{4}\s+)+\s+)+""") + + private fun unifyPlatformDependentOfException(exceptionText: String) = + exceptionText.replace(bytecodeAddressListRegex) { bytecodeAddresses -> + bytecodeAddresses.value.replace(bytecodeAddressRegex) { "0x${it.value}" } + } } private val filePathPrefix = "${wholeFile.parent}/${wholeFile.nameWithoutExtension}.$EXCEPTIONS_FILE_PREFIX" private fun analyze(e: Throwable): Matcher? { for ((_, pattern) in exceptionMessagePatterns) { - if (e.message == null) continue - val matches = pattern.matcher(e.message) + val matches = pattern.matcher(e.message ?: continue) if (matches.find()) return matches } @@ -83,7 +91,8 @@ class TestExceptionsComparator(wholeFile: File) { return when (e) { is TestsRuntimeError -> (e.original.cause ?: e.original).run { - casesAsString + toString() + stackTrace[0]?.let { ls + it } + val exceptionText = casesAsString + toString() + stackTrace[0]?.let { ls + it } + unifyPlatformDependentOfException(exceptionText) } is TestsCompilerError, is TestsCompiletimeError, is TestsInfrastructureError -> casesAsString + (e.original.cause ?: e.original).toString() } diff --git a/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/13.exceptions.runtime.txt b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/13.exceptions.runtime.txt index c5ae71cdc47..c6e71711d2c 100644 --- a/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/13.exceptions.runtime.txt +++ b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/13.exceptions.runtime.txt @@ -10,6 +10,6 @@ Exception Details: locals: { uninitializedThis } stack: { uninitializedThis, uninitializedThis } Bytecode: - 0000000: 2a2a c000 02b6 000a b700 0db1 + 0x0000000: 2a2a c000 02b6 000a b700 0db1 Foo.(13.kt) \ No newline at end of file diff --git a/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/16.exceptions.runtime.txt b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/16.exceptions.runtime.txt index 40120d21c3d..7099f46139e 100644 --- a/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/16.exceptions.runtime.txt +++ b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/16.exceptions.runtime.txt @@ -10,6 +10,6 @@ Exception Details: locals: { uninitializedThis } stack: { uninitializedThis, uninitializedThis } Bytecode: - 0000000: 2a2a c000 02b6 000a b700 0db1 + 0x0000000: 2a2a c000 02b6 000a b700 0db1 Foo.(16.kt) \ No newline at end of file diff --git a/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/17.exceptions.runtime.txt b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/17.exceptions.runtime.txt index 18be28f2284..7fe0d2bfc7a 100644 --- a/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/17.exceptions.runtime.txt +++ b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/17.exceptions.runtime.txt @@ -10,6 +10,6 @@ Exception Details: locals: { uninitializedThis } stack: { uninitializedThis, uninitializedThis } Bytecode: - 0000000: 2a2a c000 02b6 000a b700 0db1 + 0x0000000: 2a2a c000 02b6 000a b700 0db1 Foo.(17.kt) \ No newline at end of file diff --git a/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/9.exceptions.runtime.txt b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/9.exceptions.runtime.txt index 7dbd9379770..97b60986bb1 100644 --- a/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/9.exceptions.runtime.txt +++ b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/9.exceptions.runtime.txt @@ -10,6 +10,6 @@ Exception Details: locals: { uninitializedThis } stack: { uninitializedThis, uninitializedThis } Bytecode: - 0000000: 2a2a b700 09b1 + 0x0000000: 2a2a b700 09b1 Foo.(9.kt) \ No newline at end of file