diff --git a/compiler/tests/org/jetbrains/jet/JetLiteFixture.java b/compiler/tests/org/jetbrains/jet/JetLiteFixture.java index 8cd3cf81437..84587ec7b60 100644 --- a/compiler/tests/org/jetbrains/jet/JetLiteFixture.java +++ b/compiler/tests/org/jetbrains/jet/JetLiteFixture.java @@ -14,6 +14,7 @@ import com.intellij.testFramework.LightVirtualFile; import com.intellij.testFramework.TestDataFile; import com.intellij.testFramework.UsefulTestCase; import org.jetbrains.annotations.NonNls; +import org.jetbrains.jet.lang.psi.JetFile; import org.jetbrains.jet.plugin.JetLanguage; import java.io.File; @@ -71,8 +72,16 @@ public abstract class JetLiteFixture extends UsefulTestCase { return text; } - protected PsiFile createPsiFile(String name, String text) { - return createFile(name + ".jet", text); + protected JetFile createPsiFile(String name, String text) { + return (JetFile) createFile(name + ".jet", text); + } + + protected JetFile loadPsiFile(String name) { + try { + return createPsiFile(name, loadFile(name)); + } catch (IOException e) { + throw new RuntimeException(e); + } } protected PsiFile createFile(@NonNls String name, String text) { diff --git a/compiler/tests/org/jetbrains/jet/cfg/JetControlFlowTest.java b/compiler/tests/org/jetbrains/jet/cfg/JetControlFlowTest.java index b9efa562bcf..e7260983306 100644 --- a/compiler/tests/org/jetbrains/jet/cfg/JetControlFlowTest.java +++ b/compiler/tests/org/jetbrains/jet/cfg/JetControlFlowTest.java @@ -8,6 +8,7 @@ import com.intellij.openapi.util.text.StringUtil; import junit.framework.Test; import junit.framework.TestSuite; import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.JetLiteFixture; import org.jetbrains.jet.JetTestCaseBase; import org.jetbrains.jet.lang.cfg.LoopInfo; import org.jetbrains.jet.lang.cfg.pseudocode.*; @@ -20,19 +21,25 @@ import java.io.IOException; import java.io.PrintStream; import java.util.*; -public class JetControlFlowTest extends JetTestCaseBase { +public class JetControlFlowTest extends JetLiteFixture { static { System.setProperty("idea.platform.prefix", "Idea"); } + + private String myName; public JetControlFlowTest(String dataPath, String name) { - super(dataPath, name); + super(dataPath); + myName = name; } - + + protected String getTestFilePath() { + return myFullDataPath + "/" + myName; + } + @Override protected void runTest() throws Throwable { - configureByFile(getTestFilePath()); - JetFile file = (JetFile) getFile(); + JetFile file = loadPsiFile(myName + ".jet"); final Map data = new LinkedHashMap(); final JetPseudocodeTrace pseudocodeTrace = new JetPseudocodeTrace() { @@ -68,14 +75,14 @@ public class JetControlFlowTest extends JetTestCaseBase { }); try { - processCFData(name, data); + processCFData(myName, data); } catch (IOException e) { throw new RuntimeException(e); } finally { if ("true".equals(System.getProperty("jet.control.flow.test.dump.graphs"))) { - dumpDot(name, data.values()); + dumpDot(myName, data.values()); } } } @@ -120,7 +127,7 @@ public class JetControlFlowTest extends JetTestCaseBase { } } - String expectedInstructionsFileName = getTestDataPath() + "/" + getTestFilePath().replace(".jet", ".instructions"); + String expectedInstructionsFileName = getTestFilePath() + ".instructions"; File expectedInstructionsFile = new File(expectedInstructionsFileName); if (!expectedInstructionsFile.exists()) { FileUtil.writeToFile(expectedInstructionsFile, instructionDump.toString()); @@ -352,7 +359,7 @@ public class JetControlFlowTest extends JetTestCaseBase { } private void dumpDot(String name, Collection pseudocodes) throws FileNotFoundException { - String graphFileName = getTestDataPath() + "/" + getTestFilePath().replace(".jet", ".dot"); + String graphFileName = getTestDataPath() + "/" + getTestFilePath() + ".dot"; File target = new File(graphFileName); PrintStream out = new PrintStream(target); @@ -387,7 +394,7 @@ public class JetControlFlowTest extends JetTestCaseBase { public static TestSuite suite() { TestSuite suite = new TestSuite(); - suite.addTest(JetTestCaseBase.suiteForDirectory(getTestDataPathBase(), "/cfg/", true, new JetTestCaseBase.NamedTestFactory() { + suite.addTest(JetTestCaseBase.suiteForDirectory(JetTestCaseBase.getTestDataPathBase(), "/cfg/", true, new JetTestCaseBase.NamedTestFactory() { @NotNull @Override public Test createTest(@NotNull String dataPath, @NotNull String name) {