Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Recoskie2009-01-21 10:51:07 -0500
committerChris Recoskie2009-01-21 10:51:07 -0500
commit38fb615b8de0ddec965628db766621839902a617 (patch)
tree803ba71b588458d8635bdb823b9633cd521d3722 /build/org.eclipse.cdt.managedbuilder.core.tests
parenta091e59733b34837caa8ba2ad21e2a01a42a88f2 (diff)
downloadorg.eclipse.cdt-38fb615b8de0ddec965628db766621839902a617.tar.gz
org.eclipse.cdt-38fb615b8de0ddec965628db766621839902a617.tar.xz
org.eclipse.cdt-38fb615b8de0ddec965628db766621839902a617.zip
RESOLVED - bug 252966: ProjectDescription Storage: It should be possible to extend / override persistence mechanism
https://bugs.eclipse.org/bugs/show_bug.cgi?id=252966
Diffstat (limited to 'build/org.eclipse.cdt.managedbuilder.core.tests')
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core.tests/META-INF/MANIFEST.MF3
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core.tests/suite/org/eclipse/cdt/managedbuilder/tests/suite/AllManagedBuildTests.java28
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/build/core/scannerconfig/tests/CfgScannerConfigProfileManagerTests.java117
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/projectmodel/tests/CProjectDescriptionSerializationTests.java67
4 files changed, 203 insertions, 12 deletions
diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/META-INF/MANIFEST.MF b/build/org.eclipse.cdt.managedbuilder.core.tests/META-INF/MANIFEST.MF
index 46c70d7d86..b381a5bcf2 100644
--- a/build/org.eclipse.cdt.managedbuilder.core.tests/META-INF/MANIFEST.MF
+++ b/build/org.eclipse.cdt.managedbuilder.core.tests/META-INF/MANIFEST.MF
@@ -17,6 +17,7 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.ui,
org.eclipse.ui.ide,
org.eclipse.cdt.core,
- org.eclipse.cdt.managedbuilder.core
+ org.eclipse.cdt.managedbuilder.core,
+ org.eclipse.cdt.core.tests;bundle-version="5.0.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/suite/org/eclipse/cdt/managedbuilder/tests/suite/AllManagedBuildTests.java b/build/org.eclipse.cdt.managedbuilder.core.tests/suite/org/eclipse/cdt/managedbuilder/tests/suite/AllManagedBuildTests.java
index 267a50613b..d7f8e2ad82 100644
--- a/build/org.eclipse.cdt.managedbuilder.core.tests/suite/org/eclipse/cdt/managedbuilder/tests/suite/AllManagedBuildTests.java
+++ b/build/org.eclipse.cdt.managedbuilder.core.tests/suite/org/eclipse/cdt/managedbuilder/tests/suite/AllManagedBuildTests.java
@@ -8,12 +8,14 @@
* Contributors:
* IBM - Initial API and implementation
* Markus Schorn (Wind River Systems)
+ * James Blackburn (Broadcom Corp.)
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.tests.suite;
import junit.framework.Test;
import junit.framework.TestSuite;
+import org.eclipse.cdt.build.core.scannerconfig.tests.CfgScannerConfigProfileManagerTests;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IPDOMManager;
import org.eclipse.cdt.managedbuilder.core.tests.BuildDescriptionModelTests;
@@ -32,28 +34,28 @@ import org.eclipse.cdt.managedbuilder.core.tests.MultiVersionSupportTests;
import org.eclipse.cdt.managedbuilder.core.tests.OptionEnablementTests;
import org.eclipse.cdt.managedbuilder.core.tests.PathConverterTest;
import org.eclipse.cdt.managedbuilder.core.tests.ResourceBuildCoreTests;
+import org.eclipse.cdt.managedbuilder.templateengine.tests.AllTemplateEngineTests;
import org.eclipse.cdt.projectmodel.tests.BackwardCompatiblityTests;
import org.eclipse.cdt.projectmodel.tests.CProjectDescriptionSerializationTests;
import org.eclipse.cdt.projectmodel.tests.OptionStringListValueTests;
import org.eclipse.cdt.projectmodel.tests.ProjectModelTests;
/**
- *
+ * Main TestSuite for all the managed build tests
*/
public class AllManagedBuildTests {
public static void main(String[] args) {
junit.textui.TestRunner.run(AllManagedBuildTests.suite());
}
public static Test suite() {
- // May/2005 Turning off all indexing for now because the "original" indexer causes hangs...
- CCorePlugin.getDefault().getPluginPreferences().setValue(CCorePlugin.PREF_INDEXER, IPDOMManager.ID_NO_INDEXER);
- // We could enable this later...
- //CCorePlugin.getDefault().getPluginPreferences().setValue(CCorePlugin.PREF_INDEXER, IPDOMManager.ID_FULL_INDEXER);
+ CCorePlugin.getDefault().getPluginPreferences().setValue(CCorePlugin.PREF_INDEXER, IPDOMManager.ID_FAST_INDEXER);
- TestSuite suite = new TestSuite(
- "Test for org.eclipse.cdt.managedbuild.core.tests");
+ TestSuite suite = new TestSuite("Test for org.eclipse.cdt.managedbuild.core.tests");
//$JUnit-BEGIN$
-// TODO uncoment this
+ // build.core.scannerconfig.tests
+ suite.addTest(CfgScannerConfigProfileManagerTests.suite());
+
+ // managedbuilder.core.tests
suite.addTest(ManagedBuildCoreTests20.suite());
suite.addTest(ManagedBuildCoreTests.suite());
suite.addTest(ManagedProjectUpdateTests.suite());
@@ -68,13 +70,17 @@ public class AllManagedBuildTests {
suite.addTest(MultiVersionSupportTests.suite());
suite.addTest(OptionEnablementTests.suite());
suite.addTest(ManagedBuildDependencyCalculatorTests.suite());
-
suite.addTest(BuildDescriptionModelTests.suite());
suite.addTest(PathConverterTest.suite());
- suite.addTest(ProjectModelTests.suite());
- suite.addTest(OptionStringListValueTests.suite());
+
+ // managedbuilder.templateengine.tests
+ suite.addTest(AllTemplateEngineTests.suite());
+
+ // projectmodel.tests
suite.addTest(BackwardCompatiblityTests.suite());
suite.addTest(CProjectDescriptionSerializationTests.suite());
+ suite.addTest(OptionStringListValueTests.suite());
+ suite.addTest(ProjectModelTests.suite());
//$JUnit-END$
return suite;
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/build/core/scannerconfig/tests/CfgScannerConfigProfileManagerTests.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/build/core/scannerconfig/tests/CfgScannerConfigProfileManagerTests.java
new file mode 100644
index 0000000000..a68c9d730e
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/build/core/scannerconfig/tests/CfgScannerConfigProfileManagerTests.java
@@ -0,0 +1,117 @@
+package org.eclipse.cdt.build.core.scannerconfig.tests;
+
+import java.util.Map;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.eclipse.cdt.build.core.scannerconfig.CfgInfoContext;
+import org.eclipse.cdt.build.core.scannerconfig.ICfgScannerConfigBuilderInfo2Set;
+import org.eclipse.cdt.build.internal.core.scannerconfig2.CfgScannerConfigProfileManager;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
+import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.testplugin.ManagedBuildTestHelper;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+
+public class CfgScannerConfigProfileManagerTests extends BaseTestCase {
+ IProject fProject;
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite(CfgScannerConfigProfileManagerTests.class.getName());
+ suite.addTestSuite(CfgScannerConfigProfileManagerTests.class);
+ return suite;
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ fProject = ManagedBuildTestHelper.createProject("CfgScannerConfigProfileManagerProj",
+ "cdt.managedbuild.target.gnu.exe");
+ ManagedBuildTestHelper.addManagedBuildNature(fProject);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ ManagedBuildTestHelper.removeProject(fProject.getName());
+ }
+
+ /**
+ * Basic testing of Config based ScannerConfigProfile management.
+ *
+ * This test runs through some of the funcationality used by the DiscoveryTab
+ * @throws CoreException
+ */
+ public void testBasicCfgScannerConfigProfileChanges() throws CoreException {
+ ICProjectDescription prjDesc = CoreModel.getDefault().getProjectDescription(fProject);
+ ICConfigurationDescription[] cfgDescs = prjDesc.getConfigurations();
+ assertTrue(cfgDescs.length > 0);
+
+ IConfiguration cfg0 = ManagedBuildManager.getConfigurationForDescription(cfgDescs[0]);
+ ICfgScannerConfigBuilderInfo2Set scbis = CfgScannerConfigProfileManager.getCfgScannerConfigBuildInfo(cfg0);
+
+ // Test changing ICfgScannerConfigBuilderInfo2Set settings
+ boolean resCfgTypeDiscovery = scbis.isPerRcTypeDiscovery();
+ scbis.setPerRcTypeDiscovery(!resCfgTypeDiscovery);
+
+ // Test changing settings on one of the ScannerConfigBuilderInfos
+ Map<CfgInfoContext, IScannerConfigBuilderInfo2> infoMap = scbis.getInfoMap();
+ CfgInfoContext cic = infoMap.entrySet().iterator().next().getKey();
+ IScannerConfigBuilderInfo2 scbi = infoMap.entrySet().iterator().next().getValue();
+ // Get all the settings and invert them
+ boolean autoDiscovery = scbi.isAutoDiscoveryEnabled();
+ scbi.setAutoDiscoveryEnabled(!autoDiscovery);
+ boolean problemReport = scbi.isProblemReportingEnabled();
+ scbi.setProblemReportingEnabled(!problemReport);
+ boolean buildOutputParser = scbi.isBuildOutputParserEnabled();
+ scbi.setBuildOutputParserEnabled(!buildOutputParser);
+ boolean buildOutputFileAction = scbi.isBuildOutputFileActionEnabled();
+ scbi.setBuildOutputFileActionEnabled(!buildOutputFileAction);
+ String buildOutputFilePath = scbi.getBuildOutputFilePath();
+ scbi.setBuildOutputFilePath("dummyFile");
+ // Persist the changes
+ scbis.applyInfo(cic, scbi);
+
+ // Save the project description
+ CoreModel.getDefault().setProjectDescription(fProject, prjDesc);
+ fProject.close(null);
+ fProject.open(null);
+
+ // Check that the changes have persisted
+ prjDesc = CoreModel.getDefault().getProjectDescription(fProject);
+ cfg0 = ManagedBuildManager.getConfigurationForDescription(prjDesc.getConfigurations()[0]);
+ scbis = CfgScannerConfigProfileManager.getCfgScannerConfigBuildInfo(cfg0);
+ assertTrue(scbis.isPerRcTypeDiscovery() != resCfgTypeDiscovery);
+ scbi = scbis.getInfo(cic);
+ // Check that the changes have persisted
+ Assert.isTrue(autoDiscovery != scbi.isAutoDiscoveryEnabled());
+ Assert.isTrue(problemReport != scbi.isProblemReportingEnabled());
+ Assert.isTrue(buildOutputParser != scbi.isBuildOutputParserEnabled());
+ Assert.isTrue(buildOutputFileAction != scbi.isBuildOutputFileActionEnabled());
+ Assert.isTrue("dummyFile".equals(scbi.getBuildOutputFilePath()));
+
+ // Test restore defaults
+ scbis.applyInfo(cic, null);
+ // Save the project description
+ CoreModel.getDefault().setProjectDescription(fProject, prjDesc);
+ fProject.close(null);
+ fProject.open(null);
+
+ // Check settings are back to original
+ prjDesc = CoreModel.getDefault().getProjectDescription(fProject);
+ cfg0 = ManagedBuildManager.getConfigurationForDescription(prjDesc.getConfigurations()[0]);
+ scbis = CfgScannerConfigProfileManager.getCfgScannerConfigBuildInfo(cfg0);
+ scbi = scbis.getInfo(cic);
+ Assert.isTrue(autoDiscovery == scbi.isAutoDiscoveryEnabled());
+ Assert.isTrue(problemReport == scbi.isProblemReportingEnabled());
+ Assert.isTrue(buildOutputParser == scbi.isBuildOutputParserEnabled());
+ Assert.isTrue(buildOutputFileAction == scbi.isBuildOutputFileActionEnabled());
+ Assert.isTrue(buildOutputFilePath.equals(buildOutputFilePath));
+ }
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/projectmodel/tests/CProjectDescriptionSerializationTests.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/projectmodel/tests/CProjectDescriptionSerializationTests.java
index 5a2031e61a..9274031de4 100644
--- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/projectmodel/tests/CProjectDescriptionSerializationTests.java
+++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/projectmodel/tests/CProjectDescriptionSerializationTests.java
@@ -15,10 +15,13 @@ import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
+import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
+import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.core.IProjectType;
@@ -32,6 +35,8 @@ import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceDescription;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.QualifiedName;
/**
* Creates a project in a loop and checks that it is created with appropriate number
* of build configurations
@@ -139,4 +144,66 @@ public class CProjectDescriptionSerializationTests extends TestCase {
}
}
}
+
+ /**
+ * This test is intended to check persistentProperties after a project is created.
+ * @throws Exception
+ */
+ public void testPersistentProperties() throws Exception {
+ CoreModel coreModel = CoreModel.getDefault();
+ ICProjectDescriptionManager mngr = coreModel.getProjectDescriptionManager();
+
+ String pluginProjectTypeId = "cdt.managedbuild.target.gnu.cygwin.exe";
+ final String projectName = "testPersistentProperties";
+
+ {
+ // Create model project and accompanied descriptions
+ IProject project = BuildSystemTestHelper.createProject(projectName);
+ ICProjectDescription des = coreModel.createProjectDescription(project, false);
+ Assert.assertNotNull("createDescription returned null!", des);
+
+ {
+ ManagedBuildInfo info = ManagedBuildManager.createBuildInfo(project);
+ IProjectType type = ManagedBuildManager.getProjectType(pluginProjectTypeId);
+ Assert.assertNotNull("project type not found", type);
+
+ ManagedProject mProj = new ManagedProject(project, type);
+ info.setManagedProject(mProj);
+
+ IConfiguration cfgs[] = type.getConfigurations();
+ Assert.assertNotNull("configurations not found", cfgs);
+ Assert.assertTrue("no configurations found in the project type",cfgs.length>0);
+
+ for (IConfiguration configuration : cfgs) {
+ String id = ManagedBuildManager.calculateChildId(configuration.getId(), null);
+ Configuration config = new Configuration(mProj, (Configuration)configuration, id, false, true, false);
+ CConfigurationData data = config.getConfigurationData();
+ Assert.assertNotNull("data is null for created configuration", data);
+ ICConfigurationDescription cfgDes = des.createConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID, data);
+ }
+ Assert.assertEquals(2, des.getConfigurations().length);
+ }
+
+ coreModel.setProjectDescription(project, des);
+ Assert.assertEquals(project, des.getProject());
+
+ Thread.sleep(1000); // let scanner discovery participate
+ try {
+ QualifiedName pdomName = new QualifiedName(CCorePlugin.PLUGIN_ID, "pdomName");
+ QualifiedName activeCfg = new QualifiedName(CCorePlugin.PLUGIN_ID, "activeConfiguration");
+ QualifiedName settingCfg = new QualifiedName(CCorePlugin.PLUGIN_ID, "settingConfiguration");
+ QualifiedName discoveredScannerConfigFileName = new QualifiedName(MakeCorePlugin.PLUGIN_ID, "discoveredScannerConfigFileName");
+
+ assertTrue("pdomName", project.getPersistentProperties().containsKey(pdomName));
+ assertTrue("activeCfg", project.getPersistentProperties().containsKey(activeCfg));
+ assertTrue("discoveredScannerConfigFileName", project.getPersistentProperties().containsKey(discoveredScannerConfigFileName));
+ assertTrue("settingCfg", project.getPersistentProperties().containsKey(settingCfg));
+ } catch (CoreException e) {
+ Assert.fail(e.getMessage());
+ }
+
+ project.close(null);
+ }
+ }
+
}

Back to the top