[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] Updates to the Managed Build Test
|
Hi All,
Just another set of updates to the managed
build test suite. Soon, this will all be a bad memory for you poor committers
who have to indulge me this way :-)
Sean Evoy
Rational Software - IBM Software Group
Ottawa, Ontario, Canada
Index: plugin.xml
===================================================================
retrieving revision 1.26
diff -u -r1.26 plugin.xml
--- plugin.xml 16 Mar 2004 22:29:55 -0000 1.26
+++ plugin.xml 18 Mar 2004 21:26:45 -0000
@@ -33,12 +33,12 @@
point="org.eclipse.cdt.managedbuilder.core.ManagedBuildInfo">
<tool
natureFilter="both"
- sources="rc"
name="Target Independent Tool"
+ sources="rc"
headerExtensions="h"
outputFlag="/fo"
- outputs="free"
command="RC.EXE"
+ outputs="free"
id="target.independent.tool">
<optionCategory
owner="target.independent.tool"
@@ -49,8 +49,8 @@
defaultValue="Live free or die"
name="String in Free"
category="indy.cat.free"
- id="org.eclipse.cdt.core.tests.option1"
- valueType="string">
+ valueType="string"
+ id="org.eclipse.cdt.core.tests.option1">
</option>
<optionCategory
owner="indy.cat.free"
@@ -61,8 +61,8 @@
defaultValue="false"
name="Boolean in Chained"
category="indy.cat.chained"
- id="org.eclipse.cdt.core.tests.option2"
- valueType="boolean">
+ valueType="boolean"
+ id="org.eclipse.cdt.core.tests.option2">
</option>
</tool>
<target
@@ -73,17 +73,17 @@
defaultExtension="toor"
isAbstract="false"
makeCommand="make"
- makeFlags="-k"
binaryParser="org.eclipse.cdt.core.PE"
+ makeFlags="-k"
osList="win32">
<tool
natureFilter="cnature"
- name="Root Tool"
sources="foo,bar"
+ name="Root Tool"
headerExtensions="baz"
outputFlag="-r"
- command="doIt"
outputs="toor"
+ command="doIt"
id="root.tool">
<optionCategory
owner="root.tool"
@@ -93,39 +93,39 @@
<option
name="List Option in Top"
command="-L"
- id="list.option"
- valueType="stringList">
+ valueType="stringList"
+ id="list.option">
<listOptionValue
value="a">
</listOptionValue>
<listOptionValue
- builtIn="false"
- value="b">
+ value="b"
+ builtIn="false">
</listOptionValue>
<listOptionValue
- builtIn="true"
- value="c">
+ value="c"
+ builtIn="true">
</listOptionValue>
</option>
<option
defaultValue="false"
name="Boolean Option in Top"
command="-b"
- id="boolean.option"
- valueType="boolean">
+ valueType="boolean"
+ id="boolean.option">
</option>
<option
defaultValue="x"
name="String Option in Category"
category="category"
- id="string.option"
- valueType="string">
+ valueType="string"
+ id="string.option">
</option>
<option
name="Enumerated Option in Category"
category="category"
- id="enumerated.option"
- valueType="enumerated">
+ valueType="enumerated"
+ id="enumerated.option">
<enumeratedOptionValue
name="Default Enum"
isDefault="true"
@@ -198,17 +198,17 @@
</configuration>
<tool
natureFilter="both"
- name="Sub Tool"
sources="yarf"
+ name="Sub Tool"
headerExtensions="arf,barf"
- outputPrefix="lib"
outputs="bus"
+ outputPrefix="lib"
id="tool.sub">
<option
name="Include Paths"
command="-I"
- id="sub.tool.opt.inc.paths"
- valueType="includePath">
+ valueType="includePath"
+ id="sub.tool.opt.inc.paths">
<listOptionValue
value="/usr/include">
</listOptionValue>
@@ -216,45 +216,45 @@
value="/opt/gnome/include">
</listOptionValue>
<listOptionValue
- builtIn="true"
- value="/usr/gnu/include">
+ value="/usr/gnu/include"
+ builtIn="true">
</listOptionValue>
</option>
<option
name="Defined Symbols"
command="-D"
- id="sub.tool.opt.def.symbols"
- valueType="definedSymbols">
+ valueType="definedSymbols"
+ id="sub.tool.opt.def.symbols">
<listOptionValue
- builtIn="true"
- value="BUILTIN">
+ value="BUILTIN"
+ builtIn="true">
</listOptionValue>
</option>
<option
name="More Includes"
command="-I"
- id="sub.tool.opts.inc.paths.more"
- valueType="includePath">
+ valueType="includePath"
+ id="sub.tool.opts.inc.paths.more">
<listOptionValue
- builtIn="false"
- value="C:\home\tester/include">
+ value="C:\home\tester/include"
+ builtIn="false">
</listOptionValue>
<listOptionValue
- builtIn="false"
- value=""../includes"">
+ value=""../includes""
+ builtIn="false">
</listOptionValue>
</option>
<option
name="User Objects"
- id="sub.tool.opt.objs"
- valueType="userObjs">
+ valueType="userObjs"
+ id="sub.tool.opt.objs">
<listOptionValue
- builtIn="false"
- value="obj1.o">
+ value="obj1.o"
+ builtIn="false">
</listOptionValue>
<listOptionValue
- builtIn="false"
- value="obj2.o">
+ value="obj2.o"
+ builtIn="false">
</listOptionValue>
</option>
</tool>
@@ -262,8 +262,8 @@
<target
isTest="true"
name="Test Sub Sub"
- binaryParser="org.eclipse.cdt.core.ELF"
parent="test.sub"
+ binaryParser="org.eclipse.cdt.core.ELF"
defaultExtension="tss"
makeCommand="nmake"
id="test.sub.sub">
@@ -271,11 +271,17 @@
id="target.independent.tool">
</toolReference>
</target>
+ <dynamicElementProvider
+ class="org.eclipse.cdt.core.build.managed.tests.TestManagedConfigProvider">
+ </dynamicElementProvider>
+ <dynamicElementProvider
+ class="org.eclipse.cdt.core.build.managed.tests.BadManagedConfigProvider">
+ </dynamicElementProvider>
<target
isTest="true"
name="Forward Grandchild"
- binaryParser="org.eclipse.cdt.core.tests.target1"
parent="test.forward.child.target"
+ binaryParser="org.eclipse.cdt.core.tests.target1"
id="test.forward.grandchild.target">
<toolReference
command="newcommand"
@@ -286,8 +292,8 @@
isTest="true"
osList="win32,solaris,linux"
name="Forward Child"
- parent="test.forward.parent.target"
binaryParser="org.eclipse.cdt.core.tests.target2"
+ parent="test.forward.parent.target"
id="test.forward.child.target">
<toolReference
id="test.forward.tool">
Index: build/org/eclipse/cdt/core/build/managed/tests/ManagedBuildTests.java
===================================================================
retrieving revision 1.22
diff -u -r1.22 ManagedBuildTests.java
--- build/org/eclipse/cdt/core/build/managed/tests/ManagedBuildTests.java 16 Mar 2004 22:29:55 -0000 1.22
+++ build/org/eclipse/cdt/core/build/managed/tests/ManagedBuildTests.java 18 Mar 2004 21:26:46 -0000
@@ -15,6 +15,7 @@
import java.util.Arrays;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
import junit.framework.Test;
import junit.framework.TestCase;
@@ -41,6 +42,7 @@
import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
import org.eclipse.cdt.managedbuilder.core.ITarget;
import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.cdt.managedbuilder.core.IToolReference;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature;
import org.eclipse.cdt.managedbuilder.internal.core.OptionReference;
@@ -104,6 +106,7 @@
ITarget testForwardChild = null;
ITarget testForwardParent = null;
ITarget testForwardGrandchild = null;
+ int numProviderTargets = 0;
// Note secret null parameter which means just extensions
ITarget[] targets = ManagedBuildManager.getDefinedTargets(null);
@@ -126,6 +129,9 @@
testForwardParent = target;
} else if (target.getName().equals("Forward Grandchild")) {
testForwardGrandchild = target;
+ } else if (target.getId().startsWith("test.provider.Test_")) {
+ numProviderTargets++;
+ checkProviderTarget(target);
}
}
// check that the forward references are properly resolved.
@@ -134,6 +140,9 @@
assertNotNull(testForwardGrandchild);
checkForwardTargets(testForwardParent, testForwardChild, testForwardGrandchild);
+ // check that the proper number of target were dynamically provided
+ assertEquals(3, numProviderTargets);
+
// All these targets are defines in the plugin files, so none
// of them should be null at this point
assertNotNull(testRoot);
@@ -1131,6 +1140,26 @@
ToolReference grandToolRef = (ToolReference)grandTools[2];
assertEquals(parentTool, grandToolRef.getTool());
+ }
+
+ public void checkProviderTarget(ITarget target) throws Exception {
+ Properties props = new Properties();
+ props.load(getClass().getResourceAsStream("test_commands"));
+
+ // check that this target is in the file
+ String command = props.getProperty(target.getId());
+ assertNotNull(command);
+
+ ITarget parent = target.getParent();
+ assertNotNull(parent);
+ assertEquals("test.forward.parent.target", parent.getId());
+
+ ITool[] tools = target.getTools();
+ assertEquals(2, tools.length);
+ ITool toolRef = tools[1];
+ assertTrue(toolRef instanceof IToolReference);
+ assertEquals(toolRef.getId(), "test.forward.tool");
+ assertEquals(command, toolRef.getToolCommand());
}
/**
Index: build/org/eclipse/cdt/core/build/managed/tests/StandardBuildTests.java
===================================================================
retrieving revision 1.6
diff -u -r1.6 StandardBuildTests.java
--- build/org/eclipse/cdt/core/build/managed/tests/StandardBuildTests.java 9 Mar 2004 23:46:12 -0000 1.6
+++ build/org/eclipse/cdt/core/build/managed/tests/StandardBuildTests.java 18 Mar 2004 21:26:46 -0000
@@ -1,4 +1,14 @@
package org.eclipse.cdt.core.build.managed.tests;
+/**********************************************************************
+ * Copyright (c) 2002,2004 Rational Software Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * IBM Rational Software - Initial API and implementation
+***********************************************************************/
import java.util.Arrays;
import java.util.Map;
@@ -10,7 +20,6 @@
import org.eclipse.cdt.core.CCProjectNature;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.CProjectNature;
-import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.parser.IScannerInfo;
import org.eclipse.cdt.core.parser.IScannerInfoChangeListener;
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
@@ -20,7 +29,6 @@
import org.eclipse.cdt.make.core.MakeProjectNature;
import org.eclipse.cdt.make.core.MakeScannerInfo;
import org.eclipse.cdt.make.core.MakeScannerProvider;
-import org.eclipse.cdt.testplugin.CProjectHelper;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
@@ -28,17 +36,6 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
-
-/**********************************************************************
- * Copyright (c) 2002,2003 Rational Software Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * IBM Rational Software - Initial API and implementation
-***********************************************************************/
public class StandardBuildTests extends TestCase {
private static final String DEFAULT_BUILD_COMMAND = "make";
Index: build/org/eclipse/cdt/core/build/managed/tests/TestConfigElement.java
===================================================================
RCS file: build/org/eclipse/cdt/core/build/managed/tests/TestConfigElement.java
diff -N build/org/eclipse/cdt/core/build/managed/tests/TestConfigElement.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ build/org/eclipse/cdt/core/build/managed/tests/TestConfigElement.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,69 @@
+/**********************************************************************
+ * Copyright (c) 2004 TimeSys Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * TimeSys Corporation - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.cdt.core.build.managed.tests;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
+
+public class TestConfigElement implements IManagedConfigElement {
+
+ private String name;
+ private Map attributeMap;
+ private IManagedConfigElement[] children;
+
+ public TestConfigElement(String name, String[][] attributes,
+ IManagedConfigElement[] children) {
+ this.name = name;
+ this.children = children;
+ this.attributeMap = new TreeMap();
+ for (int i = 0; i < attributes.length; i++) {
+ attributeMap.put(attributes[i][0], attributes[i][1]);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IManagedConfigElement#getName()
+ */
+ public String getName() {
+ return name;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IManagedConfigElement#getAttribute(java.lang.String)
+ */
+ public String getAttribute(String name) {
+ return (String)attributeMap.get(name);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IManagedConfigElement#getChildren()
+ */
+ public IManagedConfigElement[] getChildren() {
+ return children;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IManagedConfigElement#getChildren(java.lang.String)
+ */
+ public IManagedConfigElement[] getChildren(String elementName) {
+ List ret = new ArrayList(children.length);
+ for (int i = 0; i < children.length; i++) {
+ if (children[i].getName().equals(elementName)) {
+ ret.add(children[i]);
+ }
+ }
+ return (IManagedConfigElement[])ret.toArray(new IManagedConfigElement[ret.size()]);
+ }
+}
Index: build/org/eclipse/cdt/core/build/managed/tests/TestManagedConfigProvider.java
===================================================================
RCS file: build/org/eclipse/cdt/core/build/managed/tests/TestManagedConfigProvider.java
diff -N build/org/eclipse/cdt/core/build/managed/tests/TestManagedConfigProvider.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ build/org/eclipse/cdt/core/build/managed/tests/TestManagedConfigProvider.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,67 @@
+/**********************************************************************
+ * Copyright (c) 2004 TimeSys Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * TimeSys Corporation - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.cdt.core.build.managed.tests;
+
+import java.util.Iterator;
+import java.util.Properties;
+
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
+import org.eclipse.cdt.managedbuilder.core.IManagedConfigElementProvider;
+import org.eclipse.cdt.managedbuilder.core.ITarget;
+import org.eclipse.cdt.managedbuilder.core.ITool;
+
+public class TestManagedConfigProvider implements IManagedConfigElementProvider {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IManagedConfigProvider#getConfigElements()
+ */
+ public IManagedConfigElement[] getConfigElements() {
+ try {
+ Properties props = new Properties();
+ props.load(getClass().getResourceAsStream("test_commands"));
+ IManagedConfigElement[] ret = new IManagedConfigElement[props.size()];
+ Iterator it = props.keySet().iterator();
+ int i = 0;
+ while (it.hasNext()) {
+ String targetId = (String)it.next();
+ String command = props.getProperty(targetId);
+ ret[i++] = createTarget(targetId, command);
+ }
+ return ret;
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ return new IManagedConfigElement[0];
+ }
+
+ private IManagedConfigElement createTarget(String targetId, String command) {
+ IManagedConfigElement toolRef = new TestConfigElement(
+ IConfiguration.TOOLREF_ELEMENT_NAME,
+ new String[][] {
+ {ITool.ID, "test.forward.tool"},
+ {ITool.COMMAND, command}},
+ new IManagedConfigElement[0]);
+
+ IManagedConfigElement target = new TestConfigElement(
+ ITarget.TARGET_ELEMENT_NAME,
+ new String[][] {
+ {ITarget.ID, targetId},
+ {ITarget.NAME, targetId.substring(targetId.lastIndexOf('.')+1).
+ replace('_', ' ')},
+ {ITarget.PARENT, "test.forward.parent.target"},
+ {ITarget.IS_TEST, "true"},
+ {ITarget.OS_LIST, "win32,linux,solaris"}},
+ new IManagedConfigElement[] {toolRef});
+
+ return target;
+ }
+}
Index: build/org/eclipse/cdt/core/build/managed/tests/test_commands
===================================================================
RCS file: build/org/eclipse/cdt/core/build/managed/tests/test_commands
diff -N build/org/eclipse/cdt/core/build/managed/tests/test_commands
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ build/org/eclipse/cdt/core/build/managed/tests/test_commands 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,3 @@
+test.provider.Test_One=cmd1
+test.provider.Test_Two=cmd2
+test.provider.Test_Three=cmd