mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-01 06:51:17 +07:00
Fix compilation of JUnit4Assertions after change in kotlin repo
Assertions now has one more abstract method. I tried to stop reusing Assertions from kotlin repo, but aparently JUnit4Assertions is used for testing JPS in different environments (see MockLibraryUtilExt) and I won't shave this yak GitOrigin-RevId: 8f9f46281f6bcee6ceae7420c70e91333579c912
This commit is contained in:
committed by
intellij-monorepo-bot
parent
129345e28d
commit
935f4e90df
@@ -8,6 +8,11 @@ import org.junit.Assert
|
||||
import java.io.File
|
||||
|
||||
object JUnit4Assertions : Assertions() {
|
||||
override fun doesEqualToFile(expectedFile: File, actual: String, sanitizer: (String) -> String): Boolean {
|
||||
val expectedPath = expectedFile.toPath()
|
||||
return KotlinTestHelpers.doesEqualsToPath(expectedPath, actual, sanitizer).yes
|
||||
}
|
||||
|
||||
override fun assertEqualsToFile(expectedFile: File, actual: String, sanitizer: (String) -> String, message: () -> String) {
|
||||
val expectedPath = expectedFile.toPath()
|
||||
KotlinTestHelpers.assertEqualsToPath(expectedPath, actual, sanitizer, message)
|
||||
|
||||
+15
-3
@@ -30,7 +30,9 @@ object KotlinTestHelpers {
|
||||
assertEqualsToPath(expectedPath, actual, { it }) { "Expected file content differs from the actual result" }
|
||||
}
|
||||
|
||||
fun assertEqualsToPath(expectedPath: Path, actual: String, sanitizer: (String) -> String, message: () -> String) {
|
||||
data class DoesEqual(val yes: Boolean, val processedExpected: String, val processedActual: String)
|
||||
|
||||
fun doesEqualsToPath(expectedPath: Path, actual: String, sanitizer: (String) -> String): DoesEqual {
|
||||
if (!expectedPath.exists()) {
|
||||
expectedPath.writeText(actual)
|
||||
TestCase.fail("File didn't exist. New file was created (${expectedPath.absolutePathString()}).")
|
||||
@@ -46,8 +48,18 @@ object KotlinTestHelpers {
|
||||
|
||||
val processedExpected = process(expectedPath.readText())
|
||||
val processedActual = process(actual)
|
||||
if (processedExpected != processedActual) {
|
||||
throw FileComparisonFailedError(message(), processedExpected, processedActual, expectedPath.absolutePathString())
|
||||
return DoesEqual(processedExpected == processedActual, processedExpected, processedActual)
|
||||
}
|
||||
|
||||
fun assertEqualsToPath(expectedPath: Path, actual: String, sanitizer: (String) -> String, message: () -> String) {
|
||||
val equalsToPath = doesEqualsToPath(expectedPath, actual, sanitizer)
|
||||
if (!equalsToPath.yes) {
|
||||
throw FileComparisonFailedError(
|
||||
message(),
|
||||
equalsToPath.processedExpected,
|
||||
equalsToPath.processedActual,
|
||||
expectedPath.absolutePathString()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user