mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Checked in some fixes for the managed project v2.1 update mechanism and project update tests
This commit is contained in:
parent
5e641d7377
commit
5712651d44
2 changed files with 84 additions and 32 deletions
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue