mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
fixed up test to prevent some deadlocking
This commit is contained in:
parent
c2cc81a395
commit
3f5fd52006
2 changed files with 68 additions and 45 deletions
|
@ -32,8 +32,10 @@ import org.eclipse.cdt.make.core.MakeScannerProvider;
|
|||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||
import org.eclipse.core.resources.IWorkspaceRunnable;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
|
||||
|
@ -45,12 +47,12 @@ public class StandardBuildTests extends TestCase {
|
|||
private static final String OVR_BUILD_ARGS = "-f";
|
||||
private static final String OVR_BUILD_COMMAND = "/home/tester/bin/nmake";
|
||||
private static final String OVR_BUILD_LOCATION = "src";
|
||||
private static final String[] OVR_INC_PATHS = {"/test", "C:\\windows", "//dev/home/include"};
|
||||
private static final String[] OVR_INC_PATHS = {new Path("/test").toOSString(), new Path("C:\\windows").toOSString(), new Path("//dev/home/include").toOSString()};
|
||||
private static final String[] OVR_PREPROC_SYMS = {"_RELEASE", "NO ", " YES=1"};
|
||||
private static final String PROJECT_NAME = "StandardBuildTest";
|
||||
|
||||
private class ScannerListener implements IScannerInfoChangeListener {
|
||||
private final String[] expectedPaths = {"/usr/include", "/home/tester/include", "/opt/gnome/include"};
|
||||
private final String[] expectedPaths = {new Path("/usr/include").toOSString(), new Path("/home/tester/include").toOSString(), new Path("/opt/gnome/include").toOSString()};
|
||||
private final String[] expectedSymbols = {"_DEBUG", "TRUE=1", "FALSE ", ""};
|
||||
private boolean bNotified = false;
|
||||
|
||||
|
@ -144,16 +146,21 @@ public class StandardBuildTests extends TestCase {
|
|||
private void checkOverriddenProjectSettings(IProject project) throws Exception {
|
||||
assertNotNull(project);
|
||||
|
||||
MakeScannerInfo scannerInfo = MakeScannerProvider.getDefault().getMakeScannerInfo(project, true);
|
||||
IScannerInfo scannerInfo = CCorePlugin.getDefault().getScannerInfoProvider(project).getScannerInformation(project);
|
||||
assertNotNull(scannerInfo);
|
||||
String[] includePaths = scannerInfo.getIncludePaths();
|
||||
assertNotNull(includePaths);
|
||||
assertEquals(3, includePaths.length);
|
||||
assertTrue(Arrays.equals(includePaths, OVR_INC_PATHS));
|
||||
String[] definedSymbols = scannerInfo.getPreprocessorSymbols();
|
||||
Map definedSymbols = scannerInfo.getDefinedSymbols();
|
||||
assertNotNull(definedSymbols);
|
||||
assertEquals(3, definedSymbols.length);
|
||||
assertTrue(Arrays.equals(definedSymbols, OVR_PREPROC_SYMS));
|
||||
assertEquals(3, definedSymbols.size());
|
||||
assertTrue(definedSymbols.containsKey("_RELEASE"));
|
||||
assertEquals("", definedSymbols.get("_RELEASE"));
|
||||
assertTrue(definedSymbols.containsKey("YES"));
|
||||
assertEquals("1", definedSymbols.get("YES"));
|
||||
assertTrue(definedSymbols.containsKey("NO"));
|
||||
assertEquals("", definedSymbols.get("NO"));
|
||||
|
||||
// Check the rest of the project information
|
||||
IMakeBuilderInfo builderInfo = MakeCorePlugin.createBuildInfo(project, MakeBuilder.BUILDER_ID);
|
||||
|
@ -172,20 +179,27 @@ public class StandardBuildTests extends TestCase {
|
|||
* @return
|
||||
* @throws CoreException
|
||||
*/
|
||||
private IProject createProject(String name) throws CoreException {
|
||||
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
|
||||
IProject project = root.getProject(name);
|
||||
if (!project.exists()) {
|
||||
project.create(null);
|
||||
} else {
|
||||
project.refreshLocal(IResource.DEPTH_INFINITE, null);
|
||||
}
|
||||
|
||||
if (!project.isOpen()) {
|
||||
project.open(null);
|
||||
}
|
||||
CCorePlugin.getDefault().convertProjectToC(project, new NullProgressMonitor(), MakeCorePlugin.MAKE_PROJECT_ID);
|
||||
return project;
|
||||
private IProject createProject(final String name) throws CoreException {
|
||||
final Object[] result = new Object[1];
|
||||
ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
|
||||
|
||||
public void run(IProgressMonitor monitor) throws CoreException {
|
||||
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
|
||||
IProject project = root.getProject(name);
|
||||
if (!project.exists()) {
|
||||
project.create(null);
|
||||
} else {
|
||||
project.refreshLocal(IResource.DEPTH_INFINITE, null);
|
||||
}
|
||||
|
||||
if (!project.isOpen()) {
|
||||
project.open(null);
|
||||
}
|
||||
CCorePlugin.getDefault().convertProjectToC(project, new NullProgressMonitor(), MakeCorePlugin.MAKE_PROJECT_ID);
|
||||
result[0] = project;
|
||||
}
|
||||
}, null);
|
||||
return (IProject)result[0];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
***********************************************************************/
|
||||
***********************************************************************/
|
||||
|
||||
package org.eclipse.cdt.core.cdescriptor.tests;
|
||||
|
||||
|
@ -26,6 +26,7 @@ import org.eclipse.core.resources.IProject;
|
|||
import org.eclipse.core.resources.IProjectDescription;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||
import org.eclipse.core.resources.IWorkspaceRunnable;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.w3c.dom.Element;
|
||||
|
@ -43,7 +44,7 @@ public class CDescriptorTests extends TestCase {
|
|||
static IProject fProject;
|
||||
static CDescriptorListener listener = new CDescriptorListener();
|
||||
static CDescriptorEvent fLastEvent;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor for CDescriptorTest.
|
||||
*
|
||||
|
@ -91,28 +92,32 @@ public class CDescriptorTests extends TestCase {
|
|||
|
||||
static public class CDescriptorListener implements ICDescriptorListener {
|
||||
|
||||
|
||||
public void descriptorChanged(CDescriptorEvent event) {
|
||||
fLastEvent = event;
|
||||
}
|
||||
}
|
||||
|
||||
static void oneTimeSetUp() throws Exception {
|
||||
IWorkspaceRoot root = CTestPlugin.getWorkspace().getRoot();
|
||||
IProject project = root.getProject("testDescriptorProject");
|
||||
if (!project.exists()) {
|
||||
project.create(null);
|
||||
} else {
|
||||
project.refreshLocal(IResource.DEPTH_INFINITE, null);
|
||||
}
|
||||
if (!project.isOpen()) {
|
||||
project.open(null);
|
||||
}
|
||||
CCorePlugin.getDefault().getCDescriptorManager().addDescriptorListener(listener);
|
||||
if (!project.hasNature(CProjectNature.C_NATURE_ID)) {
|
||||
addNatureToProject(project, CProjectNature.C_NATURE_ID, null);
|
||||
}
|
||||
fProject = project;
|
||||
CTestPlugin.getWorkspace().run(new IWorkspaceRunnable() {
|
||||
|
||||
public void run(IProgressMonitor monitor) throws CoreException {
|
||||
IWorkspaceRoot root = CTestPlugin.getWorkspace().getRoot();
|
||||
IProject project = root.getProject("testDescriptorProject");
|
||||
if (!project.exists()) {
|
||||
project.create(null);
|
||||
} else {
|
||||
project.refreshLocal(IResource.DEPTH_INFINITE, null);
|
||||
}
|
||||
if (!project.isOpen()) {
|
||||
project.open(null);
|
||||
}
|
||||
CCorePlugin.getDefault().getCDescriptorManager().addDescriptorListener(listener);
|
||||
if (!project.hasNature(CProjectNature.C_NATURE_ID)) {
|
||||
addNatureToProject(project, CProjectNature.C_NATURE_ID, null);
|
||||
}
|
||||
fProject = project;
|
||||
}
|
||||
}, null);
|
||||
}
|
||||
|
||||
static void oneTimeTearDown() throws Exception {
|
||||
|
@ -120,8 +125,12 @@ public class CDescriptorTests extends TestCase {
|
|||
}
|
||||
|
||||
public void testDescriptorCreation() throws Exception {
|
||||
CCorePlugin.getDefault().mapCProjectOwner(fProject, projectId, false);
|
||||
CTestPlugin.getWorkspace().run(new IWorkspaceRunnable() {
|
||||
|
||||
public void run(IProgressMonitor monitor) throws CoreException {
|
||||
CCorePlugin.getDefault().mapCProjectOwner(fProject, projectId, false);
|
||||
}
|
||||
}, null);
|
||||
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject);
|
||||
|
||||
Assert.assertNotNull(fLastEvent);
|
||||
|
@ -129,7 +138,7 @@ public class CDescriptorTests extends TestCase {
|
|||
Assert.assertEquals(fLastEvent.getType(), CDescriptorEvent.CDTPROJECT_ADDED);
|
||||
Assert.assertEquals(fLastEvent.getFlags(), 0);
|
||||
fLastEvent = null;
|
||||
|
||||
|
||||
Assert.assertEquals(fProject, desc.getProject());
|
||||
Assert.assertEquals("*", desc.getPlatform());
|
||||
}
|
||||
|
@ -143,9 +152,9 @@ public class CDescriptorTests extends TestCase {
|
|||
}
|
||||
|
||||
public void testDescriptorConversion() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void testExtensionCreation() throws Exception {
|
||||
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject);
|
||||
ICExtensionReference extRef = desc.create("org.eclipse.cdt.testextension", "org.eclipse.cdt.testextensionID");
|
||||
|
@ -155,7 +164,7 @@ public class CDescriptorTests extends TestCase {
|
|||
Assert.assertEquals(fLastEvent.getType(), CDescriptorEvent.CDTPROJECT_CHANGED);
|
||||
Assert.assertEquals(fLastEvent.getFlags(), CDescriptorEvent.EXTENSION_CHANGED);
|
||||
fLastEvent = null;
|
||||
|
||||
|
||||
Assert.assertEquals("org.eclipse.cdt.testextension", extRef.getExtension());
|
||||
Assert.assertEquals("org.eclipse.cdt.testextensionID", extRef.getID());
|
||||
}
|
||||
|
@ -178,7 +187,7 @@ public class CDescriptorTests extends TestCase {
|
|||
Assert.assertEquals(fLastEvent.getType(), CDescriptorEvent.CDTPROJECT_CHANGED);
|
||||
Assert.assertEquals(fLastEvent.getFlags(), 0);
|
||||
fLastEvent = null;
|
||||
|
||||
|
||||
Assert.assertEquals("testValue", extRef[0].getExtensionData("testKey"));
|
||||
extRef[0].setExtensionData("testKey", null);
|
||||
Assert.assertEquals(null, extRef[0].getExtensionData("testKey"));
|
||||
|
@ -224,4 +233,4 @@ public class CDescriptorTests extends TestCase {
|
|||
Assert.assertEquals(fLastEvent.getFlags(), 0);
|
||||
fLastEvent = null;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue