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.IManagedBuildInfo;
|
||||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
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.projectconverter.UpdateManagedProjectManager;
|
||||||
import org.eclipse.cdt.managedbuilder.testplugin.CTestPlugin;
|
import org.eclipse.cdt.managedbuilder.testplugin.CTestPlugin;
|
||||||
import org.eclipse.cdt.managedbuilder.testplugin.ManagedBuildTestHelper;
|
import org.eclipse.cdt.managedbuilder.testplugin.ManagedBuildTestHelper;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.resources.IWorkspace;
|
||||||
import org.eclipse.core.resources.IncrementalProjectBuilder;
|
import org.eclipse.core.resources.IncrementalProjectBuilder;
|
||||||
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
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.OperationCanceledException;
|
||||||
import org.eclipse.core.runtime.Path;
|
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;
|
import org.eclipse.ui.dialogs.IOverwriteQuery;
|
||||||
|
|
||||||
public class ManagedProjectUpdateTests extends TestCase {
|
public class ManagedProjectUpdateTests extends TestCase {
|
||||||
|
@ -112,7 +121,7 @@ public class ManagedProjectUpdateTests extends TestCase {
|
||||||
if(projects == null || projects.length == 0)
|
if(projects == null || projects.length == 0)
|
||||||
return;
|
return;
|
||||||
for(int i = 0; i < projects.length; i++){
|
for(int i = 0; i < projects.length; i++){
|
||||||
IProject curProject = projects[i];
|
final IProject curProject = projects[i];
|
||||||
|
|
||||||
//the project conversion occures the first time
|
//the project conversion occures the first time
|
||||||
//ManagedBuildManager.getBuildInfo gets called
|
//ManagedBuildManager.getBuildInfo gets called
|
||||||
|
@ -137,14 +146,38 @@ public class ManagedProjectUpdateTests extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
//check whether the project builds without errors
|
//check whether the project builds without errors
|
||||||
try{
|
IWorkspace wsp = ResourcesPlugin.getWorkspace();
|
||||||
curProject.build(IncrementalProjectBuilder.INCREMENTAL_BUILD,null);
|
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());
|
||||||
}
|
}
|
||||||
catch(CoreException e){
|
|
||||||
fail(e.getStatus().getMessage());
|
IStatus status = buildJob.getResult();
|
||||||
}
|
if(status.getCode() != IStatus.OK){
|
||||||
catch(OperationCanceledException e){
|
fail("the build job for the project \"" + curProject.getName() + "\" failed, status message: " + status.getMessage());
|
||||||
fail("the project \"" + curProject.getName() + "\" build was cancelled, exception message: " + e.getMessage());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//compare the generated makefiles to their benchmarks
|
//compare the generated makefiles to their benchmarks
|
||||||
|
|
|
@ -20,20 +20,22 @@ import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
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.IResourceProxy;
|
||||||
|
import org.eclipse.core.resources.IResourceProxyVisitor;
|
||||||
import org.eclipse.core.resources.IWorkspace;
|
import org.eclipse.core.resources.IWorkspace;
|
||||||
import org.eclipse.core.resources.IWorkspaceRunnable;
|
import org.eclipse.core.resources.IWorkspaceRunnable;
|
||||||
import org.eclipse.core.resources.ProjectScope;
|
import org.eclipse.core.resources.ProjectScope;
|
||||||
import org.eclipse.core.resources.WorkspaceJob;
|
import org.eclipse.core.resources.WorkspaceJob;
|
||||||
import org.eclipse.core.runtime.jobs.MultiRule;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
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.Platform;
|
||||||
|
import org.eclipse.core.runtime.Status;
|
||||||
import org.eclipse.core.runtime.content.IContentType;
|
import org.eclipse.core.runtime.content.IContentType;
|
||||||
import org.eclipse.core.runtime.content.IContentTypeManager;
|
import org.eclipse.core.runtime.content.IContentTypeManager;
|
||||||
import org.eclipse.core.runtime.content.IContentTypeSettings;
|
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;
|
import org.eclipse.core.runtime.preferences.IScopeContext;
|
||||||
|
|
||||||
class UpdateManagedProject21 {
|
class UpdateManagedProject21 {
|
||||||
|
@ -113,27 +115,44 @@ class UpdateManagedProject21 {
|
||||||
workspace.run(runnable, project, IWorkspace.AVOID_UPDATE, monitor);
|
workspace.run(runnable, project, IWorkspace.AVOID_UPDATE, monitor);
|
||||||
} catch (Exception e) {} // Ignore the error - the user may have to add .c extensions to
|
} catch (Exception e) {} // Ignore the error - the user may have to add .c extensions to
|
||||||
// the local definition of C++ file extensions
|
// the local definition of C++ file extensions
|
||||||
IResource[] files = project.members(IProject.EXCLUDE_DERIVED);
|
|
||||||
for (int i=0; i<files.length; i++) {
|
final boolean found[] = new boolean[1];
|
||||||
String ext = files[i].getFileExtension();
|
project.accept(new IResourceProxyVisitor(){
|
||||||
if (ext != null && ext.equals("c")) { //$NON-NLS-1$
|
|
||||||
IContentTypeManager manager = Platform.getContentTypeManager();
|
/* (non-Javadoc)
|
||||||
IContentType contentType = manager.getContentType("org.eclipse.cdt.core.cxxSource"); //$NON-NLS-1$
|
* @see org.eclipse.core.resources.IResourceProxyVisitor#visit(org.eclipse.core.resources.IResourceProxy)
|
||||||
IScopeContext projectScope = new ProjectScope(project);
|
*/
|
||||||
IContentTypeSettings settings = contentType.getSettings(projectScope);
|
public boolean visit(IResourceProxy proxy) throws CoreException {
|
||||||
// First, copy the extensions from the "global" content type
|
if(found[0] || proxy.isDerived())
|
||||||
String[] specs = contentType.getFileSpecs(IContentType.FILE_EXTENSION_SPEC);
|
return false;
|
||||||
for (int j = 0; j < specs.length; j++) {
|
if(proxy.getType() == IResource.FILE){
|
||||||
settings.addFileSpec(specs[j], IContentType.FILE_EXTENSION_SPEC);
|
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++) {
|
IResource.NONE);
|
||||||
settings.addFileSpec(specs[j], IContentType.FILE_NAME_SPEC);
|
|
||||||
}
|
if(found[0]){
|
||||||
// Add the .c extension
|
IContentTypeManager manager = Platform.getContentTypeManager();
|
||||||
settings.addFileSpec("c", IContentType.FILE_EXTENSION_SPEC); //$NON-NLS-1$
|
IContentType contentType = manager.getContentType("org.eclipse.cdt.core.cxxSource"); //$NON-NLS-1$
|
||||||
break;
|
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) {
|
} catch (CoreException e) {
|
||||||
// Ignore errors. User will need to manually add .c extension if necessary
|
// Ignore errors. User will need to manually add .c extension if necessary
|
||||||
|
|
Loading…
Add table
Reference in a new issue