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.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||||
|
import org.eclipse.core.resources.IWorkspaceRunnable;
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
import org.eclipse.core.runtime.Path;
|
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_ARGS = "-f";
|
||||||
private static final String OVR_BUILD_COMMAND = "/home/tester/bin/nmake";
|
private static final String OVR_BUILD_COMMAND = "/home/tester/bin/nmake";
|
||||||
private static final String OVR_BUILD_LOCATION = "src";
|
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[] OVR_PREPROC_SYMS = {"_RELEASE", "NO ", " YES=1"};
|
||||||
private static final String PROJECT_NAME = "StandardBuildTest";
|
private static final String PROJECT_NAME = "StandardBuildTest";
|
||||||
|
|
||||||
private class ScannerListener implements IScannerInfoChangeListener {
|
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 final String[] expectedSymbols = {"_DEBUG", "TRUE=1", "FALSE ", ""};
|
||||||
private boolean bNotified = false;
|
private boolean bNotified = false;
|
||||||
|
|
||||||
|
@ -144,16 +146,21 @@ public class StandardBuildTests extends TestCase {
|
||||||
private void checkOverriddenProjectSettings(IProject project) throws Exception {
|
private void checkOverriddenProjectSettings(IProject project) throws Exception {
|
||||||
assertNotNull(project);
|
assertNotNull(project);
|
||||||
|
|
||||||
MakeScannerInfo scannerInfo = MakeScannerProvider.getDefault().getMakeScannerInfo(project, true);
|
IScannerInfo scannerInfo = CCorePlugin.getDefault().getScannerInfoProvider(project).getScannerInformation(project);
|
||||||
assertNotNull(scannerInfo);
|
assertNotNull(scannerInfo);
|
||||||
String[] includePaths = scannerInfo.getIncludePaths();
|
String[] includePaths = scannerInfo.getIncludePaths();
|
||||||
assertNotNull(includePaths);
|
assertNotNull(includePaths);
|
||||||
assertEquals(3, includePaths.length);
|
assertEquals(3, includePaths.length);
|
||||||
assertTrue(Arrays.equals(includePaths, OVR_INC_PATHS));
|
assertTrue(Arrays.equals(includePaths, OVR_INC_PATHS));
|
||||||
String[] definedSymbols = scannerInfo.getPreprocessorSymbols();
|
Map definedSymbols = scannerInfo.getDefinedSymbols();
|
||||||
assertNotNull(definedSymbols);
|
assertNotNull(definedSymbols);
|
||||||
assertEquals(3, definedSymbols.length);
|
assertEquals(3, definedSymbols.size());
|
||||||
assertTrue(Arrays.equals(definedSymbols, OVR_PREPROC_SYMS));
|
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
|
// Check the rest of the project information
|
||||||
IMakeBuilderInfo builderInfo = MakeCorePlugin.createBuildInfo(project, MakeBuilder.BUILDER_ID);
|
IMakeBuilderInfo builderInfo = MakeCorePlugin.createBuildInfo(project, MakeBuilder.BUILDER_ID);
|
||||||
|
@ -172,20 +179,27 @@ public class StandardBuildTests extends TestCase {
|
||||||
* @return
|
* @return
|
||||||
* @throws CoreException
|
* @throws CoreException
|
||||||
*/
|
*/
|
||||||
private IProject createProject(String name) throws CoreException {
|
private IProject createProject(final String name) throws CoreException {
|
||||||
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
|
final Object[] result = new Object[1];
|
||||||
IProject project = root.getProject(name);
|
ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
|
||||||
if (!project.exists()) {
|
|
||||||
project.create(null);
|
public void run(IProgressMonitor monitor) throws CoreException {
|
||||||
} else {
|
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
|
||||||
project.refreshLocal(IResource.DEPTH_INFINITE, null);
|
IProject project = root.getProject(name);
|
||||||
}
|
if (!project.exists()) {
|
||||||
|
project.create(null);
|
||||||
if (!project.isOpen()) {
|
} else {
|
||||||
project.open(null);
|
project.refreshLocal(IResource.DEPTH_INFINITE, null);
|
||||||
}
|
}
|
||||||
CCorePlugin.getDefault().convertProjectToC(project, new NullProgressMonitor(), MakeCorePlugin.MAKE_PROJECT_ID);
|
|
||||||
return project;
|
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
|
* are made available under the terms of the Common Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/cpl-v10.html
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.core.cdescriptor.tests;
|
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.IProjectDescription;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||||
|
import org.eclipse.core.resources.IWorkspaceRunnable;
|
||||||
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.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
@ -43,7 +44,7 @@ public class CDescriptorTests extends TestCase {
|
||||||
static IProject fProject;
|
static IProject fProject;
|
||||||
static CDescriptorListener listener = new CDescriptorListener();
|
static CDescriptorListener listener = new CDescriptorListener();
|
||||||
static CDescriptorEvent fLastEvent;
|
static CDescriptorEvent fLastEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for CDescriptorTest.
|
* Constructor for CDescriptorTest.
|
||||||
*
|
*
|
||||||
|
@ -91,28 +92,32 @@ public class CDescriptorTests extends TestCase {
|
||||||
|
|
||||||
static public class CDescriptorListener implements ICDescriptorListener {
|
static public class CDescriptorListener implements ICDescriptorListener {
|
||||||
|
|
||||||
|
|
||||||
public void descriptorChanged(CDescriptorEvent event) {
|
public void descriptorChanged(CDescriptorEvent event) {
|
||||||
fLastEvent = event;
|
fLastEvent = event;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void oneTimeSetUp() throws Exception {
|
static void oneTimeSetUp() throws Exception {
|
||||||
IWorkspaceRoot root = CTestPlugin.getWorkspace().getRoot();
|
CTestPlugin.getWorkspace().run(new IWorkspaceRunnable() {
|
||||||
IProject project = root.getProject("testDescriptorProject");
|
|
||||||
if (!project.exists()) {
|
public void run(IProgressMonitor monitor) throws CoreException {
|
||||||
project.create(null);
|
IWorkspaceRoot root = CTestPlugin.getWorkspace().getRoot();
|
||||||
} else {
|
IProject project = root.getProject("testDescriptorProject");
|
||||||
project.refreshLocal(IResource.DEPTH_INFINITE, null);
|
if (!project.exists()) {
|
||||||
}
|
project.create(null);
|
||||||
if (!project.isOpen()) {
|
} else {
|
||||||
project.open(null);
|
project.refreshLocal(IResource.DEPTH_INFINITE, null);
|
||||||
}
|
}
|
||||||
CCorePlugin.getDefault().getCDescriptorManager().addDescriptorListener(listener);
|
if (!project.isOpen()) {
|
||||||
if (!project.hasNature(CProjectNature.C_NATURE_ID)) {
|
project.open(null);
|
||||||
addNatureToProject(project, CProjectNature.C_NATURE_ID, null);
|
}
|
||||||
}
|
CCorePlugin.getDefault().getCDescriptorManager().addDescriptorListener(listener);
|
||||||
fProject = project;
|
if (!project.hasNature(CProjectNature.C_NATURE_ID)) {
|
||||||
|
addNatureToProject(project, CProjectNature.C_NATURE_ID, null);
|
||||||
|
}
|
||||||
|
fProject = project;
|
||||||
|
}
|
||||||
|
}, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void oneTimeTearDown() throws Exception {
|
static void oneTimeTearDown() throws Exception {
|
||||||
|
@ -120,8 +125,12 @@ public class CDescriptorTests extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDescriptorCreation() throws Exception {
|
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);
|
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject);
|
||||||
|
|
||||||
Assert.assertNotNull(fLastEvent);
|
Assert.assertNotNull(fLastEvent);
|
||||||
|
@ -129,7 +138,7 @@ public class CDescriptorTests extends TestCase {
|
||||||
Assert.assertEquals(fLastEvent.getType(), CDescriptorEvent.CDTPROJECT_ADDED);
|
Assert.assertEquals(fLastEvent.getType(), CDescriptorEvent.CDTPROJECT_ADDED);
|
||||||
Assert.assertEquals(fLastEvent.getFlags(), 0);
|
Assert.assertEquals(fLastEvent.getFlags(), 0);
|
||||||
fLastEvent = null;
|
fLastEvent = null;
|
||||||
|
|
||||||
Assert.assertEquals(fProject, desc.getProject());
|
Assert.assertEquals(fProject, desc.getProject());
|
||||||
Assert.assertEquals("*", desc.getPlatform());
|
Assert.assertEquals("*", desc.getPlatform());
|
||||||
}
|
}
|
||||||
|
@ -143,9 +152,9 @@ public class CDescriptorTests extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDescriptorConversion() {
|
public void testDescriptorConversion() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testExtensionCreation() throws Exception {
|
public void testExtensionCreation() throws Exception {
|
||||||
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject);
|
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject);
|
||||||
ICExtensionReference extRef = desc.create("org.eclipse.cdt.testextension", "org.eclipse.cdt.testextensionID");
|
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.getType(), CDescriptorEvent.CDTPROJECT_CHANGED);
|
||||||
Assert.assertEquals(fLastEvent.getFlags(), CDescriptorEvent.EXTENSION_CHANGED);
|
Assert.assertEquals(fLastEvent.getFlags(), CDescriptorEvent.EXTENSION_CHANGED);
|
||||||
fLastEvent = null;
|
fLastEvent = null;
|
||||||
|
|
||||||
Assert.assertEquals("org.eclipse.cdt.testextension", extRef.getExtension());
|
Assert.assertEquals("org.eclipse.cdt.testextension", extRef.getExtension());
|
||||||
Assert.assertEquals("org.eclipse.cdt.testextensionID", extRef.getID());
|
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.getType(), CDescriptorEvent.CDTPROJECT_CHANGED);
|
||||||
Assert.assertEquals(fLastEvent.getFlags(), 0);
|
Assert.assertEquals(fLastEvent.getFlags(), 0);
|
||||||
fLastEvent = null;
|
fLastEvent = null;
|
||||||
|
|
||||||
Assert.assertEquals("testValue", extRef[0].getExtensionData("testKey"));
|
Assert.assertEquals("testValue", extRef[0].getExtensionData("testKey"));
|
||||||
extRef[0].setExtensionData("testKey", null);
|
extRef[0].setExtensionData("testKey", null);
|
||||||
Assert.assertEquals(null, extRef[0].getExtensionData("testKey"));
|
Assert.assertEquals(null, extRef[0].getExtensionData("testKey"));
|
||||||
|
@ -224,4 +233,4 @@ public class CDescriptorTests extends TestCase {
|
||||||
Assert.assertEquals(fLastEvent.getFlags(), 0);
|
Assert.assertEquals(fLastEvent.getFlags(), 0);
|
||||||
fLastEvent = null;
|
fLastEvent = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue