1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-09 09:15:38 +02:00

Fix JUnit tests.

This commit is contained in:
Markus Schorn 2010-02-09 13:37:33 +00:00
parent 5cf3cf47c2
commit 4bec9af75d
4 changed files with 21 additions and 14 deletions

View file

@ -15,7 +15,6 @@ import java.io.IOException;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IPDOMManager;
import org.eclipse.cdt.core.index.IIndexManager;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.testplugin.CProjectHelper;
import org.eclipse.cdt.core.testplugin.CTestPlugin;
@ -64,15 +63,4 @@ public class IndexTestBase extends BaseTestCase {
return TestSourceReader.getContentsForTest(
CTestPlugin.getDefault().getBundle(), "parser", getClass(), getName(), blocks);
}
protected void waitForIndexer(ICProject project) throws InterruptedException {
final IIndexManager indexManager = CCorePlugin.getIndexManager();
assertTrue(indexManager.joinIndexer(INDEXER_WAIT_TIME, NPM));
long waitms= 1;
while (waitms < 2000 && indexManager.isIndexerSetupPostponed(project)) {
Thread.sleep(waitms);
waitms *= 2;
}
assertTrue(indexManager.joinIndexer(INDEXER_WAIT_TIME, NPM));
}
}

View file

@ -29,9 +29,12 @@ import junit.framework.TestSuite;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ElementChangedEvent;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.IElementChangedListener;
import org.eclipse.cdt.core.testplugin.TestScannerProvider;
import org.eclipse.cdt.internal.core.CCoreInternals;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNameBase;
import org.eclipse.cdt.internal.core.pdom.PDOMManager;
import org.eclipse.core.resources.IResourceStatus;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.ILogListener;
@ -85,8 +88,8 @@ public class BaseTestCase extends TestCase {
Class superClass= clazz;
while (Test.class.isAssignableFrom(superClass) && !TestCase.class.equals(superClass)) {
Method[] methods= superClass.getDeclaredMethods();
for (int i= 0; i < methods.length; i++) {
addFailingMethod(suite, methods[i], names, clazz, prefix);
for (Method method : methods) {
addFailingMethod(suite, method, names, clazz, prefix);
}
superClass= superClass.getSuperclass();
}
@ -275,4 +278,15 @@ public class BaseTestCase extends TestCase {
}
}
}
protected void waitForIndexer(ICProject project) throws InterruptedException {
final PDOMManager indexManager = CCoreInternals.getPDOMManager();
assertTrue(indexManager.joinIndexer(10000, NPM));
long waitms= 1;
while (waitms < 2000 && !indexManager.isProjectRegistered(project)) {
Thread.sleep(waitms);
waitms *= 2;
}
assertTrue(indexManager.joinIndexer(10000, NPM));
}
}

View file

@ -203,6 +203,7 @@ public class PDOMManager implements IWritableIndexManager, IListener {
}
public Job startup() {
fInShutDown= false;
Job postStartupJob= new Job(CCorePlugin.getResourceString("CCorePlugin.startupJob")) { //$NON-NLS-1$
@Override
protected IStatus run(IProgressMonitor monitor) {

View file

@ -96,6 +96,10 @@ public class WaitForRefreshJobs extends IndexerSetupParticipant {
for (Job j : refreshJobs) {
if (fRefreshJobs.add(j)) {
j.addJobChangeListener(fJobListener);
// In case the job has finished in the meantime
if (j.getState() == Job.NONE) {
fRefreshJobs.remove(j);
}
}
}
}