Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikhail Sennikovsky2005-07-07 12:40:05 -0400
committerMikhail Sennikovsky2005-07-07 12:40:05 -0400
commit5712651d444cc799a36c35cda1d364186c4e35d4 (patch)
tree71045a1fcac1b9fa1c4a56b181a2dfe278313b83
parent5e641d7377e935d38ef463f3deb9d4654430859b (diff)
downloadorg.eclipse.cdt-5712651d444cc799a36c35cda1d364186c4e35d4.tar.gz
org.eclipse.cdt-5712651d444cc799a36c35cda1d364186c4e35d4.tar.xz
org.eclipse.cdt-5712651d444cc799a36c35cda1d364186c4e35d4.zip
Checked in some fixes for the managed project v2.1 update mechanism and project update tests
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedProjectUpdateTests.java51
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProject21.java65
2 files changed, 84 insertions, 32 deletions
diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedProjectUpdateTests.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedProjectUpdateTests.java
index b91e43b131..df084c9238 100644
--- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedProjectUpdateTests.java
+++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedProjectUpdateTests.java
@@ -20,15 +20,24 @@ import junit.framework.TestSuite;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
+import org.eclipse.cdt.managedbuilder.internal.core.ManagedMakeMessages;
import org.eclipse.cdt.managedbuilder.projectconverter.UpdateManagedProjectManager;
import org.eclipse.cdt.managedbuilder.testplugin.CTestPlugin;
import org.eclipse.cdt.managedbuilder.testplugin.ManagedBuildTestHelper;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.ui.dialogs.IOverwriteQuery;
public class ManagedProjectUpdateTests extends TestCase {
@@ -112,7 +121,7 @@ public class ManagedProjectUpdateTests extends TestCase {
if(projects == null || projects.length == 0)
return;
for(int i = 0; i < projects.length; i++){
- IProject curProject = projects[i];
+ final IProject curProject = projects[i];
//the project conversion occures the first time
//ManagedBuildManager.getBuildInfo gets called
@@ -137,16 +146,40 @@ public class ManagedProjectUpdateTests extends TestCase {
}
//check whether the project builds without errors
- try{
- curProject.build(IncrementalProjectBuilder.INCREMENTAL_BUILD,null);
- }
- catch(CoreException e){
- fail(e.getStatus().getMessage());
- }
- catch(OperationCanceledException e){
- fail("the project \"" + curProject.getName() + "\" build was cancelled, exception message: " + e.getMessage());
+ IWorkspace wsp = ResourcesPlugin.getWorkspace();
+ ISchedulingRule rule = wsp.getRuleFactory().buildRule();
+ Job buildJob = new Job("project build job"){ //$NON-NLS-1$
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ curProject.build(IncrementalProjectBuilder.INCREMENTAL_BUILD,null);
+ } catch(CoreException e){
+ fail(e.getStatus().getMessage());
+ } catch(OperationCanceledException e){
+ fail("the project \"" + curProject.getName() + "\" build was cancelled, exception message: " + e.getMessage());
+ }
+ return new Status(
+ IStatus.OK,
+ "org.eclipse.cdt.managedbuilder.core.tests",
+ IStatus.OK,
+ new String(),
+ null);
+ }
+ };
+ buildJob.setRule(rule);
+
+ buildJob.schedule();
+
+ try {
+ buildJob.join();
+ } catch (InterruptedException e) {
+ fail("the build job for the project \"" + curProject.getName() + "\" was interrupted, exception message: " + e.getMessage());
}
+ IStatus status = buildJob.getResult();
+ if(status.getCode() != IStatus.OK){
+ fail("the build job for the project \"" + curProject.getName() + "\" failed, status message: " + status.getMessage());
+ }
+
//compare the generated makefiles to their benchmarks
if (files != null && files.length > 0) {
if (i == 0) {
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProject21.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProject21.java
index 7306014e7a..34e5f7ad98 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProject21.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProject21.java
@@ -20,20 +20,22 @@ import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceProxy;
+import org.eclipse.core.resources.IResourceProxyVisitor;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.ProjectScope;
import org.eclipse.core.resources.WorkspaceJob;
-import org.eclipse.core.runtime.jobs.MultiRule;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.core.runtime.content.IContentTypeManager;
import org.eclipse.core.runtime.content.IContentTypeSettings;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.eclipse.core.runtime.jobs.MultiRule;
import org.eclipse.core.runtime.preferences.IScopeContext;
class UpdateManagedProject21 {
@@ -112,28 +114,45 @@ class UpdateManagedProject21 {
};
workspace.run(runnable, project, IWorkspace.AVOID_UPDATE, monitor);
} catch (Exception e) {} // Ignore the error - the user may have to add .c extensions to
- // the local definition of C++ file extensions
- IResource[] files = project.members(IProject.EXCLUDE_DERIVED);
- for (int i=0; i<files.length; i++) {
- String ext = files[i].getFileExtension();
- if (ext != null && ext.equals("c")) { //$NON-NLS-1$
- IContentTypeManager manager = Platform.getContentTypeManager();
- IContentType contentType = manager.getContentType("org.eclipse.cdt.core.cxxSource"); //$NON-NLS-1$
- IScopeContext projectScope = new ProjectScope(project);
- IContentTypeSettings settings = contentType.getSettings(projectScope);
- // First, copy the extensions from the "global" content type
- String[] specs = contentType.getFileSpecs(IContentType.FILE_EXTENSION_SPEC);
- for (int j = 0; j < specs.length; j++) {
- settings.addFileSpec(specs[j], IContentType.FILE_EXTENSION_SPEC);
+ // the local definition of C++ file extensions
+
+ final boolean found[] = new boolean[1];
+ project.accept(new IResourceProxyVisitor(){
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.resources.IResourceProxyVisitor#visit(org.eclipse.core.resources.IResourceProxy)
+ */
+ public boolean visit(IResourceProxy proxy) throws CoreException {
+ if(found[0] || proxy.isDerived())
+ return false;
+ if(proxy.getType() == IResource.FILE){
+ String ext = proxy.requestFullPath().getFileExtension();
+ if (ext != null && "c".equals(ext)) { //$NON-NLS-1$
+ found[0] = true;
+ }
+ return false;
+ }
+ return true;
}
- specs = contentType.getFileSpecs(IContentType.FILE_NAME_SPEC);
- for (int j = 0; j < specs.length; j++) {
- settings.addFileSpec(specs[j], IContentType.FILE_NAME_SPEC);
- }
- // Add the .c extension
- settings.addFileSpec("c", IContentType.FILE_EXTENSION_SPEC); //$NON-NLS-1$
- break;
+ },
+ IResource.NONE);
+
+ if(found[0]){
+ IContentTypeManager manager = Platform.getContentTypeManager();
+ IContentType contentType = manager.getContentType("org.eclipse.cdt.core.cxxSource"); //$NON-NLS-1$
+ IScopeContext projectScope = new ProjectScope(project);
+ IContentTypeSettings settings = contentType.getSettings(projectScope);
+ // First, copy the extensions from the "global" content type
+ String[] specs = contentType.getFileSpecs(IContentType.FILE_EXTENSION_SPEC);
+ for (int j = 0; j < specs.length; j++) {
+ settings.addFileSpec(specs[j], IContentType.FILE_EXTENSION_SPEC);
}
+ specs = contentType.getFileSpecs(IContentType.FILE_NAME_SPEC);
+ for (int j = 0; j < specs.length; j++) {
+ settings.addFileSpec(specs[j], IContentType.FILE_NAME_SPEC);
+ }
+ // Add the .c extension
+ settings.addFileSpec("c", IContentType.FILE_EXTENSION_SPEC); //$NON-NLS-1$
}
} catch (CoreException e) {
// Ignore errors. User will need to manually add .c extension if necessary

Back to the top