From d5de3de366605723c9e71b61fa75023bb3caeb1c Mon Sep 17 00:00:00 2001 From: "Gregory.Shrago" Date: Tue, 24 Dec 2013 16:56:46 +0400 Subject: [PATCH] cleanup --- .../testFramework/ParsingTestCase.java | 19 +------------------ .../testFramework/UsefulTestCase.java | 7 ++++++- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/platform/testFramework/src/com/intellij/testFramework/ParsingTestCase.java b/platform/testFramework/src/com/intellij/testFramework/ParsingTestCase.java index 071dd4b3a22b..ed629b9ca353 100644 --- a/platform/testFramework/src/com/intellij/testFramework/ParsingTestCase.java +++ b/platform/testFramework/src/com/intellij/testFramework/ParsingTestCase.java @@ -34,7 +34,6 @@ import com.intellij.openapi.options.SchemesManagerFactory; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.progress.impl.ProgressManagerImpl; import com.intellij.openapi.startup.StartupManager; -import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; @@ -46,7 +45,6 @@ import com.intellij.psi.impl.PsiFileFactoryImpl; import com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistry; import com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistryImpl; import com.intellij.psi.util.CachedValuesManager; -import com.intellij.rt.execution.junit.FileComparisonFailure; import com.intellij.util.CachedValuesManagerImpl; import com.intellij.util.Function; import com.intellij.util.messages.MessageBus; @@ -57,7 +55,6 @@ import org.picocontainer.*; import org.picocontainer.defaults.AbstractComponentAdapter; import java.io.File; -import java.io.FileNotFoundException; import java.io.IOException; import java.util.Set; @@ -272,22 +269,8 @@ public abstract class ParsingTestCase extends PlatformLiteFixture { } public static void doCheckResult(String fullPath, String targetDataName, String text) throws IOException { - text = text.trim(); String expectedFileName = fullPath + File.separatorChar + targetDataName; - if (OVERWRITE_TESTDATA) { - VfsTestUtil.overwriteTestData(expectedFileName, text); - System.out.println("File " + expectedFileName + " created."); - } - try { - String expectedText = doLoadFile(fullPath, targetDataName); - if (!Comparing.equal(expectedText, text)) { - throw new FileComparisonFailure(targetDataName, expectedText, text, expectedFileName); - } - } - catch(FileNotFoundException e){ - VfsTestUtil.overwriteTestData(expectedFileName, text); - fail("No output text found. File " + expectedFileName + " created."); - } + UsefulTestCase.assertSameLinesWithFile(expectedFileName, text); } protected static String toParseTreeText(final PsiElement file, boolean skipSpaces, boolean printRanges) { diff --git a/platform/testFramework/src/com/intellij/testFramework/UsefulTestCase.java b/platform/testFramework/src/com/intellij/testFramework/UsefulTestCase.java index 835a5e2832c7..c665ca388471 100644 --- a/platform/testFramework/src/com/intellij/testFramework/UsefulTestCase.java +++ b/platform/testFramework/src/com/intellij/testFramework/UsefulTestCase.java @@ -58,6 +58,7 @@ import org.jetbrains.annotations.Nullable; import java.awt.*; import java.io.File; +import java.io.FileNotFoundException; import java.io.IOException; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; @@ -681,11 +682,15 @@ public abstract class UsefulTestCase extends TestCase { String fileText; try { if (OVERWRITE_TESTDATA) { - FileUtil.writeToFile(new File(filePath), actualText); + VfsTestUtil.overwriteTestData(filePath, actualText); System.out.println("File " + filePath + " created."); } fileText = FileUtil.loadFile(new File(filePath)); } + catch (FileNotFoundException e) { + VfsTestUtil.overwriteTestData(filePath, actualText); + throw new AssertionFailedError("No output text found. File " + filePath + " created."); + } catch (IOException e) { throw new RuntimeException(e); }