diff options
Diffstat (limited to 'core')
3 files changed, 56 insertions, 2 deletions
diff --git a/core/src/test/java/com/intellij/rt/execution/junit/FileComparisonFailure.java b/core/src/test/java/com/intellij/rt/execution/junit/FileComparisonFailure.java new file mode 100644 index 00000000..cbb1cc3c --- /dev/null +++ b/core/src/test/java/com/intellij/rt/execution/junit/FileComparisonFailure.java @@ -0,0 +1,39 @@ + +package com.intellij.rt.execution.junit; + +import junit.framework.ComparisonFailure; + +public class FileComparisonFailure extends ComparisonFailure implements KnownException { + private final String myExpected; + private final String myActual; + private final String myFilePath; + private final String myActualFilePath; + + public FileComparisonFailure(String message, String expected, String actual, String filePath) { + this(message, expected, actual, filePath, (String)null); + } + + public FileComparisonFailure(String message, String expected, String actual, String expectedFilePath, String actualFilePath) { + super(message, expected, actual); + this.myExpected = expected; + this.myActual = actual; + this.myFilePath = expectedFilePath; + this.myActualFilePath = actualFilePath; + } + + public String getFilePath() { + return this.myFilePath; + } + + public String getActualFilePath() { + return this.myActualFilePath; + } + + public String getExpected() { + return this.myExpected; + } + + public String getActual() { + return this.myActual; + } +} diff --git a/core/src/test/java/com/intellij/rt/execution/junit/KnownException.java b/core/src/test/java/com/intellij/rt/execution/junit/KnownException.java new file mode 100644 index 00000000..c24653ea --- /dev/null +++ b/core/src/test/java/com/intellij/rt/execution/junit/KnownException.java @@ -0,0 +1,6 @@ + +package com.intellij.rt.execution.junit; + +interface KnownException { + +} diff --git a/core/src/test/kotlin/TestAPI.kt b/core/src/test/kotlin/TestAPI.kt index 19eb29d5..ee452be3 100644 --- a/core/src/test/kotlin/TestAPI.kt +++ b/core/src/test/kotlin/TestAPI.kt @@ -4,6 +4,7 @@ import com.google.inject.Guice import com.intellij.openapi.application.PathManager import com.intellij.openapi.util.Disposer import com.intellij.openapi.util.io.FileUtil +import com.intellij.rt.execution.junit.FileComparisonFailure import org.jetbrains.dokka.* import org.jetbrains.dokka.Utilities.DokkaAnalysisModule import org.jetbrains.kotlin.cli.common.messages.CompilerMessageLocation @@ -162,8 +163,8 @@ fun verifyModelOutput(it: DocumentationModule, val output = StringBuilder() outputGenerator(it, output) val ext = outputExtension.removePrefix(".") - val expectedOutput = File(sourcePath.replaceAfterLast(".", ext, sourcePath + "." + ext)).readText() - assertEqualsIgnoringSeparators(expectedOutput, output.toString()) + val expectedFile = File(sourcePath.replaceAfterLast(".", ext, sourcePath + "." + ext)) + assertEqualsIgnoringSeparators(expectedFile, output.toString()) } fun verifyOutput(path: String, @@ -184,6 +185,14 @@ fun verifyJavaOutput(path: String, } } +fun assertEqualsIgnoringSeparators(expectedFile: File, output: String) { + val expectedText = expectedFile.readText().replace("\r\n", "\n") + val actualText = output.replace("\r\n", "\n") + + if(expectedText != actualText) + throw FileComparisonFailure("", expectedText, actualText, expectedFile.canonicalPath) +} + fun assertEqualsIgnoringSeparators(expectedOutput: String, output: String) { Assert.assertEquals(expectedOutput.replace("\r\n", "\n"), output.replace("\r\n", "\n")) } |