1
0
Fork 0
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:
Mikhail Sennikovsky 2005-07-07 16:40:05 +00:00
parent 5e641d7377
commit 5712651d44
2 changed files with 84 additions and 32 deletions

View file

@ -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,15 +146,39 @@ public class ManagedProjectUpdateTests extends TestCase {
}
//check whether the project builds without errors
try{
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){
} catch(CoreException e){
fail(e.getStatus().getMessage());
}
catch(OperationCanceledException e){
} 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) {

View file

@ -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 {
@ -113,10 +115,29 @@ 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$
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;
}
},
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);
@ -132,8 +153,6 @@ class UpdateManagedProject21 {
}
// Add the .c extension
settings.addFileSpec("c", IContentType.FILE_EXTENSION_SPEC); //$NON-NLS-1$
break;
}
}
} catch (CoreException e) {
// Ignore errors. User will need to manually add .c extension if necessary