mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 17:56:01 +02:00
Fixes occasional NPE in CModelTests
This commit is contained in:
parent
e239602e33
commit
39e2a19ab7
2 changed files with 19 additions and 17 deletions
|
@ -16,14 +16,12 @@ import java.util.Stack;
|
|||
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.IInclude;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
||||
import org.eclipse.cdt.core.testplugin.util.ExpectedStrings;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* @author Peter Graves
|
||||
|
@ -87,7 +85,7 @@ public class TranslationUnitTests extends TranslationUnitBaseTest {
|
|||
* true
|
||||
*
|
||||
*/
|
||||
public void testIsTranslationUnit() throws CoreException,
|
||||
public void testIsTranslationUnit() throws Exception,
|
||||
FileNotFoundException {
|
||||
ITranslationUnit myTranslationUnit;
|
||||
|
||||
|
@ -101,7 +99,7 @@ public class TranslationUnitTests extends TranslationUnitBaseTest {
|
|||
* Simple sanity tests to make sure TranslationUnit.getChildren seems to
|
||||
* basicly work
|
||||
*/
|
||||
public void testGetChildren() throws CModelException {
|
||||
public void testGetChildren() throws Exception {
|
||||
ITranslationUnit myTranslationUnit;
|
||||
ICElement[] elements;
|
||||
int x;
|
||||
|
@ -126,7 +124,7 @@ public class TranslationUnitTests extends TranslationUnitBaseTest {
|
|||
/***************************************************************************
|
||||
* Simple sanity tests for the getElement() call
|
||||
*/
|
||||
public void testGetElement() throws CModelException {
|
||||
public void testGetElement() throws Exception {
|
||||
ITranslationUnit myTranslationUnit;
|
||||
ICElement myElement;
|
||||
Stack missing = new Stack();
|
||||
|
@ -157,7 +155,7 @@ public class TranslationUnitTests extends TranslationUnitBaseTest {
|
|||
/***************************************************************************
|
||||
* Simple sanity tests for the getInclude call
|
||||
*/
|
||||
public void testBug23478A() throws CModelException {
|
||||
public void testBug23478A() throws Exception {
|
||||
IInclude myInclude;
|
||||
int x;
|
||||
String includes[] = { "stdio.h", "unistd.h" };
|
||||
|
@ -182,7 +180,7 @@ public class TranslationUnitTests extends TranslationUnitBaseTest {
|
|||
/***************************************************************************
|
||||
* Simple sanity tests for the getIncludes call
|
||||
*/
|
||||
public void testBug23478B() throws CModelException {
|
||||
public void testBug23478B() throws Exception {
|
||||
IInclude myIncludes[];
|
||||
String includes[] = { "stdio.h", "unistd.h" };
|
||||
ExpectedStrings myExp = new ExpectedStrings(includes);
|
||||
|
@ -203,7 +201,7 @@ public class TranslationUnitTests extends TranslationUnitBaseTest {
|
|||
/***************************************************************************
|
||||
* Simple sanity tests for the getElementAtLine() call
|
||||
*/
|
||||
public void testGetElementAtLine() throws CoreException {
|
||||
public void testGetElementAtLine() throws Exception {
|
||||
ITranslationUnit myTranslationUnit;
|
||||
ICElement myElement;
|
||||
Stack missing = new Stack();
|
||||
|
|
|
@ -259,8 +259,10 @@ public class CProjectHelper {
|
|||
|
||||
/**
|
||||
* Attempts to find a TranslationUnit with the given name in the workspace
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
public static ITranslationUnit findTranslationUnit(ICProject testProject, String name) throws CModelException {
|
||||
public static ITranslationUnit findTranslationUnit(ICProject testProject, String name) throws CModelException, InterruptedException {
|
||||
for (int j=0; j<20; j++) {
|
||||
ICElement[] sourceRoots = testProject.getChildren();
|
||||
for (int i = 0; i < sourceRoots.length; i++) {
|
||||
ISourceRoot root = (ISourceRoot) sourceRoots[i];
|
||||
|
@ -273,6 +275,8 @@ public class CProjectHelper {
|
|||
}
|
||||
}
|
||||
}
|
||||
Thread.sleep(100);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue