Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ public static IProject createPluginProject(String name, JavaVersion javaVersion,
else
makeCompliantFor(javaProject, javaVersion);
JavaProjectSetupUtil.addJreClasspathEntry(javaProject);
IResourcesSetupUtil.waitForPdeClasspathUpdate();
return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jdt.internal.core.JavaModelManager;
import org.eclipse.pde.internal.core.ClasspathComputer;
import org.eclipse.pde.internal.core.PluginModelManager;
import org.eclipse.ui.actions.WorkspaceModifyOperation;
import org.eclipse.ui.texteditor.MarkerUtilities;
import org.eclipse.xtext.util.StringInputStream;
Expand Down Expand Up @@ -485,4 +487,24 @@ public static void waitForJdtIndex() {
public static void waitForJdtIndex(IProgressMonitor monitor) {
JavaModelManager.getIndexManager().waitForIndex(true, monitor);
}

/**
* Waits until PDE has computed the "Plug-in Dependencies" classpath container of plug-in projects.
*
* @since 2.45
*/
@SuppressWarnings("restriction")
public static void waitForPdeClasspathUpdate() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ArneDeutsch we talked about this possible solution in the past to try to fix the tons of flaky tests!

I hadn't tried that myself.

I thought @cdietrich already tried this and it didn't work, but maybe I misremember or we were using the wrong job ids.

If this fixes flakyness for good, besides you becoming my hero ;) , I guess we should add such a wait in all the abstract test classes that need JDT/PDE.

if (Job.getJobManager().currentRule() != null) {
return;
}
try {
Job.getJobManager().join(ClasspathComputer.class, null);
Job.getJobManager().join(PluginModelManager.class, null);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
} catch (NoClassDefFoundError e) {
// org.eclipse.pde.core is optional dependency
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ protected void joinUpdateClasspathJob() {
if (joinMe != null) {
joinMe.join();
}
IResourcesSetupUtil.waitForPdeClasspathUpdate();
} catch (Exception e) {
Exceptions.throwUncheckedException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.eclipse.xtext.ui.editor.hover.AbstractProblemHover;
import org.eclipse.xtext.ui.editor.model.IXtextDocument;
import org.eclipse.xtext.ui.editor.validation.MarkerCreator;
import org.eclipse.xtext.ui.refactoring.ui.SyncUtil;
import org.eclipse.xtext.ui.testing.AbstractEditorTest;
import org.eclipse.xtext.ui.testing.util.IResourcesSetupUtil;
import org.eclipse.xtext.ui.tests.internal.TestsActivator;
Expand Down Expand Up @@ -67,6 +68,8 @@ public List<Issue> exec(XtextResource state) throws Exception {
for (Issue issue : issues) {
markerCreator.createMarker(issue, file, MarkerTypes.forCheckType(issue.getType()));
}
TestsActivator.getInstance().getInjector(getEditorId()).getInstance(SyncUtil.class).waitForReconciler(editor);
waitForEventProcessing();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.eclipse.xtext.ui.refactoring.ui.SyncUtil;
import org.eclipse.xtext.ui.shared.SharedStateModule;
import org.eclipse.xtext.ui.testing.ContentAssistProcessorTestBuilder;
import org.eclipse.xtext.ui.testing.util.IResourcesSetupUtil;
import org.eclipse.xtext.ui.testing.util.ResourceLoadHelper;
import org.eclipse.xtext.ui.util.PluginProjectFactory;
import org.eclipse.xtext.util.Modules2;
Expand Down Expand Up @@ -72,6 +73,7 @@ public void doSetupProject() throws Exception{
XtextProjectHelper.NATURE_ID, JavaCore.NATURE_ID, "org.eclipse.pde.PluginNature");
projectFactory.addRequiredBundles(Lists.newArrayList("org.eclipse.xtext"));
project = projectFactory.createProject(new NullProgressMonitor(), null);
IResourcesSetupUtil.waitForPdeClasspathUpdate();
get(SyncUtil.class).waitForBuild(new NullProgressMonitor());
}
}
Expand All @@ -80,6 +82,7 @@ public void doSetupProject() throws Exception{
public static void doDeleteProject() throws CoreException {
if(project != null && project.exists())
project.delete(true, new NullProgressMonitor());
project = null;
}

public ISetup doGetSetup() {
Expand Down
Loading