[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] Adding Error Parsers to the Managed Build System (part deux)
|
Hi All,
Sorry to do this, but I still have not
moved the managed build tests over to their new project. So, until I do
that, I need someone to commit these changes to the managed build tests.
Last time, I promise.
Sean Evoy
Rational Software - IBM Software Group
Ottawa, Ontario, Canada
Index: plugin.xml
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/plugin.xml,v
retrieving revision 1.31
diff -u -r1.31 plugin.xml
--- plugin.xml 5 Apr 2004 17:43:15 -0000 1.31
+++ plugin.xml 22 Apr 2004 18:37:11 -0000
@@ -359,6 +359,23 @@
</optionCategory>
</tool>
</target>
+ <target
+ name="Test Error Parsers"
+ id="test.error.parsers"
+ isTest="true"
+ isAbstract="false"
+ errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser"
+ binaryParser="org.eclipse.cdt.core.PE">
+ <tool
+ natureFilter="cnature"
+ sources="x,y"
+ name="EP Tool"
+ outputFlag="-o"
+ outputs="xy"
+ command="EP"
+ id="error.parsers.tool">
+ </tool>
+ </target>
</extension>
<extension
id="runTests"
Index: build/org/eclipse/cdt/core/build/managed/tests/ManagedBuildTests.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/build/org/eclipse/cdt/core/build/managed/tests/ManagedBuildTests.java,v
retrieving revision 1.27
diff -u -r1.27 ManagedBuildTests.java
--- build/org/eclipse/cdt/core/build/managed/tests/ManagedBuildTests.java 11 Apr 2004 22:51:11 -0000 1.27
+++ build/org/eclipse/cdt/core/build/managed/tests/ManagedBuildTests.java 22 Apr 2004 18:37:14 -0000
@@ -69,6 +69,7 @@
private static final String[] listVal = {"_DEBUG", "/usr/include", "libglade.a"};
private static final String newExt = "wen";
private static final String projectName = "ManagedBuildTest";
+ private static final String projectName2 = "ManagedBuildTest2";
private static final String projectRename = "ManagedBuildRedux";
private static final String rootExt = "toor";
private static final String stringVal = "-c -Wall";
@@ -91,6 +92,7 @@
suite.addTest(new ManagedBuildTests("testScannerInfoInterface"));
suite.addTest(new ManagedBuildTests("testBug43450"));
suite.addTest(new ManagedBuildTests("testProjectRename"));
+ suite.addTest(new ManagedBuildTests("testErrorParsers"));
suite.addTest(new ManagedBuildTests("cleanup"));
return suite;
@@ -802,6 +804,9 @@
assertEquals("make", target.getMakeCommand());
assertEquals(expectedParserId, target.getBinaryParserId());
assertTrue(Arrays.equals(expectedOSList, target.getTargetOSList()));
+ // This target defines no errors parsers.
+ assertNull(target.getErrorParserIds());
+ assertTrue(Arrays.equals(target.getErrorParserList(), CCorePlugin.getDefault().getAllErrorParsersIDs()));
// Tools
ITool[] tools = target.getTools();
@@ -1237,6 +1242,7 @@
*/
public void cleanup() {
removeProject(projectName);
+ removeProject(projectName2);
}
/* (non-Javadoc)
@@ -1289,6 +1295,101 @@
assertTrue(false);
}
}
+ }
+ /**
+ * @throws CoreException
+ * @throws BuildException
+ */
+ public void testErrorParsers() throws BuildException {
+ // Create new project
+ IProject project = null;
+ try {
+ project = createProject(projectName2);
+ // Now associate the builder with the project
+ addManagedBuildNature(project);
+ IProjectDescription description = project.getDescription();
+ // Make sure it has a managed nature
+ if (description != null) {
+ assertTrue(description.hasNature(ManagedCProjectNature.MNG_NATURE_ID));
+ }
+
+ } catch (CoreException e) {
+ fail("Test failed on error parser project creation: " + e.getLocalizedMessage());
+ }
+ // There should not be any targets defined for this project yet
+ assertEquals(0, ManagedBuildManager.getTargets(project).length);
+
+ // Find the base target definition
+ ITarget targetDef = ManagedBuildManager.getTarget(project, "test.error.parsers");
+ assertNotNull(targetDef);
+
+ // Create the target for our project that builds a dummy executable
+ ITarget newTarget = ManagedBuildManager.createTarget(project, targetDef);
+ assertEquals(newTarget.getName(), targetDef.getName());
+ assertFalse(newTarget.equals(targetDef));
+ String buildArtifactName = projectName2;
+ newTarget.setArtifactName(buildArtifactName);
+ newTarget.setArtifactExtension(newExt);
+ ITarget[] targets = ManagedBuildManager.getTargets(project);
+ assertEquals(1, targets.length);
+ ITarget target = targets[0];
+ assertEquals(target, newTarget);
+ assertFalse(target.equals(targetDef));
+ checkErrorParsersTarget(target);
+
+ // Save, close, reopen and test again
+ ManagedBuildManager.saveBuildInfo(project, true);
+ try {
+ project.close(null);
+ } catch (CoreException e) {
+ fail("Failed on error parser project close: " + e.getLocalizedMessage());
+ }
+ ManagedBuildManager.removeBuildInfo(project);
+ try {
+ project.open(null);
+ } catch (CoreException e) {
+ fail("Failed on error parser project open: " + e.getLocalizedMessage());
+ }
+
+ // Test that the default config was remembered
+ IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
+
+ // Get the targets
+ targets = ManagedBuildManager.getTargets(project);
+ assertEquals(1, targets.length);
+ // See if the artifact name is remembered
+ assertEquals(targets[0].getArtifactName(), buildArtifactName);
+ // Check the rest of the default information
+ checkErrorParsersTarget(targets[0]);
+ ManagedBuildManager.removeBuildInfo(project);
+ }
+
+ /*
+ * Do a sanity check on the error parsers target.
+ */
+ private void checkErrorParsersTarget(ITarget target) throws BuildException {
+ // Target stuff
+ String expectedBinParserId = "org.eclipse.cdt.core.PE";
+ assertEquals(expectedBinParserId, target.getBinaryParserId());
+ // This target defines errors parsers. Check that the error parsers
+ // have been assigned.
+ assertEquals("org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser", target.getErrorParserIds());
+
+ // Tool
+ ITool[] tools = target.getTools();
+ ITool rootTool = tools[0];
+ assertEquals(1, tools.length);
+ assertEquals("EP Tool", tools[0].getName());
+ assertEquals("-o", tools[0].getOutputFlag());
+ assertTrue(tools[0].buildsFileType("y"));
+ assertTrue(tools[0].buildsFileType("x"));
+ assertTrue(tools[0].producesFileType("xy"));
+ assertEquals("EP", tools[0].getToolCommand());
+ assertEquals(ITool.FILTER_C, rootTool.getNatureFilter());
+
+ // There should be no defined configs
+ IConfiguration[] configs = target.getConfigurations();
+ assertEquals(0, configs.length);
}
/**