RegExp tests turned on

This commit is contained in:
greg
2008-05-04 20:45:24 +04:00
parent 490ee29ef8
commit 5368df6f6c
4 changed files with 36 additions and 30 deletions
+1
View File
@@ -7,6 +7,7 @@
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
+25 -18
View File
@@ -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<IdeaProjectTestFixture> builder = fixtureFactory.createLightFixtureBuilder();
super.setUp();
final IdeaTestFixtureFactory fixtureFactory = IdeaTestFixtureFactory.getFixtureFactory();
final TestFixtureBuilder<IdeaProjectTestFixture> 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();
}
}
+7 -9
View File
@@ -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<String, Test> myMap = new LinkedHashMap<String, Test>();
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<Element> 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()));
+3 -3
View File
@@ -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");
}