1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

patch for Sean Evoy

This commit is contained in:
Andrew Niefer 2004-03-18 23:34:10 +00:00
parent 51131345db
commit e267a0e584
6 changed files with 230 additions and 59 deletions

View file

@ -15,6 +15,7 @@ import java.io.StringReader;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Properties;
import junit.framework.Test; import junit.framework.Test;
import junit.framework.TestCase; import junit.framework.TestCase;
@ -41,6 +42,7 @@ import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IOptionCategory; import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
import org.eclipse.cdt.managedbuilder.core.ITarget; import org.eclipse.cdt.managedbuilder.core.ITarget;
import org.eclipse.cdt.managedbuilder.core.ITool; 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.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature; import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature;
import org.eclipse.cdt.managedbuilder.internal.core.OptionReference; import org.eclipse.cdt.managedbuilder.internal.core.OptionReference;
@ -104,6 +106,7 @@ public class ManagedBuildTests extends TestCase {
ITarget testForwardChild = null; ITarget testForwardChild = null;
ITarget testForwardParent = null; ITarget testForwardParent = null;
ITarget testForwardGrandchild = null; ITarget testForwardGrandchild = null;
int numProviderTargets = 0;
// Note secret null parameter which means just extensions // Note secret null parameter which means just extensions
ITarget[] targets = ManagedBuildManager.getDefinedTargets(null); ITarget[] targets = ManagedBuildManager.getDefinedTargets(null);
@ -126,6 +129,9 @@ public class ManagedBuildTests extends TestCase {
testForwardParent = target; testForwardParent = target;
} else if (target.getName().equals("Forward Grandchild")) { } else if (target.getName().equals("Forward Grandchild")) {
testForwardGrandchild = target; testForwardGrandchild = target;
} else if (target.getId().startsWith("test.provider.Test_")) {
numProviderTargets++;
checkProviderTarget(target);
} }
} }
// check that the forward references are properly resolved. // check that the forward references are properly resolved.
@ -134,6 +140,9 @@ public class ManagedBuildTests extends TestCase {
assertNotNull(testForwardGrandchild); assertNotNull(testForwardGrandchild);
checkForwardTargets(testForwardParent, testForwardChild, 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 // All these targets are defines in the plugin files, so none
// of them should be null at this point // of them should be null at this point
assertNotNull(testRoot); assertNotNull(testRoot);
@ -1133,6 +1142,26 @@ public class ManagedBuildTests extends TestCase {
} }
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());
}
/** /**
* Remove all the project information associated with the project used during test. * Remove all the project information associated with the project used during test.
*/ */

View file

@ -1,4 +1,14 @@
package org.eclipse.cdt.core.build.managed.tests; 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.Arrays;
import java.util.Map; import java.util.Map;
@ -10,7 +20,6 @@ import junit.framework.TestSuite;
import org.eclipse.cdt.core.CCProjectNature; import org.eclipse.cdt.core.CCProjectNature;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.CProjectNature; 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.IScannerInfo;
import org.eclipse.cdt.core.parser.IScannerInfoChangeListener; import org.eclipse.cdt.core.parser.IScannerInfoChangeListener;
import org.eclipse.cdt.core.parser.IScannerInfoProvider; import org.eclipse.cdt.core.parser.IScannerInfoProvider;
@ -20,7 +29,6 @@ import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.core.MakeProjectNature; import org.eclipse.cdt.make.core.MakeProjectNature;
import org.eclipse.cdt.make.core.MakeScannerInfo; import org.eclipse.cdt.make.core.MakeScannerInfo;
import org.eclipse.cdt.make.core.MakeScannerProvider; import org.eclipse.cdt.make.core.MakeScannerProvider;
import org.eclipse.cdt.testplugin.CProjectHelper;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.IWorkspaceRoot;
@ -29,17 +37,6 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path; 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 { public class StandardBuildTests extends TestCase {
private static final String DEFAULT_BUILD_COMMAND = "make"; private static final String DEFAULT_BUILD_COMMAND = "make";
private static final String EMPTY_STRING = ""; private static final String EMPTY_STRING = "";

View file

@ -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()]);
}
}

View file

@ -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;
}
}

View file

