mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Bug 157992 - Fixed up the PDOMTests to be more deterministic.
This commit is contained in:
parent
f24c4034a9
commit
bc7e82f186
6 changed files with 60 additions and 28 deletions
|
@ -31,15 +31,21 @@ import org.eclipse.core.runtime.NullProgressMonitor;
|
|||
*/
|
||||
public class ClassTests extends PDOMTestBase {
|
||||
|
||||
protected ICProject project;
|
||||
|
||||
protected PDOM pdom;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
project = createProject("classTests");
|
||||
if (pdom == null) {
|
||||
ICProject project = createProject("classTests");
|
||||
pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM(project);
|
||||
}
|
||||
pdom.acquireReadLock();
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
pdom.releaseReadLock();
|
||||
}
|
||||
|
||||
public void test1() throws Exception {
|
||||
PDOM pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM(project);
|
||||
|
||||
IBinding[] Bs = pdom.findBindings(Pattern.compile("B"), new NullProgressMonitor());
|
||||
assertEquals(1, Bs.length);
|
||||
ICPPClassType B = (ICPPClassType)Bs[0];
|
||||
|
@ -54,8 +60,6 @@ public class ClassTests extends PDOMTestBase {
|
|||
}
|
||||
|
||||
public void testNested() throws Exception {
|
||||
PDOM pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM(project);
|
||||
|
||||
IBinding[] bindings = pdom.findBindings(Pattern.compile("NestedA"), new NullProgressMonitor());
|
||||
assertEquals(1, bindings.length);
|
||||
ICPPClassType NestedA = (ICPPClassType)bindings[0];
|
||||
|
@ -79,8 +83,6 @@ public class ClassTests extends PDOMTestBase {
|
|||
}
|
||||
|
||||
public void failedTest147903() throws Exception {
|
||||
PDOM pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM(project);
|
||||
|
||||
IBinding[] bindings = pdom.findBindings(Pattern.compile("pr147903"), new NullProgressMonitor());
|
||||
assertEquals(1, bindings.length);
|
||||
ICPPNamespaceScope ns = ((ICPPNamespace)bindings[0]).getNamespaceScope();
|
||||
|
|
|
@ -28,15 +28,22 @@ import org.eclipse.core.runtime.NullProgressMonitor;
|
|||
*/
|
||||
public class EnumerationTests extends PDOMTestBase {
|
||||
|
||||
protected ICProject project;
|
||||
|
||||
protected PDOM pdom;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
project = createProject("enumerationTests");
|
||||
if (pdom == null) {
|
||||
ICProject project = createProject("enumerationTests");
|
||||
pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM(project);
|
||||
}
|
||||
pdom.acquireReadLock();
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
pdom.releaseReadLock();
|
||||
}
|
||||
|
||||
public void testC() throws Exception {
|
||||
// Check bindings
|
||||
PDOM pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM(project);
|
||||
Pattern pattern = Pattern.compile("TestCEnum");
|
||||
IBinding[] bindings = pdom.findBindings(pattern, new NullProgressMonitor());
|
||||
assertEquals(1, bindings.length);
|
||||
|
@ -69,7 +76,6 @@ public class EnumerationTests extends PDOMTestBase {
|
|||
|
||||
public void testCPP() throws Exception {
|
||||
// Check bindings
|
||||
PDOM pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM(project);
|
||||
Pattern pattern = Pattern.compile("TestCPPEnum");
|
||||
IBinding[] bindings = pdom.findBindings(pattern, new NullProgressMonitor());
|
||||
assertEquals(1, bindings.length);
|
||||
|
|
|
@ -10,9 +10,6 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.pdom.tests;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
|
@ -26,13 +23,21 @@ import org.eclipse.core.runtime.IPath;
|
|||
public class IncludesTests extends PDOMTestBase {
|
||||
|
||||
protected ICProject project;
|
||||
|
||||
protected PDOM pdom;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
project = createProject("includesTests");
|
||||
if (pdom == null) {
|
||||
project = createProject("includesTests");
|
||||
pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM(project);
|
||||
}
|
||||
pdom.acquireReadLock();
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
pdom.releaseReadLock();
|
||||
}
|
||||
|
||||
public void test1() throws Exception {
|
||||
PDOM pdom = (PDOM) CCorePlugin.getPDOMManager().getPDOM(project);
|
||||
IPath loc = project.getProject().getLocation().append("I2.h");
|
||||
PDOMFile file = pdom.getFile(loc.toOSString());
|
||||
assertNotNull(file);
|
||||
|
|
|
@ -17,10 +17,12 @@ import junit.framework.TestCase;
|
|||
import org.eclipse.cdt.core.CCProjectNature;
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.CProjectNature;
|
||||
import org.eclipse.cdt.core.dom.IPDOMManager;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.testplugin.CTestPlugin;
|
||||
import org.eclipse.cdt.internal.core.pdom.indexer.fast.PDOMFastIndexer;
|
||||
import org.eclipse.cdt.internal.core.pdom.indexer.fast.PDOMFastReindex;
|
||||
import org.eclipse.cdt.internal.core.pdom.indexer.nulli.PDOMNullIndexer;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IProjectDescription;
|
||||
import org.eclipse.core.resources.IWorkspace;
|
||||
|
@ -53,6 +55,15 @@ public class PDOMTestBase extends TestCase {
|
|||
final ICProject cprojects[] = new ICProject[1];
|
||||
workspace.run(new IWorkspaceRunnable() {
|
||||
public void run(IProgressMonitor monitor) throws CoreException {
|
||||
IPDOMManager manager = CCorePlugin.getPDOMManager();
|
||||
// Make sure the default is no indexer
|
||||
String oldDefault = manager.getDefaultIndexerId();
|
||||
if (!PDOMNullIndexer.ID.equals(oldDefault))
|
||||
manager.setDefaultIndexerId(PDOMNullIndexer.ID);
|
||||
else
|
||||
oldDefault = null;
|
||||
|
||||
// Create the project
|
||||
IProject project = workspace.getRoot().getProject(projectName);
|
||||
project.create(monitor);
|
||||
project.open(monitor);
|
||||
|
@ -89,6 +100,10 @@ public class PDOMTestBase extends TestCase {
|
|||
indexer.setProject(cproject);
|
||||
PDOMFastReindex reindex = new PDOMFastReindex(indexer);
|
||||
reindex.run(monitor);
|
||||
|
||||
// Set the default indexer back
|
||||
if (oldDefault != null)
|
||||
manager.setDefaultIndexerId(oldDefault);
|
||||
|
||||
cprojects[0] = cproject;
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ public class PDOMTests extends TestSuite {
|
|||
suite.addTestSuite(EnumerationTests.class);
|
||||
suite.addTestSuite(ClassTests.class);
|
||||
suite.addTestSuite(TypesTests.class);
|
||||
suite.addTestSuite(IncludesTests.class);
|
||||
|
||||
return suite;
|
||||
}
|
||||
|
|
|
@ -31,15 +31,21 @@ import org.eclipse.core.runtime.NullProgressMonitor;
|
|||
*/
|
||||
public class TypesTests extends PDOMTestBase {
|
||||
|
||||
protected ICProject project;
|
||||
|
||||
protected PDOM pdom;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
project = createProject("types");
|
||||
if (pdom == null) {
|
||||
ICProject project = createProject("types");
|
||||
pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM(project);
|
||||
}
|
||||
pdom.acquireReadLock();
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
pdom.releaseReadLock();
|
||||
}
|
||||
|
||||
public void testC() throws Exception {
|
||||
PDOM pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM(project);
|
||||
|
||||
// Get the binding for A::f
|
||||
IBinding [] CAs = pdom.findBindings(Pattern.compile("CA"), new NullProgressMonitor());
|
||||
assertEquals(1, CAs.length);
|
||||
|
@ -57,8 +63,6 @@ public class TypesTests extends PDOMTestBase {
|
|||
}
|
||||
|
||||
public void testCPP() throws Exception {
|
||||
PDOM pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM(project);
|
||||
|
||||
// Get the binding for A::f
|
||||
IBinding [] As = pdom.findBindings(Pattern.compile("A"), new NullProgressMonitor());
|
||||
assertEquals(1, As.length);
|
||||
|
@ -76,7 +80,6 @@ public class TypesTests extends PDOMTestBase {
|
|||
}
|
||||
|
||||
public void test145351() throws Exception {
|
||||
PDOM pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM(project);
|
||||
IBinding [] bindings = pdom.findBindings(Pattern.compile("spinlock_t"), new NullProgressMonitor());
|
||||
assertEquals(1, bindings.length);
|
||||
ITypedef spinlock_t = (ITypedef)bindings[0];
|
||||
|
|
Loading…
Add table
Reference in a new issue