[Native][tests] Minor. Prefer to use raw string literals for better readability
This commit is contained in:
@@ -175,9 +175,13 @@ internal sealed interface TestCompilationResult {
|
|||||||
is DependencyFailures -> fail { describeDependencyFailures() }
|
is DependencyFailures -> fail { describeDependencyFailures() }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Failure.describeFailure() = when (this) {
|
private fun Failure.describeFailure() = buildString {
|
||||||
is CompilerFailure -> "Compilation failed.\n\n$loggedData"
|
when (this@describeFailure) {
|
||||||
is UnexpectedFailure -> "Compilation failed with unexpected exception.\n\n$loggedData"
|
is CompilerFailure -> appendLine("Compilation failed.")
|
||||||
|
is UnexpectedFailure -> appendLine("Compilation failed with unexpected exception.")
|
||||||
|
}
|
||||||
|
appendLine()
|
||||||
|
appendLine(loggedData)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun DependencyFailures.describeDependencyFailures() =
|
private fun DependencyFailures.describeDependencyFailures() =
|
||||||
|
|||||||
@@ -109,8 +109,11 @@ private class TestOutput(
|
|||||||
|
|
||||||
private inline fun <T> verifyExpectation(expected: T, actual: T, crossinline errorMessageHeader: () -> String) {
|
private inline fun <T> verifyExpectation(expected: T, actual: T, crossinline errorMessageHeader: () -> String) {
|
||||||
assertEquals(expected, actual) {
|
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()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+16
-4
@@ -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.
|
// Don't register new test module if there is another one with the same name.
|
||||||
val testModule = testModules.getOrPut(newTestModule.name) { newTestModule }
|
val testModule = testModules.getOrPut(newTestModule.name) { newTestModule }
|
||||||
assertTrue(testModule === newTestModule || testModule.haveSameSymbols(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
|
currentTestModule = testModule
|
||||||
@@ -111,7 +115,13 @@ internal class StandardTestCaseGroupProvider(private val environment: TestEnviro
|
|||||||
directivesParser.convertToRegisteredDirective(rawDirective)
|
directivesParser.convertToRegisteredDirective(rawDirective)
|
||||||
} catch (e: AssertionError) {
|
} catch (e: AssertionError) {
|
||||||
// Enhance error message with concrete test data file and line number where the error has happened.
|
// 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) {
|
if (parsedDirective != null) {
|
||||||
@@ -228,8 +238,10 @@ internal class StandardTestCaseGroupProvider(private val environment: TestEnviro
|
|||||||
&& existingPackageName[packageName.length] == '.')
|
&& existingPackageName[packageName.length] == '.')
|
||||||
) {
|
) {
|
||||||
val location = Location(testDataFile, existingPackageDeclarationLineNumber)
|
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
|
text
|
||||||
} else
|
} else
|
||||||
|
|||||||
@@ -19,7 +19,11 @@ internal fun getAbsoluteFile(localPath: String): File = File(getHomeDirectory())
|
|||||||
|
|
||||||
internal fun computeGeneratedSourcesDir(testDataBaseDir: File, testDataFile: File, generatedSourcesBaseDir: File): File {
|
internal fun computeGeneratedSourcesDir(testDataBaseDir: File, testDataFile: File, generatedSourcesBaseDir: File): File {
|
||||||
assertTrue(testDataFile.startsWith(testDataBaseDir)) {
|
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
|
val testDataFileDir = testDataFile.parentFile
|
||||||
|
|||||||
+5
-1
@@ -15,7 +15,11 @@ import kotlin.math.min
|
|||||||
|
|
||||||
internal fun computePackageName(testDataBaseDir: File, testDataFile: File): PackageName {
|
internal fun computePackageName(testDataBaseDir: File, testDataFile: File): PackageName {
|
||||||
assertTrue(testDataFile.startsWith(testDataBaseDir)) {
|
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
|
return testDataFile.parentFile
|
||||||
|
|||||||
Reference in New Issue
Block a user