diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/TranslationUnitTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/TranslationUnitTests.java index 66c6e745972..7b56ae0f5d4 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/TranslationUnitTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/TranslationUnitTests.java @@ -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(); diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/CProjectHelper.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/CProjectHelper.java index 87bae29475d..9c9621d699c 100644 --- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/CProjectHelper.java +++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/CProjectHelper.java @@ -259,19 +259,23 @@ 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 { - ICElement[] sourceRoots = testProject.getChildren(); - for (int i = 0; i < sourceRoots.length; i++) { - ISourceRoot root = (ISourceRoot) sourceRoots[i]; - ICElement[] myElements = root.getChildren(); - for (int x = 0; x < myElements.length; x++) { - if (myElements[x].getElementName().equals(name)) { - if (myElements[x] instanceof ITranslationUnit) { - return ((ITranslationUnit) myElements[x]); + 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]; + ICElement[] myElements = root.getChildren(); + for (int x = 0; x < myElements.length; x++) { + if (myElements[x].getElementName().equals(name)) { + if (myElements[x] instanceof ITranslationUnit) { + return ((ITranslationUnit) myElements[x]); + } } } } + Thread.sleep(100); } return null; }