diff --git a/RegExpSupport/RegExpSupport.iml b/RegExpSupport/RegExpSupport.iml index bc6498abeec7..2f2d19b26a7c 100644 --- a/RegExpSupport/RegExpSupport.iml +++ b/RegExpSupport/RegExpSupport.iml @@ -7,6 +7,7 @@ + diff --git a/RegExpSupport/test/test/BaseParseTestcase.java b/RegExpSupport/test/test/BaseParseTestcase.java index bd95a17d53b1..a3f06de1a99d 100644 --- a/RegExpSupport/test/test/BaseParseTestcase.java +++ b/RegExpSupport/test/test/BaseParseTestcase.java @@ -16,6 +16,7 @@ package test; import com.intellij.openapi.application.Result; +import com.intellij.openapi.application.PathManager; import com.intellij.openapi.command.WriteCommandAction; import com.intellij.openapi.fileTypes.FileTypeManager; import com.intellij.openapi.project.Project; @@ -27,36 +28,42 @@ import com.intellij.testFramework.fixtures.TestFixtureBuilder; import junit.framework.TestCase; import org.intellij.lang.regexp.RegExpFileType; -public class BaseParseTestcase extends TestCase { +public abstract class BaseParseTestcase extends TestCase { protected CodeInsightTestFixture myFixture; protected void setUp() throws Exception { - final IdeaTestFixtureFactory fixtureFactory = IdeaTestFixtureFactory.getFixtureFactory(); - final TestFixtureBuilder builder = fixtureFactory.createLightFixtureBuilder(); + super.setUp(); + final IdeaTestFixtureFactory fixtureFactory = IdeaTestFixtureFactory.getFixtureFactory(); + final TestFixtureBuilder builder = fixtureFactory.createLightFixtureBuilder(); - final IdeaProjectTestFixture projectFixture = builder.getFixture(); - projectFixture.setUp(); + final IdeaProjectTestFixture projectFixture = builder.getFixture(); + projectFixture.setUp(); - final CodeInsightTestFixture fixture = fixtureFactory.createCodeInsightFixture(projectFixture); - fixture.setTestDataPath(getTestDataPath()); - fixture.setUp(); + final CodeInsightTestFixture fixture = fixtureFactory.createCodeInsightFixture(projectFixture); + fixture.setTestDataPath(getTestDataPath()); + fixture.setUp(); - final Project project = projectFixture.getProject(); + final Project project = projectFixture.getProject(); - new WriteCommandAction(project) { - protected void run(Result result) throws Throwable { - FileTypeManager.getInstance().registerFileType(RegExpFileType.INSTANCE, new String[]{ "regexp" }); - } - }.execute(); + new WriteCommandAction(project) { + protected void run(Result result) throws Throwable { + FileTypeManager.getInstance().registerFileType(RegExpFileType.INSTANCE, new String[]{"regexp"}); + } + }.execute(); - myFixture = fixture; + myFixture = fixture; } - protected String getTestDataPath() { - return "testData/psi/"; + protected String getTestDataRoot() { + return PathManager.getHomePath() + "/svnPlugins/RegExpSupport/testData"; + } + + protected String getTestDataPath() { + return getTestDataRoot() + "/psi"; } protected void tearDown() throws Exception { - myFixture.tearDown(); + myFixture.tearDown(); + super.tearDown(); } } diff --git a/RegExpSupport/test/test/MainParseTest.java b/RegExpSupport/test/test/MainParseTest.java index 53bc895a786d..3cce31d33d4e 100644 --- a/RegExpSupport/test/test/MainParseTest.java +++ b/RegExpSupport/test/test/MainParseTest.java @@ -16,8 +16,6 @@ package test; import com.intellij.openapi.util.io.FileUtil; -import com.intellij.openapi.application.PathManager; - import org.jdom.Document; import org.jdom.Element; import org.jdom.input.SAXBuilder; @@ -32,7 +30,6 @@ import java.util.regex.PatternSyntaxException; public class MainParseTest extends BaseParseTestcase { - private static final File OUT = new File("testData/psi/gen"); private ByteArrayOutputStream myOut; enum Result { @@ -53,9 +50,9 @@ public class MainParseTest extends BaseParseTestcase { private Map myMap = new LinkedHashMap(); protected void setUp() throws Exception { - final Document document = new SAXBuilder().build(new File(PathManager.getPluginsPath()+"/RegExpSupport/testData/RETest.xml")); + final Document document = new SAXBuilder().build(new File(getTestDataRoot(), "/RETest.xml")); final List list = XPath.selectNodes(document.getRootElement(), "//test"); - OUT.mkdirs(); + new File(getTestDataPath()).mkdirs(); int i = 0; for (Element element : list) { @@ -71,7 +68,7 @@ public class MainParseTest extends BaseParseTestcase { final boolean info = "true".equals(element.getAttributeValue("info")); myMap.put(name, new Test(result, warn, info)); - final File file = new File(OUT, name); + final File file = new File(getTestDataPath(), name); file.getParentFile().mkdirs(); final FileWriter stream = new FileWriter(file); @@ -97,7 +94,7 @@ public class MainParseTest extends BaseParseTestcase { } protected String getTestDataPath() { - return OUT.getPath() + "/"; + return super.getTestDataPath()+"/gen/"; } public void testSimple() throws Exception { @@ -169,7 +166,8 @@ public class MainParseTest extends BaseParseTestcase { myFixture.testHighlighting(test.showWarnings, true, test.showInfo, name); if (test.expectedResult == Result.ERR) { - System.out.println(" FAILED. Expression incorrectly parsed OK: " + FileUtil.loadTextAndClose(new FileReader(new File(OUT, name)))); + System.out.println(" FAILED. Expression incorrectly parsed OK: " + FileUtil.loadTextAndClose(new FileReader(new File( + getTestDataPath(), name)))); failed++; } else { System.out.println(" OK"); @@ -178,7 +176,7 @@ public class MainParseTest extends BaseParseTestcase { if (test.expectedResult == Result.ERR) { System.out.println(" OK"); } else { - System.out.println(" FAILED. Expression = " + FileUtil.loadTextAndClose(new FileReader(new File(OUT, name)))); + System.out.println(" FAILED. Expression = " + FileUtil.loadTextAndClose(new FileReader(new File(getTestDataPath(), name)))); if (myOut.size() > 0) { String line; final BufferedReader reader = new BufferedReader(new StringReader(myOut.toString())); diff --git a/RegExpSupport/test/test/ParseTest.java b/RegExpSupport/test/test/ParseTest.java index 55880e552dba..4ab429ad2d38 100644 --- a/RegExpSupport/test/test/ParseTest.java +++ b/RegExpSupport/test/test/ParseTest.java @@ -17,9 +17,9 @@ package test; public class ParseTest extends BaseParseTestcase { - public void test0() throws Throwable { - myFixture.testHighlighting("test0.regexp"); - } + //public void test0() throws Throwable { + // myFixture.testHighlighting("test0.regexp"); + //} public void test1() throws Throwable { myFixture.testHighlighting("test1.regexp"); }