Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikhail Sennikovsky2007-11-04 01:50:25 -0500
committerMikhail Sennikovsky2007-11-04 01:50:25 -0500
commit72767211236dc7199a3c061936f9212e650855ad (patch)
treeef8e6b96d3228978f81a5dc30e6116f5df27c987 /build/org.eclipse.cdt.managedbuilder.core.tests
parentdb41842f235322f1a6b4a336f9894ea49491a829 (diff)
downloadorg.eclipse.cdt-72767211236dc7199a3c061936f9212e650855ad.tar.gz
org.eclipse.cdt-72767211236dc7199a3c061936f9212e650855ad.tar.xz
org.eclipse.cdt-72767211236dc7199a3c061936f9212e650855ad.zip
Tool-chain modification status calculation enhancement
Diffstat (limited to 'build/org.eclipse.cdt.managedbuilder.core.tests')
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml377
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ToolChainModificationTests.java351
2 files changed, 723 insertions, 5 deletions
diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml b/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml
index a76365be04..ff1a2c230b 100644
--- a/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml
+++ b/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml
@@ -6545,6 +6545,7 @@
<tool
id="lv.tests.tool.base"
isAbstract="false"
+ isSystem="true"
name="lv.tests tool">
<option
name="List Option in Top"
@@ -8806,7 +8807,379 @@
</configuration>
</projectType>
+ <!-- tcModificationInfo tests -->
+ <toolChain id="tcm.tc1" name="tcm.tc1" isSystem="true">
+ <builder id="tcm.b1" name="tcm.b1">
+ </builder>
+ <tool id="tcm.t1" name="tcm.t1">
+ <supportedProperties>
+ <property id="org.eclipse.cdt.build.core.buildArtefactType">
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.exe"/>
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.sharedLib"/>
+ </property>
+ </supportedProperties>
+ <option id="tcm.o1"/>
+ <inputType id="tcm.it.1" sources="tcmfoo"/>
+ </tool>
+ <tool id="tcm.t2" name="tcm.t2">
+ <option id="tcm.o2"/>
+ <inputType id="tcm.it.2" sources="tcmbar"/>
+ </tool>
+ </toolChain>
+
+ <toolChain id="tcm.tc2" name="tcm.tc2" isSystem="true">
+ <builder id="tcm.tc2.b1" name="tcm.tc2.b1">
+ </builder>
+ <tool id="tcm.tc2.t1" name="tcm.tc2.t1">
+ <supportedProperties>
+ <property id="org.eclipse.cdt.build.core.buildArtefactType">
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.exe"/>
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.sharedLib"/>
+ </property>
+ </supportedProperties>
+ <option id="tcm.tc2.o1"/>
+ <inputType id="tcm.it.3" sources="tcmfoo"/>
+ </tool>
+ <tool id="tcm.tc2.t2" name="tcm.tc2.t2">
+ <option id="tcm.tc2.o2"/>
+ <inputType id="tcm.it.4" sources="tcmbar"/>
+ </tool>
+ </toolChain>
+
+ <toolChain id="tcm.tc3" name="tcm.tc3" isSystem="true">
+ <builder id="tcm.tc3.b1" name="tcm.tc3.b1">
+ </builder>
+ <tool id="tcm.tc3.t1" name="tcm.tc3.t1">
+ <supportedProperties>
+ <property id="org.eclipse.cdt.build.core.buildArtefactType">
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.exe"/>
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.sharedLib"/>
+ </property>
+ </supportedProperties>
+ <option id="tcm.tc3.o1"/>
+ <inputType id="tcm.it.5" sources="tcmfoo"/>
+ </tool>
+ <tool id="tcm.tc3.t2" name="tcm.tc3.t2">
+ <option id="tcm.tc3.o2"/>
+ <inputType id="tcm.it.6" sources="tcmbar"/>
+ </tool>
+ </toolChain>
+
+ <toolChain id="tcm.tc4" name="tcm.tc4" isSystem="true">
+ <builder id="tcm.tc4.b1" name="tcm.tc4.b1">
+ </builder>
+ <tool id="tcm.tc4.t1" name="tcm.tc4.t1">
+ <supportedProperties>
+ <property id="org.eclipse.cdt.build.core.buildArtefactType">
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.exe"/>
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.sharedLib"/>
+ </property>
+ </supportedProperties>
+ <option id="tcm.tc4.o1"/>
+ <inputType id="tcm.it.7" sources="tcmfoo"/>
+ </tool>
+ <tool id="tcm.tc4.t2" name="tcm.tc4.t2">
+ <option id="tcm.tc4.o2"/>
+ <inputType id="tcm.it.8" sources="tcmbar"/>
+ </tool>
+ </toolChain>
+
+ <toolChain id="tcm.tc5" name="tcm.tc5" isSystem="true">
+ <builder id="tcm.tc5.b1" name="tcm.tc5.b1">
+ </builder>
+ <tool id="tcm.tc5.t1" name="tcm.tc5.t1">
+ <supportedProperties>
+ <property id="org.eclipse.cdt.build.core.buildArtefactType">
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.exe"/>
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.sharedLib"/>
+ </property>
+ </supportedProperties>
+ <option id="tcm.tc5.o1"/>
+ <inputType id="tcm.it.9" sources="tcmfoo"/>
+ </tool>
+ <tool id="tcm.tc5.t2" name="tcm.tc5.t2">
+ <option id="tcm.tc5.o2"/>
+ <inputType id="tcm.it.10" sources="tcmbar"/>
+ </tool>
+ </toolChain>
+
+ <projectType
+ id="tcm.pt" name="tcm.pt"
+ isTest="true"
+ buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe">
+ <configuration id="tcm.pt.cfg" name="test">
+ <toolChain id="tcm.pt.cfg.tc" superClass="tcm.tc1">
+ <builder id="tcm.pt.b1" superClass="tcm.b1" name="tcm.b1">
+ </builder>
+ <tool id="tcm.pt.cfg.t1" superClass="tcm.t1">
+ </tool>
+ <tool id="tcm.pt.cfg.t2" superClass="tcm.t2">
+ </tool>
+ </toolChain>
+ </configuration>
+ </projectType>
+
+ <projectType
+ id="tcm.pt2" name="tcm.pt2"
+ isTest="true"
+ buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe">
+ <configuration id="tcm.pt2.cfg" name="test">
+ <toolChain id="tcm.pt2.cfg.tc" superClass="tcm.tc1">
+ <builder id="tcm.pt2.b1" superClass="tcm.b1" name="tcm.b1">
+ </builder>
+ <tool id="tcm.pt2.cfg.t1" superClass="tcm.t1">
+ </tool>
+ <tool id="tcm.pt2.cfg.t2" superClass="tcm.t2">
+ </tool>
+ </toolChain>
+ </configuration>
+ </projectType>
+
+<!-- 2.1 -->
+ <toolChain id="tcm2.tc" name="tcm2.tc" isSystem="true">
+ <builder id="tcm2.tc.b1" name="tcm2.tc.b1">
+ </builder>
+ <tool id="tcm2.tc.t1" name="tcm2.tc.t1">
+ <supportedProperties>
+ <property id="org.eclipse.cdt.build.core.buildArtefactType">
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.exe"/>
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.sharedLib"/>
+ </property>
+ </supportedProperties>
+ <option id="tcm2.tc.o1"/>
+ <inputType id="tcm.it.11" sources="tcmfoo"/>
+ </tool>
+ <tool id="tcm2.tc.t2" name="tcm2.tc.t2">
+ <option id="tcm2.tc.o2"/>
+ <inputType id="tcm.it.12" sources="tcmfoo"/>
+ </tool>
+ </toolChain>
+
+ <toolChain id="tcm2.tc2" name="tcm2.tc2" isSystem="true">
+ <builder id="tcm2.tc2.b1" name="tcm2.tc2.b1">
+ </builder>
+ <tool id="tcm2.tc2.t1" name="tcm2.tc2.t1">
+ <supportedProperties>
+ <property id="org.eclipse.cdt.build.core.buildArtefactType">
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.exe"/>
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.sharedLib"/>
+ </property>
+ </supportedProperties>
+ <option id="tcm2.tc2.o1"/>
+ <inputType id="tcm.it.13" sources="tcmfoo"/>
+ </tool>
+ <tool id="tcm2.tc2.t2" name="tcm2.tc2.t2">
+ <option id="tcm2.tc2.o2"/>
+ <inputType id="tcm.it.14" sources="tcmbar"/>
+ </tool>
+ </toolChain>
+ <toolChain id="tcm2.tc2.derive" superClass="tcm2.tc2" name="tcm2.tc2.derive" isSystem="true">
+ </toolChain>
+ <toolChain id="tcm2.tc.derive" superClass="tcm2.tc" name="tcm2.tc.derive" isSystem="true">
+ </toolChain>
+
+ <toolChain id="tcm.base.tc" name="tcm.base.tc" isSystem="true">
+ <builder id="tcm.base.tc.b1" name="tcm.base.tc.b1">
+ </builder>
+ <tool id="tcm.base.tc.t1" name="tcm.base.tc.t1">
+ <supportedProperties>
+ <property id="org.eclipse.cdt.build.core.buildArtefactType">
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.exe"/>
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.sharedLib"/>
+ </property>
+ </supportedProperties>
+ <option id="tcm.base.tc.o1"/>
+ <inputType id="tcm.it.15" sources="tcmfoo"/>
+ </tool>
+ <tool id="tcm.base.tc.t2" name="tcm.base.tc.t2">
+ <option id="tcm.base.tc.o2"/>
+ <inputType id="tcm.it.16" sources="tcmbar"/>
+ </tool>
+ </toolChain>
+
+ <toolChain id="tcm.derive.tc1" superClass="tcm.base.tc" name="tcm.derive.tc1" isSystem="true">
+ <builder id="tcm.derive.tc1.b1" superClass="tcm.base.tc.b1" name="tcm.derive.tc1.b1">
+ </builder>
+ <tool id="tcm.derive.tc1.t1" superClass="tcm.base.tc.t1" name="tcm.derive.tc1.t1">
+ <supportedProperties>
+ <property id="org.eclipse.cdt.build.core.buildArtefactType">
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.exe"/>
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.sharedLib"/>
+ </property>
+ </supportedProperties>
+ <option id="tcm.derive.tc1.o1"/>
+ <inputType id="tcm.it.17" sources="tcmfoo"/>
+ </tool>
+ <tool id="tcm.derive.tc1.t2" superClass="tcm.base.tc.t2" name="tcm.derive.tc1.t2">
+ <option id="tcm.derive.tc1.o2"/>
+ <inputType id="tcm.it.18" sources="tcmbar"/>
+ </tool>
+ </toolChain>
+
+ <toolChain id="tcm.derive.tc2" superClass="tcm.base.tc" name="tcm.derive.tc2" isSystem="true">
+ <builder id="tcm.derive.tc2.b1" superClass="tcm.base.tc.b1" name="tcm.derive.tc2.b1">
+ </builder>
+ <tool id="tcm.derive.tc2.t1" superClass="tcm.base.tc.t1" name="tcm.derive.tc2.t1">
+ <supportedProperties>
+ <property id="org.eclipse.cdt.build.core.buildArtefactType">
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.exe"/>
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.sharedLib"/>
+ </property>
+ </supportedProperties>
+ <option id="tcm.derive.tc2.o1"/>
+ <inputType id="tcm.it.19" sources="tcmfoo"/>
+ </tool>
+ <tool id="tcm.derive.tc2.t2" superClass="tcm.base.tc.t2" name="tcm.derive.tc2.t2">
+ <option id="tcm.derive.tc2.o2"/>
+ <inputType id="tcm.it.20" sources="tcmbar"/>
+ </tool>
+ </toolChain>
+
+ <projectType
+ id="tcm.pt.derive1" name="tcm.pt.derive1"
+ isTest="true"
+ buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe">
+ <configuration id="tcm.pt.derive1.cfg" name="test">
+ <toolChain id="tcm.pt.derive.tc1" superClass="tcm.derive.tc1">
+ <builder id="tcm.pt.derive.b1" superClass="tcm.derive.tc1.b1">
+ </builder>
+ <tool id="tcm.pt.derive.t1" superClass="tcm.derive.tc1.t1">
+ </tool>
+ <tool id="tcm.pt.derive.t2" superClass="tcm.derive.tc1.t2">
+ </tool>
+ </toolChain>
+ </configuration>
+ </projectType>
+
+<!-- 2.2 -->
+
+ <toolChain id="tcm.base2.tc" name="tcm.base2.tc" isSystem="true">
+ <builder id="tcm.base2.tc.b1" name="tcm.base2.tc.b1">
+ </builder>
+ <tool id="tcm.base2.tc.t1" name="tcm.base2.tc.t1">
+ <supportedProperties>
+ <property id="org.eclipse.cdt.build.core.buildArtefactType">
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.exe"/>
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.sharedLib"/>
+ </property>
+ </supportedProperties>
+ <option id="tcm.base2.tc.o1"/>
+ <inputType id="tcm.it.21" sources="tcmfoo"/>
+ </tool>
+ <tool id="tcm.base2.tc.t2" name="tcm.base2.tc.t2">
+ <option id="tcm.base2.tc.o2"/>
+ <inputType id="tcm.it.22" sources="tcmbar"/>
+ </tool>
+ </toolChain>
+
+ <toolChain id="tcm.derive2.tc1" superClass="tcm.base2.tc" name="tcm.derive2.tc1" isSystem="true">
+ <builder id="tcm.derive2.tc1.b1" superClass="tcm.base2.tc.b1" name="tcm.derive2.tc1.b1">
+ </builder>
+ <tool id="tcm.derive2.tc1.t1" superClass="tcm.base2.tc.t1" name="tcm.derive2.tc1.t1">
+ <supportedProperties>
+ <property id="org.eclipse.cdt.build.core.buildArtefactType">
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.exe"/>
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.sharedLib"/>
+ </property>
+ </supportedProperties>
+ <option id="tcm.derive2.tc1.o1"/>
+ <inputType id="tcm.it.23" sources="tcmfoo"/>
+ </tool>
+ <tool id="tcm.derive2.tc1.t2" superClass="tcm.base2.tc.t2" name="tcm.derive2.tc1.t2">
+ <option id="tcm.derive2.tc1.o2"/>
+ <inputType id="tcm.it.24" sources="tcmbar"/>
+ </tool>
+ </toolChain>
+
+ <toolChain id="tcm.derive2.tc2" superClass="tcm.base2.tc" name="tcm.derive2.tc2" isSystem="true">
+ <builder id="tcm.derive2.tc2.b1" superClass="tcm.base2.tc.b1" name="tcm.derive2.tc2.b1">
+ </builder>
+ <tool id="tcm.derive2.tc2.t1" superClass="tcm.base2.tc.t1" name="tcm.derive2.tc2.t1">
+ <supportedProperties>
+ <property id="org.eclipse.cdt.build.core.buildArtefactType">
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.exe"/>
+ <value id="org.eclipse.cdt.build.core.buildArtefactType.sharedLib"/>
+ </property>
+ </supportedProperties>
+ <option id="tcm.derive2.tc2.o1"/>
+ <inputType id="tcm.it.25" sources="tcmfoo"/>
+ </tool>
+ <tool id="tcm.derive2.tc2.t2" superClass="tcm.base2.tc.t2" name="tcm.derive2.tc2.t2">
+ <option id="tcm.derive2.tc2.o2"/>
+ <inputType id="tcm.it.26" sources="tcmbar"/>
+ </tool>
+ </toolChain>
+
+ </extension>
+ <extension
+ id="test.tcModificationInfo.extension.id1"
+ name="Test ToolChain Modification Info Extension"
+ point="org.eclipse.cdt.managedbuilder.core.tcModificationInfo">
+
+ <conflictDefinition>
+ <matchObject
+ objectIds="tcm.tc2"
+ objectType="toolChain"/>
+ <matchObject
+ objectIds="tcm.pt.cfg"
+ objectType="configuration"/>
+ </conflictDefinition>
+
+ <conflictDefinition>
+ <matchObject
+ objectIds="tcm.tc3"
+ objectType="toolChain"/>
+ <matchObject
+ objectIds="tcm.tc1"
+ objectType="toolChain"/>
+ </conflictDefinition>
+
+ <conflictDefinition>
+ <matchObject
+ objectIds="tcm.tc4.b1"
+ objectType="builder"/>
+ <matchObject
+ objectIds="tcm.tc1"
+ objectType="toolChain"/>
+ </conflictDefinition>
+
+ <conflictDefinition>
+ <matchObject
+ objectIds="tcm.tc5.t1"
+ objectType="tool"/>
+ <matchObject
+ objectIds="tcm.tc1"
+ objectType="toolChain"/>
+ </conflictDefinition>
+
+ <conflictDefinition>
+ <matchObject
+ objectIds="tcm.tc4.t1"
+ objectType="tool"/>
+ <matchObject
+ objectIds="tcm.tc3.t1"
+ objectType="tool"/>
+ </conflictDefinition>
+ </extension>
+ <!-- 2 -->
+ <extension
+ id="test.tcModificationInfo.extension.id2"
+ name="Test ToolChain Modification Info Extension2"
+ point="org.eclipse.cdt.managedbuilder.core.tcModificationInfo">
+
+ <conflictDefinition>
+ <matchObject
+ objectIds="tcm.base.tc"
+ objectType="toolChain"
+ searchScope="ALL_EXTENSION_SUPERCLASSES"/>
+ <matchObject
+ objectIds="tcm.base2.tc;tcm2.tc"
+ objectType="toolChain"
+ searchScope="ALL_EXTENSION_SUPERCLASSES">
+ <pattern
+ objectIds="tcm2.tc2"
+ searchScope="EXTENSION_OBJECT"/>
+ </matchObject>
+ </conflictDefinition>
</extension>
-
-
</plugin>
diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ToolChainModificationTests.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ToolChainModificationTests.java
index 20457a22b5..7f82436387 100644
--- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ToolChainModificationTests.java
+++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ToolChainModificationTests.java
@@ -10,10 +10,42 @@
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.core.tests;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
import junit.framework.Test;
import junit.framework.TestSuite;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
+import org.eclipse.cdt.core.settings.model.util.CDataUtil;
+import org.eclipse.cdt.managedbuilder.core.IBuildObject;
+import org.eclipse.cdt.managedbuilder.core.IBuilder;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IFolderInfo;
+import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.internal.core.FolderInfo;
+import org.eclipse.cdt.managedbuilder.internal.core.ToolChain;
+import org.eclipse.cdt.managedbuilder.tcmodification.IConfigurationModification;
+import org.eclipse.cdt.managedbuilder.tcmodification.IFolderInfoModification;
+import org.eclipse.cdt.managedbuilder.tcmodification.IModificationOperation;
+import org.eclipse.cdt.managedbuilder.tcmodification.IToolChainModificationManager;
+import org.eclipse.cdt.managedbuilder.tcmodification.IToolModification;
+import org.eclipse.cdt.managedbuilder.testplugin.BuildSystemTestHelper;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+
public class ToolChainModificationTests extends BasicTestCase {
+ private static final String PROJ_NAME_PREFIX="TCM_";
public static Test suite() {
TestSuite suite = new TestSuite(ToolChainModificationTests.class);
@@ -21,7 +53,320 @@ public class ToolChainModificationTests extends BasicTestCase {
return suite;
}
-// public void testChangeToolChain(){
-//
-// }
+ public void testRootToolChainStatus() throws Exception {
+ final String projName = PROJ_NAME_PREFIX + "p1";
+ IProject project = BuildSystemTestHelper.createProject(projName);
+ BuildSystemTestHelper.createDescription(project, "tcm.pt");
+ ICProjectDescriptionManager desMngr = CoreModel.getDefault().getProjectDescriptionManager();
+
+ ICProjectDescription des = desMngr.getProjectDescription(project);
+ IConfiguration cfg = ManagedBuildManager.getConfigurationForDescription(des.getConfigurations()[0]);
+ IToolChainModificationManager mngr = ManagedBuildManager.getToolChainModificationManager();
+
+ IConfigurationModification cfgM = (IConfigurationModification)mngr.getModification(cfg.getRootFolderInfo());
+ assertTrue(cfgM.isToolChainCompatible());
+ assertTrue(cfgM.isBuilderCompatible());
+
+ IToolChain[] ctcs = cfgM.getCompatibleToolChains();
+ HashSet set = new HashSet();
+ FolderInfo foInfo = (FolderInfo)cfg.getRootFolderInfo();
+ ToolChain tc = (ToolChain)foInfo.getToolChain();
+ IToolChain[] allSys = ManagedBuildManager.getRealToolChains();
+ filterPropsSupported(foInfo, tc, allSys, set);
+ set.remove(ManagedBuildManager.getRealToolChain(tc));
+ IToolChain incompatibleTc = ManagedBuildManager.getExtensionToolChain("tcm.tc2");
+ incompatibleTc = ManagedBuildManager.getRealToolChain(incompatibleTc);
+ set.remove(incompatibleTc);
+ compare(Arrays.asList(ctcs), set);
+
+ HashSet incomp = new HashSet(Arrays.asList(allSys));
+ incomp.removeAll(Arrays.asList(ctcs));
+ assertTrue(incomp.contains(incompatibleTc));
+
+ IBuilder[] cbs = cfgM.getCompatibleBuilders();
+ Set bSet = new HashSet();
+ IBuilder[] allSysB = ManagedBuildManager.getRealBuilders();
+ filterPropsSupported(cfg, allSysB, bSet);
+ IBuilder incompatibleB = ManagedBuildManager.getExtensionBuilder("tcm.tc4.b1");
+ incompatibleB = ManagedBuildManager.getRealBuilder(incompatibleB);
+ bSet.remove(cfgM.getRealBuilder());
+ bSet.remove(incompatibleB);
+ compare(Arrays.asList(cbs), bSet);
+
+ HashSet incompB = new HashSet(Arrays.asList(allSysB));
+ incompB.removeAll(Arrays.asList(cbs));
+ assertTrue(incompB.contains(incompatibleB));
+
+ IToolChain tc3 = ManagedBuildManager.getExtensionToolChain("tcm.tc3");
+ cfgM.setToolChain(tc3);
+ assertEquals(tc3, cfgM.getToolChain());
+ assertEquals(tc3.getBuilder(), cfgM.getBuilder());
+
+ IBuilder b5 = ManagedBuildManager.getExtensionBuilder("tcm.tc5.b1");
+ cfgM.setBuilder(b5);
+ assertEquals(tc3, cfgM.getToolChain());
+ assertEquals(b5, cfgM.getBuilder());
+
+ project.delete(true, null);
+ }
+
+ private boolean contains(Object[] array, Object obj){
+ return new HashSet(Arrays.asList(array)).contains(obj);
+ }
+
+ private HashSet filterSupportedToolChains(IFolderInfo foInfo, IToolChain tc){
+ HashSet set = new HashSet();
+ IToolChain[] allSys = ManagedBuildManager.getRealToolChains();
+ filterPropsSupported((FolderInfo)foInfo, (ToolChain)tc, allSys, set);
+ set.remove(ManagedBuildManager.getRealToolChain(tc));
+ return set;
+ }
+
+ public void testChildToolChainStatus() throws Exception {
+ final String projName = PROJ_NAME_PREFIX + "p2";
+ IProject project = BuildSystemTestHelper.createProject(projName);
+ BuildSystemTestHelper.createDescription(project, "tcm.pt2");
+ ICProjectDescriptionManager desMngr = CoreModel.getDefault().getProjectDescriptionManager();
+
+ ICProjectDescription des = desMngr.getProjectDescription(project);
+ IConfiguration cfg = ManagedBuildManager.getConfigurationForDescription(des.getConfigurations()[0]);
+ IToolChainModificationManager mngr = ManagedBuildManager.getToolChainModificationManager();
+
+ IConfigurationModification cfgM = (IConfigurationModification)mngr.getModification(cfg.getRootFolderInfo());
+ assertEquals(cfgM.getToolChain(), cfg.getToolChain());
+ assertTrue(cfgM.isToolChainCompatible());
+ assertTrue(cfgM.isBuilderCompatible());
+
+ IPath foPath = new Path("a");
+ IFolder fo = project.getFolder(foPath);
+ fo.create(true, true, null);
+
+ IFolderInfo foInfo = cfg.createFolderInfo(foPath);
+ IFolderInfoModification foM = mngr.getModification(foInfo);
+ assertEquals(foM.getToolChain(), foInfo.getToolChain());
+ assertTrue(foM.isToolChainCompatible());
+
+ cfgM = (IConfigurationModification)mngr.getModification(cfg.getRootFolderInfo());
+ assertEquals(cfgM.getToolChain(), cfg.getToolChain());
+ assertTrue(cfgM.isToolChainCompatible());
+ assertTrue(cfgM.isBuilderCompatible());
+
+ HashSet set = filterSupportedToolChains(cfg.getRootFolderInfo(), cfg.getToolChain());
+ IToolChain[] tcs = cfgM.getCompatibleToolChains();
+ compare(Arrays.asList(tcs), set);
+
+ tcs = foM.getCompatibleToolChains();
+ set = filterSupportedToolChains(foInfo, foInfo.getToolChain());
+ IToolChain incompatibleTc = ManagedBuildManager.getExtensionToolChain("tcm.tc3");
+ incompatibleTc = ManagedBuildManager.getRealToolChain(incompatibleTc);
+ set.remove(incompatibleTc);
+ compare(Arrays.asList(tcs), set);
+
+ foM.setToolChain(incompatibleTc);
+ assertFalse(foM.isToolChainCompatible());
+ foInfo.changeToolChain(incompatibleTc, CDataUtil.genId("blah.blah"), incompatibleTc.getName());
+ cfgM = (IConfigurationModification)mngr.getModification(cfg.getRootFolderInfo());
+ assertTrue(cfgM.isToolChainCompatible());
+ foM = mngr.getModification(foInfo);
+ assertFalse(foM.isToolChainCompatible());
+
+ project.delete(true, null);
+ }
+
+ public void testChildToolChainStatus2() throws Exception {
+ final String projName = PROJ_NAME_PREFIX + "p3";
+ IProject project = BuildSystemTestHelper.createProject(projName);
+ BuildSystemTestHelper.createDescription(project, "tcm.pt.derive1");
+ ICProjectDescriptionManager desMngr = CoreModel.getDefault().getProjectDescriptionManager();
+
+ ICProjectDescription des = desMngr.getProjectDescription(project);
+ IConfiguration cfg = ManagedBuildManager.getConfigurationForDescription(des.getConfigurations()[0]);
+ IToolChainModificationManager mngr = ManagedBuildManager.getToolChainModificationManager();
+
+ IConfigurationModification cfgM = (IConfigurationModification)mngr.getModification(cfg.getRootFolderInfo());
+ assertEquals(cfgM.getToolChain(), cfg.getToolChain());
+ assertTrue(cfgM.isToolChainCompatible());
+ assertTrue(cfgM.isBuilderCompatible());
+
+ IPath foPath = new Path("a");
+ IFolder fo = project.getFolder(foPath);
+ fo.create(true, true, null);
+
+ IFolderInfo foInfo = cfg.createFolderInfo(foPath);
+ IFolderInfoModification foM = mngr.getModification(foInfo);
+ assertEquals(foM.getToolChain(), foInfo.getToolChain());
+ assertTrue(foM.isToolChainCompatible());
+
+ cfgM = (IConfigurationModification)mngr.getModification(cfg.getRootFolderInfo());
+ assertEquals(cfgM.getToolChain(), cfg.getToolChain());
+ assertTrue(cfgM.isToolChainCompatible());
+ assertTrue(cfgM.isBuilderCompatible());
+
+ HashSet set = filterSupportedToolChains(cfg.getRootFolderInfo(), cfg.getToolChain());
+ IToolChain[] tcs = cfgM.getCompatibleToolChains();
+ compare(Arrays.asList(tcs), set);
+
+ tcs = foM.getCompatibleToolChains();
+ set = filterSupportedToolChains(foInfo, foInfo.getToolChain());
+ rmToolChains(set, new String[]{
+ "tcm.base2.tc",
+ "tcm.derive2.tc1",
+ "tcm.derive2.tc2",
+ "tcm2.tc2",
+ "tcm2.tc",
+ "tcm2.tc.derive",
+ });
+
+ compare(Arrays.asList(tcs), set);
+
+ foM.setToolChain(ManagedBuildManager.getExtensionToolChain("tcm.derive2.tc1"));
+ assertFalse(foM.isToolChainCompatible());
+ foInfo.changeToolChain(ManagedBuildManager.getExtensionToolChain("tcm.derive2.tc1"), CDataUtil.genId("blah.blah"), null);
+ cfgM = (IConfigurationModification)mngr.getModification(cfg.getRootFolderInfo());
+ assertTrue(cfgM.isToolChainCompatible());
+ foM = mngr.getModification(foInfo);
+ assertFalse(foM.isToolChainCompatible());
+
+ project.delete(true, null);
+ }
+
+ private void rmToolChains(Set set, String[] ids){
+ for(int i = 0; i < ids.length; i++){
+ IToolChain incompatibleTc = ManagedBuildManager.getExtensionToolChain(ids[i]);
+ assertNotNull("no tool-chain of id " + ids[i], incompatibleTc);
+ incompatibleTc = ManagedBuildManager.getRealToolChain(incompatibleTc);
+ assertTrue("set does not contain tc \"" + incompatibleTc.getId()
+ + "\" which is a real tc for \"" + ids[i] + "\"", set.remove(incompatibleTc));
+ }
+ }
+
+ private IToolChain getRealToolChain(String id){
+ IToolChain tc = ManagedBuildManager.getExtensionToolChain(id);
+ return ManagedBuildManager.getRealToolChain(tc);
+ }
+
+ private void compare(Collection c1, Collection c2){
+ HashSet s1 = new HashSet(c1);
+ HashSet s1c = (HashSet)s1.clone();
+
+ HashSet s2 = new HashSet(c2);
+
+ s1.removeAll(s2);
+ s2.removeAll(s1c);
+ StringBuffer buf = new StringBuffer();
+ buf.append("checking c1..\n");
+ boolean fail = checkEmpty(s1, buf);
+ buf.append("checking c2..\n");
+ fail |= checkEmpty(s2, buf);
+
+ if(fail)
+ fail(buf.toString());
+ }
+
+ private boolean checkEmpty(Collection c, StringBuffer buf){
+ if(c.size() != 0){
+ buf.append("non-empty dump:\n");
+ for(Iterator iter = c.iterator(); iter.hasNext(); ){
+ buf.append("\t ").append((((IBuildObject)iter.next()).getId())).append('\n');
+ }
+ buf.append("end\n");
+ return true;
+ }
+ return false;
+ }
+
+ private Collection filterPropsSupported(FolderInfo foInfo, ToolChain tc, IToolChain[] tcs, Collection c){
+ if(c == null)
+ c = new ArrayList();
+ for(int i = 0; i < tcs.length; i++){
+ if(foInfo.isToolChainCompatible(tc, tcs[i]))
+ c.add(tcs[i]);
+ }
+
+ return c;
+ }
+
+ private Collection filterPropsSupported(IConfiguration cfg, IBuilder[] bs, Collection c){
+ if(c == null)
+ c = new ArrayList();
+ for(int i = 0; i < bs.length; i++){
+ if(cfg.isBuilderCompatible(bs[i]))
+ c.add(bs[i]);
+ }
+
+ return c;
+ }
+
+ private boolean getReplacementToolInfo(IModificationOperation[] ops, Set set){
+ boolean removable = false;
+ for(int i = 0; i < ops.length; i++){
+ ITool tool = ops[i].getReplacementTool();
+ if(tool == null){
+ removable = true;
+ } else {
+ set.add(tool);
+ }
+ }
+ return removable;
+ }
+
+ public void testToolModificationWithChild() throws Exception {
+ final String projName = PROJ_NAME_PREFIX + "p4";
+ IProject project = BuildSystemTestHelper.createProject(projName);
+ BuildSystemTestHelper.createDescription(project, "tcm.pt");
+
+ ICProjectDescriptionManager desMngr = CoreModel.getDefault().getProjectDescriptionManager();
+
+ ICProjectDescription des = desMngr.getProjectDescription(project);
+ IConfiguration cfg = ManagedBuildManager.getConfigurationForDescription(des.getConfigurations()[0]);
+ IToolChain tc4 = ManagedBuildManager.getExtensionToolChain("tcm.tc4");
+ cfg.getRootFolderInfo().changeToolChain(tc4, CDataUtil.genId(null), null);
+
+ IToolChainModificationManager mngr = ManagedBuildManager.getToolChainModificationManager();
+
+ IConfigurationModification cfgM = (IConfigurationModification)mngr.getModification(cfg.getRootFolderInfo());
+ assertEquals(cfgM.getToolChain(), cfg.getToolChain());
+ assertTrue(cfgM.isToolChainCompatible());
+ assertTrue(cfgM.isBuilderCompatible());
+
+ IPath foPath = new Path("a");
+ IFolder fo = project.getFolder(foPath);
+ fo.create(true, true, null);
+
+ IFolderInfo foInfo = cfg.createFolderInfo(foPath);
+ IFolderInfoModification foM = mngr.getModification(foInfo);
+ assertEquals(foM.getToolChain(), foInfo.getToolChain());
+ assertTrue(foM.isToolChainCompatible());
+
+ cfgM = (IConfigurationModification)mngr.getModification(cfg.getRootFolderInfo());
+ assertEquals(cfgM.getToolChain(), cfg.getToolChain());
+ assertTrue(cfgM.isToolChainCompatible());
+ assertTrue(cfgM.isBuilderCompatible());
+
+ ITool tool41 = ManagedBuildManager.getExtensionTool("tcm.tc4.t1");
+ IToolModification tm = cfgM.getToolModification(tool41);
+ assertTrue(tm.isProjectTool());
+
+ IModificationOperation[] ops = tm.getSupportedOperations();
+ ITool tool31 = ManagedBuildManager.getExtensionTool("tcm.tc3.t1");
+ Set replacement = new HashSet();
+ boolean removable = getReplacementToolInfo(ops, replacement);
+
+ assertFalse(removable);
+ assertTrue(replacement.contains(tool31));
+
+ tm = foM.getToolModification(tool41);
+ assertTrue(tm.isProjectTool());
+
+ ops = tm.getSupportedOperations();
+ replacement = new HashSet();
+ removable = getReplacementToolInfo(ops, replacement);
+
+ assertFalse(removable);
+ assertFalse(replacement.contains(tool31));
+
+ int tmp = IToolChainModificationManager.OBJECT_CONFIGURATION;
+
+ project.delete(true, null);
+ }
}

Back to the top