diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/TestCompiler.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/TestCompiler.kt index e98c8e8b861..21b50ad96d9 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/TestCompiler.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/TestCompiler.kt @@ -175,9 +175,13 @@ internal sealed interface TestCompilationResult { is DependencyFailures -> fail { describeDependencyFailures() } } - private fun Failure.describeFailure() = when (this) { - is CompilerFailure -> "Compilation failed.\n\n$loggedData" - is UnexpectedFailure -> "Compilation failed with unexpected exception.\n\n$loggedData" + private fun Failure.describeFailure() = buildString { + when (this@describeFailure) { + is CompilerFailure -> appendLine("Compilation failed.") + is UnexpectedFailure -> appendLine("Compilation failed with unexpected exception.") + } + appendLine() + appendLine(loggedData) } private fun DependencyFailures.describeDependencyFailures() = diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/TestRunner.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/TestRunner.kt index 24d3882fac5..e0d4e59869f 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/TestRunner.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/TestRunner.kt @@ -109,8 +109,11 @@ private class TestOutput( private inline fun verifyExpectation(expected: T, actual: T, crossinline errorMessageHeader: () -> String) { assertEquals(expected, actual) { - val loggedTestRun = LoggedData.TestRun(loggedParameters, exitCode, stdOut, stdErr, finishTimeMillis - startTimeMillis) - "${errorMessageHeader()}\n\n$loggedTestRun" + """ + ${errorMessageHeader()} + + ${LoggedData.TestRun(loggedParameters, exitCode, stdOut, stdErr, finishTimeMillis - startTimeMillis)} + """.trimIndent() } } diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/group/TestCaseGroupProvider.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/group/TestCaseGroupProvider.kt index 9bce95baa08..614998a7253 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/group/TestCaseGroupProvider.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/group/TestCaseGroupProvider.kt @@ -67,7 +67,11 @@ internal class StandardTestCaseGroupProvider(private val environment: TestEnviro // Don't register new test module if there is another one with the same name. val testModule = testModules.getOrPut(newTestModule.name) { newTestModule } assertTrue(testModule === newTestModule || testModule.haveSameSymbols(newTestModule)) { - "$location: Two declarations of the same module with different dependencies or friends found:\n$testModule\n$newTestModule" + """ + $location: Two declarations of the same module with different dependencies or friends found: + $testModule + $newTestModule + """.trimIndent() } currentTestModule = testModule @@ -111,7 +115,13 @@ internal class StandardTestCaseGroupProvider(private val environment: TestEnviro directivesParser.convertToRegisteredDirective(rawDirective) } catch (e: AssertionError) { // Enhance error message with concrete test data file and line number where the error has happened. - throw AssertionError("$location: Error while parsing directive in test data file.\nCause: ${e.message}", e) + throw AssertionError( + """ + $location: Error while parsing directive in test data file. + Cause: ${e.message} + """.trimIndent(), + e + ) } if (parsedDirective != null) { @@ -228,8 +238,10 @@ internal class StandardTestCaseGroupProvider(private val environment: TestEnviro && existingPackageName[packageName.length] == '.') ) { val location = Location(testDataFile, existingPackageDeclarationLineNumber) - "$location: Invalid package name declaration found: $existingPackageDeclarationLine\nExpected: package $packageName" - + """ + $location: Invalid package name declaration found: $existingPackageDeclarationLine + Expected: package $packageName + """.trimIndent() } text } else diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/util/Files.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/util/Files.kt index 53a199d253d..3b0f728810b 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/util/Files.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/util/Files.kt @@ -19,7 +19,11 @@ internal fun getAbsoluteFile(localPath: String): File = File(getHomeDirectory()) internal fun computeGeneratedSourcesDir(testDataBaseDir: File, testDataFile: File, generatedSourcesBaseDir: File): File { assertTrue(testDataFile.startsWith(testDataBaseDir)) { - "The file is outside of the directory.\nFile: $testDataFile\nDirectory: $testDataBaseDir" + """ + The file is outside of the directory. + File: $testDataFile + Directory: $testDataBaseDir + """.trimIndent() } val testDataFileDir = testDataFile.parentFile diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/util/PackageNames.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/util/PackageNames.kt index 7dc369668f8..07393003efb 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/util/PackageNames.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/util/PackageNames.kt @@ -15,7 +15,11 @@ import kotlin.math.min internal fun computePackageName(testDataBaseDir: File, testDataFile: File): PackageName { assertTrue(testDataFile.startsWith(testDataBaseDir)) { - "The file is outside of the directory.\nFile: $testDataFile\nDirectory: $testDataBaseDir" + """ + The file is outside of the directory. + File: $testDataFile + Directory: $testDataBaseDir + """.trimIndent() } return testDataFile.parentFile