@ -0,0 +1,3 @@
test.provider.Test_One=cmd1
test.provider.Test_Two=cmd2
test.provider.Test_Three=cmd

View file

@ -33,12 +33,12 @@
point="org.eclipse.cdt.managedbuilder.core.ManagedBuildInfo"> point="org.eclipse.cdt.managedbuilder.core.ManagedBuildInfo">
<tool <tool
natureFilter="both" natureFilter="both"
sources="rc"
name="Target Independent Tool" name="Target Independent Tool"
sources="rc"
headerExtensions="h" headerExtensions="h"
outputFlag="/fo" outputFlag="/fo"
outputs="free"
command="RC.EXE" command="RC.EXE"
outputs="free"
id="target.independent.tool"> id="target.independent.tool">
<optionCategory <optionCategory
owner="target.independent.tool" owner="target.independent.tool"
@ -49,8 +49,8 @@
defaultValue="Live free or die" defaultValue="Live free or die"
name="String in Free" name="String in Free"
category="indy.cat.free" category="indy.cat.free"
id="org.eclipse.cdt.core.tests.option1" valueType="string"
valueType="string"> id="org.eclipse.cdt.core.tests.option1">
</option> </option>
<optionCategory <optionCategory
owner="indy.cat.free" owner="indy.cat.free"
@ -61,8 +61,8 @@
defaultValue="false" defaultValue="false"
name="Boolean in Chained" name="Boolean in Chained"
category="indy.cat.chained" category="indy.cat.chained"
id="org.eclipse.cdt.core.tests.option2" valueType="boolean"
valueType="boolean"> id="org.eclipse.cdt.core.tests.option2">
</option> </option>
</tool> </tool>
<target <target
@ -73,17 +73,17 @@
defaultExtension="toor" defaultExtension="toor"
isAbstract="false" isAbstract="false"
makeCommand="make" makeCommand="make"
makeFlags="-k"
binaryParser="org.eclipse.cdt.core.PE" binaryParser="org.eclipse.cdt.core.PE"
makeFlags="-k"
osList="win32"> osList="win32">
<tool <tool
natureFilter="cnature" natureFilter="cnature"
name="Root Tool"
sources="foo,bar" sources="foo,bar"
name="Root Tool"
headerExtensions="baz" headerExtensions="baz"
outputFlag="-r" outputFlag="-r"
command="doIt"
outputs="toor" outputs="toor"
command="doIt"
id="root.tool"> id="root.tool">
<optionCategory <optionCategory
owner="root.tool" owner="root.tool"
@ -93,39 +93,39 @@
<option <option
name="List Option in Top" name="List Option in Top"
command="-L" command="-L"
id="list.option" valueType="stringList"
valueType="stringList"> id="list.option">
<listOptionValue <listOptionValue
value="a"> value="a">
</listOptionValue> </listOptionValue>
<listOptionValue <listOptionValue
builtIn="false" value="b"
value="b"> builtIn="false">
</listOptionValue> </listOptionValue>
<listOptionValue <listOptionValue
builtIn="true" value="c"
value="c"> builtIn="true">
</listOptionValue> </listOptionValue>
</option> </option>
<option <option
defaultValue="false" defaultValue="false"
name="Boolean Option in Top" name="Boolean Option in Top"
command="-b" command="-b"
id="boolean.option" valueType="boolean"
valueType="boolean"> id="boolean.option">
</option> </option>
<option <option
defaultValue="x" defaultValue="x"
name="String Option in Category" name="String Option in Category"
category="category" category="category"
id="string.option" valueType="string"
valueType="string"> id="string.option">
</option> </option>
<option <option
name="Enumerated Option in Category" name="Enumerated Option in Category"
category="category" category="category"
id="enumerated.option" valueType="enumerated"
valueType="enumerated"> id="enumerated.option">
<enumeratedOptionValue <enumeratedOptionValue
name="Default Enum" name="Default Enum"
isDefault="true" isDefault="true"
@ -198,17 +198,17 @@
</configuration> </configuration>
<tool <tool
natureFilter="both" natureFilter="both"
name="Sub Tool"
sources="yarf" sources="yarf"
name="Sub Tool"
headerExtensions="arf,barf" headerExtensions="arf,barf"
outputPrefix="lib"
outputs="bus" outputs="bus"
outputPrefix="lib"
id="tool.sub"> id="tool.sub">
<option <option
name="Include Paths" name="Include Paths"
command="-I" command="-I"
id="sub.tool.opt.inc.paths" valueType="includePath"
valueType="includePath"> id="sub.tool.opt.inc.paths">
<listOptionValue <listOptionValue
value="/usr/include"> value="/usr/include">
</listOptionValue> </listOptionValue>
@ -216,45 +216,45 @@
value="/opt/gnome/include"> value="/opt/gnome/include">
</listOptionValue> </listOptionValue>
<listOptionValue <listOptionValue
builtIn="true" value="/usr/gnu/include"
value="/usr/gnu/include"> builtIn="true">
</listOptionValue> </listOptionValue>
</option> </option>
<option <option
name="Defined Symbols" name="Defined Symbols"
command="-D" command="-D"
id="sub.tool.opt.def.symbols" valueType="definedSymbols"
valueType="definedSymbols"> id="sub.tool.opt.def.symbols">
<listOptionValue <listOptionValue
builtIn="true" value="BUILTIN"
value="BUILTIN"> builtIn="true">
</listOptionValue> </listOptionValue>
</option> </option>
<option <option
name="More Includes" name="More Includes"
command="-I" command="-I"
id="sub.tool.opts.inc.paths.more" valueType="includePath"
valueType="includePath"> id="sub.tool.opts.inc.paths.more">
<listOptionValue <listOptionValue
builtIn="false" value="C:\home\tester/include"
value="C:\home\tester/include"> builtIn="false">
</listOptionValue> </listOptionValue>
<listOptionValue <listOptionValue
builtIn="false" value="&quot;../includes&quot;"
value="&quot;../includes&quot;"> builtIn="false">
</listOptionValue> </listOptionValue>
</option> </option>
<option <option
name="User Objects" name="User Objects"
id="sub.tool.opt.objs" valueType="userObjs"
valueType="userObjs"> id="sub.tool.opt.objs">
<listOptionValue <listOptionValue
builtIn="false" value="obj1.o"
value="obj1.o"> builtIn="false">
</listOptionValue> </listOptionValue>
<listOptionValue <listOptionValue
builtIn="false" value="obj2.o"
value="obj2.o"> builtIn="false">
</listOptionValue> </listOptionValue>
</option> </option>
</tool> </tool>
@ -262,8 +262,8 @@
<target <target
isTest="true" isTest="true"
name="Test Sub Sub" name="Test Sub Sub"
binaryParser="org.eclipse.cdt.core.ELF"
parent="test.sub" parent="test.sub"
binaryParser="org.eclipse.cdt.core.ELF"
defaultExtension="tss" defaultExtension="tss"
makeCommand="nmake" makeCommand="nmake"
id="test.sub.sub"> id="test.sub.sub">
@ -271,11 +271,17 @@
id="target.independent.tool"> id="target.independent.tool">
</toolReference> </toolReference>
</target> </target>
<dynamicElementProvider
class="org.eclipse.cdt.core.build.managed.tests.TestManagedConfigProvider">
</dynamicElementProvider>
<dynamicElementProvider
class="org.eclipse.cdt.core.build.managed.tests.BadManagedConfigProvider">
</dynamicElementProvider>
<target <target
isTest="true" isTest="true"
name="Forward Grandchild" name="Forward Grandchild"
binaryParser="org.eclipse.cdt.core.tests.target1"
parent="test.forward.child.target" parent="test.forward.child.target"
binaryParser="org.eclipse.cdt.core.tests.target1"
id="test.forward.grandchild.target"> id="test.forward.grandchild.target">
<toolReference <toolReference
command="newcommand" command="newcommand"
@ -286,8 +292,8 @@
isTest="true" isTest="true"
osList="win32,solaris,linux" osList="win32,solaris,linux"
name="Forward Child" name="Forward Child"
parent="test.forward.parent.target"
binaryParser="org.eclipse.cdt.core.tests.target2" binaryParser="org.eclipse.cdt.core.tests.target2"
parent="test.forward.parent.target"
id="test.forward.child.target"> id="test.forward.child.target">
<toolReference <toolReference
id="test.forward.tool"> id="test.forward.tool">